Archived

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

mmathias

spacecraft direction vectors

Recommended Posts

ok... let''s say that i have a spaceship that has three direction vectors (right,up,forward). displaying many spaceships is not a problem, i simply use a matrix to rotate my objects according to my 3 vectors. well, now i want my main spacecraft (the one i am on) to remain unrotated and all the other spacecraft to rotate around mine when i roll, pitch or yaw. this rotation has to be exactly the opposite of my own ship''s rotation, and that''s where my problem is. i can''t change my direction vector so that it points in the opposite direction, because that changes my matrix so that all other objects'' normals are pointing in the wrong direction and i can''t render them anymore. your help would be appreciated.

Share this post


Link to post
Share on other sites
Your spaceship has its own cooridnate system with 3 axis (right, up, forward).

You need to define a matrix that performs the transformation of aligning the 3 world axis with your spacecraft axis. Everything in the world will then be displayed as seen from your spaceship.

This is one of the most fundamental operations in 3d graphics. It is executed for every frame of just about every 3d image rendered.

Its called the eye transform, which transforms the world space into eye space. Graphics text explain how to compute it, sa I don''t have it on the top of my head.

If you are using Opengl, the function glulookat () does it for you.

Share this post


Link to post
Share on other sites
quote:
Original post by bishop_pass

Your spaceship has its own cooridnate system with 3 axis (right, up, forward).

You need to define a matrix that performs the transformation of aligning the 3 world axis with your spacecraft axis. Everything in the world will then be displayed as seen from your spaceship.

This is one of the most fundamental operations in 3d graphics. It is executed for every frame of just about every 3d image rendered.

Its called the eye transform, which transforms the world space into eye space. Graphics text explain how to compute it, sa I don''t have it on the top of my head.

If you are using Opengl, the function glulookat () does it for you.


yes, i know what you are getting at... i am using d3d and i want my view matrix to be independent from my world matrix. that means that i still want to be able to look at my spaceship from the outside and have it stand still in space while i (the viewer) rotate around it by changing my actual view matrix.

any other suggestions?

Share this post


Link to post
Share on other sites
You want to calculate an inverse matrix from your camera''s position and oriantion in the world. You can cheat with homogenous matrices (3x3, 4x4) and do something like this:
original camera matrix:
[a b c d]
[e f g h]
[i j k l]
[m n o p]
where the top 3x3 cells are the orientation (orthonormal vectors: right, up, forward) and m n o are the camera''s location in world space
you take this matrix and flip the orientation bit of the matrix along the horizontal and then take the negative of the location vector so that the resulting matrix will be:
[ a e i d]
[ b f j h]
[ c g k l]
[-m -n -o p]
you then multiply all your world coordinates by this matrix to transform them to camera space
i guess you could transform your spaceship by the non inverse camera matrix
I think that should do it
...or maybe i''m full of crap (highly probable )

-Jeff

Share this post


Link to post
Share on other sites