Advertisement

movement with third person cam view

Started by April 20, 2002 05:09 PM
7 comments, last by okouya 22 years, 9 months ago
yes i wanna know if someone can help me for doing a first person cam view with velocity updating each rotation how to do that se what i do : Tcamera = class position:Tvector; velocity:Tvector; view:Tvector; upvector:Tvector; rayon:glfloat; constructor Create; procedure positioncamera(posx:glfloat;posy:glfloat;posz:glfloat;viewx:glfloat; viewy:glfloat;viewz:glfloat;upx:glfloat;upy:glfloat;upz:glfloat); procedure mov(speed:glfloat); procedure rotate(dir:glfloat); procedure rotatearound(joueur:Tvector;dir:glfloat); end; implementation constructor Tcamera.Create; begin inherited Create; with position do begin x:=0; y:=0; z:=0; end; with view do begin x:=0; y:=1.0; z:=0.5; end; with upvector do begin x:=0; y:=1; z:=0; end; rayon:=5; with velocity do begin x:=0; y:=0; z:=-2; end; end; procedure Tcamera.positioncamera(posx:glfloat;posy:glfloat;posz:glfloat;viewx:glfloat; viewy:glfloat;viewz:glfloat;upx:glfloat;upy:glfloat;upz:glfloat); begin with position do begin x:=posx; y:=posy; z:=posz; end; with view do begin x:=viewx; y:=viewy; z:=viewz; end; with upvector do begin x:=upx; y:=upy; z:=upz; end; end; procedure Tcamera.mov(speed:glfloat); begin position.x:=position.x+velocity.x*speed; position.z:=position.z+velocity.z*speed; view.x:=view.x+velocity.x*speed; view.z:=view.z+velocity.z*speed; end; procedure Tcamera.rotatearound(joueur:Tvector;dir:glfloat); var aux:Tvector; begin with aux do begin x:=position.x-joueur.x; z:=position.z-joueur.z; end; position.z:=(joueur.z+sin(dir)*aux.x+cos(dir)*aux.z); position.x:=(joueur.x+cos(dir)*aux.x-sin(dir)*aux.z); velocity.z:=(sin(dir)*velocity.x+cos(dir)*velocity.z); velocity.x:=(cos(dir)*velocity.x-sin(dir)*velocity.z); velocity.y:=velocity.y; end; procedure Tcamera.rotate(dir:glfloat); var aux:Tvector; begin with aux do begin x:=view.x-position.x; y:=view.y-position.y; z:=view.z-position.z; end; view.z:=(position.z+sin(dir)*aux.x+cos(dir)*aux.z); view.x:=(position.x+cos(dir)*aux.x-sin(dir)*aux.z); velocity.z:=(sin(dir)*velocity.x)+(cos(dir)*velocity.z); velocity.x:=(cos(dir)*velocity.x)-(sin(dir)*velocity.z); end; the fonction that i used is rotate around . to make my rotation but the velocity don''t walk. because when i do a lot of rotation it tend to 0 unit. there is no more velocity after 10 rotation for exmple so i don''t still move that my problem . please help me please help me end. love and peace
love and peace
what do you actually want? first person (as you say in your post) or third person (as you say in your thread´s topic) ??
Advertisement
third person sorry like in tomb raider can you help me please./
if i post it here it''s because i think that it''s the best forum for this problem

love and peace
love and peace
sorry i´ve never done a third person view.
so explain me how to the view like in tom raider please.
look at my code and solve my problem about my velocity.please help me if you knw how

love and peace
love and peace
I don''t see what you''re going to have your velocity for (read in the other forums).

If the player-object is positioned at (x, y, z) with yaw (a) and pitch (b), the camera must be put at (x - CAM_DIST * sin(a), y - CAM_DIST * sin(b), z - CAM_DIST * cos(a + 180)), or alike. CAM_DIST is the shortest distance we can put the camera from the player object without getting any polygons inbetween. A simple ray-trace check is everything you need.
Advertisement
but i need this velocity to perform collision detection.
here the problem is that when i turn i have to have my velocity vector réoriented in the good direction and i can''t that why.
so i wanna know how to have my velocity vector in the good orientation to perform collision detection.


love and peace
love and peace
I see that you have one vector for position and a vector for the view. Due to possible errors in calcs, I give you the advice to calculate the view vector from the position and view vector.

The velocity vector moves the position. This is calculated from the current state of the view, user input and perhaps some additional stuff. Is this the major problem?
i resolve my problem now there was full things that i did not anderstand but now it is thnaks

love and peace
love and peace

This topic is closed to new replies.

Advertisement