Exemple #1
0
 public void render(Camera cam)
 {
     renderPipeline.render(cam);
 }
Exemple #2
0
 public static Camera RIGHT()
 {
     Camera cam=new Camera();
     cam.setPos(-2f,0,0);
     return cam;
 }
Exemple #3
0
 public void addCamera(string key, Camera c)
 {
     cameraData.Add(key, c);
 }
Exemple #4
0
 public static Camera LEFT()
 {
     Camera cam=new Camera();
     cam.setPos(2f,0,0);
     return cam;
 }
Exemple #5
0
 public static Camera FRONT()
 {
     Camera cam=new Camera();
     cam.setPos(0,0,-2f);
     return cam;
 }
Exemple #6
0
 public static Camera TOP()
 {
     Camera cam=new Camera();
     cam.setPos(0,-2f,0);
     return cam;
 }
Exemple #7
0
        // P U B L I C   M E T H O D S
        /// <summary>
        /// Projects this vertex into camera space
        /// </summary>
        /// <param name="vertexProjection"></param>
        /// <param name="normalProjection"></param>
        /// <param name="camera"></param>
        public void Project(Matrix vertexProjection, Matrix normalProjection, Camera camera)
        {
            pos2 = pos.Transform(vertexProjection);
            n2 = n.Transform(normalProjection);

            fact = camera.screenscale / camera.fovfact / ((pos2.Z > 0.1) ? pos2.Z : 0.1f);
            X = (int) (pos2.X * fact + (camera.screenwidth >> 1));
            Y = (int) (-pos2.Y * fact + (camera.screenheight >> 1));
            Z = (int) (65536f * pos2.Z);
            nx = (int) (n2.X * 127 + 127);
            ny = (int) (n2.Y * 127 + 127);
            if (parent.material == null) return;
            if (parent.material.texture == null) return;
            tx = (int) ((float) parent.material.texture.width * Tu);
            ty = (int) ((float) parent.material.texture.height * Tv);
        }
Exemple #8
0
        public void render(Camera cam)
        {
            // Resize if requested
            if (resizingRequested) performResizing();
            if (antialiasChangeRequested) performAntialiasChange();
            rasterizer.rebuildReferences(this);

            // Clear buffers
            MathUtility.clearBuffer(zBuffer, zFar);
            if (useIdBuffer) MathUtility.clearBuffer(idBuffer, uint.MaxValue);
            if (scene.environment.background != null)
                screen.drawBackground(scene.environment.background, 0, 0, screen.w, screen.h);
            else screen.clear(scene.environment.bgcolor);

            // Prepare
            cam.setScreensize(screen.w, screen.h);
            scene.prepareForRendering();
            emptyQueues();

            // Project

            Matrix m = Matrix.multiply(cam.getMatrix(), scene.matrix);
            Matrix nm = Matrix.multiply(cam.getNormalMatrix(), scene.normalmatrix);
            Matrix vertexProjection, normalProjection;
            SceneObject obj;
            Triangle t;
            Vertex v;
            int w = screen.w;
            int h = screen.h;
            for (uint id = 0, length = scene.objects; id < length; id++)
            {
                obj = scene._object[id];
                if (obj.visible)
                {
                    vertexProjection = obj.matrix.Clone();
                    normalProjection = obj.normalmatrix.Clone();
                    vertexProjection.transform(m);
                    normalProjection.transform(nm);

                    for (int i = 0, innerlength = obj.vertices; i < innerlength; i++)
                    {
                        v = obj.vertex[i];
                        v.Project(vertexProjection, normalProjection, cam);
                        v.clipFrustrum(w, h);
                    }
                    for (uint i = 0, innerlength = obj.triangles; i < innerlength; i++)
                    {
                        t = obj.triangle[i];
                        t.Project(normalProjection);
                        t.ClipFrustrum(w, h);
                        enqueueTriangle(t);
                    }
                }
            }

            Triangle[] tri = getOpaqueQueue();
            if (tri != null)
                for (int i = tri.Length - 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.Length; i++)
                {
                    rasterizer.loadMaterial(tri[i].parent.material);
                    rasterizer.Render(tri[i]);
                }

            screen.render();
        }