Jump to content
  • Advertisement
Sign in to follow this  
jad_salloum

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
In C++:

	
num_of_faces=mesh->GetNumFaces();
num_of_vertices=mesh->GetNumVertices();
mesh->GetIndexBuffer(&ib);
mesh->GetVertexBuffer(&vb);
fvf=mesh->GetFVF();
fvfsize=D3DXGetFVFVertexSize(fvf);

//render
g_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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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

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!