Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (vicknick, howardR, sleakz), 691 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
6D Joints / Hinge Joints and vehicles #405378
07/29/12 20:55
07/29/12 20:55
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline OP
Expert
Rei_Ayanami  Offline OP
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Hey guys!

I am currently working on car physics (using PhysX in A8) and I
have stumbled upon a problem: the wheels.

Generally the PhysX SDK would provide wheel functions, however,
they are not included in the GS-Wrapper. Furthermore, I cannotuse
the raycast-wheel GS delivers, because I need to have more settings
on the wheel (like mass, friction etc, that actually has an effect
on the wheel).

Now I tried hinge joints using an extra entity for the control-able
wheels (usually the front ones), but that did not work, as the
chassis did not move, though the "extra entity" did.

6D Joints added a lot of oscillating of the wheels and I was not
able to add rotation, as the angles were rotated (means, when I
rotated the wheel's pan, the tilt was rotated as well).

Anyone could point me in the right direction for Gamestudio?

Thanks in advance and best regards,
Rei

Re: 6D Joints / Hinge Joints and vehicles [Re: Rei_Ayanami] #405386
07/30/12 07:46
07/30/12 07:46
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
I had success with connecting a convex shaped-wheel entity with a chassis using a 6D-joint. All you have to do is to enable linear motion on the y-axis (up) and angular motion around the x-axis (forward) and y-axis (up) and set velocity as drive type, as well as constraints. If that doesn't work out for you, make two 6D joints. Don't use regular joints, like hinges or so, they are only intended for what they are designed for. Then, instead of applying forces on the wheels, I had good results with just adding a velocity to the chassis - the wheels will react then properly.

Re: 6D Joints / Hinge Joints and vehicles [Re: HeelX] #405411
07/30/12 14:01
07/30/12 14:01
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline OP
Expert
Rei_Ayanami  Offline OP
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
The linear motion on the Y-axis is for damper, right? (Because damping is not really a need for me)

A convex shape fails, as some of the tires are just to low res, which results in a really un-smooth behavior.

However, my biggest problem is still the steering. Not locking the other two rotation dimensions results in uncontrollable behavior (even with LIMITED and limits set to 0). Using an additional entity and an additional 6D joints results in "lagging" of the wheel (behind the additional entity). The additional entity also behaves odd. I guess this could be related to the masses of the objects?

Re: 6D Joints / Hinge Joints and vehicles [Re: Rei_Ayanami] #405414
07/30/12 14:06
07/30/12 14:06
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
You can upload another shape to the wheel, of course. Just take the convex hull of a cylinder and put it on the wheel. You can do that with my PhysX plugin.

Maybe you can show some code, or better: A small demo which can be inspected by others. Making a correct physics setup is a daunting task sometimes and maybe you or I overlook something here.

Re: 6D Joints / Hinge Joints and vehicles [Re: HeelX] #405418
07/30/12 14:45
07/30/12 14:45
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline OP
Expert
Rei_Ayanami  Offline OP
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Here is a example that uses the gamestudio CUBE_MDL (that shows the movement of wheels quite good).

Code:
#include <acknex.h>
#include <default.c>
#include <ackphysx.h>


void main()
{
	/* Init */
	wait(1);
	level_load(NULL);
	physX_open();
	
	camera.x = 218;
	camera.y = 442;
	camera.z =  81;
	camera.pan = 247;

	ENTITY* ground = ent_create(CUBE_MDL,vector(0,0,0),NULL);
	vec_set(ground.scale_x,vector(100,100,1));
	pXent_settype(ground,PH_STATIC,PH_BOX); 
	pXent_setfriction(ground,90);

 
	/* Vehicle */
	var motion[6] = { 0, 0, 0, NX_D6JOINT_MOTION_FREE, 0, 0};
	var drive[6] = { 0, 0, 0, NX_D6JOINT_DRIVE_VELOCITY, 0, 0 };

	VECTOR pos;
	vec_set(pos, vector(0,0,100));


	ENTITY *chassis = ent_create(CUBE_MDL, pos, NULL);
	vec_set(chassis.scale_x, vector(10,5,4));

	pXent_settype(chassis, PH_RIGID, PH_BOX);
	pXent_setgroup(chassis, 2);
	pXent_setmass(chassis, 50);


	ENTITY *wheel1 = ent_create(CUBE_MDL, pos, NULL);
	vec_fill(wheel1.scale_x, 2);
	vec_add(wheel1.x, vector(60,60,-32));

	pXent_settype(wheel1, PH_RIGID, PH_SPHERE);
	pXent_setgroup(wheel1, 2);
	pXent_setmass(wheel1, 30);

	pXcon_add(PH_6DJOINT, wheel1, chassis, 0);
	pXcon_setparams1(wheel1, wheel1.x, NULL, NULL);
	pXcon_set6djoint(wheel1, motion, drive);

	ENTITY *wheel2 = ent_create(CUBE_MDL, pos, NULL);
	vec_fill(wheel2.scale_x, 2);
	vec_add(wheel2.x, vector(60,-60,-32));

	pXent_settype(wheel2, PH_RIGID, PH_SPHERE);
	pXent_setgroup(wheel2, 2);
	pXent_setmass(wheel2, 30);

	pXcon_add(PH_6DJOINT, wheel2, chassis, 0);
	pXcon_setparams1(wheel2, wheel2.x, NULL, NULL);
	pXcon_set6djoint(wheel2, motion, drive);

	ENTITY *wheel3 = ent_create(CUBE_MDL, pos, NULL);
	vec_fill(wheel3.scale_x, 2);
	vec_add(wheel3.x, vector(-60,60,-32));

	pXent_settype(wheel3, PH_RIGID, PH_SPHERE);
	pXent_setgroup(wheel3, 2);
	pXent_setmass(wheel3, 30);

	pXcon_add(PH_6DJOINT, wheel3, chassis, 0);
	pXcon_setparams1(wheel3, wheel3.x, NULL, NULL);
	pXcon_set6djoint(wheel3, motion, drive);

	ENTITY *wheel4 = ent_create(CUBE_MDL, pos, NULL);
	vec_fill(wheel4.scale_x, 2);
	vec_add(wheel4.x, vector(-60,-60,-32));

	pXent_settype(wheel4, PH_RIGID, PH_SPHERE);
	pXent_setgroup(wheel4, 2);
	pXent_setmass(wheel4, 30);

	pXcon_add(PH_6DJOINT, wheel4, chassis, 0);
	pXcon_setparams1(wheel4, wheel4.x, NULL, NULL);
	pXcon_set6djoint(wheel4, motion, drive);


	var accel;

	while(1)
	{
		accel = (key_w-key_s)*500;
		pXcon_setmotor(wheel1, vector(0,0,accel), 0);
		pXcon_setmotor(wheel2, vector(0,0,accel), 0);
		wait(1);
	}
}



This is only for driving forward and backward, as the wheels start spinning whenever I use NX_D6JOINT_MOTION_FREE / NX_D6JOINT_MOTION_LIMITED (with limits set).

Re: 6D Joints / Hinge Joints and vehicles [Re: Rei_Ayanami] #405420
07/30/12 15:04
07/30/12 15:04
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
I see what you mean. Try to add a second 6D joint, that connects the wheel joint with the chassis with a hinge-like constraint. Enabling the Y or Z axis makes no sense, thats right.

Re: 6D Joints / Hinge Joints and vehicles [Re: HeelX] #405425
07/30/12 16:58
07/30/12 16:58
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline OP
Expert
Rei_Ayanami  Offline OP
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
I do not really get what you mean by this smirk

Because simply adding another joint (pXcon_add) between wheel and chassis disables any movement of the wheel.

Or do you mean by another entity?

Re: 6D Joints / Hinge Joints and vehicles [Re: Rei_Ayanami] #405449
07/31/12 09:50
07/31/12 09:50
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Yes, create a virtual entity for the front wheels, so that you can rotate the wheels with no respect to their rotation about the chassis' up-axis (centered at the wheel origin).

Re: 6D Joints / Hinge Joints and vehicles [Re: HeelX] #405459
07/31/12 14:00
07/31/12 14:00
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline OP
Expert
Rei_Ayanami  Offline OP
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Okay, tried it. The result is not too bad (better than anything I achieved with 6D joints thus far), however, the front wheels just move into the ground.

The example is using CUBE_MDL.

Would be awesome if you could take another look at it laugh

Code:
#include <acknex.h>
#include <default.c>
#include <ackphysx.h>


void main()
{
	/* Init */
	wait(1);
	level_load(NULL);
	physX_open();
	
	camera.x = 218;
	camera.y = 442;
	camera.z =  81;
	camera.pan = 247;

	ENTITY* ground = ent_create(CUBE_MDL,vector(0,0,0),NULL);
	vec_set(ground.scale_x,vector(100,100,1));
	pXent_settype(ground,PH_STATIC,PH_BOX); 
	pXent_setfriction(ground,90);

 
	/* Vehicle */
	var motion[6] = { 0, 0, 0, NX_D6JOINT_MOTION_FREE, 0, 0};
	var drive[6] = { 0, 0, 0, 0, 0, 0 };

	var motionRot[6] = { 0, 0, 0, 0, 0, NX_D6JOINT_MOTION_LIMITED};
	var driveRot[6] = { 0, 0, 0, 0, 0, 0 };

	VECTOR pos;
	vec_set(pos, vector(0,0,100));


	ENTITY *chassis = ent_create(CUBE_MDL, pos, NULL);
	vec_set(chassis.scale_x, vector(10,5,4));

	pXent_settype(chassis, PH_RIGID, PH_BOX);
	pXent_setgroup(chassis, 2);
	pXent_setmass(chassis, 50);


	ENTITY *wheel1Rot = ent_create(CUBE_MDL, pos, NULL);
	vec_add(wheel1Rot.x, vector(60,60,0));

	pXent_settype(wheel1Rot, PH_RIGID, PH_BOX);
	pXent_setgroup(wheel1Rot, 2);
	pXent_setmass(wheel1Rot, 30);

	pXcon_add(PH_6DJOINT, wheel1Rot, chassis, 0);
	pXcon_setparams1(wheel1Rot, wheel1Rot.x, NULL, vector(999,999,999));
	pXcon_setparams2(wheel1Rot, vector(30,30,30), vector(0,30,0), vector(999,999,999));
	pXcon_set6djoint(wheel1Rot, motionRot, driveRot);

	ENTITY *wheel2Rot = ent_create(CUBE_MDL, pos, NULL);
	vec_add(wheel2Rot.x, vector(60,-60,0));

	pXent_settype(wheel2Rot, PH_RIGID, PH_BOX);
	pXent_setgroup(wheel2Rot, 2);
	pXent_setmass(wheel2Rot, 30);

	pXcon_add(PH_6DJOINT, wheel2Rot, chassis, 0);
	pXcon_setparams1(wheel2Rot, wheel2Rot.x, NULL, vector(999,999,999));
	pXcon_setparams2(wheel2Rot, vector(30,30,30), vector(0,30,0), vector(999,999,999));
	pXcon_set6djoint(wheel2Rot, motionRot, driveRot);


	ENTITY *wheel1 = ent_create(CUBE_MDL, pos, NULL);
	vec_fill(wheel1.scale_x, 2);
	vec_add(wheel1.x, vector(60,60,-32));

	pXent_settype(wheel1, PH_RIGID, PH_SPHERE);
	pXent_setgroup(wheel1, 2);
	pXent_setmass(wheel1, 30);

	pXcon_add(PH_6DJOINT, wheel1, wheel1Rot, 0);
	pXcon_setparams1(wheel1, wheel1.x, NULL, NULL);
	pXcon_setparams2(wheel1, vector(30,30,30), vector(0,30,0), vector(999,999,999));
	pXcon_set6djoint(wheel1, motion, drive);

	ENTITY *wheel2 = ent_create(CUBE_MDL, pos, NULL);
	vec_fill(wheel2.scale_x, 2);
	vec_add(wheel2.x, vector(60,-60,-32));

	pXent_settype(wheel2, PH_RIGID, PH_SPHERE);
	pXent_setgroup(wheel2, 2);
	pXent_setmass(wheel2, 30);

	pXcon_add(PH_6DJOINT, wheel2, wheel2Rot, 0);
	pXcon_setparams1(wheel2, wheel2.x, NULL, NULL);
	pXcon_set6djoint(wheel2, motion, drive);

	ENTITY *wheel3 = ent_create(CUBE_MDL, pos, NULL);
	vec_fill(wheel3.scale_x, 2);
	vec_add(wheel3.x, vector(-60,60,-32));

	pXent_settype(wheel3, PH_RIGID, PH_SPHERE);
	pXent_setgroup(wheel3, 2);
	pXent_setmass(wheel3, 30);

	pXcon_add(PH_6DJOINT, wheel3, chassis, 0);
	pXcon_setparams1(wheel3, wheel3.x, NULL, NULL);
	pXcon_set6djoint(wheel3, motion, drive);

	ENTITY *wheel4 = ent_create(CUBE_MDL, pos, NULL);
	vec_fill(wheel4.scale_x, 2);
	vec_add(wheel4.x, vector(-60,-60,-32));

	pXent_settype(wheel4, PH_RIGID, PH_SPHERE);
	pXent_setgroup(wheel4, 2);
	pXent_setmass(wheel4, 30);

	pXcon_add(PH_6DJOINT, wheel4, chassis, 0);
	pXcon_setparams1(wheel4, wheel4.x, NULL, NULL);
	pXcon_set6djoint(wheel4, motion, drive);


	var accel;
	var steer;

	while(1)
	{
		accel = (key_w-key_s)*500;
		steer = (key_a-key_d);
		if(!steer)
		{
			pXcon_setparams2(wheel1Rot, vector(30,30,30), vector(-0.1,0.1,0), vector(999,999,999));
			pXcon_setparams2(wheel2Rot, vector(30,30,30), vector(-0.1,0.1,0), vector(999,999,999));
		}	
		else if(sign(steer) == -1)
		{
			pXcon_setparams2(wheel1Rot, vector(30,30,30), vector(-0.1,30,0), vector(999,999,999));
			pXcon_setparams2(wheel2Rot, vector(30,30,30), vector(-0.1,30,0), vector(999,999,999));
		}
		else
		{
			pXcon_setparams2(wheel1Rot, vector(30,30,30), vector(-30,0.1,0), vector(999,999,999));
			pXcon_setparams2(wheel2Rot, vector(30,30,30), vector(-30,0.1,0), vector(999,999,999));
		}
		pXent_addtorquelocal(wheel1Rot, vector(0,0,steer));
		pXent_addtorquelocal(wheel2Rot, vector(0,0,steer));
		pXent_addtorquelocal(wheel1, vector(0,accel,0));
		pXent_addtorquelocal(wheel2, vector(0,accel,0));
		wait(1);
	}
}



Re: 6D Joints / Hinge Joints and vehicles [Re: Rei_Ayanami] #405461
07/31/12 14:35
07/31/12 14:35
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
maybe you should use an dummy entity (ent_create("", ...)) instead of CUBE_MDL
should work better because it has no collision shape


Visit my site: www.masterq32.de
Page 1 of 2 1 2

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