예제 #1
0
        public static void Init()
        {
            _indices = new int[]
            {
                // bottom
                0, 1,
                1, 2,
                2, 3,
                3, 0,

                // top
                4, 5,
                5, 6,
                6, 7,
                7, 4,

                // sides
                0, 4,
                1, 5,
                2, 6,
                3, 7
            };

            _effect = Resource.ResourceManager.Global.Load <Effect>("wireframe.fx");

            _declaration = new VertexElementSet(new VertexElement[] {
                new VertexElement(0, VertexElementFormat.Float3, VertexElementUsage.Position, 0)
            });
        }
예제 #2
0
        public static void Init()
        {
            var global = Resource.ResourceManager.Global;

            _basicTexturedEffect     = global.Load <Effect>("basic_textured.fx");
            _lightmapEffect          = global.Load <Effect>("basic_lightmapped.fx");
            _lightmapNoTextureEffect = global.Load <Effect>("basic_lightmapped_notexture.fx");

            try
            {
                _radiosityEffect = global.Load <Effect>("radiosity.fx");
            }
            catch (System.IO.FileNotFoundException)
            {
                // most likely this means the renderer is Direct3D
            }

            if (_vertexDeclaration == null)
            {
                _vertexDeclaration = new VertexElementSet(new VertexElement[] {
                    new VertexElement(0, VertexElementFormat.Float3, VertexElementUsage.Position, 0),
                    new VertexElement(sizeof(float) * 3, VertexElementFormat.Float2, VertexElementUsage.TexCoord, 0),
                    new VertexElement(sizeof(float) * 5, VertexElementFormat.Float2, VertexElementUsage.TexCoord, 1)
                });
            }
        }
예제 #3
0
        public static void Init()
        {
            if (_vertexDeclaration == null)
            {
                _vertexDeclaration = new VertexElementSet(new VertexElement[] {
                    new VertexElement(0, VertexElementFormat.Float2, VertexElementUsage.Position, 0),
                    new VertexElement(2 * sizeof(float), VertexElementFormat.Float2, VertexElementUsage.TexCoord, 0)
                });
            }

            if (_2dEffect == null)
            {
                _2dEffect = Resource.ResourceManager.Global.Load <Effect>("2d.fx");
            }

            if (_vertexBuffer == null)
            {
                _vertexBuffer = RendererManager.CurrentRenderer.CreateVertexBuffer <float>(VertexBufferUsage.Stream, null, 4 * 100, _vertexDeclaration);
            }

            if (_indexBuffer == null)
            {
                _indexBuffer = RendererManager.CurrentRenderer.CreateIndexBuffer(_indices);
            }
        }
예제 #4
0
 static ModelResource()
 {
     _elements = new VertexElementSet(new VertexElement[] {
         new VertexElement(0, VertexElementFormat.Float3, VertexElementUsage.Position, 0),
         new VertexElement(3 * sizeof(float), VertexElementFormat.Float2, VertexElementUsage.TexCoord, 0),
         new VertexElement(5 * sizeof(float), VertexElementFormat.Float3, VertexElementUsage.Normal, 0)
     });
 }
예제 #5
0
        public static void Init(Resource.ResourceManager globalContent)
        {
            _vertices = new float[(_resolution + 1) * 3 * 3];

            float step  = Math.Constants.TwoPi / _resolution;
            int   index = 0;

            // XY plane
            for (float i = 0; i < Math.Constants.TwoPi; i += step)
            {
                _vertices[index * 3 + 0] = (float)System.Math.Cos(i);
                _vertices[index * 3 + 1] = (float)System.Math.Sin(i);
                _vertices[index * 3 + 2] = 0;

                index++;
            }

            // XZ plane
            for (float i = 0; i < Math.Constants.TwoPi; i += step)
            {
                _vertices[index * 3 + 0] = (float)System.Math.Cos(i);
                _vertices[index * 3 + 1] = 0;
                _vertices[index * 3 + 2] = (float)System.Math.Sin(i);

                index++;
            }

            // YZ plane
            for (float i = 0; i < Math.Constants.TwoPi; i += step)
            {
                _vertices[index * 3 + 0] = 0;
                _vertices[index * 3 + 1] = (float)System.Math.Cos(i);
                _vertices[index * 3 + 2] = (float)System.Math.Sin(i);

                index++;
            }

            _effect = globalContent.Load <Effect>("wireframe.fx");

            _declaration = new VertexElementSet(new VertexElement[] {
                new VertexElement(0, VertexElementFormat.Float3, VertexElementUsage.Position, 0)
            });
        }
예제 #6
0
        public static void Init()
        {
            // create the indices
            uint[] indices = new uint[_maxBillboards * 6];
            for (uint i = 0; i < _maxBillboards; i++)
            {
                indices[i * 6 + 0] = i * 4 + 0;
                indices[i * 6 + 1] = i * 4 + 1;
                indices[i * 6 + 2] = i * 4 + 2;

                indices[i * 6 + 3] = i * 4 + 2;
                indices[i * 6 + 4] = i * 4 + 1;
                indices[i * 6 + 5] = i * 4 + 3;
            }

            // create the elements
            _elements = new VertexElementSet(new VertexElement[] {
                new VertexElement(0, VertexElementFormat.Float3, VertexElementUsage.Position, 0),
                new VertexElement(3 * sizeof(float), VertexElementFormat.Float2, VertexElementUsage.TexCoord, 0),
                new VertexElement(5 * sizeof(float), VertexElementFormat.Float2, VertexElementUsage.TexCoord, 1)
            });

            _vertices = RendererManager.CurrentRenderer.CreateVertexBuffer(VertexBufferUsage.Dynamic, (float[])null, _maxBillboards * _billboardVertexStride, _elements);
            _indices  = RendererManager.CurrentRenderer.CreateIndexBuffer(indices);

            var global = Resource.ResourceManager.Global;

            _shader = global.Load <Effect>("texturedBillboard.fx");

            try
            {
                _alphaShader = global.Load <Effect>("radiosity_omnilight.fx");
            }
            catch (System.IO.FileNotFoundException)
            {
                // oh well, that shader just isn't available
                // (this will happen if using Direct3D renderer)
            }
        }
예제 #7
0
파일: SkyBox.cs 프로젝트: shff/gk3tools
        public static void Init()
        {
            VertexElementSet declaration = new VertexElementSet(new VertexElement[]
            {
                new VertexElement(0, VertexElementFormat.Float3, VertexElementUsage.Position, 0)
            });

            float[] vertices = new float[8 * _stride];

            Math.Vector3 rightDir   = Math.Vector3.Right;
            Math.Vector3 forwardDir = Math.Vector3.Forward;
            Math.Vector3 upDir      = Math.Vector3.Up;

            // front bottom left
            vectorAdd(-rightDir, -upDir, forwardDir, _size,
                      out vertices[0 * _stride + 0], out vertices[0 * _stride + 1], out vertices[0 * _stride + 2]);

            // front top left
            vectorAdd(-rightDir, upDir, forwardDir, _size,
                      out vertices[1 * _stride + 0], out vertices[1 * _stride + 1], out vertices[1 * _stride + 2]);

            // front bottom right
            vectorAdd(rightDir, -upDir, forwardDir, _size,
                      out vertices[2 * _stride + 0], out vertices[2 * _stride + 1], out vertices[2 * _stride + 2]);

            // front top right
            vectorAdd(rightDir, upDir, forwardDir, _size,
                      out vertices[3 * _stride + 0], out vertices[3 * _stride + 1], out vertices[3 * _stride + 2]);

            // back bottom left
            vectorAdd(-rightDir, -upDir, -forwardDir, _size,
                      out vertices[4 * _stride + 0], out vertices[4 * _stride + 1], out vertices[4 * _stride + 2]);

            // back top left
            vectorAdd(-rightDir, upDir, -forwardDir, _size,
                      out vertices[5 * _stride + 0], out vertices[5 * _stride + 1], out vertices[5 * _stride + 2]);

            // back bottom right
            vectorAdd(rightDir, -upDir, -forwardDir, _size,
                      out vertices[6 * _stride + 0], out vertices[6 * _stride + 1], out vertices[6 * _stride + 2]);

            // back top right
            vectorAdd(rightDir, upDir, -forwardDir, _size,
                      out vertices[7 * _stride + 0], out vertices[7 * _stride + 1], out vertices[7 * _stride + 2]);

            uint[] indices = new uint[]
            {
                // front
                2, 1, 0,
                2, 3, 1,

                // right
                7, 3, 2,
                6, 7, 2,

                // left
                0, 1, 5,
                4, 0, 5,

                // up
                3, 5, 1,
                7, 5, 3,

                // back
                7, 6, 4,
                5, 7, 4,

                // bottom
                0, 4, 2,
                2, 4, 6
            };

            _vertices = RendererManager.CurrentRenderer.CreateVertexBuffer(VertexBufferUsage.Static, vertices, 8, declaration);
            _indices  = RendererManager.CurrentRenderer.CreateIndexBuffer(indices);

            _skyboxEffect = Resource.ResourceManager.Global.Load <Effect>("skybox.fx");
        }