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();
}
}
Getting Textures from a Mesh
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:
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement