replacement for mesh.DrawSubset()
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 ??
In C++:
msdn: 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#
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);
do u know with what i can replace these lines ?
fvf=mesh->GetFVF();
fvfsize=D3DXGetFVFVertexSize(fvf);
g_device->SetFVF(fvf);
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);
}
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
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
ya it works if i use mesh.drawsubset .
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
i didnot work with it before is there any SDK or any sample that demonstrates this tecnique ?
rate +++ for u guys
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
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement