Jump to content
  • Advertisement
Sign in to follow this  
TheMaskedFace

[MDX] Subset of meshes

This topic is 4443 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 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.
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();
                }



            }

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
It could be a number of things, are you refreshing the sene every time, are the meshes in the correct world view?

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!