Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, degenerate_762), 1,309 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Free Cameral Selection #260885
04/14/09 12:41
04/14/09 12:41
Joined: Apr 2009
Posts: 10
W
Wayne Offline OP
Newbie
Wayne  Offline OP
Newbie
W

Joined: Apr 2009
Posts: 10
Hi all, I am new to gaming, so sorry if I am missing something very simple here. I am trying to design a 3d room. I have all the models set up with all the textures. I would like to use 1 free camera to navigate around freely, but also have the ability to move to a preconfigured position by pressing 1 through to 9. Has anyone done this before or could anyone advise me where I should be focusing my time.

Am I correct in thinking you can only have 1 free camera per map or can this be achieved by adding several free cameras to different entity’s?

Regards

Wayne

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 Offline
Expert
Germanunkol  Offline
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)
Code:
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] #260906
04/14/09 15:38
04/14/09 15:38
Joined: Apr 2009
Posts: 10
W
Wayne Offline OP
Newbie
Wayne  Offline OP
Newbie
W

Joined: Apr 2009
Posts: 10
Thank you, I will give this a go and see how we go.

Many thanks againa

Re: Free Cameral Selection [Re: Germanunkol] #297492
11/07/09 20:03
11/07/09 20:03
Joined: Aug 2005
Posts: 336
Connecticut
Galen Offline
Senior Member
Galen  Offline
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: Galen] #297496
11/07/09 20:42
11/07/09 20:42
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
[untested and because am lazy]

current_cam; //this is the current cam, default 0

function next_cam()
{
current_cam++; //go to next cam
current_cam%=9; //cycle between 9 cams
}

and in some other function or your main function, you can have:

on_c=next_cam;

now ofcourse you'll have to have each camera set to a number, for example:

if (current_cam==0)vec_set(camera.x,pos1.x); //set cam to position 1
if (current_cam==1)vec_set(camera.x,pos2.x); //so on and so forth

hope it helps... later

Re: Free Cameral Selection [Re: darkinferno] #297501
11/07/09 21:36
11/07/09 21:36
Joined: Aug 2005
Posts: 336
Connecticut
Galen Offline
Senior Member
Galen  Offline
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] #297507
11/07/09 21:57
11/07/09 21:57
Joined: Aug 2005
Posts: 336
Connecticut
Galen Offline
Senior Member
Galen  Offline
Senior Member

Joined: Aug 2005
Posts: 336
Connecticut
*bump* anyone?

Re: Free Cameral Selection [Re: Galen] #297517
11/07/09 23:09
11/07/09 23:09
Joined: Aug 2005
Posts: 336
Connecticut
Galen Offline
Senior Member
Galen  Offline
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: Galen] #297519
11/07/09 23:21
11/07/09 23:21
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
remove i-(i+1)l from your moveCamera() function...

now i want you to add a new function:

function change_Cam()
{
i++;
i%=6; //cycle between 6 views
}

now somewhere in your main function, add:

on_c=change_Cam;

you should be calling your void moveCamera() function from inside the while loop though, that or put all its instructions within a while loop

Re: Free Cameral Selection [Re: darkinferno] #297523
11/07/09 23:33
11/07/09 23:33
Joined: Aug 2005
Posts: 336
Connecticut
Galen Offline
Senior Member
Galen  Offline
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
}

}





}


Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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