[cgkit-commits] cgkit2/cgkit maimport.py,1.4,1.5
Brought to you by:
mbaas
From: Matthias B. <mb...@us...> - 2005-05-10 16:18:54
|
Update of /cvsroot/cgkit/cgkit2/cgkit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18286 Modified Files: maimport.py Log Message: Import light sources (so far as GL light sources. This will probably change. Index: maimport.py =================================================================== RCS file: /cvsroot/cgkit/cgkit2/cgkit/maimport.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** maimport.py 3 May 2005 19:54:35 -0000 1.4 --- maimport.py 10 May 2005 16:18:15 -0000 1.5 *************** *** 26,29 **** --- 26,30 ---- import freecamera import quadrics, box, plane, polyhedron, joint + import glpointlight, glfreespotlight, glfreedistantlight from cgtypes import * from worldobject import WorldObject *************** *** 158,161 **** --- 159,248 ---- onNodeRigidBody = ignoreWarning + def onNodePointLight(self, node, name, parent): + """PointLight node. + """ + parentnode = self.nodes[parent] + args = {} + self.getWorldObjectArgs(parentnode, args) + + cl = vec3(node.getAttrValue("color", "cl", "float3", 1, vec3(1))) + intensity = node.getAttrValue("intensity", "in", "float", 1, 1.0) + de = node.getAttrValue("decayRate", "de", "int", 1, 0) + if de==0: + catt = 1.0 + latt = 0.0 + qatt = 0.0 + elif de==1: + catt = 0.0 + latt = 1.0 + qatt = 0.0 + else: + catt = 0.0 + latt = 0.0 + qatt = 1.0 + + lgt = glpointlight.GLPointLight(diffuse = cl, + intensity = intensity, + constant_attenuation = catt, + linear_attenuation = latt, + quadratic_attenuation = qatt, + enabled = args["visible"], + **args) + self.newWorldObject(lgt, node.getParentName()) + + def onNodeSpotLight(self, node, name, parent): + """SpotLight node. + """ + parentnode = self.nodes[parent] + args = {} + self.getWorldObjectArgs(parentnode, args) + + cl = vec3(node.getAttrValue("color", "cl", "float3", 1, vec3(1))) + intensity = node.getAttrValue("intensity", "in", "float", 1, 1.0) + ca = node.getAttrValue("coneAngle", "ca", "float", 1, 40.0) + de = node.getAttrValue("decayRate", "de", "int", 1, 0) + if de==0: + catt = 1.0 + latt = 0.0 + qatt = 0.0 + elif de==1: + catt = 0.0 + latt = 1.0 + qatt = 0.0 + else: + catt = 0.0 + latt = 0.0 + qatt = 1.0 + + args["transform"] = args["transform"]*mat4(1).rotation(pi, vec3(1,0,0)) + + lgt = glfreespotlight.GLFreeSpotLight(diffuse = cl, + intensity = intensity, + cutoff = ca/2.0, + constant_attenuation = catt, + linear_attenuation = latt, + quadratic_attenuation = qatt, + enabled = args["visible"], + **args) + self.newWorldObject(lgt, node.getParentName()) + + def onNodeDirectionalLight(self, node, name, parent): + """DirectionalLight node. + """ + parentnode = self.nodes[parent] + args = {} + self.getWorldObjectArgs(parentnode, args) + + cl = vec3(node.getAttrValue("color", "cl", "float3", 1, vec3(1))) + intensity = node.getAttrValue("intensity", "in", "float", 1, 1.0) + + args["transform"] = args["transform"]*mat4(1).rotation(pi, vec3(1,0,0)) + + lgt = glfreedistantlight.GLFreeDistantLight(diffuse = cl, + intensity = intensity, + enabled = args["visible"], + **args) + self.newWorldObject(lgt, node.getParentName()) + def onNodeJoint(self, node, name, parent): """Joint node. *************** *** 246,250 **** args = {} self.getWorldObjectArgs(parentnode, args) ! print "MESH",name # Check if the mesh is just a regular mesh or if it's created by --- 333,337 ---- args = {} self.getWorldObjectArgs(parentnode, args) ! # print "MESH",name # Check if the mesh is just a regular mesh or if it's created by |