Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Using GDK with PhysX (not Dark Physics)

Author
Message
0renji
15
Years of Service
User Offline
Joined: 5th May 2009
Location:
Posted: 5th May 2009 21:45
Does anyone have any examples of how to integrate PhysX into a DGDK program? I have PhysX itself set up and working properly, but I'm not sure how PhysX and the main GDK loop should work together.
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 5th May 2009 23:33
I do on my other computer. Give me an email reminding me and I will get it for you. Really not hard at all, but I cant remember off the top of my head.
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 6th May 2009 21:17 Edited at: 6th May 2009 21:18
Here you go:

A program that drops boxes. None of the fancy features of PhysX, but the rigid body works fine. I want to draw your attention to the undocumented command dbSetObjectWorldMAtrix
http://darkgdk.wikia.com/wiki/DbSetObjectWorldMatrix
Feel free to use this code. Credit might be nice.

For this to compile, PhysX SDK must be installed, and the include and libraries set up correctly.
Quote: "What you need to do is go to project -> <project name> properties -> expand linker (on the left hand pane) -> click on 'input' and on the Additional Dependencies box add PhysXLoader.lib

That should fix it, assuming you have your library directories set up properly which you can setup by going to tools->options->expand 'Project and Solutions'->VC++ Directories->Under 'Show Directories For' drop down select library files and add this direcotry in: Crogram FilesNVIDIA CorporationNVIDIA PhysX SDKv2.8.1SDKslibWin32"

You also need to set "Additional Include Directoires" to contain Crogram FilesNVIDIA CorporationNVIDIA PhysX SDKv2.8.1SDKsPhysXLoaderinclude
0renji
15
Years of Service
User Offline
Joined: 5th May 2009
Location:
Posted: 7th May 2009 13:10
I have looked through it and I'm pretty sure I understand, the basic idea is to simulate the physics and then update the db object with the results? Thanks loads for the example jezza
ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 8th May 2009 04:19
Do you have an example that shows how to create a physics object from a .dbo or .x file? I have been looking through the PhysX documentation and google and have failed to find any reference of getting PhysX to create a triangle mesh from a supplied .x or .dbo file and I cannot figure this out for my self.

------------------------------------
Currently 1300+ lines of code into an "over-the-shoulder" action RPG with combat based on rag-doll physics.
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 8th May 2009 15:28
That's rather complicated. I have done it, but that was not suing DarkGDK. It involves loading it into a DirectX mesh (D3DXMESH i think) and then going through the vertices and passing them to the PhysX cooking.
And yes, Orenji. The way the PhysX samples do it in OpenGL is create a new object each frame for each of the physics objects, but the method I use enables you to keep track of object textures etc.
ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 8th May 2009 23:32
Could you provide some sample code? I really want to get PhysX working with my project.

------------------------------------
Currently 1300+ lines of code into an "over-the-shoulder" action RPG with combat based on rag-doll physics.
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 9th May 2009 10:58
Meshes for objects will slow your game down considerably, and are not able to detect collisions with other meshes. For this reason it is advisable to use another shape, such as capsule or box for normal objects. You will however want to use a mesh for the static world in most games. I worked all this out for myself using the internet, so I dare say you will be able to, but I shall see what I get to work sometime if you are still struggling.
ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 9th May 2009 11:03
OK, I will look some stuff up tomorrow. I am planning on constructing my PC/NPC's from primitives like the examples provided with the PhysX SDK, I just need to set up my terrain for collision. It would be great if you could provide me with some links in the mean time.

------------------------------------
Currently 1300+ lines of code into an "over-the-shoulder" action RPG with combat based on rag-doll physics.
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 9th May 2009 12:21
Here's what I use. These are modified versions of functions I found on the internet. You will need to include <vector.h>
Classes:

Functions for those classes:

Helper functions:

Actual Function:

My class PD_SYSTEM contains these relevant things:
NxPhysicsSDK *PhysSDK;
NxScene *PhysScene;
NxCookingInterface *CookingInterface;
LPDIRECT3DDEVICE9 Device;
LPDIRECT3D9 d3d;
There is some undocumented funciton I cannot remember in DarkGDK to get the Device. To use this function you first need the actual mesh, you can load it from a .x file using D3DXLoadMeshFromX
ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 9th May 2009 21:16
If it isn't to much trouble, could you show a snippet where you load a file and set it up with PhysX? I think I have a good idea of what I need to do, I just want to confirm.

------------------------------------
Currently 1300+ lines of code into an "over-the-shoulder" action RPG with combat based on rag-doll physics.
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 10th May 2009 11:09
cut down version of function I use:


Then I just use use something like this to load terrain for example:
PD_OBJECT ground = pdMakeCustom(&pdSystem,
"media\\terrain.x",
PD_VECTOR(0.0f,-10.0f,0.0f),
0.5f,
0.5f,
false);

Login to post a reply

Server time is: 2024-11-25 12:45:57
Your offset time is: 2024-11-25 12:45:57