当前位置:编程学习 > C#/ASP.NET >>

关于xna+hlsl的问题,求解

最近公司要求我做一个3D车模型展示的应用,刚开始我用wpf,后来发现效果不好,改用xna,研究了好久,由于在下才疏学浅,虽然效果出来了,但仍然不能达到要求,我想我应该用到的技术是天空盒与环境映射,我在网上找了一个例子,但都是xna3.0的,其中有一个例子正是我所需要的,http://blog.csdn.net/juwell0512/article/details/4077660?reload我试着改成4.0的,HLSL没有改,我改了xna中的代码:
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            carEffect.Parameters["my2DTexture_Tex"].SetValue(texture2d);
            carEffect.Parameters["myCubemap_Tex"].SetValue(textCube);
            foreach (ModelMesh mesh in m.Meshes)
            {
                carEffect.CurrentTechnique = carEffect.Techniques["BodyShader"];
                foreach (ModelMeshPart part in mesh.MeshParts)
                {
                    carEffect.Parameters["View"].SetValue(view);
                    carEffect.Parameters["Projection"].SetValue(projection);
                    carEffect.Parameters["World"].SetValue(world);
                    foreach (EffectPass pass in carEffect.CurrentTechnique.Passes)
                    {
                        pass.Apply();
                        VertexBuffer vb = part.VertexBuffer;
                        graphics.GraphicsDevice.SetVertexBuffer(part.VertexBuffer);
                        graphics.GraphicsDevice.Indices = part.IndexBuffer;
                        GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, part.VertexOffset, 0, part.NumVertices, part.StartIndex, part.PrimitiveCount);
                    }
                }
            }
            base.Draw(gameTime);
        }
但是报了个错误:
The current vertex declaration does not include all the elements required by the current vertex shader. TextureCoordinate0 is missing.

请各位前辈能够指引在下这是什么原因。 XNA HLSL --------------------编程问答-------------------- 是不是VertexBuffer的类型问题?
补充:.NET技术 ,  .NET技术前瞻
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,