• Advertisement
Sign in to follow this  

Getting Textures from a Mesh

This topic is 3658 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using XNA to create some basic simulation. I created a model using 3D World Studio. Which I then exported to a .X file. I am using an effect file i created to light the scene. One of the parameters of the effect file is the texture that needs to be drawn. What is the best way to get the textures associated with a mesh during my drawn method? Here is the loop of my draw method:
foreach (ModelMesh mesh in buildingModel.Meshes)
            {
                roomLighting.Parameters["World"].SetValue(transforms[mesh.ParentBone.Index] * Matrix.Identity);
                roomLighting.Parameters["modelTexture"].SetValue(currentTexture);  // <---- how do i get currentTexture

                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                {

                    graphics.GraphicsDevice.Vertices[0].SetSource(mesh.VertexBuffer, meshPart.StreamOffset, meshPart.VertexStride);
                    graphics.GraphicsDevice.VertexDeclaration = meshPart.VertexDeclaration;
                    graphics.GraphicsDevice.Indices = mesh.IndexBuffer;

                    roomLighting.Begin(SaveStateMode.None);
                    foreach (EffectPass pass in roomLighting.CurrentTechnique.Passes)
                    {
                        pass.Begin();
                        graphics.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 
                             meshPart.BaseVertex, 0, meshPart.NumVertices, meshPart.StartIndex, meshPart.PrimitiveCount);
                        pass.End();
                    }
                    roomLighting.End();
                }
            }



Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement