Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (dr_panther, 7th_zorro), 1,203 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
PhysX door with frame breakable. using PH_HINGE constraint #396940
03/12/12 12:42
03/12/12 12:42
Joined: Jan 2012
Posts: 8
N
nacrug Offline OP
Newbie
nacrug  Offline OP
Newbie
N

Joined: Jan 2012
Posts: 8
Hi everyone,

I've done my research for shadows and i started to physX plugin with very basic constraints.

What i try to achieve is: there is door with frames and when i press the button i want to door open. However, when i try to use force over break limit of constraint, i want to break door from constraint and fall down to floor. But even i try a lot of things i couldn't be successful.

Here it is my constraint definition;
pXcon_add ( PH_HINGE,door ,doorFrame , 0);
pXcon_setparams1(door, vector(-10.50,0,34.5), vector(0,0,-1), vector(10,10,0));
pXcon_setparams2(door, vector(-90,90,1.5), NULL, NULL);

My door action;

action door()
{
pXent_settype(my,PH_RIGID,PH_CONVEX);
pXent_setfriction(my, 101);
pXent_setelasticity(my, 0);
pXent_setdamping ( my, 100,100 );
//pXent_setmass(my,1);
door = my;
// wait(1);

}

My door frame action;

action doorF()
{
pXent_settype(my,PH_STATIC,PH_POLY);
pXent_setfriction(my, 101);
pXent_setelasticity(my, 0);
pXent_setdamping ( my, 100, 100 );
// pXent_setmass(my,10);
doorFrame = my;

//wait(1);

}

My force functions:

function add_force()
{
VECTOR temp;
temp.x= 0; temp.y= -0.5; temp.z= 0;
// now myCrate will continue to move along the x axis forever, with constant speed
//pXent_addvelcentral( door, temp );
pXent_addforcecentral( door, temp );
wait(1);

}
function add_forceWithBreak()
{
VECTOR temp;
temp.x= 0; temp.y= 50; temp.z= 0;
// now myCrate will continue to move along the x axis forever, with constant speed
//pXent_addvelcentral( door, temp );
pXent_addforcecentral( door, temp );
wait(1);

}

What it is wrong with that. I couldn't figure out cause. However, when door is moving with little force. When i use "pXcon_remove(door);" it is falling down correctly.

Thanks
Nacrug

Re: PhysX door with frame breakable. using PH_HINGE constraint [Re: nacrug] #397018
03/13/12 15:16
03/13/12 15:16
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
Try my example, maybe it helps.

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

ENTITY *EntDoor, *EntFrame;

function main()
{
	shadow_stencil = 1;
	vec_set(sky_color,vector(76,51,25));
	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),vector(76,51,25),100), 1);
	
	EntDoor = ent_create(CUBE_MDL,vector(0,0,35),NULL); ent_cloneskin(EntDoor); ent_setskin(EntDoor, bmap_fill(bmap_createblack(32,32,24),vector(76,51,255),100), 1);
	vec_set(EntDoor.scale_x, vector(.5,2,4));
	c_setminmax(EntDoor); set(EntDoor,SHADOW|LIGHT);
	pXent_settype(EntDoor,PH_RIGID,PH_BOX);
	
	EntFrame = ent_create(CUBE_MDL,vector(0,-25,35),NULL); ent_setskin(EntFrame, bmap_fill(bmap_createblack(32,32,24),vector(76,255,25),100), 1);
	vec_set(EntFrame.scale_x, vector(.5,.5,4.5));
	c_setminmax(EntFrame); set(EntFrame,SHADOW|LIGHT);
	pXent_settype(EntFrame,PH_STATIC,PH_BOX);
	
	pXcon_add(PH_HINGE, EntDoor, NULL, 1);
	
	pXcon_setparams1(EntDoor, EntFrame.x, vector(0,0,1), vector(10,10,0));
	pXcon_setparams2(EntDoor, vector(0,90,0), NULL, NULL);
	
	def_move();
	
	while(1)
	{
		draw_text("[O] - Open/Close the Door",5,5,COLOR_GREEN);
		draw_text("[B] - Break the Door",5,25,COLOR_RED);
		
		if(key_o)
		{
			while (key_o) {wait (1);} pXent_addforcecentral (EntDoor, vector(20,20,0));
		}
		if(key_b)
		{
			while (key_b) {wait (1);} pXent_addforcecentral (EntDoor, vector(20,0,-500));
		}
		wait(1);
	}
}




Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: PhysX door with frame breakable. using PH_HINGE constraint [Re: rojart] #397082
03/14/12 10:30
03/14/12 10:30
Joined: Jan 2012
Posts: 8
N
nacrug Offline OP
Newbie
nacrug  Offline OP
Newbie
N

Joined: Jan 2012
Posts: 8
Thank you very much. Your example show me the problem. I was trying to wrong masses for objects. Thanks again.


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