Hi

Just thought I would post a problem I have discovered while using the PhysX3 DLL(v0.93) for 3DGS released by 3dgs_snake.

The problem is that the friction values do not appear to be correctly set for entities attached to PhysX3 Joints.

I have produce a small program to demonstrate the problem:

The program below contains 3 cubes: 1) a large Ground cube; 2)a Top cube; and 3) a Bottom cube. The Bottom cube rest on the large Ground cube. the Top cube is above the Bottom cube and is held in place above the Bottom cube by a Fixed joint between the Top and Bottom cubes.

The friction value of the Ground and Bottom cubes is set to zero.
The friction value of the Top cube is set to 100.

When you start the program the Bottom cube should fall onto the Ground cube and not fall over (ie. the Top cube should stay directly above the Bottom cube).

Now, if you apply a force ( by pressing the W key in the program) the Top and Bottom cubes will move as the Ground and Bottom cubes both have a zero friction value. This is what should happen.

However, if you move the code that sets the Top cube's friction value to after the code that sets the Bottom cube's friction value THEN the cubes will NOT move.

Note that this problem does NOT occur with the PhysX version that comes with 3DGS version 8.45.

Code:
#include <default.c>
#include <ackphysX3.h>

ENTITY* TopCube;	
ENTITY* BottomCube;	
ENTITY* myGround; 
int mTest_IsOk;

//========functions
void assert( int IsOK )
{
	if (!IsOK ) {
		printf("assert failed");
		mTest_IsOk = IsOK;
		return;
	}
}

void On_w_Pressed()
{
	assert( pX3ent_addforcecentral ( BottomCube, vector(5,0,0) ) ); 
}

void main_init()
{
  	fps_max = 60.0;
	time_factor = 1.0;
	time_smooth = 0.0;

	physX3_open();
	level_load(NULL);
	pX3_setunit( 0.1 ); 
	pX3_setgravity(vector(0,0,-10));
}

/////////////////main for testing for friction problems
void main()
{
	ENTITY* e1;
	int JointID;
	
	main_init();
	wait(2);
	
	on_w = On_w_Pressed;
	
	/////////////////////GROUND CUBE Beg (top face at z=0)
	myGround = ent_create("cube.mdl", vector(0, 0, -80.), NULL);
	myGround.scale_x =100;
	myGround.scale_y =100;
	myGround.scale_z =10;
	c_setminmax (myGround);
	assert( pX3ent_settype (myGround, PH_STATIC, PH_BOX ) );
	/////////////////////GROUND CUBE End
	
	///////////////////////TOP CUBE Beg
	TopCube = ent_create("cube.mdl",vector(10,0,80),NULL);
	e1 = TopCube;
	assert( pX3ent_settype(e1,PH_RIGID, PH_CONVEX) );	//(PH_STATIC) PH_BOX, PH_CONVEX PH_SPHERE
			  pX3ent_setmass(e1, 1.0);
	assert( pX3ent_setmassoffset(e1, vector(0,0,0), vector(1,1,1) ) );
	///////////////////////TOP CUBE End	
	
	///////////////////////BOTTOM CUBE Beg
	BottomCube = ent_create("cube.mdl",vector(10,0,30),NULL);
	e1 = BottomCube;
	assert( pX3ent_settype(e1,PH_RIGID, PH_CONVEX) );	//(PH_STATIC) PH_BOX, PH_CONVEX PH_SPHERE
			  pX3ent_setmass(e1, 1.0);
	assert( pX3ent_setmassoffset(e1, vector(0,0,0), vector(1,1,1) ) );
	///////////////////////BOTTOM CUBE End

	//////////////////////JOINT Beg
	assert( JointID = pX3con_add (PH_FIXED, TopCube, BottomCube, 0 ) );	//PH_SLIDER, PH_HINGE, PH_BALL  PH_FIXED
	/////////////////////JOINT End

	//////////Setting friction values for ground and cubes
	assert( pX3ent_setfriction(myGround,      0.0) ); //0=ice; 100=rubber on rubber
	assert( pX3ent_setfriction(TopCube,    100.0) ); //0=ice; 100=rubber on rubber
	assert( pX3ent_setfriction(BottomCube,   0.0) ); //0=ice; 100=rubber on rubber
	//When the next line is uncomment the cubes will not move when W key is pressed (ie when a force is applied)
//	assert( pX3ent_setfriction(TopCube,    100.0) ); //0=ice; 100=rubber on rubber

	vec_set (camera.x, vector (-20,-160, 55 ));
	vec_set (camera.pan, vector (80, -15, 0 ));
	
	while(1)
	{
		VECTOR vPosn, vRotn;
		
		assert( pX3con_getposition(JointID,vPosn,vRotn) );
		draw_point3d( nullvector, vector(128,0,0), 100, 2); //Blue - Global Origin
		draw_point3d( vPosn,      vector(0,128,0), 100, 2); //Green- Joint position

  		wait(1);
	} 
}
//==============EOF


Last edited by Taskmaster065; 07/12/15 07:12.