Saturday, 20 February 2010

Engine Update: Multi-threading & BEPU

Integrated BEPU's method for easy physics Multi-Threading. The Physics class has the following code for Multi-Threading the physics.

if (Environment.ProcessorCount > 1)

{

for (int i = 0; i < Environment.ProcessorCount; i++)

{

Space.threadManager.add();

}

Space.useMultithreadedUpdate = true;

}



What this does is run through all the processors available on your machine and add it to the thread-manager to spread load across all available CPUs. Thanks to BEPU the integration is VERY easy. A pdf + sample is available on their site.

Multi-threading on the Xbox is slightly different, however it shouldn't be a problem considering the available documentation and sample by BEPU.

I still had some time left to test the performance gains using a small demo scene I made yesterday. It's basically a dominos scene with 350+ domino bricks in 3 lines getting knocked over by three boxes slinging through the air. With the debugger still attached the performance drops to 2 FPS at its lowest. Activating Multi-threading on two cores (my laptop has a Core2Duo (T9400) CPU, without Hyper-Threading) the lowest FPS recorded is 31. That is an amazing difference in performance. Another test without the debugger attached didn't get the demo-scene below 60.

Another thing I worked on today are trigger-volumes. These can be used for a number of tasks (audio triggers, portals, level events etc.) BEPU has a very nice EventManager attached to every Entity. With this manager you can easily add events to your game objects. There is not much to see so far, but I hope to have some cool demo scene ready very soon...I'd like to get rid of the boring cubes and show some actual cool stuff :)

Entity.eventManager.addEventHook(new EventHandlerInitialCollisionDetected(initialCollision));

This will fire the attached method only once when the Entity is colliding with another Entity...The fired method could be something like this:

public void initialCollision(Entity sender, Entity other, CollisionPair pair)

{

other.moveTo(new Vector3(0, 10, 0));

}

This will move the colliding Entity to the Vector3 position...More on this in a later video ;)

Image of the current demo scene:

Monday, 15 February 2010

Level & Content management [Part 2]

Another succesful coding day... :)

Loading object data (position, rotation, scale) with XML is now (finally) complete...

What does this mean?

Every level has his own .xml file containing position, rotation and scale data for each object of that particular level. When loading a level, the appropriate xml file is loaded, assigning any stored data to the correct objects in the current level regardless of the Vector positions inside your C# code. This allows for persistence when building your levels. You no longer have to tweak Vector positions inside your code files, you can easily re-position your game objects while playing...Saving and later reloading when you're ready to play.

Video

Watch video in Fullscreen! Or check out Youtube.

Sunday, 14 February 2010

Level & Content management

I've been prototyping several design concepts on how to manage my content and level data efficiently and easy. After a good day's work this is where I'm at:

- LevelCollection class manages a single LevelData class.
- LevelData class can hold all the game objects in the current scene.
- LevelCollection has control over Loading/Unloading (a particular scene) and XML LoadFromFile/SaveToFile methods (managing positions, rotations and scaling)

All the content is now being managed using Dictionaries. This provides great control over used and unused assets. In the current implementation a method is fired containing all the data of a particular scene. The current assets are compared with the assets required for the next scene. Unused data is unloaded. The remaining asset data is assigned to the proper game object.

That may sound either very straightforward or maybe you've completely lost it by now... Here's a quick summary:

LevelCollection.Load(*levelnametoload*) will know which scene you want to load, and will clear all current data present in the scene and loads all the new scene data as well as comparing current with new assets (models, textures etc.) to check if any new assets need to be loaded and if unused assets need to be unloaded to free memory.

When you're scene is loaded and visible on screen, you can either play it or start messing around with the positions. Changing a Position or Rotation will require LevelCollection.SaveToFile(*filename*) to persist after quiting the game.

I'd like to show a video about this very soon...So stay tuned!

Update: Video available HERE

Saturday, 6 February 2010

sgMotion v1.0.0 Released!

sgMotion is an animation library (based on XNAnimation by Bruno Evangelista) and provides full integration with both the Sunburn Engine and the Sunburn Framework. The project is available for download on Codeplex:

http://sgmotion.codeplex.com/

The library source + Sunburn sample code is provided to get you started! Current release supports Sunburn 1.3.x for both PC & Xbox. For the older 1.2.x release click here.


Note: The previous releases will be maintained for some time using my Dropbox public space. For new releases check out the Codeplex page above.

XNA Gizmo Released!

Finally got the time to create a sample with simplified classes of the current Gizmo used in Core Engine. It was quite a bit more than anticipated, with all engine utilities and tools used by the Gizmo and EditorComponent (the two main-classes for object movement) some parts had to be rewritten or completely removed.

The project has been published on CodePlex:
http://xnagizmo.codeplex.com/

The project status is set to Beta. Everything should work out of the box. If you run into any issues using the code/sample, leave your comment here or use the Discussions tab on the CodePlex project page.

I hope you enjoy!

Monday, 1 February 2010

XNAnimation Library for Sunburn 1.3.1

OK, so I finished it a lot sooner then expected. The sample and library is now running on the latest (1.3.1) Sunburn release. If you have any trouble running the sample or DLLs, don't hesitate to ask...

XNAnimation Sunburn 1.3.1 Source & Sample

XNAnimation Sunburn 1.3.1 DLLs

Update: For new releases check out my post about sgMotion Release.

XNAnimation Library for Sunburn 1.2.6

Hi, today I decided to update a library I had modified some time ago to use with Sunburn 1.2.6. Only slight modifications were needed to get XNAnimation running alongside Sunburn (Thanks to John Kabus at Synapse Gaming) Updated the original sample as well, making it a bit easier to browse through, while demonstrating how to render a skinned model with Sunburn.

I provided two links at the bottom of this post, one with the source code and sample project, and another with only the required .DLL files to get started with your own animations. If you have any questions regarding the integration of the XNAnimation library, please leave your comment below.

XNAnimation for Sunburn 1.2.6 Source & Sample

XNAnimation for Sunburn 1.2.6 DLLs only

Note: XNAnimation .DLL's for the newly released Sunburn 1.3.1 should soon be available...