6DOF, and my game

Started by
30 comments, last by medevilenemy 16 years, 10 months ago
I've been working on a new project for a few months now, and I'm now working on the weapon/projectile related functions and I have gradually come to notice that there are a couple issues with the way i'm handling 6DOF motion. I'm using a modified form of JYK's OpenGLObject class to handle placing and rotating objects and it itself works fine. I've noticed, however, that there is no clear way to determine absolute orientations within the game world (in a way reportable to the player, like angles or a bearing or whatever) and more importantly, there doesn't seem to be any clear way to determine absolute distances and relative orientations between objects (which is something I'll need for the AI and for collision detection. What I'm basically trying to ask is: can anyone suggest something that maintains proper 6DOF functionality (rotations/motion) but includes some practical way to determine absolute relations and values? (for those who are curious, here -- http://www.sendspace.com/file/ftezv9 -- is a recent (this afternoon) screenshot of the game. The only significant thing of note is the new HUD layout I added in last night. (the old HUD was really space-consuming and clunky. Things you cant see in the screenie: rotational controls are on the keyboard, but I also recently added mouse controls after not doing anything for a couple months, and the starfield does rotate appropriately with camera rotation)
There was a saying we had in college: Those who walk into the engineering building are never quite the same when they walk out.
Advertisement
If you are using some sort of scene graph, there should be no problem at all.
Scene graphs provide you with all the information necessary.

If you don't, let me give you a quick introduction.
A scene graph is a tree data structure that organizes objects and operations
by their spatial information - so to speak, their position.
Each node in the tree stors its relative position to its father's position,
and its orientation relative to its father's.
Getting info about absolute position and orientation is only a means of
adding up the available information starting from the root node up to the node
your object resides in.
Translation (relative position) and rotation (relative orientation) are
information which reside in special node types, as well as e.g. texturing info
and material parameters (this is not necessarily the case, but common).
If you want differential information on two objects, you can determine the first
common father node both share, and calculate spatial info for both objects
relative to that node; then all you need to do is subtract both values and you
have your differential information.

There are several types of scene graphs, which basically differ in the number of
space subdivisions per node, but with all the principle of organizing data and
retrieving this data is the same.

If you ask how to organize the handling of objects within the tree, this is just
a question of collision - with using scene graphs, you can reduce almost all
problems to collision.
Determining the node an object is put into so is really just a collision test
with a node's bounding box; the smallest box you find where your object fits in
completely is the node to put it into.
I am not currently using a scene graph. I am using jyk's OpenglObject class to handle the actual rotation and motion, which uses a series of Vector3 (3D vector) objects to store the actual data.
There was a saying we had in college: Those who walk into the engineering building are never quite the same when they walk out.
Another thought: I've looked into scene graphs, and I don't think they are quite necessary for my game. I can handle things relatively easily with lists of objects, and a handler for each type... but those handlers can't do their jobs if I don't have a practical way to compare specific relations/etc.
There was a saying we had in college: Those who walk into the engineering building are never quite the same when they walk out.
So you are using a list of objects that have spatial information in them...
that means your problem is more of a mathematical problem class than of a code
problem class, as your objects already bear all the information necessary.

Grab yourself a math textbook doing vector math and linear algebra, this should
be sufficient information for you to solve the problem on your own.

I mean, when you use a plain object list, that stores some vector3 instances that
make up the spatial information, than every object has it's absolute distance from
the system origin and it's absolute rotation to where it is heading in itself;
all you must do is expose this information, get the info of two objects, and
compute the differential info of those like it's shown in the book.
I could try to pull the data I need out of the matrix/vectors, but there is a lot of information stored in there... a lot a lot of information. And it is rather hard to figure out what is stored where... I realize I did not explain that well... sorry about that one.
There was a saying we had in college: Those who walk into the engineering building are never quite the same when they walk out.

If you can get a forward vector and create a normal vector from it (project a line segment from your position to a second point distance 1 along the views facing), then you could find/extract the angles like a bearring on the XY reference plane (compass direction) and up/down angle off that surface plane(or rather a coplanar at eye level). That would be fairly basic trig.

Absolute distances should be extractable from XYZ positions differences between the source and target. Relative orientations for a reference plane based on the cooedinate system would likewise just be trig.
--------------------------------------------[size="1"]Ratings are Opinion, not Fact
Quote:Original post by medevilenemy
I could try to pull the data I need out of the matrix/vectors, but there is a lot of information stored in there... a lot a lot of information. And it is rather hard to figure out what is stored where... I realize I did not explain that well... sorry about that one.


so you are actually asking what the data in the matrix and vectors represent so you can then understand which values to punch-into an equation? or are you asking for the equation? or both? I won't be able to answer either way, but I can see how clarifying this might help others to help you.
These are the variables in the "OpenglObject" class which store the relevant dataL

Vector3 m_pos;
Vector3 m_side;
Vector3 m_up;
Vector3 m_forward;
Vector3 m_upMove;
Vector3 m_forwardMove;

Basically, I have to figure out which vector stores what values, and then write a couple little general functions to extract it (which shouldn't be too hard... although I don't have experience working with C++ vector classes -- although I do know the trig/vector math)

Thanks for all the help, everyone.
There was a saying we had in college: Those who walk into the engineering building are never quite the same when they walk out.
Quote:Original post by medevilenemy
These are the variables in the "OpenglObject" class which store the relevant dataL

Vector3 m_pos;
Vector3 m_side;
Vector3 m_up;
Vector3 m_forward;
Vector3 m_upMove;
Vector3 m_forwardMove;

Basically, I have to figure out which vector stores what values, and then write a couple little general functions to extract it (which shouldn't be too hard... although I don't have experience working with C++ vector classes -- although I do know the trig/vector math)

Thanks for all the help, everyone.



I'm not sure what you want, but if you want to create a 3 by 3 orientation matrix for an object, you use the following format, assuming forward = x, up = y, side = z:

R = [ x.x  y.x  z.x ]    [ x.y  y.y  z.y ]    [ x.z  y.z  z.z ]


If those vectors are all unit vectors, then that should be a valid orthogonal rotation matrix. pos is the position of the object. I'm not sure what upMove and forwardMove are though, maybe velocity?

I suggest that you learn how to do the math yourself, and write your own class for scene management. It will give you lots of experience that you wouldn't have otherwise. The reasons why people like me know about all of these things is not because we asked for help on a forum, but because we took the time to actually figure it out for ourselves. It's been proven that you learn much better by teaching yourself than you do by acting in a monkey see, monkey do fashion, though it's generally a bit more painful at first.

This topic is closed to new replies.

Advertisement