spacecraft direction vectors

Started by
3 comments, last by mmathias 23 years, 10 months ago
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.
___________________________________________ //.athias .üller mmathias@magnet.at¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Advertisement
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.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
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?
___________________________________________ //.athias .üller mmathias@magnet.at¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
please... somebody has to know the right answer to my problem!?
___________________________________________ //.athias .üller mmathias@magnet.at¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
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]
<br>[m n o p]<br>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<br>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:<br>[ a e i d]<br><br>[ c g k l]<br>[-m -n -o p]<br>you then multiply all your world coordinates by this matrix to transform them to camera space<br>i guess you could transform your spaceship by the non inverse camera matrix<br>I think that should do it <img src="smile.gif" width=15 height=15 align=middle><br>…or maybe i''m full of crap (highly probable <img src="smile.gif" width=15 height=15 align=middle>)<br><br>-Jeff
http://www.inmytree.com/~roz/

This topic is closed to new replies.

Advertisement