X Format adding extra verts on load. How does this scale?

Started by
7 comments, last by Saruman 18 years, 8 months ago
When using .X files when loading in mesh viewer, the samples, or our own engine there is a jump in vertices when the file is loaded. I am not talking about the extra vertices added on export due to duplicate verts for UVs, I am talking just brand new ones and I'm not sure why they are appearing. Our model 73 bones Maya: 1800 verts X: 2400 verts (due to UVs) Loaded: ~3500 verts This is checking in mesh viewer, samples, our own engine as I specified. So than I tried the tiny.x and the very same results, the model loads with an extra 450 vertices. The extra vertices seem to scale based on bone count, possibly weighting, but does not seem to be related to normals or UVs. Our file is perfectly fine so I know that it is not related to extra verts being in the X file, so they are added at runtime. Has anybody else run into this at all?
Advertisement
I'm guessing nobody else has looked into this? I'll try and get to the bottom of it :)
I've never run into this before, because I've never used X files seriously. However, the fact that it relates to bones got me thinking...perhaps it adds additional vertices to satisfy some maxBonesPerVertex constraint? Though that doesn't make much sense (duplication wouldn't solve anything)...

I'll try to look into it when I have more time [smile]

I've not seen this myself, but a couple of ideas you might want to try..

D3DXWeldVertices() and D3DXOptimizeInPlace() (or is it D3DXOptimizeMesh()?). I don't have my MSDN links to hand to check the exact details.

The idea being that if the 'loader' adds something, you might be able to weld them back together, OR, the process of optimizing might well find redundant data and get rid of it. Then again, given they're both D3DX it's quite possible that it won't make a difference [oh]

Be sure to post back here if you find the answer though [smile]

Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Actually I tried welding and optimizing before I posted, I do appreciate the help though :) I saw a reduction of 40 vertices with weld/optimize.. I should have posted that in the original post. This is compared to the 1000 vertices added just from loading.

I am totally thrown off today. I was ready to throw in the towel and call it a D3DX issue as even the Microsoft model Tiny.x has this same behavior.. adding 400 vertices that aren't in the source file... which is the exact behavior we were seeing. But after loading the other model from another studio it has 8202 source verts and 8202 when loaded.. which just throws all of my theories so far out the window :)

Still workin on it!


EDIT: I should have mentioned that ours was built in Maya and dumped with Okino, whereas the working one was built in 3DS and dumped from the MS exporters. I just fail to see how this could matter because the source files are fine.. unless this is a degenerate triangle issue possibly.
Try DirectXDev. Craig Peeper usually answers all D3DX related questions in time.

Quote:Original post by Coder
Try DirectXDev. Craig Peeper usually answers all D3DX related questions in time.

Someone else here already did this morning, I was beat to it :)
Maya vertices and D3D vertices are quite different. Maya (like most DCC packages) stores lots of per polygon specific information in each vertex for all polygons that it touches. Additionally DCC packages support polygons with > 3 sides while D3D is triangles only. Because of this, many Maya vertices are mapped into multiple D3D vertices. The mapping back is stored as pointreps (adjacencies after loaded with D3DXLoadHierarchyFromFile)

Older version of the DXSDK maya exporter were very naive in optimizing away these vertices since many developers use optimize functions anyways after loading. But in the June release of the DXSDK many of those optimizations are now done for you. You should see a significant decrease over older versions. The exporter also autogenerates tangents and binormals from the texture coordinates because many advanced effects require this information which is not available for export from Maya. This may cause extra vertex splits for some models based on characteristics of the UV mapping.

I highly suggest that you try the version of the exporter from June or later if you are not already. If you cannot make that change, hold on to the adjacency buffers and try using ID3DXMesh::Optimize and D3DXWeldVertices. If you use these functions don't forget to remap your ID3DXSkinInfo based on the vertex remaps they returns.

-Daniel Horowitz
Microsoft, DirectX Solution
Thank you very much Daniel, I appreciate your time! :) I'll begin working on this solution tomorrow.

This topic is closed to new replies.

Advertisement