- # Get a projector for this object
- proj = Projector(cameraObj, obj, self.canvasSize)
-
- # Let's store the transformed data
- transformed_mesh = NMesh.New("flat"+obj.name)
- transformed_mesh.hasVertexColours(1)
-
- # Store the materials
- materials = obj.getData().getMaterials()
-
- meshfaces = obj.getData().faces
-
- for face in meshfaces:
-
- # if the face is visible flatten it on the "picture plane"
- if self._isFaceVisible_old(face, obj, cameraObj):
-
- # Store transformed face
- newface = NMesh.Face()
-
- for vert in face:
-
- p = proj.doProjection(vert.co)
-
- tmp_vert = NMesh.Vert(p[0], p[1], p[2])
-
- # Add the vert to the mesh
- transformed_mesh.verts.append(tmp_vert)
-
- newface.v.append(tmp_vert)
-
-
- # Per-face color calculation
- # code taken mostly from the original vrm script
- # TODO: understand the code and rewrite it clearly
- ambient = -150
-
- fakelight = Object.Get("Lamp").loc
- if fakelight == None:
- fakelight = [1.0, 1.0, -0.3]
-
- norm = Vector(face.no)
- vektori = (norm[0]*fakelight[0]+norm[1]*fakelight[1]+norm[2]*fakelight[2])
- vduzine = fabs(sqrt(pow(norm[0],2)+pow(norm[1],2)+pow(norm[2],2))*sqrt(pow(fakelight[0],2)+pow(fakelight[1],2)+pow(fakelight[2],2)))
- intensity = floor(ambient + 200*acos(vektori/vduzine))/200
- if intensity < 0:
- intensity = 0
-
- if materials:
- tmp_col = materials[face.mat].getRGBCol()
- else:
- tmp_col = [0.5, 0.5, 0.5]
-
- tmp_col = [ (c>intensity) and int(round((c-intensity)*10)*25.5) for c in tmp_col ]
-
- vcol = NMesh.Col(tmp_col[0], tmp_col[1], tmp_col[2])
- newface.col = [vcol, vcol, vcol, 255]
-
- transformed_mesh.addFace(newface)
-
- # at the end of the loop on obj
+ print "Rendering: ", obj.getName()
+
+ mesh = obj.data
+
+ self._doModelToWorldCoordinates(mesh, obj.matrix)
+
+ self._doObjectDepthSorting(mesh)
+
+ self._doBackFaceCulling(mesh)
+
+ self._doColorAndLighting(mesh)
+
+ # TODO: 'style' can be a function that determine
+ # if an edge should be showed?
+ self._doEdgesStyle(mesh, style=None)
+
+ self._doProjection(mesh, proj)