PH_SLIDER (Problems in Z axis)

Posted By: greyplasma

PH_SLIDER (Problems in Z axis) - 05/05/03 16:21

I was trying out Slider Constraint

I made 2 map entities -
1. Hollow Cylinder (One end open)
2. Cylinder with a smaller radius

Something same as the image given in the manual (without the cube though)

I am unable to move them on Z axis

here is my code

// Attached to the cylinder of lower radius

action upper
{
Up_Piston=my;
my.shadow=on;

while(Dw_Piston==NULL){wait(1);}

phent_settype(my,PH_RIGID,PH_BOX);

sleep(1);

phent_setgroup(my,2);
phent_setmass(my,10,PH_BOX);
phent_setfriction(my,0);
phent_setelasticity(my,0,0);
phent_setdamping(my,0,0);
vec_set(p2,vector(0,0,1));
vec_set(p3,vector(-400,400,0));
UPPER_ID=phcon_add(PH_SLIDER,Dw_Piston,my);
phcon_setparams1(UPPER_ID,p2,nullvector,nullvector);
phcon_setparams2(UPPER_ID,p3,nullvector,nullvector);
}

// attached to hollow cylinder
action lower
{

Dw_Piston=my;
my.shadow=on;

while(Up_Piston==NULL){wait(1);}

phent_settype(my,PH_RIGID,PH_BOX);

sleep(1);

phent_setgroup(my,2);
phent_setmass(my,10,PH_BOX);
phent_setfriction(my,0);
phent_setelasticity(my,0,0);
phent_setdamping(my,0,0);

}

// forces

if(key_a==1)
{
vec_set(m1,vector(-50,250,0));
phcon_setmotor(UPPER_ID,m1,nullvector,nullvector);
}
if(key_s==1)
{
vec_set(m1,vector(50,250,0));
phcon_setmotor(UPPER_ID,m1,nullvector,nullvector);
}

If i keep the entire system verticle it doesnt work

if i rotate the entire system and change p2 to
vec_set(p2,vector(1,0,0));
Same code works.

Moreover if i use PH_CYLINDER instead of PH_BOX my cylinders just penitrate the floor and disappear (as if no collision)
Posted By: greyplasma

Re: PH_SLIDER (Problems in Z axis) - 05/07/03 15:22

I am still stuck on this
maybe i am doing some really stupid error

Any helps please
Posted By: ventilator

Re: PH_SLIDER (Problems in Z axis) - 05/11/03 06:26

i tried to use a slider for the first time now. it doesn't work at all for me! i experimented with it for over one hour but there seems to be no way to get it working. [Frown]

and i get an error E1513 with:

slider1_id=phcon_add(PH_SLIDER,my,0);

why isn't it possible to constrain it to the world?
Posted By: ventilator

Re: PH_SLIDER (Problems in Z axis) - 05/11/03 07:04

i found my mistake! i constrained the slider and some other objects to an anchor object with mass 0. all objects that get connected to an object with mass 0 seem to freeze. and if other physics objects collide with the frozen constrained objects they freeze too! marco, is this a bug?

now i use a hinge constrained to the world for my anchor object.

@greyplasma: try to use bigger force values for your motors. i had to use values around 100000 to get it moving...
Posted By: ventilator

Re: PH_SLIDER (Problems in Z axis) - 05/11/03 07:32

...using a combination of more than 15 constraints i have a fully functional crane simulator now! with realistic wire physics!

...wow! controlling a crane is really difficult! [Big Grin]
Posted By: greyplasma

Re: PH_SLIDER (Problems in Z axis) - 05/13/03 15:25

Thanks Ventilator,

It worked finally, you were right about appying a higher force value,

Your crane simulator seems really nice, please do share your programming experiences.

Thanks
Posted By: Anonymous

Re: PH_SLIDER (Problems in Z axis) - 05/16/03 08:03

quote:
Originally posted by ventilator:
and i get an error E1513 with:
slider1_id=phcon_add(PH_SLIDER,my,0);
why isn't it possible to constrain it to the world?

Because of a bug in the engine- I am trying to query the 2nd object's position, which is not a good idea if there is no second object..
Fixed.
Posted By: Jason Bryant

Re: PH_SLIDER (Problems in Z axis) - 08/11/03 22:11

Hi. I am getting an error using the slider joint as well. (The error flashes on and off too fast for me read it.) I have been trying to constrain it to the world as well.

This is listed as fixed below and this topic is from May (3 months ago). Is this fixed in any public version or does fixed refer to the private beta?

What is the best simple work around for this assuming this is still bugged in the public release? Is constraining it to another physics object the only method for a slider constraint to work? Does the 2nd physics object have to be active? What restrictions are there? It can't have a mass of 0?

thanks for any help,
Jason
Posted By: ventilator

Re: PH_SLIDER (Problems in Z axis) - 08/11/03 22:48

a work around for this bug would be to attach a hinge with all limits set to 0 to the world and attach the slider to this hinge then.

attaching things to an object with mass 0 leads to strange results.
Posted By: Jason Bryant

Re: PH_SLIDER (Problems in Z axis) - 08/11/03 22:57

Thanks ventilator.

Does it matter where I position the hinge? I am assuming I can position the hinge somewhere out of sight and the location is of no issue.

edit - And, am I allowed to attach an arbitrary number of constraints to this hinge? For example, I could attach several blocks that I want to have as slider joints constrained to this one hinge? Hope thats readable.

thanks,
Jason
Posted By: ventilator

Re: PH_SLIDER (Problems in Z axis) - 08/11/03 23:16

make the hinge invisible and passable (i am not sure - it could be necessary that it also is in the same group with the attached objects) and place it exactly where you want to have the sliders. you can attach as many sliders as you want.
Posted By: Jason Bryant

Re: PH_SLIDER (Problems in Z axis) - 08/11/03 23:56

The hinge that I am trying to use is in the same physics group. I don't understand what you mean... "place it exactly where you want to have the sliders."

I would like to have several blocks constrained on different slider constraints(some being constrained on the x axis and some being constrained on the y axis). I want have moving blocks that go back and forth across different areas on the level that the player has to avoid. Does this mean that I need a different hinge for each moving block in this situation?

thanks,
Jason
Posted By: ventilator

Re: PH_SLIDER (Problems in Z axis) - 08/12/03 00:04

yes, then it's better to have an individual hinge for each slider...

...
you could connect all of them to the same hinge. but all sliders and the hinge would be connected with each other. no constraint of the a6 physics engine can be totally rigid and so if you bump into a slider for example not only this slider would shake but the whole "construction" with all sliders connected to it...
© 2024 lite-C Forums