Jump to content
  • Advertisement

Archived

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

The Pentium Guy

"A Camera" in d3d

This topic is 5279 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey im making a racing game(First PErson, so you move the camera WITH the oject) i want to have a camera where i can change my View i have a caemra class and i created an instance of it however, when i render my objects i want to move the car, and make the camera "Follow" it, how would i change the view - im usign LookAtLH VIew matrix to position the car and everything, but how would i change from what perspective i see it from(in my example, how would i "follow" the car) do i need to Matrix Multply the platform''s position with the View matrix and then matrix multiply the car''s position with the view matrix? how would i acheive that effect? or is it simpler than that? pent

Share this post


Link to post
Share on other sites
Advertisement
Well lok's like I am at asistence again
(your lucky day)

When you watn to move camera with Matrix Lok At (or somthing like that) you pass the folowing parameters to function

VEye
VLookAt
VUp

So you position the VEye vector a lithel behind your car and a lithel above (3rd person camera).
VLookAt shoud be even closer to the car buth still far enough to see the road.
When you "Move the car" you must move the camera in the same direction for the same distance .

VUp shoud be somthing like 0,1,0.



[edited by - Red Drake on June 4, 2004 1:44:15 PM]

Share this post


Link to post
Share on other sites
that's exactly what im doing lol


see i did this

begin scne

world = identity

platform.setupwrld
platfor.render

car.setupworld
car.render

//theproblem comes in here:

d3ddev.transform.view = matrix.lookatLH(view.pos,view.target,new vector3(0,1,0)

//the line above has *no* effect because you're changing it at the end after all the objects have been rendered, if you change it in the beginning it'll have no effect becuase the you "setup the world" *again* (meaning you change the View again) for each individual object and such immeditaely after

end scene
present



but what im trying to accomplish is this:
*after* you've rendered all the objects, how wuold you change the "View" camera so that you see your scene from a different angle(in my case, behind the car)

(Btw in response to your sugestions, yes, the View camera is behind the car and moves whenever the car moves)

[edited by - The Pentium Guy on June 4, 2004 1:56:51 PM]

Share this post


Link to post
Share on other sites
Puth the camera below
platform.setupwrld
and if this does not help then
What do you do at this "platform.setupwrld" ?
You shud make a funnction & variables in your camera class that woud remeber the last position of camera so when you use "platform.setupwrld" the last cordinates woud be enterd .

Share this post


Link to post
Share on other sites
You realy shoud write your code like this


void D3D_Render (void)
{
D3D_Device.BeginScene(); //Somthing like this ;) i dont remember

D3D_Device.SetTransform (WORLD,ClassCamera.Get_camera()); // You set this once per frame at the top


// now when you want to move camera

ClassCamera.MoveCamera(...);

D3D_Device.EndScene();
}


and the camera class


class ClassCamera
{
public:
void MoveCamera ( .... );
D3DMatrix Get_camera(void);

private:
D3DMatrix CamMatrix;

};
void ClassCamera::MoveCamera ( .... )
{
CamMatrix = D3DXTransformCamera (.....)
}

D3DMatrix ClassCamera::Get_camera(void)
{
return CamMatrix;
}


Please note that the functions used are probably not corect (Direct3D functions) buth i don''t want to go and read on the D3D documentation.
So the point is
Set the camera at begining of the frame render and NEWER after.
If you move your camera after you will update it at next frame.

Share this post


Link to post
Share on other sites
i read ur last post again and i think this is what you''re saying
first, my platform''s gonna always be at Identity by default
ill move the platform down when the car moves up
ill store the car''s "real" position, but won''t use it

identity
platform.setupworld ''moves down when car moves up..etc
platform.render

//my COLLISION is gonna be like this:
car.setupworld ''but don''t render the car yet.., just move the car to where it "really" is in space

car.mesh.intersect //CHECK FOR COLLISION with D3DXMeshIntersect


identity ''car''s gonna be in the same place anyways
car.render

i hope i got it right
thanks
pent

Share this post


Link to post
Share on other sites
Yes, that''s it.

And I hawe noticed that you use Visual Basic - i hink becouse you put " '' " at comments and not // If it''s true you coud say so , and I woud wrote the camera class in VB code at first place (if you don''t know c++ that class might look a lithel strange - right?

P.S.
Can you tell me what is "lol" - what does it means ?
I look at it and cant recognize it, so what is it

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!