Jump to content
  • Advertisement
Sign in to follow this  
Egelsoft

Mesh can... but I can't! [MDX]

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

Hello, I have been using a Mesh to render stuff, but recently have begun work on eliminating it (I find that it is not flexible enough to properly intergrate into an engine, but then again I just like reinventing the wheel :). Anyway I have a very simple sample that renders a rotating double sided triangle to the screen, well it *should* as far as I can tell. Simply put, it doesn't show up. I have turned off culling and lighting to be sure I can atleast see a black triangle (on a blue background mind you, I figured that part out quite quickly). Camera is at (0, 0, -5) looking at origin. Triangle is equilateral with sides of 1 so it should be properly visible. Strange part is, if I load it directly from a .X file (using a Mesh) it works, so that excludes matrix, math, hardware and dx problems. I get no errors or warnings from the DX debugger, I even ran DXSpy on a compile using Mesh and vertex/index buffers I created myself. I made a screen of some of the elements of the spy, you can see here (hope I get the ubb code right, couldn't find forum help). The only difference with the Spy I get when using Mesh is the order of the render setup calls (stuff like, I set material after buffers, but Mesh does that first). Can this sort of order matter? Or does it only matter that you have a correct state when calling DrawPrimitive? For those interrested, here is my render code: the part that is commented out is what I use when rendering a Mesh (which works)
{
	Matrix m = RenderTransform;
	device.Indices = IndexBuffer;
	device.VertexDeclaration = model.VertexBuffer.GetVertexDeclaration(); //or creates it if not cached
	device.SetStreamSource(0, VertexBuffer, 0);
	foreach (ModelPart mp in model.ModelParts)
	{
		//setup textures & render stuff.
		device.Transform.World = mp.PartTransform * m;
		device.Material = mp.Material;
		device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, mp.VertexStart, mp.VertexCount, mp.FaceStart * 3, mp.FaceCount);
	}
//	device.Transform.World = m;
//	for (int i = 0; i < mesh.NumberAttributes; i++)
//	{
//		device.Material = mats.Material3D;
//		mesh.DrawSubset(i);
//	}
}
//note to self: needs optimization
Any thoughts anyone? EDIT: fixed it now... for some reason dx chose to set stride size to 0 on the SetStreamSource call. [Edited by - Egelsoft on March 29, 2006 1:56:15 AM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Can this sort of order matter? Or does it only matter that you have a correct state when calling DrawPrimitive?

You should just make sure that you have the correct states and the correct information set before you try and render such as setting materials, textures and vertex declaration/formats before you try and render. Other than that I don't really see any problem.

I hope this helps.
Take care.

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!