Optimizing D3D meshes

Started by
3 comments, last by Motorherp 19 years, 10 months ago
Hi there people, I was wondering if anyone could help me please. I am attempting to create a collision engine for convex geometry based on the Voroni clip algorithm. In order to simplify the code and be able to traverse between adjacent features efficiently I require that each feature be unique (ie no duplicates). The convex geometry class I have written takes a D3DXMESH as an input from which it creates its features (and voroni regions). However I have noticed that many vertices are duplicated in the mesh''s vertex buffer leading to feature degeneracies, even for simple objects such as a cube created using the D3DXCreateBox function. I have tried using the mesh optimize and optimize in place functions but they dont remove these duplicate verticies (unless of course Im using them wrong). Does anyone know if directX has any built in functionality to perform this kind of operation or will I have to create my own? Thanks in advance
[size="1"] [size="4"]:: SHMUP-DEV ::
Advertisement
The MeshView program with the SDK has a weld vertices option that may do the trick
------------------------See my games programming site at: www.toymaker.info
Cheers for the reply but I''ve solved the problem and it was just me being silly. Still not quite used to this direct x stuff. The D3DXCreate* functions make non-indexed meshes and my .x loaded meshes weren''t working correctly because I had a DWORD pointer looking at the index buffer instead of a WORD pointer. Doh.
[size="1"] [size="4"]:: SHMUP-DEV ::
Duplicate positions will happen when the vertex needs to be split because of UV mapping, or normals (for sharp creases in the mesh), among other reasons.

If you want no duplicates, you should re-map the position data into a welded array yourself after loading. It''s really quite simple to do using, say, binning on the X coordinate, or hashing. Or just plain O(N^2) search -- probably will be lost in the noise.
enum Bool { True, False, FileNotFound };
Thanks for the ideas. The main area of confusion however was that I assumed the D3DXCreate* functions created indexed meshes which they dont. As you say it is often necessary to duplicate verts in meshes for rendering purposes. However these meshes are often far to complicated to use for collision detection. For anyone interested in implementing a similar collision system I suggest creating purpose built simple collision meshes. This way the number of collision checks are reduced and vertex degeneracy can be avoided in the modelling package. Just dont do what I did and assume you can use the D3DXCreate stuff as a quick check. Very confusing. Then again they're designed for rendering so (for the box at least) it was appropriate for it duplicate the verts. Just not got my thinking cap on

[edited by - motorherp on June 5, 2004 5:16:18 PM]
[size="1"] [size="4"]:: SHMUP-DEV ::

This topic is closed to new replies.

Advertisement