AckphysX3 development thread

Posted By: 3dgs_snake

AckphysX3 development thread - 10/08/12 14:20

Hi,

I have developped for some months now a new physX plugin based on physX3 (actually 3.2.4). The current physX plugin is good but there were some (not so many)missing things for me (raycasts whithout an entity, sweep tests, ...). Actually, I have implemented rigid body dynamics, scene queries, character controllers and vehicles (No cloths and fluids, for now tongue ) I will continue to develop the remaining functionalities depending on interests shown by the community.

Anyway, below is a first demo for you all to test and experiment with the thing (And also for debugging purposes). Please tell me if you find some weird things or if there are things that you think missing.

20121008 - AckphysX3 Demo

20131128_ackphysX3CHECKED(0.93) (physX 3.2.4)
Actually, there is no documentation tongue except the description of every function that can be found in the header file (ackphysX3.h). The file also contains some files I created to test the implementation (Function names are quite similar to the actual physX plugin, just add 3 after the X)

If I remember well (But not sure after changes I made lately tongue ), the plugin (Not the demo files) is working with A7

Files in the zip
  • ackphysX3_main.c : Actor creation
  • cctbehaviour.c : CCT behaviour test (Can Ride & Slide)
  • constraints_test.c : Test for all the type of constraints (Ball, Rope, Fixed, Slider, 6D).
  • ackphysX3_main.c : Actor creation
  • controller_test.c : CCT Test
  • controller_test_2.c : CCT and trigger test Test
  • forces_test.c : Test file for different kind of force APIs
  • ford.c : Vehicles test
  • scenequery_test.c : Test file for scene queries (raycast, sweep : sphere_cast; capsule_cast, overlap : sphere_check, capsule_check);

I will implement more demos soon.

Hope you like it.
Posted By: bodden

Re: AckphysX3 development thread - 10/08/12 17:41

I tried the examples. Works fine for me. Really nice work.

But what I don't understand: Where are the differences to physX? Are there any advantages/disadvantages?
Posted By: rojart

Re: AckphysX3 development thread - 10/08/12 19:46

Originally Posted By: bodden
But what I don't understand: Where are the differences to physX? Are there any advantages/disadvantages?

Quote:
NVIDIA PhysX SDK 3.x (PhysX Software Development Kit version 3.0-3.2; PhysX-3) is a physics simulation middleware, new major version of PhysX SDK released by NVIDIA in May 2011.

While PhysX SDK 2.x is based on patchwork design and old code base, developed in Ageia and NovodeX, new PhysX SDK 3.0 has undergone arhitecture and API improvements, code was cleaned and refactored, considerable legacy cluster was removed, new features were added.

http://physxinfo.com/wiki/PhysX_SDK_3.x

Originally Posted By: 3dgs_snake
Hi, ...(No cloths and fluids, for now tongue )...
Hope you like it.


Hi 3dgs_snake, I like it very much!

I can implement the cloth simulation, but I need your ackphysX3CHECKED.dll source code, pm me if you are interested?
Posted By: 3dgs_snake

Re: AckphysX3 development thread - 10/09/12 05:15

Hi,

You can grab a new version of the dll (I fixed some minor bugs).

Quote:
I can implement the cloth simulation, but I need your ackphysX3CHECKED.dll source code, pm me if you are interested?

Thanks rojart, I will contact you when the plugin is more stable (There are some functionalities still not fully tested - eg Tanks - And I want to change some little things in the vehicles internal creation process). Also, physX3 cloth is quite different from the 2.x version (But not so much I hope), as they don't collide with the scene geometries but instead with collision shapes you need to provide on the cloth creation (They think to implement that in a future version). That's also why I didn't try an implementation because I'm still thinking of the best way to do that while still keeping things simple and clean for GS.
Posted By: 3run

Re: AckphysX3 development thread - 10/09/12 07:33

It's perfect mate! laugh Please, don't give up on this! Continue developing and add cloth, particles, destructions (omg.. I'm waiting for this one so long..)! laugh I'll do my best to test and help you with finding bugs. Thank you for it mate, it's awesome! And thank you for your time which you've spent on it.
Posted By: 3dgs_snake

Re: AckphysX3 development thread - 10/09/12 14:50

Hi,

Some tip :

By default Character controllers don't push bodies (I think I saw some complaints on this with the physX plugin). If needed, that can be done using cct collision event (and can depend on other properties, like object mass, character strength, ...).

1. ENABLE_FRICTION for the CCT
Code:
cct->event = cct_event;
cct->emask |= ENABLE_FRICTION;



2. Push bodies in the event handler
Code:
/// \brief CCT event handling
///
void cct_event()
{
   VECTOR hit_dir;
   vec_set(hit_dir, hit.blue); // Hit direction is stored on the (red, green blue) :)
   
   var hit_length = hit.alpha; // Hit length is stored on the alpha :)
   
   if (hit_dir.z == 0)                              
   {
      var coeff = pX3ent_getmass(you) * hit_length / 40; // Scale to meter 
         
      // Set force to impulse
      pX3_setforcemode(PX_IMPULSE);
      vec_scale(hit_dir, coeff);
      //set(you, TRANSLUCENT);
      pX3ent_addforceatlocalpos(you, hit_dir, nullvector);
      
   }
}



More complete documentation soon.

Quote:
// Hit direction is stored on the (red, green blue) laugh

Sorry for that, but I wanted to use the CONTACT struct, so I choose what was available. grin
Posted By: rojart

Re: AckphysX3 development thread - 10/19/12 10:27

Originally Posted By: 3dgs_snake
Hi,

You can grab a new version of the dll (I fixed some minor bugs).

Quote:
I can implement the cloth simulation, but I need your ackphysX3CHECKED.dll source code, pm me if you are interested?

Thanks rojart, I will contact you when the plugin is more stable ...


Thanks it would be really useful, I played a bit with sdk 3.2.1 and got to work also, but only the SDK works for me now.

Here is my converted CreateCube definition code, here i missed something that the code don't Transforms the PhysX Object like the Engine Entity?

Code:
void PhysX3::CreateCube(ENTITY * ent, const PxVec3& pos, int body, PxVec3& TempScale)
{
	PX_ASSERT(0 != gScene);

	PxVec3 vec_min,vec_max;
	GetMinMax(ent,vec_min,vec_max);

	PxMaterial* mMaterial = gPhysicsSDK->createMaterial(1.0,1.0,1.0);
	
	// Setting up the Dimensions
	PxVec3 dimensions = (vec_max-vec_min)/2;
	dimensions.x *= TempScale.x;
	dimensions.y *= TempScale.y;
	dimensions.z *= TempScale.z;
	PxBoxGeometry geometry(dimensions);

	PxReal density = 1.0f;
	PxTransform transform(PxVec3(pos.x, pos.y, pos.z)* PXSize, PxQuat::createIdentity());

	PxRigidDynamic *actor = PxCreateDynamic(*gPhysicsSDK, transform, geometry, *mMaterial, density);
	actor->setAngularDamping(0.75);
	actor->setLinearVelocity(PxVec3(0,0,0));
	if (!actor)
		error("create actor failed!");

	box = actor;

	// Save the entity's index to the userData of the shape
	box->userData = (long*)ent->link.index;

	mPhysicsActors.push_back(box);

	PxU32 nShapes = box->getNbShapes();
	
	PxShape** shapes = new PxShape*[nShapes];

	box->getShapes(shapes, nShapes);
	
	PxTransform pT = transform;
	pT.p  = PXSize * pos;
	PxBoxGeometry bg = geometry;

	PxMat33 pose = PxMat33(pT.q );
	float mat[16];
	getColumnMajor(pose,pT.p, mat);
	ang_to_matrix((ANGLE*)&(ent->pan),&(mat[0]));

	box->setDominanceGroup(1);
	PX_ASSERT(box->isValid());
	gScene->addActor(*box);
}

Posted By: 3dgs_snake

Re: AckphysX3 development thread - 10/19/12 11:17

Hi,

I think that the proble is in the
Code:
getColumnMajor(

function. Or try to use rowMajor wink .
Posted By: rojart

Re: AckphysX3 development thread - 10/19/12 12:07

My getColumnMajor definition looks like this, it's wrong?

Code:
inline void getColumnMajor(PxMat33 m, PxVec3 t, float* mat)
{
	mat[0] = m.column0[0];
	mat[1] = m.column0[1];
	mat[2] = m.column0[2];
	mat[3] = 0;

	mat[4] = m.column1[0];
	mat[5] = m.column1[1];
	mat[6] = m.column1[2];
	mat[7] = 0;

	mat[8] = m.column2[0];
	mat[9] = m.column2[1];
	mat[10] = m.column2[2];
	mat[11] = 0;

	mat[12] = t[0];
	mat[13] = t[1];
	mat[14] = t[2];
	mat[15] = 1;
}

Posted By: 3dgs_snake

Re: AckphysX3 development thread - 10/19/12 12:23

Hi,

I didn't use m.columnx. I used m[i] directly wink
Posted By: Anonymous

Re: AckphysX3 development thread - 10/31/12 15:21

I tested the plugIn with A7 and its working great!
In my game i will only need basic physics and hopefully a physical character (pX3ent_move).
I will test it further and report any errors.
THanks 3dgs_snake for this awesome PlugIn!
Posted By: Anonymous

Re: AckphysX3 development thread - 10/31/12 21:34

hmmm does Terrains work already with that plugin?
My Terrain is always passable for physical entities.
i tried the following codes:
Code:
pX3ent_settype(me, PH_STATIC, PH_POLY);

or...
Code:
pX3ent_settype(me,PH_STATIC,PH_TERRAIN|PH_MODIFIED);


both ways seems not to work for me.
Posted By: Sajeth

Re: AckphysX3 development thread - 10/31/12 23:12

PhysX seems to have problems with scaled terrain. Try it with unscaled terrain laugh
Posted By: Anonymous

Re: AckphysX3 development thread - 11/01/12 09:26

jep, that did it! Thanks Sajeth laugh
Posted By: BySharDe

Re: AckphysX3 development thread - 11/01/12 09:50

Write onw DLLs is really amazing!
I tested on A8.40 and it works fine.
Posted By: 3dgs_snake

Re: AckphysX3 development thread - 12/13/12 11:07

The DLL has been updated. A CCT bug has been found(and fixed) thanks to 3run.
Posted By: Rackscha

Re: AckphysX3 development thread - 01/11/13 19:09

This plugin looks great.
Any plans/time eta on adding the PhysX Particle system? Soo waiting for it, to experiment laugh
Posted By: Rackscha

Re: AckphysX3 development thread - 01/14/13 22:41

Oh and one additional request: GPU acceleration, it seeems that it currently runs on CPU only? o.O
Posted By: 3dgs_snake

Re: AckphysX3 development thread - 01/29/13 06:21

Hi,

The plugin has been updated to physX 3.2.2. A little bug in CCT creation has been fixed (thanks to 3run). You can grab it here.

Quote:
Oh and one additional request: GPU acceleration, it seeems that it currently runs on CPU only?

I have an ATI card, so for now, I can't test GPU acceleration. I'll try to find a n NVidia card and will wee what I can do smile .
Posted By: Rackscha

Re: AckphysX3 development thread - 01/29/13 11:47

In the PhysX manual, there is an example on how to do it(check for GPU support, enable GPU and check if GPU is REALLY enabled or just a fallback to cpu).

I think even a blindwrite is possible with this^^

Otherwhise: i have a NVidiaCard*hint hint*
Posted By: 3dgs_snake

Re: AckphysX3 development thread - 01/29/13 12:54

Ok, ok, I'll try blush
Posted By: 3dgs_snake

Re: AckphysX3 development thread - 04/08/13 05:03

Updated physX3 plugin ( v0.90.2.0 - physX 3.2.2 ).

The main features are :
  • Some bugfixes (Update loop, CCT, capsulecheck)
  • More stable
  • Added :
    • pX3_gpusupport : Check GPU support
    • New functions for raycast with one additional ignoreFlag parameter (pX3_*_ignore) that can be used to filter entities (PX_IGNORE_ME, PX_IGNORE_YOU, PX_IGNORE_FLAG2, PX_IGNORE_PASSABLE)
    • ...
  • Removed watermark (the plugin is free for non commercial use)
Posted By: BySharDe2

Re: AckphysX3 development thread - 04/08/13 11:05

Excellent!
BTW, what is the relation between nowaday PhysX plugin and "native" acknex's PhysX plugin ?
Posted By: 3dgs_snake

Re: AckphysX3 development thread - 04/08/13 11:17

Hi,
"Native" acknex's physX plugin uses physX 2.8.5, this plugin uses physX 3.2.2. Internally, physX 3.x is not the same as physX 2.x but I tried to make them look the same when used (similar function names ex pX3ent_settype in ackphysX3 and pXent_settype in ackphysX). There are also many additional things, like better cct, scenequeries (raycast, sweep, overlap) or a different vehicle implementation. I'm working on a better documentation and guide/tutorial.
Posted By: Emre

Re: AckphysX3 development thread - 04/08/13 12:01

Dude... You are unbelievable! i am still using a7 and it works very well with a7. You save my life. laugh
Posted By: 3dgs_snake

Re: AckphysX3 development thread - 04/08/13 13:14

Good.
Posted By: Emre

Re: AckphysX3 development thread - 04/08/13 15:28

Okay. i think there is little bug with 3.2.2. (20130408)

pX3ent_setcollisionflag is doesn't work with null pointer.
pX3ent_setcollisionflag(me,NULL,PX_PF_NOTIFY_TOUCH);

but it work's in previous version (20121008)
sorry for bad english.
Posted By: 3dgs_snake

Re: AckphysX3 development thread - 04/09/13 04:44

Hi,

That's strange, I thought that the bug was in the previous versions, for me it is working.

Try the code bellow (create a level in WED with a simple box in the center)
Code:
#include <acknex.h>
#include <default.c>
#include <ackphysX3.h>

#define PRAGMA_PATH "C:\\Program Files (x86)\\GStudio8\\templates\\sounds";

SOUND *snd_left="shot1.wav";
SOUND *snd_impact = "aiimpact.wav";
SOUND *trigger_enter = "tap.wav";
SOUND *trigger_leave = "splash.wav";

ENTITY *cube1 = NULL;
ENTITY *cube2 = NULL;
ENTITY *trigger = NULL;

// Impact event : 
void impact_event()
{
   if (event_type == EVENT_FRICTION && hit->flags & PX_EVENT_TOUCH_LOST)
   {
      ent_playsound(me, snd_left, 100);
   }
   else if (event_type == EVENT_FRICTION && hit->flags & PX_EVENT_TOUCH_FOUND)
   {
      ent_playsound(me, snd_impact, 100);
   }
}

// Cube action : 
void cube_action()
{
   while(trigger == NULL || cube2 == NULL) wait(1);
   pX3ent_settype(me, PH_RIGID, PH_BOX);
   set(me, SHADOW);
   
   pX3ent_setcollisionflag(me, NULL, PX_PF_NOTIFY_TOUCH);
   //pX3ent_setcollisionflag(me, cube2, PX_PF_NOTIFY_TOUCH_LOST);
   
   me->event = impact_event;  
}

// Trigger event : 
void trigger_event()
{
   if (event_type != EVENT_TRIGGER)
      return;
   
   if (hit->flags & PX_EVENT_TOUCH_FOUND)
      ent_playsound(me, trigger_enter, 100);
   
   if (hit->flags & PX_EVENT_TOUCH_LOST)
      ent_playsound(me, trigger_leave, 100);
}

// Trigger action :
void trigger_action()
{
   while(cube1 == NULL || cube2 == NULL) wait(1);
   pX3ent_settype(me, PH_STATIC, PH_BOX);
   
   pX3ent_settriggerflag(me, PX_TF_TRIGGER_ENABLE, 1);
   
   me->event = trigger_event;
}

// App entry point
void main()
{
   // Open physX : 
   physX3_open();
   
   // Level config : 
   shadow_stencil = 2;
   
   // Load level : 
   level_load("IMPACT_LEVEL.WMB");
   vec_set(camera.x, vector(-253, -6, 128));
   camera.tilt = -26;
   
   // Create cube : 
   cube1 = ent_create(CUBE_MDL, vector(0, 0, 300), cube_action);
   cube2 = ent_create(CUBE_MDL, vector(0, 0, 30), NULL);
   trigger = ent_create(CUBE_MDL, vector(0, 0, 60), trigger_action);
   vec_set(trigger->scale_x, vector(2, 2, 2));
   set(trigger, TRANSLUCENT);
   
   pX3ent_settype(cube2, PH_RIGID, PH_BOX);
   
   wait(-5);
   
   pX3ent_addforcecentral(cube1, vector(0, -5, 10));
   
   diag(str_printf(NULL, "Cube1:%X, Cube2:%X, Cube3:%X\n", handle(cube1), handle(cube2), handle(level_ent)));
}

Posted By: Emre

Re: AckphysX3 development thread - 04/09/13 05:48

Thanks. Yes your code is works but i don't want to use trigger action. Try this code:

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

#define PRAGMA_PATH "C:\\Program Files\\GStudio8\\templates\\sounds";
#define PRAGMA_PATH "C:\Program Files\\GStudio8\templates\models";

#define PRAGMA_PATH "C:\\Program Files (x86)\\GStudio8\\templates\\sounds";
#define PRAGMA_PATH "C:\\Program Files (x86)\\GStudio8\\templates\\models";

SOUND *snd_impact = "aiimpact.wav";

ENTITY* terrain_ent;


// Impact event : 
void impact_event()
{
	if (event_type == EVENT_FRICTION)
	{
		ent_playsound ( my, snd_impact,100);
	}

}


// App entry point
void main()
{
	// Open physX : 
	physX3_open();
	
	// Load level : 
	level_load("");
	vec_set(camera.x, vector(-253, -6, 128));
	camera.tilt = -26;
	
	// Create cube : 
	terrain_ent = ent_create("water.hmp", vector(0, 0, 0), NULL);
	pX3ent_settype(terrain_ent, PH_STATIC, PH_TERRAIN);
	
}

VECTOR p_target;
VECTOR kick_vec;
void on_space_event()
{
	p_target.x=camera.x+cos(camera.pan)*cos(camera.tilt)*50;
	p_target.y=camera.y+sin(camera.pan)*cos(camera.tilt)*50;
	p_target.z=camera.z+sin(camera.tilt)*50;
	
	you=ent_create(CUBE_MDL, p_target.x, NULL);
	pX3ent_settype(you, PH_RIGID, PH_BOX);
	you.emask|=(ENABLE_FRICTION);
	pX3ent_setcollisionflag(you, NULL,PX_PF_NOTIFY_TOUCH);
	
	kick_vec.x=100;
	kick_vec.y=0;
	kick_vec.z=0;
	vec_rotate(kick_vec,camera.pan);
	pX3ent_addvelcentral(you, vector(kick_vec.x, kick_vec.y, kick_vec.z));
	you.event=impact_event;
	
}



it only works in the previous version. (0.85.0)
Posted By: 3dgs_snake

Re: AckphysX3 development thread - 04/09/13 07:00

laugh Yes, you found the bug I was talking about. NULL is used only for level geometries (level_ent). Here, you are creating a terrain, called terrain_ent. So to enable event between those two entities, you need to change

Code:
pX3ent_setcollisionflag(you, NULL,PX_PF_NOTIFY_TOUCH);



to

Code:
pX3ent_setcollisionflag(you, terrain_ent,PX_PF_NOTIFY_TOUCH);



In the previous version, event is always called after you used an entity to register for an event, even if the entity is colliding with a different entity.
Posted By: Emre

Re: AckphysX3 development thread - 04/09/13 08:31

Ahh okay, sorry. blush
Posted By: 3dgs_snake

Re: AckphysX3 development thread - 06/28/13 05:35

Plugin v0.92 physX 3.2.4 on first page
Posted By: Taskmaster065

Re: AckphysX3 development thread - 07/12/15 06:29

If you are using AckphysX3(v0.93) you may be interested in this thread:
PhysX3 (v0.93): Problems,Bugs,Errors
© 2024 lite-C Forums