Sign in to follow this  
mayankz

Help with DirectX Meshes

Recommended Posts

mayankz    122
We're making an automated 3D face modeler that generates a full 3D model of the human head from a single frontal view (image). We're using a Shape from Shading (SFS) algorithm (works on brightness level of pixels) to generate the depth map. Well the depth map isn't really satisfactory, so we did some smoothing using Bezier's algos. The Shape from Shading algorithm works ok for images taken sans Ambient light, but we don't want to put restrictions on our system and want it to work on images taken from any digicam. For this, we're trying to deform a previously generated (ideal) model to the shape that the SFS algorthm gives. We've made the base model in 3DSMAX and exported it to DirectX's .X format via Milkshape. We're then reading the model via the D3DXLoadMeshFromX. The problem now is this: We need to map vertices from the base model to the model generated by SFS. But we found out that ordering of vertices in the Mesh is random (due to some optimization perhaps?). Is there a way to order the vertices in the Mesh so that they are sorted as per X,Y ? Meaning we should be able to start reading from the top left and end at the right bottom. After performing corrections on the model, we need to map the texture from the original image (obtained from the digicam) to the face. We're able to do that for the model generated by SFS by copying regions from the image on each triangle drawn by the DrawPrimitive call. Is there a better way ? Also, if anyone has suggestions on the whole thing, please do reply. We'll be grateful for the much needed help. Thanks, Mayank http://www.myspace.com/mayankz

Share this post


Link to post
Share on other sites
jollyjeffers    1570
Quote:
Original post by mayankz
We need to map vertices from the base model to the model generated by SFS. But we found out that ordering of vertices in the Mesh is random (due to some optimization perhaps?).
Yes, it's quite likely that optimization will create a seemingly random pattern of vertices.

However I would recommend you actually create an extra layer of indirection - a look-up table if you will. The D3DX optimizer is pretty damned good and for the sort of polygon density that you're using I would imagine it'll be well worth hanging on to.

Load up and optimize the mesh then simply lock the VB and project each vertex onto the relevant plane (e.g. XY) and store this look-up for later on (e.g. a <x,y,index> tuple).

Quote:
Original post by mayankz
Meaning we should be able to start reading from the top left and end at the right bottom.
Just as an aside... you're looking at this in the wrong way as far I can tell. Direct3D and its resources are much more geared towards visualisation than dynamic data or regular editing (thats not to say it can't do these though). Consequently your re-ordering of the data really helps with an occasional or even one-off data generation step but then is quite likely to hurt the actual presentation and rendering of that data. Whilst not always intuitive, bending your algorithm to be favourable to the output rather than the input is a good idea [smile]

Quote:
Original post by mayankz
After performing corrections on the model, we need to map the texture from the original image (obtained from the digicam) to the face. We're able to do that for the model generated by SFS by copying regions from the image on each triangle drawn by the DrawPrimitive call. Is there a better way ?
I'm not familiar with all the algorithms you've mentioned, but it sounds to me like you're doing simple projective texturing - that shouldn't require any data copying or manipulation. Simply use the same process I mentioned above - project vertices onto the texture's plane and derive the UV coordinates as necessary...

hth
Jack

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