Jump to content

  • Log In with Google      Sign In   
  • Create Account


directx 9 skinned mesh morphing


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 ryuu38   Members   -  Reputation: 106

Like
0Likes
Like

Posted 12 February 2014 - 10:30 AM

Hi all

 

I'm trying to morph 2 skinned meshes (through software for now) to alter a facial expression.

The 2 meshes load in with no problems as a hierarchy and render without issue too. Both have identical index buffers (they're the exact same mesh but with some vertices slightly altered) to simulate the expressions.

 

The issue I'm having is that there is no alteration to the facial expression at all. Even when loading them both as static meshes and trying that way

The following is the code I'm using to morph the meshes (Vertex is the custom vertex struct)

Vertex *srce = NULL, *dest = NULL;

src->GetMesh()->LockVertexBuffer(0, (void**)&srce);
bln->GetMesh()->LockVertexBuffer(D3DLOCK_READONLY, (void**)&dest);

for(int i = 0; i < src->GetMesh()->GetNumVertices(); ++i)
{
	srce->nor = srce->nor * weight + dest->nor * (1.0f - weight);
	srce->pos = srce->nor * weight + dest->pos * (1.0f - weight);
}

bln->GetMesh()->UnlockVertexBuffer();
src->GetMesh()->UnlockVertexBuffer();

If it helps; I can provide the meshes to see if it's an issue with them (but they're a little larger than than the single file size limit)

 

Any help would be greatly appreciated.



Sponsor:

#2 kauna   Crossbones+   -  Reputation: 2361

Like
0Likes
Like

Posted 12 February 2014 - 03:00 PM

Looks to me that your destination has "read only" flags. Shouldn't it be for the source?

 

Otherwise I suggest strongly not to read from a vertex buffer. It could result as poor performance.

 

Cheers!



#3 ryuu38   Members   -  Reputation: 106

Like
0Likes
Like

Posted 13 February 2014 - 04:14 AM

Sorry, poor naming convention on my part. The part I'm writing to is srce.

 

Thanks for the tip about reading from the vertex buffer; I'm hoping to switch to hardware morphing but need to get this working as a proof of concept



#4 kauna   Crossbones+   -  Reputation: 2361

Like
0Likes
Like

Posted 14 February 2014 - 09:17 AM

Well before using hardware morphing you could still store your vertex data in two different (CPU side) constant arrays and then store the blended result in the vertex buffer.

 

If I understand correctly, your code uses the already blended data to blend some more, so I'm not sure if this is what you are after. Eventually the src buffer content will be the same as the dst buffer content. 

 

Cheers!



#5 Buckeye   Crossbones+   -  Reputation: 4584

Like
0Likes
Like

Posted 15 February 2014 - 12:00 PM

First, your loop modifies only a single vertex. There's no change in pointers. [ EDIT: and other problems ]

for(int i = 0; i < src->GetMesh()->GetNumVertices(); ++i)
{
    srce->nor = srce->nor * weight + dest->nor * (1.0f - weight);
    srce->pos = srce->nor * weight + dest->pos * (1.0f - weight); // scre->pos based on srce->nor ???
    // srce += size_of_vertex ???
    // dest += size_of_vertex ???
    // is weight same for every calc? if so, that's fine. EDIT: I assume that's the time-dependent morphing
    // EDIT: Also assume you have changed "srce->nor =" to "dest->nor =" etc. as mentioned.
}

EDIT: ignore the following. I now see what you're doing with the weight morphing.

Is there a specific need for copying over the entire buffer? Can you just change the mesh buffer pointer depending on which expression you want to use?


Edited by Buckeye, 15 February 2014 - 01:34 PM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS