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
#402
Thanks
P
10/22/2014 (6:50 am)
^ that was me by the way... seems my colleague Brian was still logged into GG on this computer lol.Thanks
P
#403
Sounds like some cool stuff you are working on :)
The mass does indeed come from ShapeBase. Since the Player class is a child of that you should be able to modify it directly. ShapeBase has a function called updateMass where it will set mMass and mOneOverMass (that is just 1.0/mass). It takes into account any mounted images and add's in the mass from those too. Yep the initial mass is set from the datablock. Anyways what i would be doing is setting the mMass and mOneOverMass yourself in the Player class (just be aware if you mount any images ShapeBase will recalculate the mass thus destroying your changes). In the player class when you call getMass() it just returns mMass anyway.
I think i just found a harmless bug in ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload ), it updates the mass twice for no reason :). That updateMass function is actually in shapeImage.cpp
Hope that helps.
10/22/2014 (5:07 pm)
Hey Paul,Sounds like some cool stuff you are working on :)
The mass does indeed come from ShapeBase. Since the Player class is a child of that you should be able to modify it directly. ShapeBase has a function called updateMass where it will set mMass and mOneOverMass (that is just 1.0/mass). It takes into account any mounted images and add's in the mass from those too. Yep the initial mass is set from the datablock. Anyways what i would be doing is setting the mMass and mOneOverMass yourself in the Player class (just be aware if you mount any images ShapeBase will recalculate the mass thus destroying your changes). In the player class when you call getMass() it just returns mMass anyway.
I think i just found a harmless bug in ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload ), it updates the mass twice for no reason :). That updateMass function is actually in shapeImage.cpp
Hope that helps.
#404
So if anyone is using cloth with terrains of that size just watch out for that one ;-)
Solution:
I added a new group called PX3_NOCOLLIDE and stored it in word3. Than you can do something like this in the filter shader:
Hope that helps if anyone else has this problem(this is not in the physx3 repo). I spent days trying to figure out what was causing the crash lol.
10/30/2014 (6:28 pm)
I come across a limitation with large terrain and cloth. One DM level is 2048 x2048 terrain size (4 million odd verts) and physx and cloth go crazy over this. The only solution i could work out was to filter out collisions between cloth and terrain (which for our case is fine because we don't need collisions between those two).So if anyone is using cloth with terrains of that size just watch out for that one ;-)
Solution:
I added a new group called PX3_NOCOLLIDE and stored it in word3. Than you can do something like this in the filter shader:
//No collision between these pairs if added to that group in word3 if (filterData0.word3 == PX3_NOCOLLIDE && filterData1.word3 == PX3_NOCOLLIDE ) return physx::PxFilterFlag::eSUPPRESS;
Hope that helps if anyone else has this problem(this is not in the physx3 repo). I spent days trying to figure out what was causing the crash lol.
#405
- Fixed memory leak when creating terrain with physx 3
- Fixed terrain tessellation with physx 3
I'll have to merge in 3.6.x at some stage when i get time. I have heaps of other changes(physx3 ragdoll's for one) in DM for this plugin but i'm not sure how much of it i'll push back because it does take time testing it all with vanilla T3D and maintaining it all.
11/07/2014 (8:10 pm)
Repo update for both advanced & basic- Fixed memory leak when creating terrain with physx 3
- Fixed terrain tessellation with physx 3
I'll have to merge in 3.6.x at some stage when i get time. I have heaps of other changes(physx3 ragdoll's for one) in DM for this plugin but i'm not sure how much of it i'll push back because it does take time testing it all with vanilla T3D and maintaining it all.
#406
11/08/2014 (3:56 am)
Sounds awesome :). I'm really excited imagining what sort of stuff you're working on for DM ;).
#407
Sorry for the late reply, got sidelined for a while on something else... thanks for the info, I had actually tried somethkng very close to that but for various reasons it was causing me grief so I ended up finding another solution.
I used the player's jumpjetforce and energy drain, both of which I have working with the player object now, and by being clever and setting those two variables we can now have a hovering character that can go up or down by increasing or decreasing the force. When he is neither thrusting nor descending, his drain vs. Thrust is neutral and he hovers in place.
So we can now thrust up until energy is almost drained, then lock into a hover and glide around the map dropping physics blocks like bombs onto targets :)
Lots of fun!
Would like to post a video here soon to show this off, is there a secret to embedding videos into posts by chance?
Cheers
Paul
11/08/2014 (6:59 am)
Hi again!Sorry for the late reply, got sidelined for a while on something else... thanks for the info, I had actually tried somethkng very close to that but for various reasons it was causing me grief so I ended up finding another solution.
I used the player's jumpjetforce and energy drain, both of which I have working with the player object now, and by being clever and setting those two variables we can now have a hovering character that can go up or down by increasing or decreasing the force. When he is neither thrusting nor descending, his drain vs. Thrust is neutral and he hovers in place.
So we can now thrust up until energy is almost drained, then lock into a hover and glide around the map dropping physics blocks like bombs onto targets :)
Lots of fun!
Would like to post a video here soon to show this off, is there a secret to embedding videos into posts by chance?
Cheers
Paul
#408
11/08/2014 (1:25 pm)
Sounds awesome paul, yeah do show off some of your work :). Vids are easy to embed just check here www.garagegames.com/support/markuplite
#409
Have lots of neat stuff working in this physx build:
-advanced character animations
-jetpack hovering
-gravity gun to move physics shapes around
-custom flag blocks, each user can upload an image to the website and the game picks it up and uses it for the user's flag block
-various ways to build with the blocks, either staircases or bridges in the direction you are pointing, or grid based where blocks snap together like mine craft, or physics block mode to fire physics shapes, or you can fire prefab walls which have 16 blocks in them for fast building
Also made a cool mini game like Angry birds, where you have so many physics blocks of a certain type to throw at a tower made up of various blocks. You need to pick and choose which blocks to throw based on what you are trying to knock down, since each block has distinct mass and damage characteristics, and you have only a certain amount of shots to destroy all the blocks or the tower resets to try again. Pretty fun and addictive lol :)
11/08/2014 (1:37 pm)
OK cool, maybe I will make that my Sunday project for tomorrow :)Have lots of neat stuff working in this physx build:
-advanced character animations
-jetpack hovering
-gravity gun to move physics shapes around
-custom flag blocks, each user can upload an image to the website and the game picks it up and uses it for the user's flag block
-various ways to build with the blocks, either staircases or bridges in the direction you are pointing, or grid based where blocks snap together like mine craft, or physics block mode to fire physics shapes, or you can fire prefab walls which have 16 blocks in them for fast building
Also made a cool mini game like Angry birds, where you have so many physics blocks of a certain type to throw at a tower made up of various blocks. You need to pick and choose which blocks to throw based on what you are trying to knock down, since each block has distinct mass and damage characteristics, and you have only a certain amount of shots to destroy all the blocks or the tower resets to try again. Pretty fun and addictive lol :)
#410
11/08/2014 (1:52 pm)
Sweet, look forward to checking it out :)
#411
11/08/2014 (2:06 pm)
Thanks dan, we are going to try and do a blog post this month (time permitting) for DM and show some of the latest stuff.
#412
I signed up for BlockAbout and payed the rego fee (gotta help ya fellow indie out). Is there anything else i have to do? It's kinda a little confusing on the webpage.
11/11/2014 (3:14 am)
@Paul:I signed up for BlockAbout and payed the rego fee (gotta help ya fellow indie out). Is there anything else i have to do? It's kinda a little confusing on the webpage.
#413
Ya I need to make it more clear I guess :)
The basic account itself is free, and is needed to play online against a buddy so each player has a unique name. If you don't log in to the game that's fine, it just won't go out to the master server to look for anyone else on the net. But you can still play locally on the LAN with any name you like without logging in.
If somebody pays to register, I just flag their game account as paid/registered when I get the PayPal email. If the PayPal sender doesn't match any email I have in the users, I contact the person directly to find out what their account in the game is so I can flag it.
When you are logged in with a paid account, it will also prompt you after each mission to send your score up to the LeaderBoard where it will track everyone's communal score. The LeaderBoard is visible within the game on the Main Menu, and also on the website.
Finally, on the website, if you log in with a paid/registered account, there is an option under My Account where you can upload an image that will be used in your Flag block within the game. Players drop a flag when they are killed by another player, and players can pick up flags to score them. You can also plant your flag somewhere when the mission starts, so you will not be carrying it when you die and it will not get tossed. Flags are worth 10,000 points which can quickly end the mission if you capture a few. Enemy AI will also toss flags when you kill them.
Everything is still in an experimental state, the game is currently just a showcase of all the mechanics and physics, with various sample missions. These will be streamlined into a single player story campaign over the next while, with additional maps added that will be more geared to multiplayer.
Final launch date is set for the spring some time, once we finalize the game play and features. But for now there is still a lot of fun stuff in there to try :)
Cheers and thanks!
P
11/11/2014 (8:23 am)
Cool!Ya I need to make it more clear I guess :)
The basic account itself is free, and is needed to play online against a buddy so each player has a unique name. If you don't log in to the game that's fine, it just won't go out to the master server to look for anyone else on the net. But you can still play locally on the LAN with any name you like without logging in.
If somebody pays to register, I just flag their game account as paid/registered when I get the PayPal email. If the PayPal sender doesn't match any email I have in the users, I contact the person directly to find out what their account in the game is so I can flag it.
When you are logged in with a paid account, it will also prompt you after each mission to send your score up to the LeaderBoard where it will track everyone's communal score. The LeaderBoard is visible within the game on the Main Menu, and also on the website.
Finally, on the website, if you log in with a paid/registered account, there is an option under My Account where you can upload an image that will be used in your Flag block within the game. Players drop a flag when they are killed by another player, and players can pick up flags to score them. You can also plant your flag somewhere when the mission starts, so you will not be carrying it when you die and it will not get tossed. Flags are worth 10,000 points which can quickly end the mission if you capture a few. Enemy AI will also toss flags when you kill them.
Everything is still in an experimental state, the game is currently just a showcase of all the mechanics and physics, with various sample missions. These will be streamlined into a single player story campaign over the next while, with additional maps added that will be more geared to multiplayer.
Final launch date is set for the spring some time, once we finalize the game play and features. But for now there is still a lot of fun stuff in there to try :)
Cheers and thanks!
P
#414
* Merged in latest development branch (i think that is devel branch for the upcoming 3.7 lol)
* Fixed issue creating the physx shared cpu dispatcher.
Sorry i haven't had time to update the basic version yet. I'll have to create a basic "show off" level for all this, something that shows a bit more than the physx samples in the first post (which are out of date by the way).
11/16/2014 (1:20 am)
Repo update for advanced:* Merged in latest development branch (i think that is devel branch for the upcoming 3.7 lol)
* Fixed issue creating the physx shared cpu dispatcher.
Sorry i haven't had time to update the basic version yet. I'll have to create a basic "show off" level for all this, something that shows a bit more than the physx samples in the first post (which are out of date by the way).
#415
Having said that, the plugin will work ok with 3.3.2 (i have tested it) you will just have to manually change the lib directories etc yourself.
11/16/2014 (1:27 am)
Also sorry i haven't updated the build system for physx 3.3.2 either (will only work with 3.3.1 due to NVidia changing a few directories in the physx SDK). I didn't want to run two seperate version of the SDK on my devel PC because i'm still using 3.3.1 in DeadlyMatter and don't want to update it right at the moment as it's not an appropriate time due to heavy development going on ;-)Having said that, the plugin will work ok with 3.3.2 (i have tested it) you will just have to manually change the lib directories etc yourself.
#416
Hey dan it will need the updated projects.xml and also those changes to the project manager i made in this pull request github.com/GarageGames/Torque3D-ProjectManager/pull/27 because the current project manager won't allow two modules that share "physx" string ;)
Also dan i have a few fixes for the physx3 plugin that i haven't had a chance yet to add so i will have to send a few PR's through to the official GG repo over the next few days.
11/29/2014 (3:38 am)
Ok sweet physx3_basic has been merged into the official development branch now on GG :)Hey dan it will need the updated projects.xml and also those changes to the project manager i made in this pull request github.com/GarageGames/Torque3D-ProjectManager/pull/27 because the current project manager won't allow two modules that share "physx" string ;)
Also dan i have a few fixes for the physx3 plugin that i haven't had a chance yet to add so i will have to send a few PR's through to the official GG repo over the next few days.
#417
The two options for this are
1)define NDEBUG in torqueConfig.h (with debug build _DEBUG is already defined)
2)Modify the tpl templates for the project gen and add for the release mode
Personally in the DeadlyMatter build i went with option number 2. Either way works fine though.
If you prefer option 1 than you need to add
11/29/2014 (4:07 am)
Oh and also dan currently the release build of the official development branch will not compile in release mode under VisualStudio with physx3 enabled. It needs NDEBUG defined in release mode (annoying i know).The two options for this are
1)define NDEBUG in torqueConfig.h (with debug build _DEBUG is already defined)
2)Modify the tpl templates for the project gen and add for the release mode
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Personally in the DeadlyMatter build i went with option number 2. Either way works fine though.
If you prefer option 1 than you need to add
#ifndef _DEBUG #define NDEBUG #endif
#418
https://developer.nvidia.com/physx-sdk
I have provided a link :)
12/12/2014 (10:34 pm)
Question - What version of Physx is this the most recent SDK supports Linux, Android, iOS and Consoles out of the box.https://developer.nvidia.com/physx-sdk
I have provided a link :)
#419
*Edit:
Sorry i tell a lie, the physx3_advanced i haven't updated yet, it only supports 3.3.1. The basic version now in the official GG devel branch supports 3.3.1. I must update the physx3_advanced sometime soon.
12/13/2014 (1:04 am)
3.3.2*Edit:
Sorry i tell a lie, the physx3_advanced i haven't updated yet, it only supports 3.3.1. The basic version now in the official GG devel branch supports 3.3.1. I must update the physx3_advanced sometime soon.
#420
Although I'm sure it's mentioned somewhere in the thread, could anyone fill me in on the final status re: vehicles? Has anyone actually delivered yet on a fully physx driven Cheetah, car or tank? Waiting and salivating...
12/27/2014 (4:33 pm)
So, sorry, I'm late to the game here, great work Timmy and Andy and everybody else who's contributed!!!Although I'm sure it's mentioned somewhere in the thread, could anyone fill me in on the final status re: vehicles? Has anyone actually delivered yet on a fully physx driven Cheetah, car or tank? Waiting and salivating...
Torque Owner Brian M
Gambit Realm
Been doing some really cool stuff with the plugin, but have run into an issue with trying to implement a per-player mass variable, wondering if you had any ideas on that?
We already have a dynamic agility system, which placed control of speed, jump force, etc into the player object instead of the data block, works great for power ups and such, but I can't get that to work with mass in the same way. Seems like it gets mass from shape base or something, because adding it into the player object agility code does nothing. Mass always seems to be set to 24 according to an echo statement I put in the engine code.
I am trying to flip the player's mass between 0 and normal (which is 120 in the player data block), so I can have him hover. Have jetting working but want to have hover mode as well so player will not fall down when jetpack key is released.
Thoughts?
Thanks :)
Paul