public static warp_Camera TOP()
        {
            warp_Camera cam = new warp_Camera();

            cam.setPos(0, -2f, 0);
            return(cam);
        }
        public static warp_Camera FRONT()
        {
            warp_Camera cam = new warp_Camera();

            cam.setPos(0, 0, -2f);
            return(cam);
        }
        public static warp_Camera RIGHT()
        {
            warp_Camera cam = new warp_Camera();

            cam.setPos(-2f, 0, 0);
            return(cam);
        }
示例#4
0
		public void project (warp_Matrix vertexProjection, warp_Matrix normalProjection, warp_Camera camera)
			// Projects this vertex into camera space
		{
			pos2 = pos.transform (vertexProjection);
			n2 = n.transform (normalProjection);

			float fact;
			if (camera.isOrthographic)
			{
				x = (int)(pos2.x * (camera.screenscale / camera.orthoViewWidth) + (camera.screenwidth >> 1));
				y = (int)(-pos2.y * (camera.screenscale / camera.orthoViewHeight) + (camera.screenheight >> 1));
			} else
			{
				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);
			sw = -(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 * u);
			ty = (int)((float)parent.material.texture.height * v);
		}
示例#5
0
        public void destroy()
        {
            objects = objectData.Count;
            foreach (warp_Object o in objectData.Values)
            {
                o.destroy();
            }

            objectData.Clear();
            lightData.Clear();
            materialData.Clear();
            cameraData.Clear();
            if (renderPipeline != null)
            {
                renderPipeline.Dispose();
            }
            environment   = null;
            defaultCamera = null;
            wobject       = null;
        }
示例#6
0
        public void project(warp_Matrix vertexProjection, warp_Matrix normalProjection, warp_Camera camera)
        // Projects this vertex into camera space
        {
            pos2 = pos.transform(vertexProjection);
            n2   = n.transform(normalProjection);

            //old float fact;
            if (camera.isOrthographic)
            {
                //old x = (int)(pos2.x * (camera.screenscale / camera.orthoViewWidth) + (camera.screenwidth >> 1));
                //old y = (int)(-pos2.y * (camera.screenscale / camera.orthoViewHeight) + (camera.screenheight >> 1));
                x = (int)(pos2.x * camera.EfectiveFovFactX + (camera.screenwidth >> 1));
                y = (int)(-pos2.y * camera.EfectiveFovFactY + (camera.screenheight >> 1));
            }
            else
            {
                // old fact = camera.screenscale / camera.fovfact / ((pos2.z > 0.1) ? pos2.z : 0.1f);
                float fact = camera.EfectiveFovFactX / ((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);
            sw = -(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)(parent.material.texture.width * u);
            ty = (int)(parent.material.texture.height * v);
        }
示例#7
0
		public static warp_Camera TOP ()
		{
			warp_Camera cam = new warp_Camera ();
			cam.setPos (0, -2f, 0);
			return cam;
		}
示例#8
0
		public static warp_Camera RIGHT ()
		{
			warp_Camera cam = new warp_Camera ();
			cam.setPos (-2f, 0, 0);
			return cam;
		}
示例#9
0
		public static warp_Camera LEFT ()
		{
			warp_Camera cam = new warp_Camera ();
			cam.setPos (2f, 0, 0);
			return cam;
		}
示例#10
0
		public static warp_Camera FRONT ()
		{
			warp_Camera cam = new warp_Camera ();
			cam.setPos (0, 0, -2f);
			return cam;
		}
 public void addCamera(String key, warp_Camera c)
 {
     cameraData.Add(key, c);
 }
        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();
        }
示例#13
0
		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();
		}
示例#14
0
		public void addCamera (String key, warp_Camera c)
		{
			cameraData.Add (key, c);
		}