some a6 physics questions

Posted By: ventilator

some a6 physics questions - 04/26/03 06:17

i played around with a6's physics engine for a while now and have some questions...

is PH_CYLINDER already implemented as collision hull? i saw it in the manual under physics constants but it isn't listed under collision hulls and it didn't seem to work when i tried to use it.

i would like to set up a car with realistic physics. i know i have to attach the wheels to the chassis per constraints (probably with the PH_WHEEL constraint?). how does the car move then? do i have to add a force to the chassis or should i add torque to the wheels (wheel constraint motor?) and the chassis moves automatically with the wheels then? and where should the chassis model's point of origin be? in the middle between the rear wheels?
Posted By: Anonymous

Re: some a6 physics questions - 04/26/03 06:57

quote:
Originally posted by ventilator:
is PH_CYLINDER already implemented as collision hull? i saw it in the manual under physics constants but it isn't listed under collision hulls and it didn't seem to work when i tried to use it.

PH_CYLINDER can be used for testing purposes- it is not officially implemented. The part that is missing (and I would need to double-check that) is Cylinder to Mesh collisions. So if you create a box or sphere entity and set another one to cylinder, they should collide. Because the level is a mesh though, cylinders will fall straight through it. [Frown]

quote:
i would like to set up a car with realistic physics. i know i have to attach the wheels to the chassis per constraints (probably with the PH_WHEEL constraint?).
Use PH_WHEEL for the joint between the wheel and the chassis. Then use phcon_setmotor to apply a torque to the wheel. The wheels then rotate, undergo frictional forces from the ground and thereby drag the chassis along with them. Finding the right numbers for mass, friction, damping, torque, etc. can be difficult. Also make sure your setmotor parameters are not too large or the wheels will start to slip. There is one unresolved issue with the axle bending when the chassis is too heavy, or the wheels spin too fast.
Posted By: Anonymous

Re: some a6 physics questions - 04/26/03 07:01

Would it be possible to use the physics engine for a car or other complex/multiple-part object using the one object physics in commercial edition?

P.S. @Ventilator: How did you get your update to A6 already?
Posted By: Anonymous

Re: some a6 physics questions - 04/26/03 07:07

quote:
Originally posted by Fredmaster:
Would it be possible to use the physics engine for a car or other complex/multiple-part object using the one object physics in commercial edition?

Not in the way I described below. For the commercial edition it would make more sense to use a single MDL car model including wheels and turn this into a physics entity. Then add forces and torques to it for accelerating/turning.
Posted By: ventilator

Re: some a6 physics questions - 04/26/03 07:36

quote:
Because the level is a mesh though, cylinders will fall straight through it.
that's exactly what i experienced. so i have to use PH_SPHERE instead of it for the wheels of my car. should work too...

if i want the car to go around a curve, do i just need to turn the front wheels? [Smile] or do i need to apply torque/motor (front wheel drive) so that they "pull" the car around the corner?

...
the physics engine is really cool! in my experiments i had over 200 active physics entities and didn't have any jerks or any noticeable framerate drop. i didn't expect that!

quote:
P.S. @Ventilator: How did you get your update to A6 already?
ordered yesterday, got it today! [Smile]
Posted By: greyplasma

Re: some a6 physics questions - 04/26/03 16:55

Hi Ventilator,

Need your help can you post a small example of a working physics code. Since you said you have some 200 entities working.

I am unabble to compile my script.
I have updated all the dlls and everything.

It gives error:
Code:

action ball
{
myCrate=my;
phent_settype(myCrate,PH_RIGID,PH_SPHERE);
phent_setmass(crateMass);
}

MISSING/WRONG PARAMETER, COMMA UNEXPECTED.

Also is their a probelm with SED and mouse scrolling, the script just scrolls up whether using mouse scroll up or down.....
Posted By: ventilator

Re: some a6 physics questions - 04/26/03 17:20

i think this function needs more parameters: phent_setmass(crateMass);

i also have the scrollwheel problem in sed...
Posted By: greyplasma

Re: some a6 physics questions - 04/26/03 17:24

But error is caused in the first line..

phent_settype(myCrate,PH_RIGID,PH_SPHERE);
Posted By: ventilator

Re: some a6 physics questions - 04/26/03 17:34

this is some working code from my tests:

code:
action sphere
{
my.shadow=on;

phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setmass(my, 5, PH_SPHERE);
phent_setfriction(my, 70);
phent_setelasticity(my, 50, 10);
phent_setdamping(my, 20, 20 );

temp.x=cos(camera.pan)*cos(camera.tilt)*300000;
temp.y=sin(camera.pan)*cos(camera.tilt)*300000;
temp.z=sin(camera.tilt)*300000;
phent_addforcelocal(my,temp,nullvector);
}

string mdl_sphere=<sphere_0.mdl>;
function emit_sphere()
{
temp.x=camera.x+cos(camera.pan)*cos(camera.tilt)*100;
temp.y=camera.y+sin(camera.pan)*cos(camera.tilt)*100;
temp.z=camera.z+sin(camera.tilt)*100;
ent_create(mdl_sphere,temp,sphere);
}

on_mouse_left=emit_sphere;

it emits spheres from the camera position! [Smile]
Posted By: Anonymous

Re: some a6 physics questions - 04/27/03 07:00

Thanks Dude,
There's realy not much working script examples in the manual and none template scripts for the new physics engine(as far as I know)

I added some gravity and had to end the loop after one model was emited (com edition) [Confused]
Posted By: ventilator

Re: some a6 physics questions - 04/26/03 20:44

some more question:

if a physics entity stops movement completely (but is still a physics entity) it does only require very minimal or no cpu performance right?

if i stack some boxes then i can notice that they jitter a little sometimes when i look very closely. how can i avoid this? ...because i think this takes more cpu performance than it would take when they were completely standing still.
Posted By: Juff

Re: some a6 physics questions - 04/26/03 21:32

how do I add gravity to the code ventilator posted
EDIT nevermind I got it, this is really cool
Posted By: Anonymous

Re: some a6 physics questions - 04/26/03 21:40

Yo could try:

var earthgravity[3] = 0,0, -386; //////////////////////////////
// -386 is the downward pulling force along the z axis
//////////////////////////////

action sphere
{

my.shadow=on;

ph_setgravity( earthgravity );//////////////////////////////
// and now you set the gravity
//////////////////////////////
phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setmass(my, 5, PH_SPHERE);
phent_setfriction(my, 70);
phent_setelasticity(my, 70, 5);
phent_setdamping(my, 20, 20 );

temp.x=cos(camera.pan)*cos(camera.tilt)*300000;
temp.y=sin(camera.pan)*cos(camera.tilt)*300000;
temp.z=sin(camera.tilt)*300000;
phent_addforcelocal(my,temp,nullvector);

}

string mdl_sphere=<sphere_0.mdl>;
function emit_sphere()
{

temp.x=camera.x+cos(camera.pan)*cos(camera.tilt)*100;
temp.y=camera.y+sin(camera.pan)*cos(camera.tilt)*100;
temp.z=camera.z+sin(camera.tilt)*100;
ent_create(mdl_sphere,temp,sphere);
}
on_mouse_left=emit_sphere;
Posted By: Anonymous

Re: some a6 physics questions - 04/26/03 23:06

lets update our profile
Posted By: Juff

Re: some a6 physics questions - 04/27/03 00:53

okay now I want the ball to be removed about 5 seconds after I shoot it, so i can shoot another ball, since I have com.
Posted By: ventilator

Re: some a6 physics questions - 04/27/03 01:02

code:
action sphere
{
my.shadow=on;
phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setmass(my, 5, PH_SPHERE);
phent_setfriction(my, 70);
phent_setelasticity(my, 50, 10);
phent_setdamping(my, 20, 20 );
temp.x=cos(camera.pan)*cos(camera.tilt)*300000;
temp.y=sin(camera.pan)*cos(camera.tilt)*300000;
temp.z=sin(camera.tilt)*300000;
phent_addforcelocal(my,temp,nullvector);

sleep(5);
ent_remove(my);
}

this could work...
Posted By: Juff

Re: some a6 physics questions - 04/27/03 01:40

thanks alot [Big Grin] but I need one more thing [Roll Eyes]
I want it so that if you press the left mouse button, you can't shoot another ball for 5 seconds, so I don't get that error
thanks
Posted By: ventilator

Re: some a6 physics questions - 04/27/03 01:44

code:
action sphere
{
my.shadow=on;
phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setmass(my, 5, PH_SPHERE);
phent_setfriction(my, 70);
phent_setelasticity(my, 50, 10);
phent_setdamping(my, 20, 20 );
temp.x=cos(camera.pan)*cos(camera.tilt)*300000;
temp.y=sin(camera.pan)*cos(camera.tilt)*300000;
temp.z=sin(camera.tilt)*300000;
phent_addforcelocal(my,temp,nullvector);


on_mouse_left=null;
sleep(5);
on_mouse_left=emit_sphere;
ent_remove(my);
}

...could work! [Smile]
Posted By: fastlane69

Re: some a6 physics questions - 04/27/03 01:49

Hey, since we talking about wheels, let me ask this:
Is rotational inertia ("I") implemented?

It doesn't seem to be. There is a setMass, but no setRotInertia or the like. In the absense of "I", it would be more accurate to say that we can impart entities with a set angular acceleration and that __torque has nothing to do with it__. The help files even say this:

"The torque vector can be visualized as the axis of desired rotation and the magnitude of this vector determines the desired acceleration"

By this definition, I'm guessing you use a unit "I" for all rotations so that

Torque = Angular Accelration x 1

However, the definition of mass states that "...Thus by increasing an object’s mass you will have to use a stronger force (or torque) to make them move..." by which I believe that

Torque = Angular Acceleration x Mass

If I'm mistaken or if "I" will be implemented later, I would like to know so I don't have to implement it myself. Otherwise a verification of which equation is actually used would be most helpful!

[Smile]
Posted By: ventilator

Re: some a6 physics questions - 04/27/03 02:00

quote:
An object's hulltype determines its resistance to torque and thus the way it rotates. You can use one of the predefined constants to use an approximation of the object's shape or use PH_POLY to deduce the actual shape.
maybe this is what you are looking for?
Posted By: Juff

Re: some a6 physics questions - 04/27/03 02:04

thanks for the fast reply! But now I can only shoot one ball, I want to be able to shoot one every 5 seconds
thanks again
Posted By: ventilator

Re: some a6 physics questions - 04/27/03 02:09

on_mouse_left=null;
sleep(5);
on_mouse_left=emit_sphere;
ent_remove(my);

do you have it that way? i accidentally had the on_mouse_left=emit_sphere; after the ent_remove(my); in the first version...
Posted By: Juff

Re: some a6 physics questions - 04/27/03 02:17

Now I have another problem. I get an error sying that it can't find emit_sphere. I heard that when you call an action or function, it looks above for it, so I moved the emit_sphere function above the sphere action. When I did that I got an error saying it can't find the action sphere. Now what do I do?
Posted By: ventilator

Re: some a6 physics questions - 04/27/03 02:27

you have to define a prototype of the function.

function emit_sphere(); //prototype of the function

... // other functions...

function emit_sphere() // implementation of the function
{

}
Posted By: Juff

Re: some a6 physics questions - 04/27/03 02:30

sorry, I don't understand what to do [Embarrassed] I can't script ver well, I only know a few basic things
Posted By: ventilator

Re: some a6 physics questions - 04/27/03 02:33

code:
function emit_sphere();

action sphere
{
my.shadow=on;

phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setmass(my, 5, PH_SPHERE);
phent_setfriction(my, 70);
phent_setelasticity(my, 50, 10);
phent_setdamping(my, 20, 20 );

temp.x=cos(camera.pan)*cos(camera.tilt)*300000;
temp.y=sin(camera.pan)*cos(camera.tilt)*300000;
temp.z=sin(camera.tilt)*300000;
phent_addforcelocal(my,temp,nullvector);

on_mouse_left=null;
sleep(5);
on_mouse_left=emit_sphere;
ent_remove(my);
}

string mdl_sphere=<sphere_0.mdl>;
function emit_sphere()
{
temp.x=camera.x+cos(camera.pan)*cos(camera.tilt)*100;
temp.y=camera.y+sin(camera.pan)*cos(camera.tilt)*100;
temp.z=camera.z+sin(camera.tilt)*100;
ent_create(mdl_sphere,temp,sphere);
}

on_mouse_left=emit_sphere;

i am also not really good in programming. i just do trial and error all the time! [Smile]
Posted By: Juff

Re: some a6 physics questions - 04/27/03 02:39

Oh I get it now, how stupid could I be. Thanks for all of the help, its very appreciated!!
Posted By: fastlane69

Re: some a6 physics questions - 04/27/03 03:08

<<Smack!!>>

Thanks Vent!

It's mostly all there in the setmass routine, duh! A little bit of testing should answer any remaining questions I suppose.
[Embarrassed]

Amazing, simply amazing. Full translational AND rotational physics engine.

G**damn sweet!
Posted By: FlorianP

Re: some a6 physics questions - 04/27/03 03:15

http://www.conitecserver.com/cgi-bin/ubbcgi/ultimatebb.cgi?ubb=get_topic;f=20;t=001078

UNBEDINGT REINSCHAUEN !!!
Posted By: ventilator

Re: some a6 physics questions - 04/27/03 04:24

code:
var FR_wheel_ID;
var FL_wheel_ID;
var RL_wheel_ID;
var RR_wheel_ID;

action FR_tyre
{
my.shadow=on;

phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setgroup(my,2);
phent_setmass(my, 5, PH_SPHERE);
phent_setfriction(my, 70);
phent_setelasticity(my, 50, 10);
phent_setdamping(my, 20, 20 );

FR_wheel_ID=phcon_add(PH_WHEEL,my,p_player);
phcon_setparams1(FR_wheel_ID, my.x, vector(0,0,1),vector(0,1,0));
phcon_setparams2(FR_wheel_ID, vector(35,-35,0),vector(-360,360,0),vector(0.9,0.001,0));
}

action FL_tyre
{
my.shadow=on;
my.pan=180;

phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setgroup(my,2);
phent_setmass(my, 5, PH_SPHERE);
phent_setfriction(my, 70);
phent_setelasticity(my, 50, 10);
phent_setdamping(my, 20, 20 );

FL_wheel_ID=phcon_add(PH_WHEEL,my,p_player);
phcon_setparams1(FL_wheel_ID, my.x, vector(0,0,1),vector(0,1,0));
phcon_setparams2(FL_wheel_ID, vector(35,-35,0),vector(-360,360,0),vector(0.9,0.001,0));
}

action RL_tyre
{
my.shadow=on;
my.pan=180;

phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setgroup(my,2);
phent_setmass(my, 5, PH_SPHERE);
phent_setfriction(my, 70);
phent_setelasticity(my, 50, 10);
phent_setdamping(my, 20, 20 );

RL_wheel_ID=phcon_add(PH_WHEEL,my,p_player);
phcon_setparams1(RL_wheel_ID, my.x, vector(0,0,1),vector(0,1,0));
phcon_setparams2(RL_wheel_ID, vector(0,0,0),vector(-360,360,0),vector(0.9,0.001,0));
}

action RR_tyre
{
my.shadow=on;

phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setgroup(my,2);
phent_setmass(my, 5, PH_SPHERE);
phent_setfriction(my, 70);
phent_setelasticity(my, 50, 10);
phent_setdamping(my, 20, 20 );

RR_wheel_ID=phcon_add(PH_WHEEL,my,p_player);
phcon_setparams1(RR_wheel_ID, my.x, vector(0,0,1),vector(0,1,0));
phcon_setparams2(RR_wheel_ID, vector(0,0,0),vector(-360,360,0),vector(0.9,0.001,0));
}

action car
{
p_player=my;
wait(1);
my.shadow=on;
my.material=mat_metal;

phent_settype(my,PH_RIGID,PH_BOX);
phent_setgroup(my,2);
phent_setmass(my,40,PH_BOX);
phent_setfriction(my,50);
phent_setelasticity(my,50,10);
phent_setdamping(my,20,20);

vec_for_vertex(temp,my,306);
ent_create(mdl_tyre,temp,FR_tyre);

vec_for_vertex(temp,my,36);
ent_create(mdl_tyre,temp,FL_tyre);

vec_for_vertex(temp,my,5);
ent_create(mdl_tyre,temp,RL_tyre);

vec_for_vertex(temp,my,304);
ent_create(mdl_tyre,temp,RR_tyre);
}

why does my car explode when this code runs? first i create the car and the car creates it's tyres then. after reading the manual i came to the conclusion that this would be the way to do it...

and what do the spring damper constants exactly do?
Posted By: ventilator

Re: some a6 physics questions - 04/27/03 04:51

quote:
vector(var x,var y,var z) ... The vector returned has the same restrictions like a local vector: it can't be passed as vector parameter to other functions. It can be used as vector parameter for vector instructions, but only for one of the instruction's parameters.
...oh! only one parameter... it works now! the wheels are attached..
Posted By: Juff

Re: some a6 physics questions - 04/27/03 05:02

sorry for all of the questions, sorry I can't hekp you. I just need one more thing, I won't ask for anything else. Instead of the ball being removed after 5 seconds, how could I make it so that it is removed when you press the middle mouse button.
Posted By: ventilator

Re: some a6 physics questions - 04/27/03 05:10

just replace the sleep(5); with:

while(mouse_middle==0){wait(1);}
Posted By: ventilator

Re: some a6 physics questions - 04/28/03 07:54

 -
i have a car which can drive forwards and backwards now but if i try to rotate the front wheels to drive around curves they don't rotate properly anymore (see image). it looks like ph_wheel axis 2 isn't a child of axis 1...
Posted By: Anonymous

Re: some a6 physics questions - 04/27/03 21:27

Hey Ventilator slightly off topic but did you have any trouble seting the shadow flag in A6.
For example:
action sphere
{

my.shadow=on;

ph_setgravity( earthgravity );
phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setmass(my, 5, PH_SPHERE);
phent_setfriction(my, 70);
phent_setelasticity(my, 100, 5);
phent_setdamping(my, 20, 20 );

temp.x=cos(camera.pan)*cos(camera.tilt)*300000;
temp.y=sin(camera.pan)*cos(camera.tilt)*300000;
temp.z=sin(camera.tilt)*300000;
phent_addforcelocal(my,temp,nullvector);
------------------------------------------

I'm not getting any shadow for the sphere

And in adition While placing an entity in wed and using the shadow flag i'm not getting any shadow unles I lift the entity slightly of the ground

And the weirdest thing is if I use the wed from A5 And open the level in A6 and run it it's all fine
Posted By: ventilator

Re: some a6 physics questions - 04/27/03 21:39

yes, i also had this shadow problem! but only with the tyres of my car and i don't know why but it works now. [Smile] maybe because i added lod...
Posted By: Anonymous

Re: some a6 physics questions - 04/27/03 21:57

Thanks for a prompt reply.
Yeah it is kinda strange I'll have to ask one of the conitec guys on monday...

What did you have in mind by lod did you make it longer or shorter?
Posted By: Anonymous

Re: some a6 physics questions - 04/28/03 07:17

ventilator:
At first: Great what you have done with the Physics Engine until now in this short time...

About your problem:
quote:
manual v6.00 -> PH_Wheel -> Parameter 4
... Use (-360, 360, 0) to remove all limits.

This you do! And perhaps this is the reason for your snapped wheel... because if you don't allow it to change its angle in this direction, the problem shouldn't appears !??
Because I haven't understand the usage with the angles yet (I wait for the german translation [Razz] ), I don't know what the right valuas are (/should be).

Greets,
Clemens

P.S. Upload your car-demo when it is done [Wink] [only a suggestion [Big Grin] ]... And all free source code is also appreciated!

EDIT:
Two other things about your Code:
1.)
<EDIT> DELETED! reason: stupid question/idea...
2.)
Do you use a motor, yet?
If "yes":
Where is the updated code [Razz] ?
If "no":
How do you give the car a force? By giving only the p_player a CENTRALFROCE ?
Posted By: Anonymous

Re: some a6 physics questions - 04/28/03 08:00

Hmm... I think, I have written bullshit!?
After I looked the PH_Wheel picture of the manual again, I remarked that the second axis could't change the wheel in that way, like in your screenshot...:
Only the first axis could - if any (=wenn überhaupt) because meanwhile I'm not sure anymore if it has anything to do with the axis!!!
Posted By: Anonymous

Re: some a6 physics questions - 04/28/03 08:45

Boah Mann!
Was habe ich mir denn unten bei "1.)" schon wieder gedacht??
Du hast ja "MY.X" als Vector benutzt...!!!
Echt ey! Ich sollte jetzt ganz schnell ins Bett gehen bevor ich noch auf die Idee komme, anderen Leuten probieren zu helfen!
Sorry - nächstes Mal kommt was sinnvolles!

Gut' Nacht,
Clemens

P.S. War mir jetzt zu blöd und anstrengend, noch weiteres falsches Englisch mit zusätzlichem überflüssigem Inhalt zu verzapfen - daher jetzt auf Deutsch!
Posted By: Anonymous

Re: some a6 physics questions - 04/28/03 09:20

quote:

Sorry - nächstes Mal kommt was sinnvolles!

Das kann ich dir jetzt doch nicht so ganz garantieren, da mich dein Problem einfach nicht los lassen will - ich aber trotzdem geistig so am Ende bin, das wahrscheinlich wieder nur totaler Mist rauskommt...
Also, der wirklich letzte Versuch!
Ich habe mir dieses Bild (Handbuch -> PH_Wheel) nochmal angeguckt. Und da ich im Moment anscheinend mehr schlafe als wach bin, faszinieren mich schöne bunte Bilder mehr als logische Gedanken... daher:
Wenn man nun also wirklich vom Bild ausgeht und sich so davon faszinieren lässt (wie ich es im Moment tue), so liegt der Anchor-Punkt ja nicht genau auf dem Rad, sondern einzelne Stangen unterteilen das ganze. Vielleicht ist das das Problem deines abgeknickten Rades:
Dein Rad hat den Anchor-Point genau in sich drinne... [Wink]

Ich seh's schon kommen: Morgen, wenn ich wieder einigermaßen geistig dabei bin - werde ich es bereuen, nicht einfach schon nach dem ersten Posting (am besten gar keins geschrieben zu haben) aufgehört zu haben! Abgesehen mal davon, dass ich morgen früh mir wieder überlegen werde, was mich davon abgehalten hat, etwa so früh ins Bett zu gehen, dass ich nicht aus Müdigkeit den Gedanken habe, so zu tun als hät ich Bauchweh oder so'wat, nur um länger schlafen zu können...

Endgültige gute Nacht,
Clemens
Posted By: Anonymous

Re: some a6 physics questions - 04/28/03 15:04

quote:
Originally posted by ventilator:
if a physics entity stops movement completely (but is still a physics entity) it does only require very minimal or no cpu performance right?

Unless an object is disabled (see manual) it will always consume CPU time. If the object is free falling that time is negligible. If that object is colliding with other objects or the level, however, this can be costly. I used to have an auto-disable function which puts almost non-moving objects into stasis. However, there are some situation where this mechanism can be fooled (objects gliding along each other very slowly would come to an abrupt stop). Because of this I have decided to disable this feature for now, until I can think of a more reliable detection and then they will indeed not cause a performance hit. Sorry about that.

quote:
if i stack some boxes then i can notice that they jitter a little sometimes when i look very closely. how can i avoid this?
By disabling them using group masks or individual disabling.

quote:
Ich habe mir dieses Bild (Handbuch -> PH_Wheel) nochmal angeguckt. Und da ich im Moment anscheinend mehr schlafe als wach bin, faszinieren mich schöne bunte Bilder
Danke, ich habe mir viel Muehe mit den Bildern gegeben [Smile]
Der Ankerpunkt liegt dort wo sich die beiden Achsen schneiden. Die Raeder koennen einknicken, so wie es im Bild geschieht, wenn a) die Masse des Autos zu gross ist (bzw. die Gravitationskonstante), b) sich die Raeder zu schnell drehen oder c) die Spring/Damper Konstanten falsch gewaehlt sind. Ich muss mir das morgen im Buero genauer anschauen.

Es gibt ein Problem mit den Schatten, dass diese erst projiziert werden, sobald sich das Physikobjekt bewegt. Das wird z.Zt. untersucht.
Posted By: ventilator

Re: some a6 physics questions - 04/28/03 16:11

code:
<edit>newer code above!</edit>

this is my motor code... i would like to emit dust particles when the wheels slip. how could i find out if a wheel slips? should i compare the moved distance per frame with (wheel_circumference/360)*rotated_degrees and if it doesn't match it means the wheel slips?

...
thanks for the answers marco!

what do the spring/damper constants do? this isn't explained in the manual very well...
Posted By: fastlane69

Re: some a6 physics questions - 04/29/03 05:44

////////////////////////////////////////////////
I am unabble to compile my script.
I have updated all the dlls and everything.

It gives error:
Code:MISSING/WRONG PARAMETER, COMMA UNEXPECTED.

action ball
{
myCrate=my;
phent_settype(myCrate,PH_RIGID,PH_SPHERE);
phent_setmass(crateMass);
}

////////////////////////////////////////////////
////////////////////////////////////////////////

Has anyone made headway on this? I'm sure it's something stupid and trivial, but I can't work around it!
I'm getting the same problem having installed and reinstalled a6. I'm working from an A5 script and according to manual, there are no templetes to include, just register and go!
Anyways, can't register my entities, can't play with the engine, boo hoo [Frown]
Posted By: Anonymous

Re: some a6 physics questions - 04/29/03 06:08

Dude just look few posts down

I would try to define some more stuff
//
action sphere
{

my.shadow=on;

phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setmass(my, 7, PH_SPHERE);
phent_setfriction(my, 70);
phent_setelasticity(my, 50, 5);
phent_setdamping(my, 20, 20 );
}
Posted By: Anonymous

Re: some a6 physics questions - 04/29/03 06:24

Check the manual entry for phent_setmass, there are some parameters missing in your code.
Posted By: fastlane69

Re: some a6 physics questions - 04/29/03 06:37

quote:
Originally posted by Seban:
Dude just look few posts down

I would try to define some more stuff
//
action sphere
{

my.shadow=on;

phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setmass(my, 7, PH_SPHERE);
phent_setfriction(my, 70);
phent_setelasticity(my, 50, 5);
phent_setdamping(my, 20, 20 );
}

You're missing my point as you did with grey's original post. My fault as I should have posted later replies not the original. [Frown]

The error is in phent_settype. I actually cut the above ACTION and put it in, attached to an entity and all the PH code returns the same error 'wrong/missing parameter; unexpected comma" for EVERY PH function. I've tried all manner of capitalization variations and experiments and always the same error for phent_settype. The others don't matter since if I can't get the entity registered, all else will naturally fail.

Again, the error is that I can't register an entity since settype won't work.
Posted By: Anonymous

Re: some a6 physics questions - 04/29/03 07:43

Just to check the obvious, before we move to more complicated ideas: you do have A6 Commercial or Professional and run the sample with the A6 engine, right?
Posted By: fastlane69

Re: some a6 physics questions - 04/29/03 07:49

quote:
Originally posted by Marco Grubert:
Just to check the obvious, before we move to more complicated ideas: you do have A6 Commercial or Professional and run the sample with the A6 engine, right?

Actually, It is something obvious then. I'm using the trial edition in consideration of upgrading to A6 pro edition comes in. Since trial == extra, not commercial, the physics engine isn't enabled in the trial version; Silly really considering that if I didn't already need the physics engine and I can't test it in the trial version, how do I know what I'm paying for?

Never occured to me that I would have to pay to test out the upgrade is what I'm saying; Not a good way to promote the key features of the upgrade IMO.

Anyways, thanks Marco, I'm sure that's all it is. I'm quite impressed with the promises of A6 and thus I'll get the pro upgrade tommorrow. My guess is that I won't have any problems then.
[Smile]
Posted By: elsewood

Re: some a6 physics questions - 04/29/03 08:00

Make the code like that:
code:
 

entity* myCrate;
action ball
{
myCrate=my;
phent_settype(myCrate,PH_RIGID,PH_SPHERE);
phent_setmass(crateMass);
}

This DOES NOT fix phent_setmass!!, only phent_settype
Posted By: fastlane69

Re: some a6 physics questions - 04/29/03 09:19

quote:
Originally posted by elsewood:
Make the code like that:
code:
 

entity* myCrate;
action ball
{
myCrate=my;
phent_settype(myCrate,PH_RIGID,PH_SPHERE);
phent_setmass(crateMass);
}

This DOES NOT fix phent_setmass!!, only phent_settype
That's because phent_settype is correct above but phent_setmass isn't. _setmass takes 3 parameters.

Given that i'm pretty sure my woes are edition related, sorry I ever brought this up [Embarrassed]
Posted By: thuan

Re: some a6 physics questions - 04/29/03 21:12

Hello,
I try this script:

var earthgravity[3] = 0,0, -386;
function emit_sphere(); //prototype of the function
action sphere

{

my.shadow=on;
ph_setgravity( earthgravity );
phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setmass(my, 5, PH_SPHERE);
phent_setfriction(my, 70);
phent_setelasticity(my, 50, 10);
phent_setdamping(my, 20, 20 );

temp.x=cos(camera.pan)*cos(camera.tilt)*300000; temp.y=sin(camera.pan)*cos(camera.tilt)*300000;
temp.z=sin(camera.tilt)*300000;

phent_addforcelocal(my,temp,nullvector);
}

string mdl_sphere=<sphere_0.mdl>;

function emit_sphere()
{
temp.x=camera.x+cos(camera.pan)*cos(camera.tilt)*100;
temp.y=camera.y+sin(camera.pan)*cos(camera.tilt)*100;
temp.z=camera.z+sin(camera.tilt)*100;
temp.z=camera.z+sin(camera.tilt)*100;
ent_create(mdl_sphere,temp,sphere);
}

on_mouse_left=emit_sphere;

It don't work.I receive this message:

Malfunction W1600:
entity not a physics object in sphere : phent_setmass(my, 5, PH_SPHERE);
phent_setfriction(my, 70);
phent_setelasticity(my, 50, 10);
phent_setdamping(my, 20, 20 );

Can you help me . Thanks
Posted By: ventilator

Re: some a6 physics questions - 04/29/03 21:45

which edition are you using? the physics engine doesn't work in the trial version.

i don't know what could cause your problem...
do you have a sphere_0.mdl in your directory?
gravity is a global setting it doesn't have to be set in the entity's action.
Posted By: thuan

Re: some a6 physics questions - 04/29/03 21:52

I have A6 commercial.
Ihave a sphere_0.mdl in my directory.
What it means :"entity not a physics object in sphere "?
Strange?
Posted By: ventilator

Re: some a6 physics questions - 04/29/03 21:57

this error message doesn't seem to be included in the manual yet...

try to rename sphere_0.mdl to sphere.mdl because with _0 it expects LOD...

does the error message appear at compilation time or when you press the mouse button?
Posted By: thuan

Re: some a6 physics questions - 04/29/03 22:12

the error message appear when I press the mouse button.
Posted By: ventilator

Re: some a6 physics questions - 04/29/03 22:19

try to place the sphere in WED and assign the sphere action to it. without the phent_addforcelocal...

does it happen with the first sphere you want to emit or only with the following ones? [Wink]
Posted By: thuan

Re: some a6 physics questions - 04/29/03 22:41

Again ,i have the same error message.
it happen only with the following ones.
[Confused]
Posted By: Anonymous

Re: some a6 physics questions - 04/29/03 23:20

thuan: I copied your whole script exactly and tested it -> it goes on my system!
Are you sure, there isn't nothing else, which could make the error??
Because - my tip would be:
Make a new level, with only this code... If than the error message also appears it have to be a bug ?!

ventilator: I copied your car code (the VECTOR-"Bug" have I edit! -- so it doesn't explodes anymore [Big Grin] ) and have the problem, that the wheels centers its selve (=drehen sich um sich selber...!? [Wink] ). The aftereffect is, that the car jumps around the room [Razz] .
...Do you have an idea what's the reason??

Thx,
Clemens

P.S. Man-man... Was ich da für ein Müll unten geschrieben habe [Big Grin] . Aber naja, sieh's positiv: Evtl. hätte Marco sonst dein Problem übersehen. Außerdem konnte ich ihm somit mit dem Bilder-Lob eine Freude machen [Razz] [Big Grin] !!!
Posted By: thuan

Re: some a6 physics questions - 04/29/03 23:43

[QUOTE]Originally posted by Clemens:
[Because - my tip would be:
Make a new level, with only this code... If than the error message also appears it have to be a bug ?!

I do it and i have the same error message.

[Confused]
Posted By: thuan

Re: some a6 physics questions - 04/29/03 23:59

Wao, i just find my bug. I add this line :
ent_remove(my);

in the end of the action sphere and now it work fine; this is the good script:

var earthgravity[3] = 0,0, -386;
function emit_sphere(); //prototype of the function
action sphere

{

my.shadow=on;
ph_setgravity( earthgravity );
phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setmass(my, 5, PH_SPHERE);
phent_setfriction(my, 70);
phent_setelasticity(my, 50, 10);
phent_setdamping(my, 20, 20 );

temp.x=cos(camera.pan)*cos(camera.tilt)*300000; temp.y=sin(camera.pan)*cos(camera.tilt)*300000;
temp.z=sin(camera.tilt)*300000;

phent_addforcelocal(my,temp,nullvector);
on_mouse_left=null;
sleep(5);
on_mouse_left=emit_sphere;
ent_remove(my);
}

string mdl_sphere=<roue.wmb>;

function emit_sphere()
{
temp.x=camera.x+cos(camera.pan)*cos(camera.tilt)*100;
temp.y=camera.y+sin(camera.pan)*cos(camera.tilt)*100;
temp.z=camera.z+sin(camera.tilt)*100;
temp.z=camera.z+sin(camera.tilt)*100;
ent_create(mdl_sphere,temp,sphere);
}

on_mouse_left=emit_sphere;

One more time , great thanks to Ventilator.

[Smile] [Smile]
Posted By: ventilator

Re: some a6 physics questions - 04/30/03 02:18

@clemens:
code:
<edit>newer code above!</edit>

i haven't continued working on it but this is my current code... the car doesn't jump around but the front wheels don't rotate properly (see screenshot below) and so i can't steer. driving forwards and backwards works! [Smile]

the wheels are attached stiffly. i though the wheel constraint has dampers? is that what the spring/damper constants should set?
Posted By: Anonymous

Re: some a6 physics questions - 04/30/03 02:43

thuan: I don't understad why the other code doesn't go, but if it is okey now: Nice! [Smile]

ventilator: Yes, the same code I have, too... Perhabs the models are the problem, but I have used a cube for the car and symple cylinders for the wheels for testing it: same result [Frown]
I think there was a change between the actually A6 Physics Engine and the Beta Physics Engine - and because I have to use the Beta Physics Engine, yet - I have a car, which jumps around the room... could this be right [Wink] ?
Posted By: ventilator

Re: some a6 physics questions - 04/30/03 04:16

it works for thuan now because he has com and com does only support 1 physics object! [Smile]
Posted By: Anonymous

Re: some a6 physics questions - 04/30/03 04:27

@Venti:
Would you mind sending me a zip with your car script/level/models, so I can inspect it ?
Posted By: ventilator

Re: some a6 physics questions - 04/30/03 06:04

marco, i sent you an email!

clemens, your car probably jumps around because you use cylinders for collision. they don't have collision detection with level geometry yet. or do they in the beta?
Posted By: Anonymous

Re: some a6 physics questions - 04/30/03 08:49

From the A6 manual:
quote:

max_ph_entites
Determines the number of entities that can be registered for physics.

Type:
Variable, read/only.

Range:
0 - no physics engine available (S E)
1 - physics for 1 object (C)
999999 - unlimited physics (P)

CAPS_PHYSICS
Defined if the engine is capable of physics (C P).

By checking for these values it's possible to avoid obscure error messages if a user does not have the required engine version..

@Ventilator:
Got your e-mail and I will be looking into it.
Posted By: Anonymous

Re: some a6 physics questions - 05/01/03 07:08

@Ventilator: I have it working now, but I still need to figure out, why it did not work. Before I get back to you on this, some general tips:
- use hinges for the back wheels
- don't use addtorque on the wheels- set a motor value, otherwise the wheels will get kicked away in different directions by the environment. Motor values try to maintain a certain speed/direction no matter what.
- don't set the spring-damper values unless you have to, just pass a nullvector in order to use the defaults

Now how do I get that boulder off of the roof of my car? [Wink]
Posted By: Anonymous

Re: some a6 physics questions - 05/01/03 09:40

Some corrections to the manual concerning PH_WHEEL:
- axis 1 is specified relative to the first entity's frame
- axis 2 is specified relative to the second entity's frame
- only axis 1 can have a limit set on its turning range

What this means is that you should model your tires in the same direction that your car frame has been modeled. For setting up the constraint use the illustration provided in the manual with axis 1 pointing up. Ignore the angle limit for axis 2. Here's a sample:
code:
FR_wheel_ID=phcon_add(PH_WHEEL,car_frame, wheel);
phcon_setparams1(FR_wheel_ID,wheel.x,vector(0,0,1),vector(0,1,0));
phcon_setparams2(FR_wheel_ID,vector(-40,40,0),nullvector,nullvector);

This expects the wheel's axle to be aligned with the y axis and allows a steering angle of +/-40 degrees.
Posted By: ventilator

Re: some a6 physics questions - 05/01/03 17:56

thank you very much marco!

it works now! all i had to change was the order of the entities in the wheel constraint definition... now i am ready for some more experiments! [Smile]

i still don't know what the spring/damper constant specifies?

if i want to have shocks / suspension, do i have to use an additional slider constraint for each wheel? and how would i set this constrain up so that it works like a spring? just set a motor for the slider which is active all the time?
Posted By: ventilator

Re: some a6 physics questions - 05/02/03 07:12

how could i force the front wheels to stay parallel?

would the cylinder hull work better (less slip) for the wheels because it has more ground contact area than a sphere?

...maybe i should try to program a ESP system like some real cars have. [Smile]
Posted By: Phantom88

Re: some a6 physics questions - 05/01/03 22:16

I can't get your code to work, could you post your working code?

~Phantom88~
Posted By: ventilator

Re: some a6 physics questions - 05/01/03 22:21

vehicle script -> http://www.conitecserver.com/ubb/ultimatebb.php?ubb=get_topic;f=32;t=000006
Posted By: Jason Bryant

Re: some a6 physics questions - 05/02/03 03:35

I'm having trouble with the code below and the template camera system. Any advice as to what I need to do for modifications?

Thanks in advance,

Jason
Posted By: Anonymous

Re: some a6 physics questions - 05/02/03 05:05

quote:
Originally posted by ventilator:
i still don't know what the spring/damper constant specifies?

Those two values are the same parameters as the ones set in ph_setcorrections.
quote:
Sets global correction factors for the physis simulation. ERP stands for Error Reduction Parameter and defines how quickly misaligned constraints get adjusted. Setting ERP to 0 will have constrained objects drift apart after some time because errors get not corrected. With ERP set to its maximum value any constrained objects that get forced into an unacceptable position/orientation will be corrected within a single frame. This however can cause overshooting and it is thus recommended to use smaller values instead. Constraint Force Mixing on the other hand determines how much a constraint is allowed to be violated. Setting CFM to 0 results in very stiff joints (this will lead to errors though- do not do it). Setting CFM to its maximum value makes constrained objects act as though limited by rubber bands
If you want spring-like connections you can set the CFM value to something a little above 0.1, or the ERP value to a little less than 0.9. Try setting a keyboard shortcut for changing these values, as getting them just right takes a lot of trial and error.

Here's a formula for converting spring/damper coefficients (s, d) to ERP/CFM values corrected for the time value (I prefer using trial and error, though ;] )
CFM= 1/ (time*s+d)
ERP= time*s * CFM

quote:
if i want to have shocks / suspension, do i have to use an additional slider constraint for each wheel? and how would i set this constrain up so that it works like a spring? just set a motor for the slider which is active all the time?
You could soften up the wheel constraint by altering CFM/ERP, or use a slider attached to the wheel. Try setting the slider motor to a desired velocity of 0, with some margin in its max/min limits. If this does not work then use the technique described below: query the slider position and apply a positive/negative motor velocity depending on whether the position is <0 or >0. Make sure to time-correct this value or else you will have a "lowrider" if the framerate drops and the slider overshoots. [Wink]

quote:
how could i force the front wheels to stay parallel?
a) Well, in real cars, you have a beam connected to both wheels. So one idea would be to attach a limited/motorized slider to the front end of the front wheels.
b) The other way is to query the axis1 orientation of both front wheels (phcon_getposition) and then apply motor values (scaled by time) in order to rotate them to the desired position. Both methods have their advantages and disadvantages, please try both to see which gives you best performance and stability.
I just realized that the manual only refers to axis2 motors for PH_WHEEL. It should read:
quote:
Motor1: Set desired angular velocity around axis1 and the maximum torque allowed to achieve this velocity, e.g. (10, 50,0) will set a desired angular velocity of 10 Hz and a maximum torque of 50,000 Nm
Motor2: Set desired angular velocity around axis2 and the maximum torque allowed to achieve this velocity, e.g. (10, 50,0) will set a desired angular velocity of 10 Hz and a maximum torque of 50,000 Nm

quote:
would the cylinder hull work better (less slip) for the wheels because it has more ground contact area than a sphere?
The physics engine is not using surface patches, so in a way there is no "area". Instead, contact points are used, which in the case of spheres result in a single contact point underneath its center. Cylinders would yield more accurate collision results in that a number of contact points will be generated along the top and bottom cylinder caps. However, each contact adds an inequality(read: slow) constraint to the system. If these contacts differ only slightly you will probably run into problems of bouncing. (This is why PH_POLY collision often causes bouncing- a number of redundant contacts are created along the colliding edges. I am working on a fix for that right now). I have not tried creating a car with cylinders because they don't collide with level geometry. Cylinders or boxes are always slower than spheres, but they might yield better stability. Again, I urge you to try it out and see what works best for you.
Posted By: ventilator

Re: some a6 physics questions - 05/02/03 20:20

thanks for the answers!

i tried to adjust the spring/damper parameters now. it works pretty well but the car wouldn't pass the elktest yet! [Smile]

quote:
b) The other way is to query the axis1 orientation of both front wheels (phcon_getposition) and then apply motor values (scaled by time) in order to rotate them to the desired position.
i thought motor values get time corrected automatically because the units are based on seconds (Hz, quants / second)?

<edit>i think i understand now. time correction is only necessary if you use motors for corrections like keeping the front wheels parallel...</edit>

...
@jason: i updated the script below. you don't need the templates with it. control the camera with the right mouse button and the scrollwheel. try to adjust the sc and dc variables for different spring / damper settings. currently i use 4WD because i think there is less slip during acceleration then... i will work on the front wheels next because they still don't stay parallel...
Posted By: ventilator

Re: some a6 physics questions - 05/02/03 21:22

is it possible to apply more than one constraint to an entity?
Posted By: greyplasma

Re: some a6 physics questions - 05/02/03 22:22


Posted By: ventilator

Re: some a6 physics questions - 05/02/03 22:26

hm.. i don't know... but try again because i just altered the code...
Posted By: Jason Bryant

Re: some a6 physics questions - 05/02/03 22:35

@ventilator: Thank you for providing this script. It is very helpful!

Jason
Posted By: ventilator

Re: some a6 physics questions - 05/02/03 23:31

code:
function flipl()
{
phent_addtorquelocal(p_player,vector(-100000,0,0));
}

function flipr()
{
phent_addtorquelocal(p_player,vector(100000,0,0));
}

on_z=flipl;
on_x=flipr;

..could be helpful if your car flips over! [Smile]

...
the q, a, w, s keys i had in my code didn't do anything except changing the values in the debug panel. [Smile] so i removed them...
Posted By: fastlane69

Re: some a6 physics questions - 05/03/03 01:29

Suggestion Vent,

Start another topic called Car Physics so we have a nice forum to share Phys Eng C-script code on the subject.
A thread like that would be gangbusters!

BTW, thanks for the code!
Posted By: Anonymous

Re: some a6 physics questions - 05/03/03 03:41

quote:
Originally posted by ventilator:
is it possible to apply more than one constraint to an entity?

Yes. But if you apply too many constraints it can cause problems; that´s what I was referring to with regards to contact points of a cylinder. Contacts are essentially constraints that take a little longer to calculate.
Posted By: Anonymous

Re: some a6 physics questions - 05/12/03 04:33

I was wondering if there was going to be a physics demo any time soon coming out.
© 2024 lite-C Forums