Sign in to follow this  
Zbychs

[XNA] [SOLVED] Problem with understanding ModelMeshPart

Recommended Posts

Hi I'd like to draw a ModelMeshPart manually (and not using model.Draw() or modelMesh.Draw()). But I can't figure out what vertices from VertexBuffer are used by a particular ModelMeshPart, and most importantly what indices are being used. The fields present in ModelMeshPart confuse me: BaseVertex - Gets the offset to add to each vertex index in the index buffer. NumVertices - Gets the number of vertices used during a draw call. PrimitiveCount - Gets the number of primitives to render. StartIndex - Gets the location in the index array at which to start reading vertices. StreamOffset - Gets the offset in bytes from the beginning of the VertexBuffer. How should I construct a DrawPrimitive call using those values? I've tried various combinations but just couldn't get it right... Also is ModelMeshPart always a TriangleList, or a TriangleStrip sometimes? Zbychs [Edited by - Zbychs on July 27, 2008 1:54:37 AM]

Share this post


Link to post
Share on other sites
First, I'm not an XNA C# person so this is pretty much a guess.

From the description (right from the docs, it appears), it sounds like you might try:

set the FVF(I don't know if you have to do that in XNA C# ??), index and vertex buffer stream sources from the MeshModel (and texture, materials, etc.)

then

DrawIndexedPrimitive( D3DPT_TRIANGLELIST, BaseVertex, 0, NumVertices, StartIndex, PrimitiveCount );


EDIT: I'm thinking StartIndex in the DrawIndexedPrimitive call should be set to 0 in this case, since BaseVertex should get you started at the correct position.

Share this post


Link to post
Share on other sites
Thanks man. It works with StartIndex, not 0. BaseVertex was the thing that got me confused - it's really a second component of StreamOffset, like in:
EffectiveStreamOffset = StreamOffset + BaseVertex * VertexStride

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this