1 registered members (AndrewAMD),
1,306
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Free Cameral Selection
[Re: Wayne]
#260887
04/14/09 13:07
04/14/09 13:07
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
Expert
|
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
Well, there is the predefined view called "camera" which can be moved by altering camera.x,camera.y and camera.z. Then you can also define more "views" (see 'view' in the manual) which can be displayed on different parts of the screen and which can show different parts of the level (for example: your camera looks into the direction your player car is facing, and then you define another view called "rearview" which will be displayed at the top of your screen and which, in your level, always is at that camera's position but facing backwards. Try this: (call moveCamera(); in your "main" function, after a level is loaded)
var camPos1[3] = {100,0,0}; //define these at the beginning of your script. change the 100,0,0 to the positions you want the camera to
var camPos2[3] = {-100,0,0}; //be at when you press 1 to 9
var camPos3[3] = {1000,0,0};
var camPos4[3] = {300,0,0};
var camPos5[3] = {0,400,0};
var camPos6[3] = {100,0,100};
var camPos7[3] = {100,35,0};
var camPos8[3] = {0,0,23};
var camPos9[3] = {100,1,0};
void moveCamera()
{
mouse_mode = 4;
while(1)
{
camera.pan += mouse_force.x*time_step*5;
camera.tilt += mouse_forc.y*time_step*5;
vec_set(temp,vector((key_w-key_s)*time_step*10,(key_d-key_a)*time_step*10,0));
vec_rotate(temp,camera.pan);
vec_add(camera.x,temp);
if(key_1 == on) //if key 1 is pressed, move the camera to the position defined before as camPos1
vec_set(camera.x,camPos1);
if(key_2 == on)
vec_set(camera.x,camPos3);
if(key_3 == on)
vec_set(camera.x,camPos3);
if(key_4 == on)
vec_set(camera.x,camPos4);
if(key_5 == on)
vec_set(camera.x,camPos5);
if(key_6 == on)
vec_set(camera.x,camPos6);
if(key_7 == on)
vec_set(camera.x,camPos7);
if(key_8 == on)
vec_set(camera.x,camPos8);
if(key_9 == on)
vec_set(camera.x,camPos9);
wait(1);
}
}
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: Free Cameral Selection
[Re: Germanunkol]
#297492
11/07/09 20:03
11/07/09 20:03
|
Joined: Aug 2005
Posts: 336 Connecticut
Galen
Senior Member
|
Senior Member
Joined: Aug 2005
Posts: 336
Connecticut
|
Anyone have a script (or script idea) for converting this to iterate through a collection of camera positions by hitting one key only? I was thinking of setting up a list of camera positions as shown here, but then using just one key to jump from one position to the next (I plan on having several dozen, so 0-9 keys wouldn't be enough).
Last edited by Galen; 11/07/09 20:09.
|
|
|
Re: Free Cameral Selection
[Re: darkinferno]
#297501
11/07/09 21:36
11/07/09 21:36
|
Joined: Aug 2005
Posts: 336 Connecticut
Galen
Senior Member
|
Senior Member
Joined: Aug 2005
Posts: 336
Connecticut
|
Thanks. Wasn't working for me though.
Trying to figure out why the following won't work: var i = 0; void moveCamera() { var camPos0[3] = {30,71,1405}; var camPos1[3] = {-120,71,1405}; var camPos2[3] = {-270,71,1405}; var camPos3[3] = {-390,71,1405}; var camPos4[3] = {-510,71,1405}; var camPos5[3] = {-630,71,1405}; var camPos6[3] = {-750,71,1405}; STRING* camPosF = "camPos" + i; vec_set(camera.x,camPosF); i = (i + 1); }
Last edited by Galen; 11/07/09 22:09.
|
|
|
Re: Free Cameral Selection
[Re: Galen]
#297517
11/07/09 23:09
11/07/09 23:09
|
Joined: Aug 2005
Posts: 336 Connecticut
Galen
Senior Member
|
Senior Member
Joined: Aug 2005
Posts: 336
Connecticut
|
Okay, I almost have it working. When I hit "p" (the button I assigned for changing the camera view), I briefly see the new camera position flash on the screen, but then I just end up back at my camera's starting position. Anyone have any idea what I may be doing wrong?
Here's my latest code: (orange for camera movement, blue for the rest of my default camera code):
int i = 0;
void moveCamera() { mouse_mode = 4; var camPos0[3] = {30,71,1405}; var camPos1[3] = {-120,71,1405}; var camPos2[3] = {-270,71,1405}; var camPos3[3] = {-390,71,1405}; var camPos4[3] = {-510,71,1405}; var camPos5[3] = {-630,71,1405}; var camPos6[3] = {-750,71,1405}; if (i == 0) {vec_set(camera.x,camPos0);} if (i == 1) {vec_set(camera.x,camPos1);} if (i == 2) {vec_set(camera.x,camPos2);} if (i == 3) {vec_set(camera.x,camPos3);} if (i == 4) {vec_set(camera.x,camPos4);} if (i == 5) {vec_set(camera.x,camPos5);} if (i == 6) {vec_set(camera.x,camPos6);}
i = (i + 1); }
action free_camera() { // c_setminmax(my);
//video_switch(11,32,1); //1024x768 in fullscreen mode video_set(1920,1200,0,1); d3d_antialias = 9;
//camera.clip_near = 5;
//camera.clip_far = 20000;
VECTOR camera_force; set(my,INVISIBLE|POLYGON); // set(my,PASSABLE);
camera_force.z = 0; vec_set(camera.x,my.x); vec_set(camera.pan,my.pan); my.pan = 340; my.tilt = 250; //my.roll = 340;
camera.flags |= ISOMETRIC; camera.arc = 10;
while(1) { camera_force.x = (key_w - key_s)*50*time_step; camera_force.y = (key_a - key_d)*50*time_step; vec_add(my.pan,vector(mouse_force.x*(-6)*time_step,mouse_force.y*6*time_step,0));
c_move(my,camera_force,nullvector,GLIDE+IGNORE_PASSABLE+IGNORE_PASSENTS+IGNORE_PUSH); vec_set(camera.x,vector(my.x,my.y,my.z)); vec_set(camera.pan,my.pan);
wait(1); }
}
|
|
|
Re: Free Cameral Selection
[Re: darkinferno]
#297523
11/07/09 23:33
11/07/09 23:33
|
Joined: Aug 2005
Posts: 336 Connecticut
Galen
Senior Member
|
Senior Member
Joined: Aug 2005
Posts: 336
Connecticut
|
Thanks for the reply!
I tried that, but it crashes acknex.exe--here's the code as I have it:
int i = 0;
action free_camera() { // c_setminmax(my);
//video_switch(11,32,1); //1024x768 in fullscreen mode video_set(1920,1200,0,1); d3d_antialias = 9;
//camera.clip_near = 5;
//camera.clip_far = 20000;
VECTOR camera_force; set(my,INVISIBLE|POLYGON); // set(my,PASSABLE);
camera_force.z = 0; vec_set(camera.x,my.x); vec_set(camera.pan,my.pan); my.pan = 340; my.tilt = 250; //my.roll = 340;
camera.flags |= ISOMETRIC; camera.arc = 10;
while(1) { camera_force.x = (key_w - key_s)*50*time_step; camera_force.y = (key_a - key_d)*50*time_step; vec_add(my.pan,vector(mouse_force.x*(-6)*time_step,mouse_force.y*6*time_step,0));
c_move(my,camera_force,nullvector,GLIDE+IGNORE_PASSABLE+IGNORE_PASSENTS+IGNORE_PUSH); vec_set(camera.x,vector(my.x,my.y,my.z)); vec_set(camera.pan,my.pan);
wait(1);
void moveCamera() { mouse_mode = 4; var camPos0[3] = {30,71,1405}; var camPos1[3] = {-120,71,1405}; var camPos2[3] = {-270,71,1405}; var camPos3[3] = {-390,71,1405}; var camPos4[3] = {-510,71,1405}; var camPos5[3] = {-630,71,1405}; var camPos6[3] = {-750,71,1405}; if (i == 0) {vec_set(camera.x,camPos0);} if (i == 1) {vec_set(camera.x,camPos1);} if (i == 2) {vec_set(camera.x,camPos2);} if (i == 3) {vec_set(camera.x,camPos3);} if (i == 4) {vec_set(camera.x,camPos4);} if (i == 5) {vec_set(camera.x,camPos5);} if (i == 6) {vec_set(camera.x,camPos6);}
}
function change_Cam() { i++; i%=6; //cycle between 6 views }
}
}
|
|
|
|