コード例 #1
0
 public void RasterizeObject(UInt16 address)
 {
     Parent.StartRender();
     Parent.LoadLightVector();
     Parent.LoadViewPosition();
     ParseObjectList(address);
     Parent.EndRender();
 }
コード例 #2
0
            public void Rasterize()
            {
                // locate the tile table in memory
                System.Diagnostics.Debug.Assert(Memory[TERRAIN_BASE_ADDRESS] == 0xE00);
                TileTableBaseAddress = Memory[TERRAIN_BASE_ADDRESS]; // always 0x0E00

                Parent.StartRender();

                Parent.LoadLightVector();
                Parent.LoadViewPosition();
                Parent.LoadViewMatrix(0x15);
                Rotation = Parent.ViewRotation;
                Parent.SetWorldMatrix(ref Parent.Terrain.Rotation);

                // determine rendering method (dot/vector/polygon)
                switch (Memory[TERRAIN_RENDERING_MODE])
                {
                case 0x0000: renderMode = Mathbox.RenderMode.Polygon; break;

                case 0x0100: renderMode = Mathbox.RenderMode.Vector; break;

                default: renderMode = Mathbox.RenderMode.Dot; break;
                }

                // get address of terrain object buffer
                ObjectList = Memory[TERRAIN_OBJECT_LIST_ADDRESS];

                Int16 z_max    = (Int16)Memory[TERRAIN_Z_MAX];
                Int16 z_min    = (Int16)Memory[TERRAIN_Z_MIN];
                Int16 x        = (Int16)Memory[TERRAIN_X];
                Int16 z_frac   = (Int16)Memory[TERRAIN_Z_FRAC];
                Int16 x_offset = (Int16)Memory[TERRAIN_X_OFFSET];
                Int16 z_offset = (Int16)Memory[TERRAIN_Z_OFFSET];

                // locate left front tile corner (x1,y1,z1)
                //         +-------+
                //        /       /|
                //       /       / |           x2 = x1 + Mathbox.Tile.SIZE_X
                // y1-- +-------+  |           y2 = y1 + Mathbox.Tile.SIZE_Y
                //      |       |  + --z2      z2 = z1 + Mathbox.Tile.SIZE_Z
                //      |       | /
                //      |       |/
                // y2-- +-------+ --z1
                //      |       |
                //      x1      x2
                Vector3 corner = new Vector3(
                    Tile.WIDTH_X - x_offset * 128 - x,
                    -Parent.ViewPosition.Y,
                    z_max * 128 - z_frac);

                // render each row in the terrain
                int row = z_offset / 16 + z_max; // first absolute row to be rendered

                Row.Count = z_max - z_min + 1;   // number of rows to display
                while (Row.Count-- > 0)
                {
                    DrawTerrainRow(row-- & 31, corner);
                    corner.Z -= Tile.DEPTH_Z; // move to next row along the Z axis
                }

                Parent.EndRender();
            }