public void render(warp_Camera cam) { rasterizer.rebuildReferences(this); warp_Math.clearBuffer(zBuffer, zFar); //System.Array.Copy(screen.zBuffer,0,zBuffer,0,zBuffer.Length); if (useId) { warp_Math.clearBuffer(idBuffer, -1); } if (scene.environment.background != null) { screen.drawBackground(scene.environment.background, 0, 0, screen.width, screen.height); } else { screen.clear(scene.environment.bgcolor); } cam.setScreensize(screen.width, screen.height); scene.prepareForRendering(); emptyQueues(); // Project warp_Matrix m = warp_Matrix.multiply(cam.getMatrix(), scene.matrix); warp_Matrix nm = warp_Matrix.multiply(cam.getNormalMatrix(), scene.normalmatrix); warp_Matrix vertexProjection, normalProjection; warp_Object obj; warp_Triangle t; warp_Vertex v; int w = screen.width; int h = screen.height; for (int id = scene.objects - 1; id >= 0; id--) { obj = scene.wobject[id]; if (obj.visible) { vertexProjection = obj.matrix.getClone(); normalProjection = obj.normalmatrix.getClone(); vertexProjection.transform(m); normalProjection.transform(nm); for (int i = obj.vertices - 1; i >= 0; i--) { v = obj.fastvertex[i]; v.project(vertexProjection, normalProjection, cam); v.clipFrustrum(w, h); } for (int i = obj.triangles - 1; i >= 0; i--) { t = obj.fasttriangle[i]; t.project(normalProjection); t.clipFrustrum(w, h); enqueueTriangle(t); } } } //screen.lockImage(); warp_Triangle[] tri; tri = getOpaqueQueue(); if (tri != null) { for (int i = tri.GetLength(0) - 1; i >= 0; i--) { rasterizer.loadMaterial(tri[i].parent.material); rasterizer.render(tri[i]); } } tri = getTransparentQueue(); if (tri != null) { for (int i = 0; i < tri.GetLength(0); i++) { rasterizer.loadMaterial(tri[i].parent.material); rasterizer.render(tri[i]); } } //screen.unlockImage(); }