Sign in to follow this  
DevLiquidKnight

Rendering System

Recommended Posts

I was wondering what is the best way to convert a .x file mesh to tris and what not? Main reason I ask is to inplement frustrum culling I must first have a way of grabbing all the polygon data and rendering it all as a whole to determain which polygons exist inside the frustrum, Or would it be easier to just render the .x subsets if they are in the frustrum, if thats the case then how do you determain the location of each subset? I was orginally going to use an octree based frustrum system but it seemed to complicated for me at the current time so I guess im looking for a easier alternative. Anyone have any suggestions on how to achieve what I want? Thanks.

Share this post


Link to post
Share on other sites
Leafteaner    860
Assuming you are loading the mesh into an ID3DXMesh (or LPD3DXMESH) you need to retrieve the vertex / index buffers, and use the attribute table to copy the data from them into their respective material groups. Check out the documentation.

The culling for the meshes depends what you're using the .x meshes for. If you have a big mesh that is used for a level, view frustum culling using just a mesh subset or the mesh itself isn't gonna do much performance wise. But if they are relatively small it's probably the way to go. I'm not sure how to figure out the subset sizes without exctracting polygon data, but for culling the whole mesh just use it's bounding box / sphere. Unless the mesh subsets are pretty far apart there's no reason to frutum cull them seperately.

Share this post


Link to post
Share on other sites
Dakiar    124
I've said this before, but I find the best way to do things like that is using a hierarchy in the x file, so that each objects bounding sphere/box can be found within the hierarchy. Culling individual triangles for one object is hardly ever worth it, either the object is visible and you draw the entire thing, or it's not and you don't draw it.

There are exceptions if you're for example using a mesh for terrain, but in that case I'd use a quad-tree. Hope this helps!

That said if you're still have your mind set on the polygons, this is the way I do it ( I'm not using it for culling though ), this will give you the vertex and index buffer, when just go through them to find each individual polygon.

------------------------------------------
LPDIRECT3DVERTEXBUFFER9 pVB;
LPDIRECT3DINDEXBUFFER9 pIB;
sm.sysMemMesh->GetVertexBuffer( &pVB );
sm.sysMemMesh->GetIndexBuffer( &pIB );
------------------------------------------

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this