ranges = mesh.GetAttributeTable();
//Mesh array for subsets
meshes = new Mesh[ranges.Length];
vertexBuffers = new VertexBuffer[ranges.Length];
for (int i = 0; i < meshes.Length; i++)
{
meshes = new Mesh(ranges.VertexCount * 3, ranges.VertexCount, MeshFlags.Managed, CustomVertex.PositionNormalTextured.Format, device);
rangeVertices = (CustomVertex.PositionNormalTextured[])mesh.VertexBuffer.Lock(ranges.VertexStart * sizeof(CustomVertex.PositionNormalTextured), typeof(CustomVertex.PositionNormalTextured), LockFlags.None, ranges.VertexCount);
using (VertexBuffer vb = meshes.VertexBuffer)
{
GraphicsStream data = vb.Lock(0, 0, LockFlags.None);
data.Write(rangeVertices);
vb.Unlock();
}
}
[MDX] Subset of meshes
I am trying to develop some 3D application. I have a model class that loads a mesh from a file.What I want is this:
For example the model that I am loading have some other parts(subset),I want to sepearete them and consider each of them as DirectX.Direct3D.Mesh.My code snippet is like that.I hope that I had describes what I want.
But when I do my rendering,I can not see any thing or with some changes in Vertexformats I have some StackOverFlow or FatalEngine errors.
Is this code snippet is ok for what I want?
I am waiting for some more info
Yes it is possible to do so. What you need to do is lock the Attribute buffer of the mesh and separate the mesh out using what attribute index the mesh is. Usually if the mesh has n materials applied to it, there will be n attribute buffers.
I can't see what's wrong with your code at first glance, but maybe our sample on splitting a mesh (1st sample on page) might be of help. We split the mesh's vertices into seperate vertexbuffers, but you could also create a new Mesh object for each subset and fill the vertexbuffer of these mesh objects using the same technique.
Hope his helps :)
Hope his helps :)
I had been looked at mdxinfo tutorial. I had tried to develop some more things releated with it and also my own code above. I do not get any debug errors but can not see anything on renderscreen.When I debug my code, it seems good.I mean information that is set seems ok.What can cause my problem?Nothing is rendered.
It could be a number of things, are you refreshing the sene every time, are the meshes in the correct world view?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement