Skinned models / Vertex Data

Started by
1 comment, last by ColDet 16 years, 8 months ago
hi, i am facing a little problem concerning vertex data. i would like to use engine created object oriented bounding boxes for macro collision checks. i implemented this using the jacobi method, retrieving the eigenvectors and the centroid to build the bounding box. it works fine with static meshes. the problem arises when i try to port this algorythm to skinned models. a quick point draw of the vertices retrieved by this method:

        protected override Vector3[] GetVertices()
            // To do this, the mesh must exist
            if (mesh != null)
            {
                // This will get the verts info from the vertex buffer
                GraphicsStream stm = mesh.VertexBuffer.Lock(0, 0, LockFlags.None);

                // The vertices to be returned
                Vector3[] v = new Vector3[mesh.NumberVertices];

                // Loop through the vertices
                for (int i = 0; i < mesh.NumberVertices; i++)
                {
                    // Get the current vertex info
                    v = (Vector3)stm.Read(typeof(Vector3));
                }
                // Unlock the vertex buffer
                mesh.VertexBuffer.Unlock();

                // Return the vertices
                return v;
            }
            return null;
        }
shows that the vertices do not move, and are (probably) stuck in the model's original position (ie, not affected by skeleton influences). so what i would like to ask is, how do i access properly the vertex data to get the skeleton weighted vertices positions?
Advertisement
You'll almost certainly have to manually transform the geometry according to whatever skinning algorithm you're using. You might be able to use IDirect3DDevice9::ProcessVertices() (not sure what the MDX equivalent is) to hide the complexity.

You need to be careful that you don't end up eliminating the advantage of hardware skinning (assuming you're using it). If you keep doing software transforms you're effectively pulling the animation back from the GPU to the CPU. Look into analyzing possible animation steps at load-time (e.g. pre-generate bounding boxes) or some sort of low-detail mesh to avoid processing 1000's of vertices when 100's would suffice...

hth
JAck

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

yeah, i am conscious of that, i am already using low poly meshes to keep the thing efficient. thanks for the suggestion though i'll check it.

This topic is closed to new replies.

Advertisement