Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 16,302 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Camera roams within box boundaries HELP #252152
02/16/09 20:25
02/16/09 20:25
Joined: Feb 2009
Posts: 11
T
ToyLetBowl Offline OP
Newbie
ToyLetBowl  Offline OP
Newbie
T

Joined: Feb 2009
Posts: 11
This is my free roaming camera code..how do i implement it such that it is not able to move outside my room box and stays within the boundaries?


//this function updates camera object, which implements free roaming camera
void freeRoamCamera(void)
{
VECTOR vMove = {_VAR(0), _VAR(0), _VAR(0)};
VECTOR vForce = {_VAR(0), _VAR(0), _VAR(0)}; //temp variables for moving and rotating the camera

//update camera rotation variables based on mouse input, and multiply by mouse sensitivity
vForce.x = _VAR(-1*MOUSE_SENSITIVITY*_FLOAT(v(mouse_force).x)*FLOATV(time_frame)); //set pan angle variable
vForce.y = _VAR(MOUSE_SENSITIVITY*_FLOAT(v(mouse_force).y)*FLOATV(time_frame)); //set tilt angle variable
//set roll based on q and e keys
vForce.z = _VAR((FLOATV(key_e) - FLOATV(key_q))*FLOATV(time_frame)); //set roll angle variable

//update camera position variables based on keyboard input W,A,S,D,home,end keys
vMove.x = _VAR(CAMERA_SPEED*(FLOATV(key_w) - FLOATV(key_s))*FLOATV(time_frame)); //set forward variable
vMove.y = _VAR(CAMERA_SPEED*(FLOATV(key_a) - FLOATV(key_d))*FLOATV(time_frame)); //set sideways variable
vMove.z = _VAR(CAMERA_SPEED*(FLOATV(key_home) - FLOATV(key_end))*FLOATV(time_frame)); //set upward variable

//update the camera's rotation and position
vec_add((VECTOR*)&v(camera).pan, &vForce); //rotate camera based on vForce variable

vec_rotate(&vMove, (ANGLE*)&v(camera).pan); //rotate vMove variable in direction of camera
vec_add((VECTOR*)&v(camera).x, &vMove); //move camera position based on vMove variable
}


Aye Carumba~
Re: Camera roams within box boundaries HELP [Re: ToyLetBowl] #252314
02/17/09 16:41
02/17/09 16:41
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Take a look at:
clamp - http://www.conitec.net/beta/aclamp.htm

Basicly clamp every coordinate (x,y,z) to the specific boundaries.

Re: Camera roams within box boundaries HELP [Re: Xarthor] #253692
02/26/09 05:06
02/26/09 05:06
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline
Serious User
PrenceOfDarkness  Offline
Serious User

Joined: Aug 2004
Posts: 1,305
New York
Take a look at my two camera codes that I contributed. They are very simple. What you then do is have an entity and have the camera c_trace it like I did the player. If there is something between the camera and the object you can just have it zoom in. Altough xartor's idea will work, it seems like your will need to clamp every single room, which might suck for you wink


"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1