Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello,

 

I am loading mesh information from a file format other than .X. I have created the vertex and index buffers successfully but I would also like to create subsets for texturing. I have tried a couple routes, originally getting the GraphicsStream by locking the Attribute Buffer and writing to it, which always crashed at run time. Obviously I wasn't writing to the stream properly.

 

The second method -

 

int faceStart = 0;

int vertexStart = 0;

AttributeRange[] test = new AttributeRange[importer.mesh.PolygonList.Count];

GraphicsStream attributeStream = mesh.LockAttributeBuffer(LockFlags.None);

for (int i = 0; i < importer.mesh.PolygonList.Count; i++)

{

IMDPolygon currentPoly = ((IMDPolygon)importer.mesh.PolygonList);

//Loop through all IMDMeshes

//Note that these should probably be divided into a Dx Subset

test.AttributeId = i;

test.FaceCount = currentPoly.TriangleList.Count;

test.FaceStart = faceStart;

test.VertexCount = currentPoly.VertexList.Count;

test.VertexStart = vertexStart;

faceStart += currentPoly.TriangleList.Count;

vertexStart += currentPoly.VertexList.Count;

}

mesh.UnlockAttributeBuffer();

mesh.SetAttributeTable(test);

 

The examples I see in C++ (few and far between) simply lock the AttributeStream which returns a DWORD pointer which they then set for each indice.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...