Accueil > > > EXTENSION DE ROTATION ET PROJECTION3D SOUS INKSCAPE
EXTENSION DE ROTATION ET PROJECTION3D SOUS INKSCAPE
Information sur la source
Description
ce programme permet de faire tourner un dessin sous inkscape comme si il était dans un monde 3D. La visualisation du monde se faisant soit avec une projection orthogonal soit avec une projection 3D (perspective). Les dessins doivent être composé d'un ensemble de point càd par exemple si l'on veut faire tourner une chaine de caractére il faut avant tout convertir la chaine en chemin (shift+ctrl+C). /!\Il ne fait pas tourné les groupes d'objet, il faut donc dégrouper les dessins et tous les sélectionner. Pour qu'Inkscape charge le programme il faut placer les 2 fichiers dans le répertoire extension d'inkscape...
Source
- #!/usr/bin/env python
- """
- inkex.py
- A helper module for creating Inkscape extensions
-
- Copyright (C) 2005,2007 Aaron Spike, aaron@ekips.org
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- """
- import sys, copy, optparse, random, re
- import simplestyle, simplepath
- import math, string
-
- #a dictionary of all of the xmlns prefixes in a standard inkscape doc
- NSS = {
- u'sodipodi' :u'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd',
- u'cc' :u'http://web.resource.org/cc/',
- u'svg' :u'http://www.w3.org/2000/svg',
- u'dc' :u'http://purl.org/dc/elements/1.1/',
- u'rdf' :u'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
- u'inkscape' :u'http://www.inkscape.org/namespaces/inkscape',
- u'xlink' :u'http://www.w3.org/1999/xlink',
- u'xml' :u'http://www.w3.org/XML/1998/namespace'
- }
-
- #a dictionary of unit to user unit conversion factors
- uuconv = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'pc':15.0}
- def unittouu(string):
- '''Returns userunits given a string representation of units in another system'''
- unit = re.compile('(%s)$' % '|'.join(uuconv.keys()))
- param = re.compile(r'(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)')
-
- p = param.match(string)
- u = unit.search(string)
- if p:
- retval = float(p.string[p.start():p.end()])
- else:
- retval = 0.0
- if u:
- try:
- return retval * uuconv[u.string[u.start():u.end()]]
- except KeyError:
- pass
- return retval
-
- try:
- from lxml import etree
- except:
- sys.exit('The fantastic lxml wrapper for libxml2 is required by inkex.py and therefore this extension. Please download and install the latest version from <http://cheeseshop.python.org/pypi/lxml/>, or install it through your package manager by a command like: sudo apt-get install python-lxml')
-
- def debug(what):
- sys.stderr.write(str(what) + "\n")
- return what
-
- def check_inkbool(option, opt, value):
- if str(value).capitalize() == 'True':
- return True
- elif str(value).capitalize() == 'False':
- return False
- else:
- raise OptionValueError("option %s: invalid inkbool value: %s" % (opt, value))
-
- def addNS(tag, ns=None):
- val = tag
- if ns!=None and len(ns)>0 and NSS.has_key(ns) and len(tag)>0 and tag[0]!='{':
- val = "{%s}%s" % (NSS[ns], tag)
- return val
-
- def rotz(V,alpha):
- c=V
- if alpha!=0:
- ca=math.cos(alpha)
- sa=math.sin(alpha)
- c=[ca*V[0] - sa*V[1], sa*V[0] +ca*V[1] ,V[2]]
- return c
-
- def roty(V,alpha):
- c=V
- if alpha!=0:
- ca=math.cos(alpha)
- sa=math.sin(alpha)
- c=[sa*V[2] + ca*V[0] , V[1] , ca*V[2] - sa*V[0]]
- return c
-
- def rotx(V,alpha):
- c=V
- if alpha!=0:
- ca=math.cos(alpha)
- sa=math.sin(alpha)
- c=[V[0] , ca*V[1] - sa*V[2] , sa*V[1]+ca*V[2]]
- return c
-
- def project_vue(V,vue):
- #debug(V)
- temp=V[2]
- if vue=="X":
- #V[1]=V[1]
- V[2]=-V[0]
- V[0]=temp
- if vue=="Y":
- #V[0]=V[0]
- V[2]=-V[1]
- V[1]=temp
- #debug(V)
- return V
-
- """C correspond a la position de la camera
- V position du point a faire tourner
- La position de l'ecran est egale a (1-zoom)*C[2]"""
- def project(V,C,zoom):
- cp=[V[0]-C[0],V[1]-C[1],V[2]-C[2]]
- norm_cp=math.sqrt(cp[0]**2+cp[1]**2+cp[2]**2)
- u=[cp[0]/norm_cp,cp[1]/norm_cp,cp[2]/norm_cp]
- coef=-(zoom*C[2])/ u[2]
- vc=[C[0]+coef*u[0],C[1]+coef*u[1]]
- if V[2]-(1-zoom)*C[2]<=0:
- debug("Coordonnee en Z negative!\n augmentez la profondeur")
- return vc
-
- class InkOption(optparse.Option):
- TYPES = optparse.Option.TYPES + ("inkbool",)
- TYPE_CHECKER = copy.copy(optparse.Option.TYPE_CHECKER)
- TYPE_CHECKER["inkbool"] = check_inkbool
-
- class Effect:
- """A class for creating Inkscape SVG Effects"""
- def __init__(self, *args, **kwargs):
- self.id_characters = '0123456789abcdefghijklmnopqrstuvwkyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
- self.document=None
- self.ctx=None
- self.selected={}
- self.doc_ids={}
- self.options=None
- self.args=None
- self.OptionParser = optparse.OptionParser(usage="usage: %prog [options] SVGfile",option_class=InkOption)
- self.OptionParser.add_option("--id",
- action="append", type="string", dest="ids", default=[],
- help="id attribute of object to manipulate")
- #rajout des options______________
- """ permet de creer la variable self.options.rx"""
- self.OptionParser.add_option("--rx",
- action="store", type="float", dest="rx", default=0.0,
- help="Angle de rotation selon x")
- self.OptionParser.add_option("--ry",
- action="store", type="float", dest="ry", default=0.0,
- help="Angle de rotation selon y")
- self.OptionParser.add_option("--rz",
- action="store", type="float", dest="rz", default=0.0,
- help="Angle de rotation selon z")
- self.OptionParser.add_option("--px",
- action="store", type="float", dest="px", default=10.0,
- help="Centre de rotation en X")
- self.OptionParser.add_option("--py",
- action="store", type="float", dest="py", default=10.0,
- help="Centre de rotation en Y")
- self.OptionParser.add_option("--pz",
- action="store", type="float", dest="pz", default=10.0,
- help="Position de l'objet en Z")
- self.OptionParser.add_option("--zoom",
- action="store", type="int", dest="zoom", default=1,
- help="Zoom")
- self.OptionParser.add_option("--dup",
- action="store", type="inkbool", dest="dup", default=[],
- help="Aucune utilite...")
- self.OptionParser.add_option("--vue",
- action="store", type="string", dest="vue", default=[],
- help="Permet de selectionner la vue")
-
- def getoptions(self,args=sys.argv[1:]):
- """Collect command line arguments"""
- self.options, self.args = self.OptionParser.parse_args(args)
-
- def parse(self,file=None):
- """Parse document in specified file or on stdin"""
- try:
- try:
- stream = open(file,'r')
- except:
- stream = open(self.args[-1],'r')
- except:
- stream = sys.stdin
- self.document = etree.parse(stream)
- stream.close()
- def getposinlayer(self):
- #defaults
- self.current_layer = self.document.getroot()
- self.view_center = (0.0,0.0)
-
- layerattr = self.document.xpath('//sodipodi:namedview/@inkscape:current-layer', namespaces=NSS)
- if layerattr:
- layername = layerattr[0]
- layer = self.document.xpath('//svg:g[@id="%s"]' % layername, namespaces=NSS)
- if layer:
- self.current_layer = layer[0]
-
- xattr = self.document.xpath('//sodipodi:namedview/@inkscape:cx', namespaces=NSS)
- yattr = self.document.xpath('//sodipodi:namedview/@inkscape:cy', namespaces=NSS)
- doc_height = unittouu(self.document.getroot().get('height'))
- if xattr and yattr:
- x = xattr[0]
- y = yattr[0]
- if x and y:
- self.view_center = (float(x), doc_height - float(y)) # FIXME: y-coordinate flip, eliminate it when it's gone in Inkscape
- def getselected(self):
- """Collect selected nodes"""
- for id in self.options.ids:
- path = '//*[@id="%s"]' % id
- for node in self.document.xpath(path, namespaces=NSS):
- self.selected[id] = node
- def getdocids(self):
- docIdNodes = self.document.xpath('//@id', namespaces=NSS)
- for m in docIdNodes:
- self.doc_ids[m] = 1
- def output(self):
- """Serialize document into XML on stdout"""
- self.document.write(sys.stdout)
- def affect(self):
- """Affect an SVG document with a callback effect"""
- self.getoptions()
- self.parse()
- self.getposinlayer()
- self.getselected()
- self.getdocids()
- self.effect()
- self.output()
-
- def uniqueId(self, old_id, make_new_id = True):
- new_id = old_id
- if make_new_id:
- while new_id in self.doc_ids:
- new_id = "%s%s" % (new_id,random.choice(self.id_characters))
- self.doc_ids[new_id] = 1
- return new_id
-
- def xpathSingle(self, path):
- try:
- retval = self.document.xpath(path, namespaces=NSS)[0]
- except:
- debug("No matching node for expression: %s" % path)
- retval = None
- return retval
-
- #fonction a modifier pour faire les modifications sur le dessin...__________________
- """self.options.ids correspond aux nom des objets selectionnes
- self.selected[id] correspond aux noeud xml de l'objet id"""
- def effect(self):
- """_______INITIALISATION_____"""
- ax=self.options.rx*math.pi/180
- ay=self.options.ry*math.pi/180
- az=self.options.rz*math.pi/180
- cr=[self.options.px,self.options.py,self.options.pz] #centre de rotation (repere local)
- C=[self.options.px,self.options.py,-100.0] #position de la camera /!\ il faut qu'elle soit derriere l'ecran (z<0)
- """______________________"""
- """Cherche l'envelope du groupe d'objet"""
- xmin=1000000.0
- xmax=-1000000.0
- ymin=1000000.0
- ymax=-1000000.0
- for objetID in self.options.ids:
- XmlNode=self.selected[objetID]
- arbre=simplepath.parsePath(XmlNode.get('d'))
- for noeud in arbre:
- noeuds=noeud[1]
- nbpoint=len(noeuds)/2
- for n in range(nbpoint):
- if xmin>noeuds[2*n]:
- xmin=noeuds[2*n]
- if xmax<noeuds[2*n]:
- xmax=noeuds[2*n]
- if ymin>noeuds[2*n+1]:
- ymin=noeuds[2*n+1]
- if ymax<noeuds[2*n+1]:
- ymax=noeuds[2*n+1]
-
- OG=[(xmax+xmin)/2, (ymax+ymin)/2,0.0]
- if self.options.vue=="Z":
- cr[0]=OG[0] #centre de rotation = centre de gravite
- cr[1]=OG[1]
- C[0]=OG[0] #place la camera au centre de gravite
- C[1]=OG[1]
- sys.stderr.write("Centre de rotation :("+str(OG[0])+", "+str(OG[1])+", "+str(self.options.pz)+")\nCamera :("
- +str(OG[0])+", "+str(OG[1])+", "+str(C[2])+")\n")
- """
- if self.options.vue=="Y":
- C[0]=OG[0] #place la camera au centre de gravite
- C[1]=self.options.pz
- if self.options.vue=="X":
- C[0]=self.options.pz #place la camera au centre de gravite
- C[1]=OG[1]
- #C=project_vue(C,self.options.vue)
- cr=project_vue(cr,self.options.vue)
- """
- """boucle sur les objets"""
- for objetID in self.options.ids:
- XmlNode=self.selected[objetID]
- arbre=simplepath.parsePath(XmlNode.get('d'))
- a=[]
- """on boucle sur les noeuds de l'arbre """
- for noeud in arbre:
- noeuds=noeud[1]
- nbpoint=len(noeuds)/2
- newNoeud=[]
- for n in range(nbpoint):
- V=project_vue([noeuds[2*n],noeuds[2*n+1],self.options.pz],self.options.vue)
- #On place V dans le repere local de rotation
- V=[V[0]-cr[0],V[1]-cr[1],V[2]-cr[2]]
- #debug(V)
- V=rotx(V,ax)
- V=roty(V,ay)
- V=rotz(V,az)
- #replace V dans le repere global
- V[0]+=cr[0]
- V[1]+=cr[1]
- V[2]+=cr[2]
- if self.options.dup==False:
- V=project(V,C,self.options.zoom)
- newNoeud.append(V[0])
- newNoeud.append(V[1])
- a.append([noeud[0],newNoeud]) #reconstruit l'ensemble des points
- XmlNode.set('d', simplepath.formatPath(a))
-
- #debut du code principal____________
- effect= Effect()
- #debug("debut")
- effect.affect()
#!/usr/bin/env python
"""
inkex.py
A helper module for creating Inkscape extensions
Copyright (C) 2005,2007 Aaron Spike, aaron@ekips.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
import sys, copy, optparse, random, re
import simplestyle, simplepath
import math, string
#a dictionary of all of the xmlns prefixes in a standard inkscape doc
NSS = {
u'sodipodi' :u'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd',
u'cc' :u'http://web.resource.org/cc/',
u'svg' :u'http://www.w3.org/2000/svg',
u'dc' :u'http://purl.org/dc/elements/1.1/',
u'rdf' :u'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
u'inkscape' :u'http://www.inkscape.org/namespaces/inkscape',
u'xlink' :u'http://www.w3.org/1999/xlink',
u'xml' :u'http://www.w3.org/XML/1998/namespace'
}
#a dictionary of unit to user unit conversion factors
uuconv = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'pc':15.0}
def unittouu(string):
'''Returns userunits given a string representation of units in another system'''
unit = re.compile('(%s)$' % '|'.join(uuconv.keys()))
param = re.compile(r'(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)')
p = param.match(string)
u = unit.search(string)
if p:
retval = float(p.string[p.start():p.end()])
else:
retval = 0.0
if u:
try:
return retval * uuconv[u.string[u.start():u.end()]]
except KeyError:
pass
return retval
try:
from lxml import etree
except:
sys.exit('The fantastic lxml wrapper for libxml2 is required by inkex.py and therefore this extension. Please download and install the latest version from <http://cheeseshop.python.org/pypi/lxml/>, or install it through your package manager by a command like: sudo apt-get install python-lxml')
def debug(what):
sys.stderr.write(str(what) + "\n")
return what
def check_inkbool(option, opt, value):
if str(value).capitalize() == 'True':
return True
elif str(value).capitalize() == 'False':
return False
else:
raise OptionValueError("option %s: invalid inkbool value: %s" % (opt, value))
def addNS(tag, ns=None):
val = tag
if ns!=None and len(ns)>0 and NSS.has_key(ns) and len(tag)>0 and tag[0]!='{':
val = "{%s}%s" % (NSS[ns], tag)
return val
def rotz(V,alpha):
c=V
if alpha!=0:
ca=math.cos(alpha)
sa=math.sin(alpha)
c=[ca*V[0] - sa*V[1], sa*V[0] +ca*V[1] ,V[2]]
return c
def roty(V,alpha):
c=V
if alpha!=0:
ca=math.cos(alpha)
sa=math.sin(alpha)
c=[sa*V[2] + ca*V[0] , V[1] , ca*V[2] - sa*V[0]]
return c
def rotx(V,alpha):
c=V
if alpha!=0:
ca=math.cos(alpha)
sa=math.sin(alpha)
c=[V[0] , ca*V[1] - sa*V[2] , sa*V[1]+ca*V[2]]
return c
def project_vue(V,vue):
#debug(V)
temp=V[2]
if vue=="X":
#V[1]=V[1]
V[2]=-V[0]
V[0]=temp
if vue=="Y":
#V[0]=V[0]
V[2]=-V[1]
V[1]=temp
#debug(V)
return V
"""C correspond a la position de la camera
V position du point a faire tourner
La position de l'ecran est egale a (1-zoom)*C[2]"""
def project(V,C,zoom):
cp=[V[0]-C[0],V[1]-C[1],V[2]-C[2]]
norm_cp=math.sqrt(cp[0]**2+cp[1]**2+cp[2]**2)
u=[cp[0]/norm_cp,cp[1]/norm_cp,cp[2]/norm_cp]
coef=-(zoom*C[2])/ u[2]
vc=[C[0]+coef*u[0],C[1]+coef*u[1]]
if V[2]-(1-zoom)*C[2]<=0:
debug("Coordonnee en Z negative!\n augmentez la profondeur")
return vc
class InkOption(optparse.Option):
TYPES = optparse.Option.TYPES + ("inkbool",)
TYPE_CHECKER = copy.copy(optparse.Option.TYPE_CHECKER)
TYPE_CHECKER["inkbool"] = check_inkbool
class Effect:
"""A class for creating Inkscape SVG Effects"""
def __init__(self, *args, **kwargs):
self.id_characters = '0123456789abcdefghijklmnopqrstuvwkyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
self.document=None
self.ctx=None
self.selected={}
self.doc_ids={}
self.options=None
self.args=None
self.OptionParser = optparse.OptionParser(usage="usage: %prog [options] SVGfile",option_class=InkOption)
self.OptionParser.add_option("--id",
action="append", type="string", dest="ids", default=[],
help="id attribute of object to manipulate")
#rajout des options______________
""" permet de creer la variable self.options.rx"""
self.OptionParser.add_option("--rx",
action="store", type="float", dest="rx", default=0.0,
help="Angle de rotation selon x")
self.OptionParser.add_option("--ry",
action="store", type="float", dest="ry", default=0.0,
help="Angle de rotation selon y")
self.OptionParser.add_option("--rz",
action="store", type="float", dest="rz", default=0.0,
help="Angle de rotation selon z")
self.OptionParser.add_option("--px",
action="store", type="float", dest="px", default=10.0,
help="Centre de rotation en X")
self.OptionParser.add_option("--py",
action="store", type="float", dest="py", default=10.0,
help="Centre de rotation en Y")
self.OptionParser.add_option("--pz",
action="store", type="float", dest="pz", default=10.0,
help="Position de l'objet en Z")
self.OptionParser.add_option("--zoom",
action="store", type="int", dest="zoom", default=1,
help="Zoom")
self.OptionParser.add_option("--dup",
action="store", type="inkbool", dest="dup", default=[],
help="Aucune utilite...")
self.OptionParser.add_option("--vue",
action="store", type="string", dest="vue", default=[],
help="Permet de selectionner la vue")
def getoptions(self,args=sys.argv[1:]):
"""Collect command line arguments"""
self.options, self.args = self.OptionParser.parse_args(args)
def parse(self,file=None):
"""Parse document in specified file or on stdin"""
try:
try:
stream = open(file,'r')
except:
stream = open(self.args[-1],'r')
except:
stream = sys.stdin
self.document = etree.parse(stream)
stream.close()
def getposinlayer(self):
#defaults
self.current_layer = self.document.getroot()
self.view_center = (0.0,0.0)
layerattr = self.document.xpath('//sodipodi:namedview/@inkscape:current-layer', namespaces=NSS)
if layerattr:
layername = layerattr[0]
layer = self.document.xpath('//svg:g[@id="%s"]' % layername, namespaces=NSS)
if layer:
self.current_layer = layer[0]
xattr = self.document.xpath('//sodipodi:namedview/@inkscape:cx', namespaces=NSS)
yattr = self.document.xpath('//sodipodi:namedview/@inkscape:cy', namespaces=NSS)
doc_height = unittouu(self.document.getroot().get('height'))
if xattr and yattr:
x = xattr[0]
y = yattr[0]
if x and y:
self.view_center = (float(x), doc_height - float(y)) # FIXME: y-coordinate flip, eliminate it when it's gone in Inkscape
def getselected(self):
"""Collect selected nodes"""
for id in self.options.ids:
path = '//*[@id="%s"]' % id
for node in self.document.xpath(path, namespaces=NSS):
self.selected[id] = node
def getdocids(self):
docIdNodes = self.document.xpath('//@id', namespaces=NSS)
for m in docIdNodes:
self.doc_ids[m] = 1
def output(self):
"""Serialize document into XML on stdout"""
self.document.write(sys.stdout)
def affect(self):
"""Affect an SVG document with a callback effect"""
self.getoptions()
self.parse()
self.getposinlayer()
self.getselected()
self.getdocids()
self.effect()
self.output()
def uniqueId(self, old_id, make_new_id = True):
new_id = old_id
if make_new_id:
while new_id in self.doc_ids:
new_id = "%s%s" % (new_id,random.choice(self.id_characters))
self.doc_ids[new_id] = 1
return new_id
def xpathSingle(self, path):
try:
retval = self.document.xpath(path, namespaces=NSS)[0]
except:
debug("No matching node for expression: %s" % path)
retval = None
return retval
#fonction a modifier pour faire les modifications sur le dessin...__________________
"""self.options.ids correspond aux nom des objets selectionnes
self.selected[id] correspond aux noeud xml de l'objet id"""
def effect(self):
"""_______INITIALISATION_____"""
ax=self.options.rx*math.pi/180
ay=self.options.ry*math.pi/180
az=self.options.rz*math.pi/180
cr=[self.options.px,self.options.py,self.options.pz] #centre de rotation (repere local)
C=[self.options.px,self.options.py,-100.0] #position de la camera /!\ il faut qu'elle soit derriere l'ecran (z<0)
"""______________________"""
"""Cherche l'envelope du groupe d'objet"""
xmin=1000000.0
xmax=-1000000.0
ymin=1000000.0
ymax=-1000000.0
for objetID in self.options.ids:
XmlNode=self.selected[objetID]
arbre=simplepath.parsePath(XmlNode.get('d'))
for noeud in arbre:
noeuds=noeud[1]
nbpoint=len(noeuds)/2
for n in range(nbpoint):
if xmin>noeuds[2*n]:
xmin=noeuds[2*n]
if xmax<noeuds[2*n]:
xmax=noeuds[2*n]
if ymin>noeuds[2*n+1]:
ymin=noeuds[2*n+1]
if ymax<noeuds[2*n+1]:
ymax=noeuds[2*n+1]
OG=[(xmax+xmin)/2, (ymax+ymin)/2,0.0]
if self.options.vue=="Z":
cr[0]=OG[0] #centre de rotation = centre de gravite
cr[1]=OG[1]
C[0]=OG[0] #place la camera au centre de gravite
C[1]=OG[1]
sys.stderr.write("Centre de rotation :("+str(OG[0])+", "+str(OG[1])+", "+str(self.options.pz)+")\nCamera :("
+str(OG[0])+", "+str(OG[1])+", "+str(C[2])+")\n")
"""
if self.options.vue=="Y":
C[0]=OG[0] #place la camera au centre de gravite
C[1]=self.options.pz
if self.options.vue=="X":
C[0]=self.options.pz #place la camera au centre de gravite
C[1]=OG[1]
#C=project_vue(C,self.options.vue)
cr=project_vue(cr,self.options.vue)
"""
"""boucle sur les objets"""
for objetID in self.options.ids:
XmlNode=self.selected[objetID]
arbre=simplepath.parsePath(XmlNode.get('d'))
a=[]
"""on boucle sur les noeuds de l'arbre """
for noeud in arbre:
noeuds=noeud[1]
nbpoint=len(noeuds)/2
newNoeud=[]
for n in range(nbpoint):
V=project_vue([noeuds[2*n],noeuds[2*n+1],self.options.pz],self.options.vue)
#On place V dans le repere local de rotation
V=[V[0]-cr[0],V[1]-cr[1],V[2]-cr[2]]
#debug(V)
V=rotx(V,ax)
V=roty(V,ay)
V=rotz(V,az)
#replace V dans le repere global
V[0]+=cr[0]
V[1]+=cr[1]
V[2]+=cr[2]
if self.options.dup==False:
V=project(V,C,self.options.zoom)
newNoeud.append(V[0])
newNoeud.append(V[1])
a.append([noeud[0],newNoeud]) #reconstruit l'ensemble des points
XmlNode.set('d', simplepath.formatPath(a))
#debut du code principal____________
effect= Effect()
#debug("debut")
effect.affect()
Historique
- 13 juillet 2008 14:13:06 :
- petite explication comment installer le programme pour qu'Inkscape le voit...
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
charger une image 3D [ par ghadroud ]
Bonjour,Je suis sensée développer une application en python qui charge un image 3D et qui soit inclue dans la page web.Comment procéder a ca?merci
CHERCHE FORMATEUR PYTHON orienté 3D (XSI) [ par potoche ]
Bonjour, Je cherche un spécialiste python appliqué aux logiciels 3D style XSI. Il s'agit d'aider les gros studio à développer leurs outils à l'aide d
[clos] un morpion 3D ( Débutant) [ par heeeeeeeelp ]
Bonsoir ; [size=300][u][b]Alerte[/b][/u] [/size]a tous les geek et/ou fanatique d'informatique & de programmation ,, j'ai besoin de votre génie . Je s
Morpion 3D [ par lola413 ]
Bonjour, Dans le cadre de mon cours de programmation j'ai pour exercice (a rendre pour le 23, youpi!) de réaliser un morpion 4*4 en 3D (alignement de
Le programme qui effectue une rotation [ par meriem222 ]
Je suis nouveau dans le monde de Python, ma question est la suivante : comment écrire un programme qui effectue une rotation de cypher. c à d "Attack
|
Derniers Blogs
CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT)CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT) par FREMYCOMPANY
Bonjour à tous, Je viens de publier une proposition comprenant 5 pseudo-classes pour le CSS Working Group ayant trait à l'état de chargement d'un élément (ex: IMG,VIDEO,AUDIO,OBJECT pour l'HTML.). Si le c½ur vous en dit, vous pouvez retrouver cette p...
Cliquez pour lire la suite de l'article par FREMYCOMPANY MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ?MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ? par ROMELARD Fabrice
Formation initiale Durant la formation, le découpage classique est le suivant (je donnerai les équivalences Suisse lorsque je les connaîtrais) : Ecole primaire jusqu'au Collège : Formation générale permettant d'obtenir les méthodes...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice Y'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENTY'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENT par Aleks
Quand on a ce genre d'erreur sans log :
Et bas on a juste envie de choper le gas de Microsoft qu'a développé ça et lui foutre des baffes de Coboye ! ...
Cliquez pour lire la suite de l'article par Aleks [HYPER-V 3] PRéSENTATION DES COMMANDLETS POWERSHELL[HYPER-V 3] PRéSENTATION DES COMMANDLETS POWERSHELL par Pierrick CATRO-BROUILLET
Avec la sortie prochaine de la Beta Consumer Preview de Windows 8, j'avais envie de revenir sur une des fonctionnalités que j'attends le plus et que, en bon geek que je suis, j'utilise déjà : Hyper-V 3 ainsi son module PowerShell.
Il y a déjà pléthor...
Cliquez pour lire la suite de l'article par Pierrick CATRO-BROUILLET IIS7 - COMPRESSION GZIPIIS7 - COMPRESSION GZIP par cyril
La compression GZIP permet d'améliorer les performances de navigation en compressant ce qu'envoie le serveur à un client. Pour comprendre comment cela fonctionne, regardons ce qu'il se passe au niveau HTTP lorsqu'un client tente d'accéder à une ress...
Cliquez pour lire la suite de l'article par cyril
Forum
PYVISA PROBLèMEPYVISA PROBLèME par sandrine44
Cliquez pour lire la suite par sandrine44
Logiciels
Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning Academy System (17.1.3.0)ACADEMY SYSTEM (17.1.3.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|