Moving a mesh around in 3D space.

This topic is 4229 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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 on other sites
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 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.