# replacement for mesh.DrawSubset()

This topic is 4716 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hi guys is there any way to draw a mesh without using mesh.drawsubset ??? i think that it can be drawn using device.drawPrimitives but am not sure about it and how to do it ,with what mesh.drawsubset can be replaced ??

##### Share on other sites
In C++:

	num_of_faces=mesh->GetNumFaces();num_of_vertices=mesh->GetNumVertices();mesh->GetIndexBuffer(&ib);mesh->GetVertexBuffer(&vb);fvf=mesh->GetFVF();fvfsize=D3DXGetFVFVertexSize(fvf);//renderg_device->SetFVF(fvf);g_device->SetIndices(ib);g_device->SetStreamSource(0,vb,0,fvfsize);g_device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,num_of_vertices,0,num_of_faces);

msdn: In C#

##### Share on other sites
thanx for ur reply , look i am converting it to c# but there is no mesh.getFVF

do u know with what i can replace these lines ?
fvf=mesh->GetFVF();
fvfsize=D3DXGetFVFVertexSize(fvf);
g_device->SetFVF(fvf);

##### Share on other sites
Lookup Mesh.VertexFormat and Mesh.Declaration.

##### Share on other sites
this is my source but i am not getting any thing on the screen when i run the game please tell me where is the error in it

	device.Transform.World = AllMatrix;					///mesh is the MeshContainer				ExtendedMaterial[] materials = mesh.GetMaterials();				for (int i = 0; i < materials.Length; ++i)				{					device.Material = materials.Material3D;					device.SetTexture(0, mesh.GetTextures());				//	mesh.MeshData.Mesh.DrawSubset(i);								int numFaces = mesh.MeshData.Mesh.NumberFaces;					int numVertexs = mesh.MeshData.Mesh.NumberVertices;					IndexBuffer ib = mesh.MeshData.Mesh.IndexBuffer;					VertexBuffer vb = mesh.MeshData.Mesh.VertexBuffer;					VertexFormats fvf= mesh.MeshData.Mesh.VertexFormat;					device.VertexFormat=fvf;					device.Indices=ib;					device.SetStreamSource(0,vb,0);					device.DrawIndexedPrimitives(PrimitiveType.TriangleList,0,0,numVertexs,0,numFaces);

}

##### Share on other sites
Did it work before, with DrawSubset? (to make sure that your matrices etc are set correctly)

##### Share on other sites
Your code wont properly work for a mesh with more than 1 material [smile]

For each material you're drawing the entire mesh - so for multiple materials you'll basically get a complete mess where it attempts to combine all the materials together.

You need to customize the draw call such that it only renders the correct part for that subset. That is, you need to examine the attribute table.

I'm not a C# programmer, so I don't know exactly what it'll look like... but try Mesh.GetAttributeTable() to get an array of AttributeRange structures. For each subset, you need to use the corresponding values from the AttributeRange.

hth
Jack

##### Share on other sites
ya it works if i use mesh.drawsubset .
Quote:
 For each material you're drawing the entire mesh - so for multiple materials you'll basically get a complete mess where it attempts to combine all the materials together.

ya i didnot pay attention to this material error but should't it draw it with messy material ?? at least something should appear on the screen

Quote:
 you need to examine the attribute table

i didnot work with it before is there any SDK or any sample that demonstrates this tecnique ?

rate +++ for u guys

##### Share on other sites
is there any other advice ??

##### Share on other sites
Have you tried using the debug runtimes? I can't see any mention of that in the thread?

If you get the params to DIP() wrong then it's likely to ignore the whole call - thus not rendering anything. If this is the case you'll often get 100's if not 1000's of messages from the debug runtime screaming-and-shouting about what it doesn't like [smile]

I'm running under Vista right now which doesn't pick up my RAID array, but when I get back to XP I'll see about digging up my re-implementation of DrawSubset() - it's in C++, but it should be trivial enough to convert.

hth
Jack

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633364
• Total Posts
3011516
• ### Who's Online (See full list)

There are no registered users currently online

×