Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 10:32
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (AndrewAMD, alibaba, fairtrader, ozgur, TipmyPip, Quad), 604 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 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 | chip programmers | 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