PhysX 3.x Plugin
by Timmy01 · in Torque 3D Professional · 10/28/2013 (5:11 am) · 500 replies
Update:
If you wish to follow this than please check here github.com/ChrisCalef/Torque3D/tree/physx3_advanced_WIP
If you wish to follow this than please check here github.com/ChrisCalef/Torque3D/tree/physx3_advanced_WIP
About the author
#222
05/20/2014 (4:17 am)
I'm using your player class. Looks like if kinematic is disabled the player will not float over the coliision box.
#223
Have been trying in vain to get a PhysicsShape to activate a trigger...
Seems to work OK for the player, I can scatter some test triggers around and walk through them and they fire correctly. But the shapes do not, they appear to be ignored somehow in the PhysX build?
I have the Torque bouncing boulder working fine as a PhysicsShape, can shoot it and roll it along, but it just rolls through the trigger without activating it.
How would we go about making that work for the PhysicsShapes?
Thanks!
Paul
05/21/2014 (8:08 pm)
Hi again all,Have been trying in vain to get a PhysicsShape to activate a trigger...
Seems to work OK for the player, I can scatter some test triggers around and walk through them and they fire correctly. But the shapes do not, they appear to be ignored somehow in the PhysX build?
I have the Torque bouncing boulder working fine as a PhysicsShape, can shoot it and roll it along, but it just rolls through the trigger without activating it.
How would we go about making that work for the PhysicsShapes?
Thanks!
Paul
#224
05/22/2014 (2:19 am)
You will have to change the collision filter shader.
#225
Ummm... what exactly is the collision filter shader and where would I change it?
Lol thanks :)
05/22/2014 (6:25 am)
Of course, the collision filter shader, how did I not think of that? Duh..Ummm... what exactly is the collision filter shader and where would I change it?
Lol thanks :)
#226
//filter shader with support for CCD pairs
static physx::PxFilterFlags sCcdFilterShader(
physx::PxFilterObjectAttributes attributes0,
physx::PxFilterData filterData0,
physx::PxFilterObjectAttributes attributes1,
physx::PxFilterData filterData1,
physx::PxPairFlags& pairFlags,
const void* constantBlock,
physx::PxU32 constantBlockSize)
{
pairFlags = physx::PxPairFlag::eRESOLVE_CONTACTS;
pairFlags |= physx::PxPairFlag::eCCD_LINEAR;
return physx::PxFilterFlags();
}
I tried adding a line for Triggers, like so:
pairFlags = physx::PxPairFlag::eRESOLVE_CONTACTS;
pairFlags |= physx::PxPairFlag::eCCD_LINEAR;
pairFlags |= physx::PxPairFlag::eTRIGGER_DEFAULT;
which was based on similar examples I found when digging around...
But still, the physics ball just rolls right through the trigger without the trigger seeing it pass.
Also, am looking to enable onCollision callbacks for the physics shapes - so I can script what happens when the rolling boulder hits a certain object, or inflict damage to the player if the boulder hits them, etc.
As it stands, trying something like bouncingBoulder.onCollision() does not fire.
Thanks in advance to anyone with ideas :)
Cheers
Paul
05/22/2014 (9:07 pm)
OK, so I found the code in px3World.cpp://filter shader with support for CCD pairs
static physx::PxFilterFlags sCcdFilterShader(
physx::PxFilterObjectAttributes attributes0,
physx::PxFilterData filterData0,
physx::PxFilterObjectAttributes attributes1,
physx::PxFilterData filterData1,
physx::PxPairFlags& pairFlags,
const void* constantBlock,
physx::PxU32 constantBlockSize)
{
pairFlags = physx::PxPairFlag::eRESOLVE_CONTACTS;
pairFlags |= physx::PxPairFlag::eCCD_LINEAR;
return physx::PxFilterFlags();
}
I tried adding a line for Triggers, like so:
pairFlags = physx::PxPairFlag::eRESOLVE_CONTACTS;
pairFlags |= physx::PxPairFlag::eCCD_LINEAR;
pairFlags |= physx::PxPairFlag::eTRIGGER_DEFAULT;
which was based on similar examples I found when digging around...
But still, the physics ball just rolls right through the trigger without the trigger seeing it pass.
Also, am looking to enable onCollision callbacks for the physics shapes - so I can script what happens when the rolling boulder hits a certain object, or inflict damage to the player if the boulder hits them, etc.
As it stands, trying something like bouncingBoulder.onCollision() does not fire.
Thanks in advance to anyone with ideas :)
Cheers
Paul
#227
A few pages back i mentioned this is definitely an area in T3D that needs work. Unfortunately i never got time before i moved on from T3D.
05/22/2014 (9:20 pm)
The eTRIGGER_DEFAULT is not used in the plugin for trigger shapes. Take a look for enum Px3CollisionGroup in px3World and modify to suit. Also check out Px3Body::init. It's just a matter of creating a custom group for whatever sort of filtering you want to do.A few pages back i mentioned this is definitely an area in T3D that needs work. Unfortunately i never got time before i moved on from T3D.
#228
The plugin really is very good, and suits our needs well. Hopefully I can fix these last few things, at least it wlll force me to get better with my c++ coding lol.
Cheers
P
05/22/2014 (9:29 pm)
OK, thanks for everything Timmy.The plugin really is very good, and suits our needs well. Hopefully I can fix these last few things, at least it wlll force me to get better with my c++ coding lol.
Cheers
P
#229
05/22/2014 (9:31 pm)
If i get overly excited over the weekend i'll post an example of what i mean :-). There was actually a few updates i wanted to post i just never got around to it. I have a lot more spare time these days as i'm not involved in that game project i mentioned above.
#230
I looked at that enum px3collisiongroup, and it appears that px3_trigger is already in there, so hopefully its just a quick something needed in the init to get this working...
If we can also get the boulder and other physics shapes to inflict damage, similar to what the projectile already does, in addition to them being able to activate triggers, then I have all kinds of cool ideas for physics games :)
Cheers
P
05/23/2014 (10:10 am)
That would be awesome, thanks again!I looked at that enum px3collisiongroup, and it appears that px3_trigger is already in there, so hopefully its just a quick something needed in the init to get this working...
If we can also get the boulder and other physics shapes to inflict damage, similar to what the projectile already does, in addition to them being able to activate triggers, then I have all kinds of cool ideas for physics games :)
Cheers
P
#231
Still stuck on the triggers and collisions, having a hard time deciphering the physx code, a bit out of my league lol.
Thanks
P
05/27/2014 (8:15 pm)
Hey Timmy, any news on those updates? :)Still stuck on the triggers and collisions, having a hard time deciphering the physx code, a bit out of my league lol.
Thanks
P
#232
05/27/2014 (9:58 pm)
Sorry mate didn't get any free time over the weekend. Hopefully get a chance later in the week.
#233
I have had a good look over this and it's going to take a bit of work to get it all working happily with the physics side. The main problem is the way physics stuff has been implemented into T3D, honestly it's not very nice.
I am just not sure how much of my spare time i want to spend on this considering i have no great intentions of using T3D in any projects for now. In all honesty, there is soo much of T3D that needs redesigning that i wonder if it wouldn't be easier just starting with a clean slate. The more stuff that keeps on getting hacked into T3D the worse it becomes.
05/31/2014 (4:03 am)
@Paul:I have had a good look over this and it's going to take a bit of work to get it all working happily with the physics side. The main problem is the way physics stuff has been implemented into T3D, honestly it's not very nice.
I am just not sure how much of my spare time i want to spend on this considering i have no great intentions of using T3D in any projects for now. In all honesty, there is soo much of T3D that needs redesigning that i wonder if it wouldn't be easier just starting with a clean slate. The more stuff that keeps on getting hacked into T3D the worse it becomes.
#234
05/31/2014 (4:16 am)
Timmy, you may be interested in Jeff's component/entity work. We all feel a little like that, but hopefully this will provide a bit of a refresh for the engine's core gameplay classes.
#235
05/31/2014 (5:00 am)
Daniel have you got a link for that? Sorry i haven't been on the forums for a while and couldn't see anything obvious that popped up just having a quick look through.
#236
I was dreading hearing something like that... The plugin was so awesome that we went and built our whole game around it. I was really hoping we would be able to have sensed collisions on the physics shapes so we could have them do damage to the player and also have them activate triggers. Its the final piece in a cool game concept we're trying to finish off lol.
If its a lot of work, I'd be happy to pay something... not very wealthy yet but could flip somebody a quick 100 bucks if they get that working?
Gotten better with t3d engine coding but the physx code is beyond me.
Thanks cheers!
P
05/31/2014 (7:01 am)
Hey guys,I was dreading hearing something like that... The plugin was so awesome that we went and built our whole game around it. I was really hoping we would be able to have sensed collisions on the physics shapes so we could have them do damage to the player and also have them activate triggers. Its the final piece in a cool game concept we're trying to finish off lol.
If its a lot of work, I'd be happy to pay something... not very wealthy yet but could flip somebody a quick 100 bucks if they get that working?
Gotten better with t3d engine coding but the physx code is beyond me.
Thanks cheers!
P
#237
Just so we are on the same page, you want objects that use PhysicsShapeData datablock to be able to trigger events with objects from the TriggerData datablock?
05/31/2014 (5:14 pm)
Honestly paul keep your money in ya pocket, i know it's tough out there for us indie developers. I'll finish this part off, it may take a few weeks though, see how i go.Just so we are on the same page, you want objects that use PhysicsShapeData datablock to be able to trigger events with objects from the TriggerData datablock?
#238
Yes, I have triggerdata triggers in my map that the player is able to activate by walking into them, that works, but if I roll a physicsshape boulder in there the trigger doesn't sense it.
Also if a physicsshape hits the player right now it bounces off but I cannot use oncollision to make it damage the player. Need to be able to have boulders crush the player, etc.
So just those two things is all we need, thanks again.
Cheers!
P
05/31/2014 (5:42 pm)
That's awesome news thanks :)Yes, I have triggerdata triggers in my map that the player is able to activate by walking into them, that works, but if I roll a physicsshape boulder in there the trigger doesn't sense it.
Also if a physicsshape hits the player right now it bounces off but I cannot use oncollision to make it damage the player. Need to be able to have boulders crush the player, etc.
So just those two things is all we need, thanks again.
Cheers!
P
#239
05/31/2014 (5:53 pm)
Hmmm currently i can't get any of the physics plugins to activate a triggerdata item (with the player i mean). I'll figure it out.
#240
05/31/2014 (6:02 pm)
I think I got player to activate the triggers by commenting out trigger related exceptions in the physx player code... something there talks about skipping triggers so took that out as a test and the trigger fired for the player.
Timmy01
Yep it's definitely a design decision by NVidia. The character controller is a tricky one so they leave it up to the developer how it interacts with other physics objects and this was the right call imho. Different projects are always going to want different interactions and if NVidia forced one way upon you the whole character controller wouldn't be flexible at all (although the source code is available for the character controller).