EDIT: If anyone comes to this thread through the link in my sig, know that pdEngine is now on SourceForge: http://sourceforge.net/projects/pdengine/ and you can follow it's development in my blog: http://whileboredblog.blogspot.com/
For the six months or so I have been working on this little project. It has now got to s stage where it is stable enough for others to make use of it, so I am posting it here. By no means is it finished, but it's usable.
What is pdEngine?
pdEngine is a wrapper combining DirectX and NVidia's physX into one easy to use system for C++. In ways it can be seen as similar to DarkGDK, but it is completely object oriented and has native physics.
It started as a way for me to learn DirectX. I got bits of code off tutorial websites and fitted them together. I integrated physX, and several months on I have a working game engine with several nice features. Credits go to: chillypacman from the NVidia Developer forums, directxtutorial.com and all the guys who write bits for gamedev.net. Most of the code I copied has now been rewritten because I understand it fully.
Features
Rigid body physics.
Forces
Per pixel phong rendering with normal and specualr texture support.
Z-Fail Stencil Shadows/Shadow Volumes for sharp edged shadows.
Console with printf, cin and cout support
Custom .x mesh loading for terrains
Multiple windows from same WinMain program
2D sprites for HUDs etc
Onscreen text
Particles with physics
3D audio
Planned Features
Advanced object manipulation functions (currently physX functions have to be used directly)
Raycasting for bullets etc.
Cloth with physics
Limbs and skeletal animation
Character and vehicle controllers
And when I get really bored during the summer holidays, I plan to get working Realtime Radiosity and Soft Shadows using Imperfect Shadow Maps - paper:
http://www.uni-koblenz.de/~ritschel/dokumente/ISM.pdf
What does the code look like?
Here's a very simple program, using the release downlaodable below. The next version will be slightly different, using descriptors to intialise objects.
#define PD_ENGINE_DIR H:Documents and SettingsJezza.JEREMYMyDocumentsProgrammingCpdEngine
#include <pdengine.h>
PD_SYSTEM mySystem;
PD_OBJECT Objects[1000];
PD_LIGHT light[1];
int objs = 1;
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
mySystem.Init(NULL, hInstance, nCmdShow, true, false, 800, 600, 200, 200, "pdEngine Example
Program", true, true);
//point camera at ground
mySystem.Camera->pitchUp(90);
//create a single light
light[0] = pdMakePointLight(&mySystem, PD_VECTOR(5,10,5));
//create ground
Objects[0] = pdMakeCuboid(&mySystem, PD_VECTOR(0.0f,-10.0f,0.0f),
0,1,100,1,100,true,10.0f,0.5f,0.5f,false);
int time = 0;
while(true){
//set background colour and prepare frame
mySystem.SetupFrame(PD_COLOUR(0.5f,0.5f,1.0f,1.0f));
//point camera with mouse
mySystem.Camera->pitchUp((float)mySystem.Input->MouseMoveY());
mySystem.Camera->yawRight((float)mySystem.Input->MouseMoveX());
//move camera with arrow keys
if(mySystem.Input->KeyDown(DIK_UP))
mySystem.Camera->moveForward(1.0f);
if(mySystem.Input->KeyDown(DIK_DOWN))
mySystem.Camera->moveForward(-1.0f);
if(mySystem.Input->KeyDown(DIK_RIGHT))
mySystem.Camera->moveRight(1.0f);
if(mySystem.Input->KeyDown(DIK_LEFT))
mySystem.Camera->moveRight(-1.0f);
//drop box from camera on pressing space
if(mySystem.Input->KeyDown(DIK_SPACE)){
if(time> 100){//cant have too many boxes
time=0;
Objects[objs] = pdMakeCuboid(&mySystem, mySystem.Camera->Position);
objs++;
}
}
time++;
//update internal physics of all objects
for(int i = 0; i<objs; i++){
Objects[i].physUpdate();
}
//render all objects from light, using shadows
mySystem.Renderer->Render(Objects, objs, light, 1, NULL, NULL, true);
//display some text
pdText(&mySystem, "Use mouse and arrow keys to move", 0,0,PD_COLOUR(0.0f,0.0f,0.0f,1.0f));
pdText(&mySystem, "Press Space to drop a box", 0,10,PD_COLOUR(0.0f,0.0f,0.0f,1.0f));
char *text = new char[100];
pdText(&mySystem, pdIntToString(objs, text), 0,20,PD_COLOUR(0.0f,0.0f,0.0f,1.0f));
//display frame
//this returns false if window was closed
if(!mySystem.FinishFrame())
break;
}
//clean up
for(int i = 0; i<objs; i++){
Objects[i].Release();
}
mySystem.Release();
return 0;
}
What does it cost?
Nothing! But for now, no commerical uses whatsoever and I keep the source for myself.
pdEngine by Jeremy Parker is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 2.0 UK: England & Wales License.
What do I need
It was written using Visual C++ Express 2008 and DirectX SDK November 2008. You will need the physX SDK installed, version 2.8.1. I'm not sure what else will work, but I'm keen to find out.
You will need a Shader Model 3 Graphics card to use the shaders.
Screenies?
Here is a shot of my game BlockTower 3D. Bear in mind I am not an artist. Notice the specular highlights and normal map on the crate.
Where's the documentation?
For next release, I will write a good one, but for now you'll have to read the examples and the header files and experiment. I'll be happy to give support.
Where do I download it?
All the files below are zipped. They are built on pdEngine 0.3. To run the .exe files either move them to the project directory or edit the included shortcut so the startup directory is the project directory.
BlockTower 3D: contains media, .exe and source.
http://www.mediafire.com/download.php?jvhmvmnnzwv 8.96MB
Basic Program: The code above made into a solution, with a compiled .exe
http://www.mediafire.com/download.php?20iktyu0mnt 4.63MB
pdEngine: The library itself. Contains .lib, .h and default media files.
http://www.mediafire.com/download.php?y2w1mztjw4i 3.46MB
How do I set it up?
Extract the pdEngine.zip to a suitable location, such as Program Files. Open up visual studio, and go to tools>options>Projects and solutions>VC++ Directories.
From here choose "Library files" in the top right drop down, and add to this list the location where you extracted pdEngine + lib
Take the same steps for "Include files" but use include instead.
When creating a new project, you must put into your active directory nxcooking.dll and all of the media directory that come with either BlockTower or the example program.
To run a successful debug build, #define PD_USE_DEBUG must be decalred before including pdengine.h.
It is also likely that in the project settings you need to add /NODEFAULTLIB:libcmt.lib at the linker command line, otherwise clashes may occur.
SECONDS RELEASE - [href=http://www.mediafire.com/file/fmingolkfah/pdEngine.7z
]http://www.mediafire.com/file/fmingolkfah/pdEngine.7z[/href]
You can now safely ignore most of the above, just follow the readme.txt it come with.
EDIT: this post has been changed to rectify my stupid mistakes so that these should actually run on other computers.
Feel free to email me at the link below.