Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Vector help
Topic Started: May 28 2009, 04:17 PM (330 Views)
Sothh
Member Avatar
Shaman Of Time
[ *  *  *  *  *  * ]
I am trying to lean vetors so I can make the camera set in the front seat of an airplane and rotate correctly.

Could some one give me the codes to do this, or point me in the right direction?

Thanks.
“You can’t outrun Death forever.
But you can make the Bastard work for it.”

Major Korgo Korgar
“Last of The Lancers” - AFC 32
(Andromeda Ascendant Record Database)
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
You'll need something better than vectors if you want to keep the camera aligned to the seat - welcome to the matrix ;) .

That matrix should describe the position and orientation of the camera, relative to the plane model (or seat model). Then you transform that matrix with the built-in matrix of that model, and the resulting matrix will describe the desired camera position and orientation. Apply it to the camera and that's it.

In camera Step Event:
Code:
 
var CamToPlaneMatr;

CamToPlaneMatr=CreateTransformationMatrix(-1,x_offs,y_offs,z_offs,rotx_rel,roty_rel,rotz_rel,1,1,1);
TransformMatrix(CamToPlaneMatr,CamToPlaneMatr,GetObjectTransformation(PlaneModel));
//applying the matrix will set the correct values for the regular rotx/y/z
//needed by the Step() function to update the camera transformation
ApplyTransformationMatrix(CamToPlaneMatr);
ReleaseMatrix(CamToPlaneMatr);

Note that where you normally work with rotx/roty/rotz directly to set the orientation of the camera (for example when using the mouse to look around), you will now have to use some other variables (like rotx_rel/roty_rel/rotz_rel) instead, because you're not setting the absolute orientation, but the one relative to the plane model.

I hope I pointed you and your camera in the right direction ^_^ .
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
Sothh
Member Avatar
Shaman Of Time
[ *  *  *  *  *  * ]
Thank you SO much. :mad:

I tried it and it works fine to keep the camera in the center of the plane.

Now, what would I change to off set the camera to the side?

THANKS!!!


“You can’t outrun Death forever.
But you can make the Bastard work for it.”

Major Korgo Korgar
“Last of The Lancers” - AFC 32
(Andromeda Ascendant Record Database)
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
Sothh
May 28 2009, 05:32 PM
what would I change to off set the camera to the side?
That would be the "x_offs" variable in my code. Just experiment, or use your modelling program of choice to get the best value. Remember, these offsets are relative to the origin of the model, so you have to know where that is first.

EDIT: if that doesn't change anything, you might have to set a different value for y_offs or z_offs instead, depending on the default orientation of the plane model.
Edited by MysteriXYZ, May 28 2009, 05:52 PM.
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
Sothh
Member Avatar
Shaman Of Time
[ *  *  *  *  *  * ]
Thanks, it works like a charm.

I am just having one problem, when I go faster I move farther back, and when I slow down I go father forward.


“You can’t outrun Death forever.
But you can make the Bastard work for it.”

Major Korgo Korgar
“Last of The Lancers” - AFC 32
(Andromeda Ascendant Record Database)
Offline Profile Quote Post Goto Top
 
Atarian
Advanced Member
[ *  *  * ]
make the camera code in the end-step event, most likely you are setting the camera then moving.
At least thats what i think
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
Sothh
May 28 2009, 06:00 PM
I am just having one problem, when I go faster I move farther back, and when I slow down I go father forward.
This could again be due to the default orientation of the plane; try turning it in your modelling program so it ends up pointing in the direction of the positive Y-axis (in your U3D scene).

Alternatively, add 180 to roty_rel, or simply negate the speed.
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
ghost
[ *  *  *  *  *  * ]
MysteriXYZ is right, but there is an easier way. Simply add a joint to your model and set the camera to the position and rotation of the bone. That way you can precisely see the location of the player's eyes, in your model viewer.
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply