Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (ozgur, howardR, AndrewAMD, exile, Ayumi), 725 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: Car simulation using physics engine (PRO) [Re: ventilator] #23402
02/23/04 20:21
02/23/04 20:21
Joined: Feb 2004
Posts: 10
X
Xenolith Offline
Newbie
Xenolith  Offline
Newbie
X

Joined: Feb 2004
Posts: 10
I've tried tonnes of rotating. wheels, chassis and all

Re: Car simulation using physics engine (PRO) [Re: Xenolith] #23403
02/23/04 23:28
02/23/04 23:28
Joined: Sep 2003
Posts: 51
Newton Offline
Junior Member
Newton  Offline
Junior Member

Joined: Sep 2003
Posts: 51
you need to set the vehicle just like it is in the demo.

load the chassis in the model editor, and rotate the verices until the principal
axis are aligned the same way that the model in the demo.

do the same for the tires.

the go to the level editor and reposition the car.

before you do this first make a backup of you models.
Newton.

Last edited by Newton; 02/23/04 23:30.
Re: Car simulation using physics engine (PRO) [Re: Newton] #23404
02/24/04 16:03
02/24/04 16:03
Joined: Feb 2004
Posts: 10
X
Xenolith Offline
Newbie
Xenolith  Offline
Newbie
X

Joined: Feb 2004
Posts: 10
Thanx alot man! i was trying 2 fix that for hours

Just one more thing, is there a way to make the camera follow the car rather
than having to constantly rotate it with right click?

Re: Car simulation using physics engine (PRO) [Re: Xenolith] #23405
02/24/04 16:48
02/24/04 16:48
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
Quote:

Just one more thing, is there a way to make the camera follow the car rather
than having to constantly rotate it with right click?


sure, just look for the camera movement function and change it! ...probably there are several threads about such camera scripts on the forum...

Re: Car simulation using physics engine (PRO) [Re: Xenolith] #23406
02/25/04 00:21
02/25/04 00:21
Joined: May 2003
Posts: 212
Finland / Helsinki
Don Pedro Offline
Member
Don Pedro  Offline
Member

Joined: May 2003
Posts: 212
Finland / Helsinki
Here is one piece of code that will do it (from Georges magicbox)

camera.x = p_vehicle.x - 350 * cos(p_vehicle.pan);
camera.y = p_vehicle.y - 350 * sin(p_vehicle.pan);
camera.z = p_vehicle.z + 100;
camera.pan = p_vehicle.pan;
camera.tilt = -10;

btw. comment all other code in while loop...

Last edited by Don Pedro; 02/25/04 00:22.

The only place where success comes before work - is dictionary.
Re: Car simulation using physics engine (PRO) [Re: Don Pedro] #23407
02/25/04 02:38
02/25/04 02:38
Joined: Sep 2003
Posts: 51
Newton Offline
Junior Member
Newton  Offline
Junior Member

Joined: Sep 2003
Posts: 51
that is a nice camera follow code. but is too rigid, you can add some nice dampening by filtering the camare angle a litle.
somethihg like this:
Code:

var prevPan = 0;
function SetCamera()
{
var tau;
camera.x = p_vehicle.x - 350 * cos(p_vehicle.pan);
camera.y = p_vehicle.y - 350 * sin(p_vehicle.pan);
camera.z = p_vehicle.z + 100;
//camera.pan = p_vehicle.pan;
// apply a low pass filter to the camera angles
// tau = 0.3; // play with this for different damping effects
prevPan = prevPan * (1 - tau) + p_vehicle.pan * tau;
camera.pan = prevPan;

// to do: apply fi;terring to this angle too
camera.tilt = -10;
}



this code will produce a nice lagging of the camara allowing you to see the relative movement of the vehicle chassis.

I hope it works because I did not tested.
(Please do not take it offesinvely, I just one to help you people )

Newton


Last edited by Newton; 02/25/04 02:38.
Re: Car simulation using physics engine (PRO) [Re: Newton] #23408
02/25/04 03:20
02/25/04 03:20
Joined: May 2003
Posts: 212
Finland / Helsinki
Don Pedro Offline
Member
Don Pedro  Offline
Member

Joined: May 2003
Posts: 212
Finland / Helsinki
Yup!

It's far from perfect especially if the car is going fast and flies off from a bump. During flight the camera goes like a wild horse

I tested the code you gave Newton. There's on thing though. On a certain angle it "jitters" so there should be some kind of a IF statement or something to prevent that to happen. I have no idea (yet) how to use the debugging tools so I don't know variable values on that certain state but it's not >360 degrees anyway - that I've tested


The only place where success comes before work - is dictionary.
Re: Car simulation using physics engine (PRO) [Re: Don Pedro] #23409
02/25/04 03:29
02/25/04 03:29
Joined: Sep 2003
Posts: 51
Newton Offline
Junior Member
Newton  Offline
Junior Member

Joined: Sep 2003
Posts: 51
did you uncomment the line where tau is set to 0.3?
I added a comment there by accident.
you can also make tau smaller.

yes you are correct. the interpolation suffer for angle aliasing.
that is when one angle is on one side of the axis and the previus is on the other side. for example one angle is 1 degree and the other is 359. The difference should be 2 degrees, but it come out to be 361. You can use the mod function.
It may be difficult to get it work correctly.
if it does not work. I will post a camera interpolation function tonight.
all written with script code.

Newton.



Newton

Last edited by Newton; 02/25/04 03:36.
Re: Car simulation using physics engine (PRO) [Re: Newton] #23410
02/25/04 14:37
02/25/04 14:37
Joined: Sep 2003
Posts: 51
Newton Offline
Junior Member
Newton  Offline
Junior Member

Joined: Sep 2003
Posts: 51
@ don pedro
I tested you original camera function. I found it very nice the way it was first proposed.
there is not need to do anything to it. In fact what I proposed is totally incorrect.

this is the function I tested
Code:
  
starter move_camera()
{
camera.arc=72;
camera.clip_near=20;
camera.clip_far=24000;

var cam_ang[3];
var cam_dist=500;
cam_ang.pan=180;
cam_ang.tilt=30;
cam_ang.roll=0;
while(!p_vehicle){wait(1);}

while(1)
{
camera.x = p_vehicle.x - 350 * cos(p_vehicle.pan);
camera.y = p_vehicle.y - 350 * sin(p_vehicle.pan);
camera.z = p_vehicle.z + 100;
camera.pan = p_vehicle.pan;
camera.tilt = -10;
wait(1);
}
}



Newton



Re: Car simulation using physics engine (PRO) [Re: Newton] #23411
02/26/04 04:20
02/26/04 04:20
Joined: Sep 2000
Posts: 300
Ohio, USA
V
vrkaya Offline
Senior Member
vrkaya  Offline
Senior Member
V

Joined: Sep 2000
Posts: 300
Ohio, USA
Hi everyone,

I added an enhancement to the new camera code so you can change your viewpoint in relation to the car. I didn't like always being directly behind it. Just change the function to this, then use the "left arrow" and "right arrow" to adjust your view angle of the car. We need to also add a function to reset the car. I keep flipping it on it's top

Code:

starter move_camera()
{
camera.arc=72;
camera.clip_near=20;
camera.clip_far=24000;
var cam_ang[3];
var cam_dist=500;
var pan_adjustment = 0;
cam_ang.pan=180;
cam_ang.tilt=30;
cam_ang.roll=0;

while(!p_vehicle){wait(1);}

while(1)
{
camera.x = p_vehicle.x - 350 * cos(p_vehicle.pan + pan_adjustment);
camera.y = p_vehicle.y - 350 * sin(p_vehicle.pan + pan_adjustment);
camera.z = p_vehicle.z + 100;
camera.pan = p_vehicle.pan + pan_adjustment;
camera.tilt = -10;

// Adjust viewing angle with left arrow and right arrow keys
if (key_cul == 1)
{ pan_adjustment += 1; }
if (key_cur == 1)
{ pan_adjustment -= 1; }

wait(1);
}
}



Regards, Ron

Page 2 of 3 1 2 3

Moderated by  HeelX, Spirit 

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