Irrlicht and PhysX Demo

A forum to store posts deemed exceptionally wise and useful
night_hawk
Posts: 153
Joined: Mon Mar 03, 2008 8:42 am
Location: Suceava - Romania
Contact:

Irrlicht and PhysX Demo

Post by night_hawk »

This is a more straigth-forward tutorial-demo to show how easy it is to add PhysX to Irrlicht. It shows a nice class to use to keep Irr-nodes updated, the functions you need to initialise and destroy the PhysX scenes and 300 (THIS IS PHYSX!!!!) cubes falling from the sky. The loss of framerate is mostly because of the 300 nodes, as irrlicht seems to prefer fewer nodes with more polys than more nodes with less polys in total. As it is normal though...

Tutorial 2 also adds a trimesh to the whole scene.

You will need the PhysX drivers. A small game-installer can be downloaded here.

Tutorial 1 - Bare Basics:
The source code and binaries can be found here.

Tutorial 2 - Let's go a wee bit advanced:
The source code and binaries can be found here.

Please tell me any mistakes in my code and feel free to ask me any questions you might have about this.

To quit the application, Alt-F4 :D. Sorry for no ESC function... was too lazy.
EDIT: Fixed in tutorial 2!!!

Thanks to: jimanjr - for that nice box texture.
Last edited by night_hawk on Sat Jul 12, 2008 9:17 am, edited 4 times in total.
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

Well I'm surprised to say, but the framerate didn't seem at all low to me? And I am running on a pretty low-end system. I get 76 FPS (with everything interacting, and colliding, etc.) on a:

- 866 Mhz AMD Moblie Sempron 2600+
- 256 MB RAM
- ATI Raedon 200M Xpress

Overall, this is very straightforward, and I like it. I have one problem though, and that is the fact that you should at an 'Esc' quit button. ;) Because you locked the cursor with the FPS camera.

EDIT: I would also like to see a demo like this, with fluid particles instead falling from the skies. I have only seen the UE3, and PhysX SDK demo for fluid particles.
TheQuestion = 2B || !2B
ecsos
Posts: 30
Joined: Mon Feb 04, 2008 8:02 am

Post by ecsos »

well i compiled it myself and it works well.. but i'm a total newb at irrlicht as yet so can't comment further. thanks for the code
cooljayman
Posts: 22
Joined: Wed Mar 05, 2008 8:25 am

Post by cooljayman »

Thats awesome NightHawk!, any idea how to implement terrain collision? How would you go about adding support for other primitives eg. convex hull mesh?

Do I need the physX sdk to compile this? Have a link to it?

Cheers.
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

cooljayman wrote:Thats awesome NightHawk!, any idea how to implement terrain collision? How would you go about adding support for other primitives eg. convex hull mesh?

Do I need the physX sdk to compile this? Have a link to it?

Cheers.
If you are developing software that uses a kit provided by another developer. Then I would assume that you need the software development kit (SDK).
TheQuestion = 2B || !2B
night_hawk
Posts: 153
Joined: Mon Mar 03, 2008 8:42 am
Location: Suceava - Romania
Contact:

Post by night_hawk »

Adding support for TriMeshes or ConvexMeshes is already a bit more advanced. I have them working (see sNow or Never), but the code is a lot bigger...
night_hawk
Posts: 153
Joined: Mon Mar 03, 2008 8:42 am
Location: Suceava - Romania
Contact:

Post by night_hawk »

Sorry for the double post, but a second tutorial is up! This one boasts a TriMesh and 300 cubes falling from the sky. Details in first post.
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

First off: nice job
Second: Excellent!
Third: When's the convex mesh? :P
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

Great job on the second tutorial. I am planning on using PhysX in my next programs, and these tutorials will definitely help. Thanks man.

The demo still runs at ~77 FPS for me, which is great on this low-end system. And Alt-F4 is no problem, I just couldn't quit at all in the first demo when I ran it.
TheQuestion = 2B || !2B
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

I finally suceeded compiling the PhysX...
I tried to load my own .x level, but it said there are ";" missing in its normal declaraitons.

I want to load BSP level, but have no clue how to do it. I tried using the code from another PhysX example( actually the tutorial ) which had .BSP laoded, but without any sucess. :oops:

Can somebody write the code for loading BSPs?

I want to implement a controlled character, but again I don`t know how... :cry:
Can somebody explain shortly how can this be done?

Will for example a .BSP level of 12000 trigs using PhysX collisions run slower than running in the buid-in Irrlicht collision system or not?
night_hawk
Posts: 153
Joined: Mon Mar 03, 2008 8:42 am
Location: Suceava - Romania
Contact:

Post by night_hawk »

Well, I have limited to no experience in using BSPs, but I suppose it shouldn't be much of a difference in using them with PhysX.

As for a 12k poly mesh, PhysX will run faster than Irr's default collission ANY time. Take sNow or Never. The terrain there is pretty high-poly and NOT optimized in any way. Yet, constant framerates (and decent) can be gotten even on low end systems.
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

As for a 12k poly mesh, PhysX will run faster than Irr's default collission ANY time. Take sNow or Never. The terrain there is pretty high-poly and NOT optimized in any way. Yet, constant framerates (and decent) can be gotten even on low end systems.
This is a really good news :P

But this ain`t helping me much in moving the character and loading BSP. There is a really nice example in the PhysX samples for character control, but when using Irrlicht things are pretty different and turn into a herculean task for my about-ten-days Irr experience... :?

If I decide to use .X level for now, for testing purposes why I`m not able to load my level? And will there be any difference in performance in 12k BSP and 12k .X?
night_hawk
Posts: 153
Joined: Mon Mar 03, 2008 8:42 am
Location: Suceava - Romania
Contact:

Post by night_hawk »

Well, I haven't gotten the PhysX Character controller to work either. I got bored and made my own. Piece of cake :D Much more control and overall better I say. You should try that too!

As for a 12k BSP and 12k .x, PhysX related, there shouldn't be any difference at all. Irr related, .x loads faster and is imo, better technically-wise. But that's just me.
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Night_hawk....props to you man. You pretty much gave us the elementary functions and made a great tutorial. Thanks a bunch :)
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

I made some tests, trying to compare PhysX and Newton. I used as a level the chiropteraDM and a starting amount of 40 boxes. In the beginning both the engines were on about 75 frames (vsync=off). After this PhysX continued to maintain about 75 frames, adding more boxes gave only a small desrease, but never rised until the end. Newton started more firmly on 75 too. Than seemingly after the Sleeptimer activation rised to 130. Throwing another boxes on the others resulted in desrease to 65. If I add more and more boxes without placing too much in one place keeps the frame rate over 100, no matter the count.

How do you think? Which one is better? PhysX has more functions, but Newton is a good alternative to have...
Well, I haven't gotten the PhysX Character controller to work either. I got bored and made my own. Piece of cake Very Happy Much more control and overall better I say. You should try that too!
Yeah, I tried... lost 4 hours in endless efforts without any results... :(

I even don`t know how to call the identifier of my chracter to set forces. Any chance of posting some code?
:roll:

Same does for a Newton character movement. How can I call the physics identifier to set forces? Plese post some code if possible, because I`m starting to give up... I just need to use the basic collisions to avoid the build in Irrlicht one, but there`s no fun if the chracter is standing still and watching dumb from the one side, while I`m looking dumb on the other side of the world... Goofy...

HEEELP PLEEEASE.... :cry:
Post Reply