Jump to content
  • Advertisement
Sign in to follow this  
Zbychs

[XNA] [SOLVED] Problem with understanding ModelMeshPart

This topic is 3736 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

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
Advertisement
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
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!