Skip to main content
GameDev.net gamedev.net
🔒 Locked

Camera again.....

Started by Scooter Sep 3, 2000 at 8:54 PM 9 replies 500+ views
Original Post
Scooter
Scooter
Hey, I''m trying to get the camera to always stay behind my jet. (to follow it and always face the direction it faces. What I have so far is this: mDir.x = -matWorld(3,0); mDir.y = -matWorld(3,1)-1.5; mDir.z = -matWorld(3,2)+8; //worldMatrix D3DUtil_SetTranslateMatrix(matView, mDir); pd3dDevice->SetTransform( D3DTRANSFORMSTATE_VIEW, &matView); but this only moves the camera in the same x,y,and z direction and does not keep it behind when it is rotated in anyway. How do i keep it behind and always facing the same way?
We are here just like this,It really doesn't matter why.The world is here like it is,'We could laugh we could cry.Is it good or is it bad,Wright or maybe wrong?There's no use of being sad,Without a purpose within a song.
Scooter
Scooter
Ok scratch that code i''ve come up with this

D3DVECTOR view_point;
D3DVECTOR view_to;

view_point.x = matWorld(3,0) - (matWorld(0,2) * -8);
view_point.y = 2.5;
view_point.z = matWorld(3,2) + (matWorld(0,0) * -8);


view_to.x = matWorld(3,0);
view_to.y = 1.5;
view_to.z = matWorld(3,2);

// create and set the view matrix
D3DMATRIX view_matrix;
D3DUtil_SetViewMatrix(view_matrix,view_point,view_to,D3DVECTOR(0.0f,0.0f,0.0f));
pd3dDevice->SetTransform(D3DTRANSFORMSTATE_VIEW,&view_matrix);

this follows in the z direction and when it is turned in the x direction, but when the plane does a loop the camera doesnt follow behind it. Help.
We are here just like this,It really doesn't matter why.The world is here like it is,'We could laugh we could cry.Is it good or is it bad,Wright or maybe wrong?There's no use of being sad,Without a purpose within a song.
Scooter
Scooter
JimBo you wouldn''t happen to know how to get the normalized vecotor of my object and scale it negativly would you? where''s it at in the objects matrix..ect/ ?
We are here just like this,It really doesn't matter why.The world is here like it is,'We could laugh we could cry.Is it good or is it bad,Wright or maybe wrong?There's no use of being sad,Without a purpose within a song.
Scooter
Scooter
I''m extreamly new, so where exactly do i get object.position and camera.position from ??
We are here just like this,It really doesn't matter why.The world is here like it is,'We could laugh we could cry.Is it good or is it bad,Wright or maybe wrong?There's no use of being sad,Without a purpose within a song.
gumball
gumball
object.position and camera.position are variables (VECTORS) that YOU create and maintain throughout the life of your program.

For every object in your world you should maintain a position variable for it (in world space).

For your camera object you maintain 3 vectors,
Origin (Position)
LookAt (where the camera is looking)
Up (which axis is up)
rtime
rtime
Hi Scooter :-)

ok... the thing with the camera is quite easy
just rotate the camera''s position around the object
this is done by

Transform Camera by (Object.world.position)
rotate Camera
Transform Camera by -(Object.world.position)

(rotating about a pivot point)

the difficult part of the rotation is to find the
angles so that it looks nicely... (there is a ton of
possiblities....)

the 2nd problem is that the camera will jump around
like a stoned pig ;-) you have to use quaternions for this
(but i think quaternions are only really usefull
for camera-stuff.... (yes i''m aware of the gimbal lock))

but if you are really new to this stuff, you should take
a look to the topic "view transformation" of the DX-SDK

you have to calculate 3 vectors (up,right and front)
(if you need to know how to calculate them, just reply
here :-))

an other word to the 1st,2nd and 3rd person stuff..

i would base the X-Person on the different
story-telling-forms:
1st person: the viewer is the actor (the teller is the
main-actor of the story)
3rd person: the viewer is passive, but present
(the teller was present, but not acting)

this would mean, that everything from the looking the action from the outside (like in tomb raider) is 3rd person.

so long
torsten

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.