Jump to content
  • Advertisement
Sign in to follow this  
TheMac

Moving a mesh around in 3D space.

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

This is weird, I have a mesh that I'm animating and moving the position along the -Z axis. The issue I have is the mesh starts out slow, then speeds up to what looks like to be a constant speed. All I'm doing right now is moving the mesh using a 3D vector, then multipling the vector with the world view like so.
[Source]
D3DXVECTOR3 vMovePos;
vMovePos = D3DXVECTOR3(0.0, 0.0f, 1.0f);
D3DXVec3Scale(&vMovePos, &vMovePos, float(-8.0f * Engine->GetTimeDelta()));
D3DXVec3Add(SkinnedMesh->GetPosition(), &vMovePos, SkinnedMesh->GetPosition() );
SkinnedMesh->SetPosition(SkinnedMesh->GetPosition());
[/Source]
[/source] Then calls this method.
[Source]
// SetPosition();
memcpy(m_Pos, Vector, sizeof(D3DXVECTOR3));
D3DXMATRIX m;
D3DXMatrixTranslation(&m, m_Pos->x, m_Pos->y, m_Pos->z);
D3DXMatrixMultiply(m_World, m_World, &m);
[/Source]
[/source] Any idea why the mesh would move slow at first then slowly build up speed? Also Engine->GetTimeDelta() method is working fine. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
I've got no idea, and the code you've provided doesn't make things much clearer to me, but you might want to render the involved vectors with some colored lines, and see which ones are behaving different than expected.

Bytheway, why do you pass certain variabeles to those functions multiple times? It doesn't make sense to me. At the very least, use operator overloading, as it's much cleaner to read. Also, why set the position of the SkinnedMesh with the position it already has?

Share this post


Link to post
Share on other sites
It's the same it I was to go:

[Source]
D3DXVec3Add(&vMovePos, &vMovePos, SkinnedMesh->GetPosition() );
SkinnedMesh->SetPosition(&vMovePos);
[/Source]


It still does the same thing. As far as it being confusing, thats just becase I've hacked my code up so much trying to get this to work properly. But I still need some suggestions or if someone could tell me what I'm doing wrong.

Thanks.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!