none
Matertials and multiple light RRS feed

  • 问题

  • 我把MaterialsAndLightsSample示例中的代码改为4.0后,怎么无法显示物体,不知道是那个地方没有搞对?

    谁有4.0版本的代码?

    核心代码改动


                //graphics.GraphicsDevice.RenderState.DepthBufferEnable = true;
                //graphics.GraphicsDevice.RenderState.DepthBufferWriteEnable = true;
                //4.0
                graphics.GraphicsDevice.BlendState = BlendState.Opaque;
                graphics.GraphicsDevice.DepthStencilState = DepthStencilState.Default;

                viewParameter.SetValue(camera.ViewMatrix);
                cameraPositionParameter.SetValue(camera.Position);

                for (int i = 0; i < 8; i++)
                {
                    Matrix world = meshRotation * meshWorlds[i];
                    materials[(i + materialRotation) % 8].DrawModelWithMaterial(
                        sampleMeshes[i % 4], ref world);
                }
               
                floorMaterial.DrawModelWithMaterial(sampleMeshes[0], ref floorWorld);

    。。。。。

    public void DrawModelWithMaterial(Model model, ref Matrix world)
            {
                if (model == null)
                {
                    throw new ArgumentNullException("model");
                }
                ModelMesh mesh = model.Meshes[0];
                ModelMeshPart meshPart = mesh.MeshParts[0];
                device.SamplerStates[0] = SamplerState.LinearWrap;


                //device.Vertices[0].SetSource(
                //    mesh.VertexBuffer, meshPart.StreamOffset, meshPart.VertexStride);


                //device.VertexDeclaration = meshPart.VertexDeclaration;
                device.SetVertexBuffer(meshPart.VertexBuffer);


                device.Indices = meshPart.IndexBuffer;
                

                effectInstance.Parameters["world"].SetValue(world);

                //effectInstance.Begin(SaveStateMode.None);
                //effectInstance.CurrentTechnique.Passes[0].Begin();

               
                effectInstance.CurrentTechnique.Passes[0].Apply();

     

               device.DrawIndexedPrimitives(
                    PrimitiveType.TriangleList, meshPart.VertexOffset, 0,
                    meshPart.NumVertices, meshPart.StartIndex, meshPart.PrimitiveCount);

    。。。。

    2013年10月14日 12:17

答案

  • 你好:

    建议你把你的问题发布到Xbox LIVE Indie Games中文论坛以获取更多人的帮助。


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2013年10月16日 2:06
    版主