Public Group

#### Archived

This topic is now archived and is closed to further replies.

# 3D space movement

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

## Recommended Posts

Okay, I have a basic engine set up that allows movement in 2D space, however, i''m having trouble working out how to extend it into 3D. I want to have a movement similar to the game Elite, with a Truespeed (the resultant of the three X,Y and Z speed) a rotation and a pitch. at the moment i''m stumped, I think i''m getting close but then I start confusing myself. can anyone help? I''m a big scary monster and i''m comming to eat you - raaargh

##### Share on other sites
bump

[edited by - oliii on May 26, 2003 11:45:16 AM]

##### Share on other sites
an example of a structure

  struct CCoolShip{    Vector3 Pos, Vel, Acc;    Matrix3 Orient;    CCoolShip()    : Pos(Vector3::Zero())    , Vel(Vector3::Zero())    , Acc(Vector3::Zero())    , Orient(Matrix3::Identity())    {}    void Update(float Accel, float Roll, float Pitch, float dt)    {         Vector3 Dir  = Orient.GetDirection(Vector3::eForward);        Orient.RotateAroundAxis(Dir, (Roll * dt));        Vector3 Right= Orient.GetDirection(Vector3::eRight);        Orient.RotateAroundAxis(Right, (Pitch * dt));        Acc += Dir * Accel;                Orient *= (RotRoll * RotPitch);        Pos += Vel * dt + Acc * dt*dt;        Vel += Acc * dt;        Acc = Vector3::Zero();    }};

If you want to code a 3D game, you''d better write your own matrix and vector libraries, with operator overloading and all that. Or use on from the net. There are loads.

In short Orient.GetDirection() return either one the rows or column (depending if your matrices are column or row major). All the other operations are standard matrix operations, that you should really know about. Also, it is better to use quaternions than matrices for rotations. Quaternions may sound scary at first, but it''s the safest way to achieve rotations in 3D.

##### Share on other sites
Do you know any reputable sites where I can get matrix definitions?

I already have a vector definition.

I''m a big scary monster and i''m comming to eat you - raaargh

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 23
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631768
• Total Posts
3002240
×