PhysX collision hull has wrong position

Posted By: oliver2s

PhysX collision hull has wrong position - 01/22/13 17:24

The problem is this:



If the model is not centered in MED (Object->Transform Global->Center model) the PhysX hull/bounding box is automaticly centered in the engine and doesn't fit the original boundig box position anymore. The hull has a wrong position.

Is there another solution than to center the model in MED? Is this the normal behavouir?
Posted By: oliver2s

Re: PhysX collision hull has wrong position - 01/22/13 21:16

Anyone?
Posted By: Uhrwerk

Re: PhysX collision hull has wrong position - 01/22/13 22:09

Have you used c_setminmax before registering the entity as a physics entity? Have you tried setting min_x ... max_z by hand?
Posted By: oliver2s

Re: PhysX collision hull has wrong position - 01/22/13 22:26

Sure. The engine debug mode shows the right hull. But PhysX uses a shifted hull (if the model was not centered in MED).
Posted By: oliver2s

Re: PhysX collision hull has wrong position - 01/23/13 10:21

Btw: this problem happens only with PH_BOX.
Posted By: rojart

Re: PhysX collision hull has wrong position - 01/23/13 10:50

Originally Posted By: oliver2s
Is this the normal behavouir?

Yes, this is normal behaviour, take a look at PhysX Plugin Source by CreateCube Algorithm definition.

Originally Posted By: oliver2s
Is there another solution than to center the model in MED?

Yes, check my example below, but you need change the contact algorithm for automatic computation.

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

ENTITY *Cube;

function on_space_event()
{
	while (key_space){wait (1);}
	
	int i = ent_status(Cube,0); // number of vertices 
	for (; i>0; i--) 
	{    CONTACT* c = ent_getvertex(Cube,NULL,i);    
		c.v.y += 8.0; // raise the vertex (y is the height in DX coordinates)    
		ent_setvertex(Cube,c,i);  
	}
}

function main()
{
	shadow_stencil = 1;
	vec_set(sky_color,vector(76,51,25));
	mouse_mode = 4;
	physX_open();
	level_load(""); 
	pXent_settype(NULL,PH_STATIC,PH_PLANE);
	vec_set(camera.x,vector(-250,0,50));
	you = ent_createterrain(NULL,nullvector,10,10,70);
	ent_setskin(you, bmap_fill(bmap_createblack(32,32,24),COLOR_GREY,100), 1);
	
	Cube = ent_create(CUBE_MDL,vector(0,0,100),NULL);
	ent_setskin(Cube, bmap_fill(bmap_createblack(32,32,24),COLOR_GREEN,100), 1);
	vec_fill(Cube.scale_x, 2);
	c_setminmax(Cube);
	
	int i = ent_status(Cube,0); // number of vertices 
	for (; i>0; i--) 
	{    CONTACT* c = ent_getvertex(Cube,NULL,i);    
		c.v.y += -8.0; // raise the vertex (y is the height in DX coordinates)    
		ent_setvertex(Cube,c,i);  
	}

	set(Cube,SHADOW|LIGHT);
	pXent_settype(Cube,PH_RIGID,PH_BOX);
	
	def_move();
	def_debug();
	d3d_lines = 3;
	
	while(1)
	{
		draw_text("[SPACE] - Reset Origin",5,120,COLOR_GREEN);
		pX_pick();
		wait(1);
	}
}



Posted By: oliver2s

Re: PhysX collision hull has wrong position - 01/23/13 12:51

Thank you for your code, but this workaround doesn't seem very accurate too me.

So I guess, if this is normal PhysX behaviour, I need to center the models in MED...
© 2023 lite-C Forums