by date
PhysX Integration
PhysX Integration
| Name: | James Thompson | |
|---|---|---|
| Date Posted: | Apr 11, 2006 | |
| Rating: | 3.5 out of 5 | |
| Public: | YES | |
| Comments: | YES | |
| RSS Feed: | or Subscribe with . | |
| Profile Page: | View profile page for James Thompson |
Blog post
Hi,
This seems like an impossible task, im going to try to integrate the PhysX SDK into Torque for DawnOfMen.
I know this has already been done so I know that the code is out there somewhere but Ageia wont reply to my e-mails, and GG did not write the code, at least I don't think they did?
So there you have it im going to go for it. It should be worth it, in my castle siege game. Lets hope it is :)
Ill update you on the progress every time I hit a new landmark.
Any tips, including code, would be great ;)
EDIT: Already been done :) see below
This seems like an impossible task, im going to try to integrate the PhysX SDK into Torque for DawnOfMen.
I know this has already been done so I know that the code is out there somewhere but Ageia wont reply to my e-mails, and GG did not write the code, at least I don't think they did?
So there you have it im going to go for it. It should be worth it, in my castle siege game. Lets hope it is :)
Ill update you on the progress every time I hit a new landmark.
Any tips, including code, would be great ;)
EDIT: Already been done :) see below
Recent Blog Posts
| List: | 11/04/06 - DOM, SG and future resources 10/01/06 - Progress on various things 09/02/06 - DawnOfMen & me 07/01/06 - DawnOfMen Alpha Progress 06/25/06 - DawnOfMen Alpha Release 06/18/06 - RSS 06/05/06 - DawnOfMen 0.8 05/29/06 - X-Fire Integration continued |
|---|
Submit your own resources!| N R Bharathae (Apr 11, 2006 at 10:20 GMT) |
| Martin de Richelieu (Apr 11, 2006 at 10:31 GMT) Resource Rating: 4 |
| X-Tatic (Apr 11, 2006 at 10:57 GMT) Resource Rating: 1 |
| Scott Burns (Apr 11, 2006 at 13:01 GMT) |
When I downloaded the sdk I was playing the reinforced wall demos and thought it would be perfect for a castle seige game.
| Alan H (Apr 11, 2006 at 13:03 GMT) |
| Matt Vitelli (Apr 11, 2006 at 13:45 GMT) |
| Jeremiah Fulbright (Apr 11, 2006 at 13:59 GMT) |
As for integration, Good luck.. I had done some preliminary stuff got everything init'ing and even actor creation, but all non-visible (ala not in the game world). I talked to my Account Rep at AGEIA and they told me to talk to GG, as an implementation was supposedly being done by GG, but I have recieved no answer either way.
I have access to another engine which already had PhysX integrated and wrapped into C#, so I know alot of stuff needed to wrap functions and variables into TorqueScript, but not sure how much help it'll give me, If I decide to give it a go again
Feel free to contact me if I can of any service though
Edited on Apr 11, 2006 15:44 GMT
| James Thompson (Apr 11, 2006 at 16:25 GMT) |
Jeremiah: yeah ive got no response from GG when i've asked about PhysX, did you need to make any changes to the PhysX files to get them to init?
Edited on Apr 11, 2006 16:27 GMT
| James Thompson (Apr 11, 2006 at 17:35 GMT) |
I've created a file in 'game' called physx.h and put this in it:
//-----------------------------------------------------------------------------
// Torque Game Engine PhysX Core
//-----------------------------------------------------------------------------
#ifndef PhysX
#define PhysX
#define NOMINMAX
#ifdef WIN32
#include <windows.h>
#include "NxPhysics.h"
That loads up the physx engine, i believe.
now on to some more advanced stuff :(
Edited on Apr 11, 2006 17:39 GMT
| James Thompson (Apr 11, 2006 at 18:00 GMT) |
but with a major change that enables you to actually compile it :)
#ifndef PhysX_H
#define PhysX_H
#define NOMINMAX
#ifdef WIN32
#include <windows.h>
#include "NxPhysics.h"
#include <GL/gl.h>
#include <GL/glut.h>
#elif LINUX
#include <windows_replacement.h>
#include <GL/gl.h>
#include <GL/glut.h>
#elif __APPLE__
#include <windows_replacement.h>
#include <OpenGL/gl.h>
#include <GLUT/glut.h>
#endif
#include <stdio.h>
void PrintControls();
void ProcessCameraKeys();
void SetupCamera();
void RenderActors(bool shadows);
void ProcessForceKeys();
void ProcessInputs();
void RenderCallback();
void ReshapeCallback(int width, int height);
void IdleCallback();
void KeyboardCallback(unsigned char key, int x, int y);
void KeyboardUpCallback(unsigned char key, int x, int y);
void SpecialCallback(int key, int x, int y);
void MouseCallback(int button, int state, int x, int y);
void MotionCallback(int x, int y);
void ExitCallback();
void InitGlut(int argc, char** argv);
void InitNx();
void ReleaseNx();
void ResetNx();
void StartPhysics();
void GetPhysicsResults();
int main(int argc, char** argv);
#endif // PhysX
| Luke *V8motorhead* Jones (Apr 11, 2006 at 22:17 GMT) |
#include <GL/gl.h>
#include <GL/glut.h>
#elif LINUX
#include <windows_replacement.h>
#include <GL/gl.h>
#include <GL/glut.h>
#elif __APPLE__
#include <windows_replacement.h>
#include <OpenGL/gl.h>
#include <GLUT/glut.h>
#endif
#include <stdio.h>
that stuff isn't needed, unless you plan to write cubes in the code and render them with your own GL calls.
All you really need are :
void InitNx();
void ReleaseNx();
void ResetNx();
void StartPhysics();
void GetPhysicsResults();
You want to call InitNx from main.cc somewhere (this is all very much the same as Newton Dynamics) ReleaaseNx needs to be called when the game ends, ResetNx, guess thats for when you start a new game and need to clear the physics world. StartPhysics, call that when you start your game.
Most important GetPhysicsResults, call that every tick to update with the simulation.
Now, a couple of the callbacks will be needed, most notably rendercallback, so you can update the torque screen. And, your going to have to write your own callback functions for it.
You got some hard work ahead of you bud.
If you want, I can do a quick conversion from my Newton code so that you can see how PhysX will be initialised.
| Luke *V8motorhead* Jones (Apr 11, 2006 at 22:22 GMT) |
The one problem I had, was getting the terrain collision, getting shapes seems to be easy enough, but thats it.
| James Thompson (Apr 12, 2006 at 09:02 GMT) |
I could put
void InitNx();
in
static bool initLibraries()
or should it be in
bool initGame(int argc, const char **argv)
Edited on Apr 12, 2006 09:10 GMT
| James Thompson (Apr 12, 2006 at 09:04 GMT) |
void ReleaseNx();
in
static void shutdownLibraries()
or in
void shutdownGame()
Edited on Apr 12, 2006 09:06 GMT
| James Thompson (Apr 12, 2006 at 09:07 GMT) |
in
void fpsReset()
| James Thompson (Apr 12, 2006 at 09:09 GMT) |
in
void fpsUpdate()
| James Thompson (Apr 12, 2006 at 09:27 GMT) |
The mission load up too :)
So I believe I have got the physx sdk to load and release, got to put in some echos to the console to make sure
| Shannon "ScarWars" Scarvaci (Apr 13, 2006 at 00:51 GMT) |
www.scarvaci.com/small_physx.avi
Edited on Apr 13, 2006 00:52 GMT
| Chris \"C2\" Byars (Apr 13, 2006 at 02:13 GMT) Resource Rating: 5 |
Looking forward to a resource ;)
| Shannon "ScarWars" Scarvaci (Apr 13, 2006 at 09:08 GMT) |
There is a bit of improvement but the terrain is still the problem.
The physX limit for terrain is 256x256 so if your mission have terrain with squareSize = 2 and you may notice the gap between it coz terrain is 512x512 but for collision in physX would be 256x256. So I'll working it out for this terrain later but now I try use player to push it around.
And for networking seem work well with minor lag.
| James Thompson (Apr 13, 2006 at 09:32 GMT) |
Could you send me those files? Or upload them as a resource?
| Shannon "ScarWars" Scarvaci (Apr 13, 2006 at 09:41 GMT) |
Yes I'll put them as a resource...but I need to fix things up before put in the resource.
Please wait for a week or two.
| James Thompson (Apr 13, 2006 at 10:46 GMT) |
| James Thompson (Apr 13, 2006 at 10:48 GMT) |
| Shannon "ScarWars" Scarvaci (Apr 13, 2006 at 12:01 GMT) |
| James Thompson (Apr 13, 2006 at 14:24 GMT) |
Edited on Apr 13, 2006 14:38 GMT
| Christian Weber (Apr 13, 2006 at 15:48 GMT) Resource Rating: 5 |
| James Thompson (Apr 13, 2006 at 18:24 GMT) |
The library is free as long as you include support for the PhysX H/W
| James Thompson (Apr 13, 2006 at 18:27 GMT) |
| Christian Weber (Apr 13, 2006 at 20:23 GMT) Resource Rating: 5 |
| Luke *V8motorhead* Jones (Apr 14, 2006 at 01:30 GMT) |
I'm seriosly hoping that shannons code will provide the missing bits for my newton integration....
| Jeremiah Fulbright (Apr 14, 2006 at 02:33 GMT) |
HW Physics means alot more items, but it also means more optimization for collisions and meshes themselves, and there are limits for HW Physics currently.. Software can actually do more overall, than HW right now..
And for PPU support, its a matter of enabling it in the SDK and you need 2.4.0 SDK or better which isn't publically available (that I have seen), but an Aegia rep should be able to supply you with it (as they did for me)
| Scott Burns (Apr 14, 2006 at 18:15 GMT) |
c:\torque 1.4\lib\physx\foundation\include\nx.h(34) : fatal error C1189: #error : custom definition of NX_CALL_CONV for your OS needed!
BSCMAKE: error BK1506 : cannot open file '..\engine\out.VC6.DEBUG\game.sbr': No such file or directory
| Shannon "ScarWars" Scarvaci (Apr 15, 2006 at 01:24 GMT) |
At the configuration properties of this game, put WIN32 in c/c++ -> preproccessor definitions. Or put #define WIN32 before calling #include <NxPhysics.h>
| Scott Burns (Apr 17, 2006 at 18:08 GMT) |
Thanks, I thought I had that in there but I guess I missed it. I've started over now and am up to NxAllocatable now.
| Shannon "ScarWars" Scarvaci (Apr 18, 2006 at 00:09 GMT) |
You can find the resource in here to save your time :D
Edited on Apr 18, 2006 00:18 GMT
You must be a member and be logged in to either append comments or rate this resource.


3.5 out of 5


