コード例 #1
0
ファイル: Model.cs プロジェクト: nyx1220/sharpdx-examples
        private bool InitializeBuffers(Device device)
        {
            try
            {
                // Create the vertex array.
                var vertices = new LightShader.Vertex[VertexCount];
                // Create the index array.
                var indices = new int[IndexCount];

                for (var i = 0; i < VertexCount; i++)
                {
                    vertices[i] = new LightShader.Vertex()
                    {
                        position = new Vector3(ModelObject[i].x, ModelObject[i].y, ModelObject[i].z),
                        texture  = new Vector2(ModelObject[i].tu, ModelObject[i].tv),
                        normal   = new Vector3(ModelObject[i].nx, ModelObject[i].ny, ModelObject[i].nz)
                    };

                    indices[i] = i;
                }

                // Create the vertex buffer.
                VertexBuffer = Buffer.Create(device, BindFlags.VertexBuffer, vertices);

                // Create the index buffer.
                IndexBuffer = Buffer.Create(device, BindFlags.IndexBuffer, indices);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #2
0
ファイル: Model.cs プロジェクト: nyx1220/sharpdx-examples
        private bool InitializeBuffers(Device device)
        {
            try
            {
                // Create the vertex array.
                var vertices = new LightShader.Vertex[VertexCount];
                // Create the index array.
                var indices = new int[IndexCount];

                for (var i = 0; i < VertexCount; i++)
                {
                    vertices[i] = new LightShader.Vertex()
                    {
                        position = new Vector3(ModelObject[i].x, ModelObject[i].y, ModelObject[i].z),
                        texture = new Vector2(ModelObject[i].tu, ModelObject[i].tv),
                        normal = new Vector3(ModelObject[i].nx, ModelObject[i].ny, ModelObject[i].nz)
                    };

                    indices[i] = i;
                }

                // Create the vertex buffer.
                VertexBuffer = Buffer.Create(device, BindFlags.VertexBuffer, vertices);

                // Create the index buffer.
                IndexBuffer = Buffer.Create(device, BindFlags.IndexBuffer, indices);

                return true;
            }
            catch
            {
                return false;
            }
        }