Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 831 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
tilt + roll + pan using VECTOR* #428333
08/24/13 19:23
08/24/13 19:23
Joined: Mar 2005
Posts: 514
Brazil
Carloos Offline OP
User
Carloos  Offline OP
User

Joined: Mar 2005
Posts: 514
Brazil
Hi there

I´m translating a Project to Lite-C, and I´m founding this problem :
Before, I was able to use var(3) to calc tilt, pan and roll.
Now, I´m not being able to do it anymore.

The following code :

Code:
var CamFromWheel	= 200;
var CamFromGround       = 45;
var CamCarAxis          = -4.5;					

function move_camera()
{
	VECTOR* Temp[3];
	vec_zero(Temp);
	VECTOR* cam_ang[3];
	vec_zero(cam_ang);
	var cam_dist 		=       0;
	camera.arc		=	72;
	camera.clip_near	=	0;
	camera.clip_far	        =	7000;
	cam_ang[0]		=	Race_Car.tilt;
	cam_ang[1]		=	Race_Car.roll + 120;
	cam_ang[2] 		=	Race_Car.pan  - 180;
	cam_dist		=	clamp(cam_dist,CamFromWheel,2000);
	camera.x		= 	(((Race_Car.x ) + cos(cam_ang[2]))*(cam_dist*cos(cam_ang[0])));
	camera.y		= 	((Race_Car.y + sin(cam_ang[2]))*((cam_dist*cos(cam_ang[0])))) ;
	camera.z		= 	(((Race_Car.z + CamFromGround)+ sin(cam_ang[0]) ) * cam_dist);
	vec_set(Temp[0],Race_Car.x);
	vec_sub(Temp[0],camera.x);
	vec_to_angle(camera.pan,Temp[0]);
	camera.tilt 		= 	(CamCarAxis);
	camera.roll 		= 	Race_Car.roll;
}



Returns the error :

Can´t convert : CONV:POINTER::DOUBLE

at :
Code:
camera.x = (((Race_Car.x ) + cos(cam_ang[2]))*(cam_dist*cos(cam_ang[0])));



Its not clear to me if I can use pan,tilt & roll in a vector.
I searched the manual but didnt find a solution.
Can someone point me if I´m loosing something ?
After convert lots of lines I cané think clear anymore frown

Fórum Admin : sorry is this in´t the place to ask this.

Thankyou all.



Last edited by Carloos; 08/24/13 19:26.
Re: tilt + roll + pan using VECTOR* [Re: Carloos] #428334
08/24/13 19:28
08/24/13 19:28
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
VECTOR* cam_ang[3];

[...]

cam_ang[0] = Race_Car.tilt;
cam_ang[1] = Race_Car.roll + 120;
cam_ang[2] = Race_Car.pan - 180;


how should this work?

1. You're creating an array of 3 VECTOR pointers
2. You're using them without setting them to actual vectors or allocating memory before
3. 'cam_ang[0] = Race_Car.tilt;' -> 'vector-pointer = var'... what exactly do you want to do here?

Last edited by Kartoffel; 08/24/13 19:32.

POTATO-MAN saves the day! - Random
Re: tilt + roll + pan using VECTOR* [Re: Kartoffel] #428335
08/24/13 19:31
08/24/13 19:31
Joined: Mar 2005
Posts: 514
Brazil
Carloos Offline OP
User
Carloos  Offline OP
User

Joined: Mar 2005
Posts: 514
Brazil
Kartoffel, sorry, I don´t get your point.

Re: tilt + roll + pan using VECTOR* [Re: Carloos] #428336
08/24/13 19:31
08/24/13 19:31
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
edited it, have another look


POTATO-MAN saves the day! - Random
Re: tilt + roll + pan using VECTOR* [Re: Carloos] #428337
08/24/13 19:33
08/24/13 19:33
Joined: Mar 2005
Posts: 514
Brazil
Carloos Offline OP
User
Carloos  Offline OP
User

Joined: Mar 2005
Posts: 514
Brazil
this was what I had in c-script, and it worked :
Code:
function move_camera()
{
	var cam_ang[1];
	var cam_dist            = 0;
	camera.arc		= 72;
	camera.clip_near	= 0;
	camera.clip_far	        = 7000;
	cam_ang.tilt		= Race_Car.tilt;
	cam_ang.roll		= Race_Car.roll + 120;
	cam_ang.pan 		= Race_Car.pan - 180;
	cam_dist		= clamp(cam_dist.z,CamFromWheel,2000);// era 20
	camera.x	= ((((Race_Car.x ))+ cos(cam_ang.Pan)*(cam_dist*cos(cam_ang.tilt))));
	camera.y	= ((Race_Car.y + sin(cam_ang.Pan)*((cam_dist*cos(cam_ang.tilt))))) ;
	camera.z	= ((((Race_Car.z + CamFromGround)+ sin(cam_ang.tilt)*cam_dist)));
	vec_set(temp,Race_Car.x);
	vec_sub(temp,camera.x);
	vec_to_angle(camera.pan,temp);
	camera.tilt 	= (CamCarAxis);
	camera.roll 	= Race_Car.roll;
}


Last edited by Carloos; 08/24/13 19:34.
Re: tilt + roll + pan using VECTOR* [Re: Carloos] #428338
08/24/13 19:35
08/24/13 19:35
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
var cam_ang[3];

cam_ang[0] = Race_Car.tilt;
cam_ang[1] = Race_Car.roll + 120;
cam_ang[2] = Race_Car.pan - 180;

or

VECTOR cam_ang;

cam_ang.x = Race_Car.pan - 180;
cam_ang.y = Race_Car.tilt;
cam_ang.z = Race_Car.roll + 120;

Last edited by Kartoffel; 08/24/13 19:41. Reason: swapped y and z

POTATO-MAN saves the day! - Random
Re: tilt + roll + pan using VECTOR* [Re: Kartoffel] #428339
08/24/13 19:41
08/24/13 19:41
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
...wait, actually there's ANGLE ._.'

so it would be:
Code:
ANGLE cam_ang;

cam_ang.pan = Race_Car.pan - 180;
cam_ang.tilt = Race_Car.tilt;
cam_ang.roll = Race_Car.roll + 120;



POTATO-MAN saves the day! - Random
Re: tilt + roll + pan using VECTOR* [Re: Kartoffel] #428340
08/24/13 19:44
08/24/13 19:44
Joined: Mar 2005
Posts: 514
Brazil
Carloos Offline OP
User
Carloos  Offline OP
User

Joined: Mar 2005
Posts: 514
Brazil
yes, that´s made it.

Thankyou a LOT.

Re: tilt + roll + pan using VECTOR* [Re: Carloos] #428342
08/24/13 19:54
08/24/13 19:54
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
no problem, feel free to ask if you need further help


POTATO-MAN saves the day! - Random

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