Jump to content
  • Advertisement
Sign in to follow this  
evanofsky

D3DXSplitMesh

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

I'm trying to split a mesh into smaller ones with 9 vertices each. The original one is pretty darn big. (182^2 vertices) It gives me an error but doesn't tell me why; it says there's no source code for the error. See anything wrong? // split the big mesh ID3DXBuffer* newMeshes; hr = D3DXSplitMesh( mesh, &adjacencyBuffer[0], 9, D3DXMESH_MANAGED, &numMeshes, &newMeshes, 0, 0, 0); if(FAILED(hr)) { ::MessageBox(0, "D3DXSplitMesh failed!", "Error", MB_OK); exit(1); } littleMeshes = (ID3DXMesh*)newMeshes->GetBufferPointer(); // draw for(int i = 0; i < numMeshes; i++) { littleMeshes.DrawSubset(0); }

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Well, I never tried to use D3DXSplitMesh... usually, I divide my meshes in the modeling software (before exporting them). But considering that (182^2)/9 = 3680.444... you will have at least 3681 meshes... are you sure it's possible to create an array containing 3681 ID3DXMesh interfaces?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Big mesh: 182^2 = 33124 vertices
Number of small meshes: 33124/9 = 3680.444...

Share this post


Link to post
Share on other sites
Oh, woops. Didn't see you already divided it by 9. :)

I tried turning on full D3D debugging and linking it to d3dx9d.lib, and now it doesn't even popup a messagebox telling me about the error. Wierd.

Here's the debug output:

/** bajillion other DLLs cut out for brevity*/
'Red Moon.exe': Loaded 'C:\WINDOWS\system32\ksuser.dll', No symbols loaded.
D3DX: (INFO) Using 3DNow Instructions
Miss rate before optimization: 1.989011
Miss rate after optimization: 1.175220
The program '[1340] Red Moon.exe: Native' has exited with code 0 (0x0).

It exits with code 0 'cause I ended it with the Task Manager.

Share this post


Link to post
Share on other sites
Quote:
Original post by evanofsky
I tried turning on full D3D debugging and linking it to d3dx9d.lib, and now it doesn't even popup a messagebox telling me about the error. Wierd.

Make sure your mesh was properly loaded in release. It could be some path problem , i.e. the mesh loads correctly if the app is run from Visual Studio, because the working directory is then the project directory.

Share this post


Link to post
Share on other sites
This mesh is for a terrain; it's loaded from a .raw heightmap file. I know it's loaded correctly because I had it working before with just the big mesh. I want to split it into smaller meshes so I can do geomipmapping and things like that.

BTW, thanks for being patient with me!

Share this post


Link to post
Share on other sites
Okay, it turns out I didn't have full D3D debugging on. Now it is, and it doesn't give me any more info. I tried drawing just the big mesh, and it lags to about 1-2 fps and locks up when I exit the game. I did find out, however, that the "littleMeshes" variable isn't initialized, because when I exit the game, it tries to release the littleMeshes and locks up. I'm getting closer... :)

Share this post


Link to post
Share on other sites
Woohoo, it's fixed! Turns out the "littleMeshes" var needed to be of type "ID3DXMesh**" instead of "ID3DXMesh*". Thanks a bunch, rate++!

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!