Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (TedMar, AndrewAMD), 1,344 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19053 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
PH_CHAR stopped before touching ground #383342
09/19/11 08:51
09/19/11 08:51
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline OP
Senior Member
3dgs_snake  Offline OP
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Hi,

PH_CHAR with pXent_move is stopped at some distance before colliding a static entity (A8.30.2).

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

void main()
{
	physX_open();
	
	// Set shadow
	shadow_stencil = 2;
	
	level_load("PLATE.WMB");
	wait(3);
	
	// Set camera
	vec_set(camera->x, vector(-265, -30, 90));
	vec_set(camera->pan, vector(0, -11, 0));
	
	// Create player
	ENTITY *e = ent_create("CUBE.MDL", vector(0, 0, 50), NULL);
	//vec_set(e->scale_x, vector(2, 2, 2));
	//vec_set(e->scale_x, vector(0.5, 0.5, 0.5));
	set(e, SHADOW);
	pXent_settype(e, PH_CHAR, PH_CAPSULE /*PH_BOX*/);
	
	// Create
	ENTITY *box = ent_create("CUBE.MDL", vector(20, 20, 50), NULL);
	set(box, SHADOW);
	pXent_settype(box, PH_RIGID, PH_BOX /*PH_CAPSULE*/);
	
	// Player movement
	var player_gravity = 0.1;
	var player_speed = 0;
	
	// 
	while(1)
	{
		// Add gravity to speed
		player_speed += player_gravity;
		
		// Move charachter downward
		pXent_move(e, NULL, vector(0, -2 * time_step, -player_speed * time_step));
		
		// Debug entity z
		DEBUG_VAR(e->z, 10);
		
		// Wait frame
		wait(1);
	}
}



Re: PH_CHAR stopped before touching ground [Re: 3dgs_snake] #383414
09/20/11 09:04
09/20/11 09:04
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline OP
Senior Member
3dgs_snake  Offline OP
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Hi,

Please, can someone explain the 8 quants, keeping a PH_CHAR from colliding into a static actor? Files

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

void main()
{
	physX_open();
	
	// Set shadow
	shadow_stencil = 2;
	
	level_load("PLATE.WMB");
	wait(3);
	
	// Set camera
	vec_set(camera->x, vector(-265, -30, 90));
	vec_set(camera->pan, vector(0, -11, 0));
	
	// Create player
	ENTITY *e = ent_create("CUBE.MDL", vector(0, 0, 100), NULL);
	//vec_set(e->scale_x, vector(2, 2, 2));
	//vec_set(e->scale_x, vector(0.5, 0.5, 0.5));
	set(e, SHADOW);
	pXent_settype(e, PH_CHAR, PH_CAPSULE /*PH_BOX*/);
	
	// Create
	ENTITY *box = ent_create("CUBE.MDL", vector(20, 20, 50), NULL);
	set(box, SHADOW);
	pXent_settype(box, PH_RIGID, PH_BOX /*PH_CAPSULE*/);
	
	// Player movement
	var player_gravity = 0.1;
	var player_speed = 0;
	
	ENTITY *sphere = ent_create(SPHERE_MDL, vector(-20, 0, 100), NULL);
	set(sphere, SHADOW);
	pXent_settype(sphere, PH_RIGID, PH_SPHERE);	
	pXent_setmaterial(sphere, vector(100, 0, 0), vector(100, 100, 100), vector(0, 1, 0));
		
	// 
	while(1)
	{
		// Add gravity to speed
		player_speed += player_gravity;
		
		// Move charachter downward
		pXent_move(e, NULL, vector((key_cuu - key_cud) * 2 * time_step, (key_cul - key_cur) * 2 * time_step, -player_speed * time_step));
		
		// Debug entity z
		DEBUG_VAR(e->z, 10);
		
		VECTOR temp;
		vec_set(temp, e->x);
		temp.z -= 1000;
		my = e;
		
		var dist = c_trace(e->x, temp, IGNORE_ME | USE_BOX);
		DEBUG_VAR(dist, 22);
		
		// Distance to ground
		DEBUG_VAR(e->z - dist, 34);
		
		//DEBUG_VAR(pX_stats(1), 50);
		
		// Wait frame
		wait(1);
	}
}



Thanks in advance.

Re: PH_CHAR stopped before touching ground [Re: 3dgs_snake] #383415
09/20/11 10:08
09/20/11 10:08
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
You use PH_RIGID not PH_STATIC, what exactly do you mean by static actor?


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: PH_CHAR stopped before touching ground [Re: rojart] #383418
09/20/11 10:33
09/20/11 10:33
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline OP
Senior Member
3dgs_snake  Offline OP
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
I used PH_RIGID for the box and sphere, but the level is PH_STATIC (created by physX_open()). Every frame, I move the box downward, but it is prevented from touching the ground. Below is a modified source code, and you can try to move to the left, but the PH_CHAR box can't touch the STATIC wall.

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

void main()
{
	physX_open();
	
	// Set shadow
	shadow_stencil = 2;
	
	level_load("PLATE.WMB");
	wait(3);
	
	// Set camera
	vec_set(camera->x, vector(-265, -30, 90));
	vec_set(camera->pan, vector(0, -11, 0));
	
	// Create player
	ENTITY *e = ent_create("CUBE.MDL", vector(0, 0, 100), NULL);
	//vec_set(e->scale_x, vector(2, 2, 2));
	//vec_set(e->scale_x, vector(0.5, 0.5, 0.5));
	set(e, SHADOW);
	pXent_settype(e, PH_CHAR, PH_CAPSULE /*PH_BOX*/);
	
	// Create
	ENTITY *box = ent_create("CUBE.MDL", vector(20, 20, 50), NULL);
	set(box, SHADOW);
	pXent_settype(box, PH_RIGID, PH_BOX /*PH_CAPSULE*/);
	
	// Player movement
	var player_gravity = 0.1;
	var player_speed = 0;
	
	ENTITY *sphere = ent_create(SPHERE_MDL, vector(-20, 0, 100), NULL);
	set(sphere, SHADOW);
	pXent_settype(sphere, PH_RIGID, PH_SPHERE);	
	pXent_setmaterial(sphere, vector(100, 0, 0), vector(100, 100, 100), vector(0, 1, 0));
	
	// Create static wall
	ENTITY *wall = ent_create(CUBE_MDL, vector(0, 40, 20), NULL);
	vec_set(wall->scale_x, vector(5, 0.5, 5));
	c_setminmax(wall);
	set(wall, LIGHT | SHADOW);
	vec_set(wall->blue, vector(150, 0, 0));
	
	pXent_settype(wall, PH_STATIC, PH_BOX);
	
	
	// 
	while(1)
	{
		// Add gravity to speed
		player_speed += player_gravity;
		
		// Move charachter downward
		pXent_move(e, NULL, vector((key_cuu - key_cud) * 2 * time_step, (key_cul - key_cur) * 2 * time_step, -player_speed * time_step));
		
		// Debug entity z
		DEBUG_VAR(e->z, 10);
		
		VECTOR temp;
		vec_set(temp, e->x);
		temp.z -= 1000;
		my = e;
		
		var dist = c_trace(e->x, temp, IGNORE_ME | USE_BOX);
		DEBUG_VAR(dist, 22);
		
		// Distance to ground
		DEBUG_VAR(e->z - dist, 34);
		
		//DEBUG_VAR(pX_stats(1), 50);
		
		// Wait frame
		wait(1);
	}
}



Re: PH_CHAR stopped before touching ground [Re: 3dgs_snake] #383426
09/20/11 11:58
09/20/11 11:58
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
ok, I see what you mean, normally you should to activate the ccd function, but there is something wrong with it.
I'm very busy, right now, but I'll look into the physx source code what happens.


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: PH_CHAR stopped before touching ground [Re: rojart] #384471
10/03/11 15:30
10/03/11 15:30
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
I found a solution to reduce the distances, in the pX_setunit (var scale); function you need to increase the scale factor.

eg:
Code:
void main()
{
	physX_open(); pX_setunit(5);
...




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

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