1. PhysX Includes

Jump To:
main.cpp Source
Download

Main.CPP File:

Welcome to the first of MANY PhysX tutorials helping you to start off with Ageia’s PhysX SDK. If you haven’t got the SDK already, head to Ageia’s website and download it. You will need it for these tutorials.

Anyway, once you have the SDK, navigate to the:
\Program Files\AGEIA Technologies\AGEIA PhysX SDK\v2.7.0\SDKs\

folder and copy the Physics folder to:
\Program Files\Microsoft Visual Studio\VC98\Include\

Next up we are going to navigate to:
\Program Files\AGEIA Technologies\AGEIA PhysX SDK\v2.7.0\SDKs\lib\win32
and we are going to copy every file from this folder to:
\Program Files\Microsoft Visual Studio\VC98\Lib

Theoretically, we should now be able to start coding using the PhysX SDK. So lets test it out. The first lines of code we are going to use are:

// #include <Physics\include\NxPhysics.h>

// #define NOMINMAX

*note, you must #define NOMINAX before using the windows.h file*

Next up we are going to attach our library files. These are:

// #pragma comment(lib,"PhysXLoader.lib")

// #pragma comment(lib,"NxCharacter.lib")
// #pragma comment(lib,"NxCooking.lib")
// #pragma comment(lib,"NxExtensions.lib")

Now you can test this out, by just having a simple int main(){return0;} function to see if it will compile if you want, but I am going to go just one step further and create our SDK for use. We first need a NxPhysicsSDK type variable which is going to be called gPhysicsSDK (If you have played with the PhysX SDK before, you will notice that alot of my variables are named the same as theirs, simply because I learnt it that way 😛 So here’s our gPhysicsSDK variable:

// static NxPhysicsSDK* gPhysicsSDK = NULL;

Now that we have something to create our PhysicsSDK with, we go to our int main() function which will start off like so:

// int main(int argc, char** argv) {
// return 1;
// }

Now that we have a main function, we are going to set out gPhysicsSDK. we do this with the following line:

// gPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION);

This will create the Physics SDK using the current PhysX version you have installed on your computer. In my case, version 2.7.0 as of this tutorial.

If this creates properly we are then going to need to release our Physics SDK so we can clean up and close our program, this is done with the following line:

// gPhysicsSDK->release();

So our main function will look like:

// int main(int argc, char** argv) {

// gPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION);
// gPhysicsSDK->release();
// return 1;
// }

Now just compile and run this program. If it works, we are ready to start some serious coding. If it doesn’t please email me and I will try to help you sort it out.

It may not seem like much, but once you get all this done, IMO you have just completed the hardest part in beginning with the SDK.

The next tutorial here is about creating a GLUT window to draw to for when we get to rendering our Physics

If you have any questions, just email me at swiftless@gmail.com

#include <stdio.h>

#include <GL\glut.h>
#include <GL\gl.h>

#include <Physics\include\NxPhysics.h>

#define NOMINMAX

#include <windows.h>

#pragma comment(lib,"PhysXLoader.lib")
#pragma comment(lib,"NxCharacter.lib")
#pragma comment(lib,"NxCooking.lib")
#pragma comment(lib,"NxExtensions.lib")

static NxPhysicsSDK* gPhysicsSDK = NULL;

int main(int argc, char** argv) {
gPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION);
gPhysicsSDK->release();
return 1;
}

Download:

Download main.cpp Source Code for this Tutorial

 

  • March 25, 2010
  • 7