Hello SunBurn community!
As you know the SunBurn Game Engine early adopter is going very well. SunBurn is more feature rich than ever and we’ve nearly completed the early adopter roadmap.
To top it off, this week we’ve completed two of the remaining five engine features on the roadmap - one of which I’ll cover today.
Of course if you’re following me on Twitter you’ve probably already heard (literally ;) some of the details...
Audio System
Player, environmental, ui, and other sounds (especially 3D) add an enormous amount of depth to games. Until now adding audio to SunBurn games involved different code for ambient, ui, and 3D audio sources (using the XNA api), and while relatively easy to setup it still required more work than necessary.
Now SunBurn includes an audio system that handles all of the details for you. Simply create an AudioSource object in the editor (or in code and submit it to the AudioManager), and enjoy lots of beautiful audio goodness. :)
The audio system supports:
- Point / location based 3D sounds (with control of the audible distance)
- Ambient and UI non-3D sounds
- Continuous looping sounds
- Single-shot sounds
- Playing / stopping
- Automatically handles maximum platform audio sources (on Xbox and WP7, Windows has no limit)
And all using the AudioSource class – no audio playback or device code is required.
Creating Audio Sources
Audio sources can be created in the SunBurn editor by importing a sound file into the game’s content repository, then dragging the sound into the scene.
Sources can also be created in code by passing an XNA SoundEffect into the AudioSource constructor, and submitting the source to the AudioManager:
SoundEffect sound = Content.Load<SoundEffect>(“sound_file_name”);
AudioSource source = new AudioSource(sound);
sceneInterface.AudioManager.Submit(source);
source.Play();
Drag-and-Drop Assets
In the SunBurn editor you can change the sound used by an audio source by drag-and-dropping an imported sound from the game’s content repository onto the source’s Sound Effect property (similar to changing the model assigned to a scene object).
However, what if you create a component that assigns audio to an object? Or an object that uses multiple sounds? Wouldn’t it be cool to use the same drag-and-drop control in your own objects and components?
Now you can! We’ve introduced two classes, which are used by the editor as drag-and-drop targets for content repository assets:
- SoundEffectAsset – add a property of this type to your class and the editor will automatically support drag-and-dropping sound files onto the property
- ModelAsset – add a property of this type to your class and the editor will automatically support drag-and-dropping models onto the property
The classes also provide direct access to the contained asset, without the need to load the asset manually. This provides a ton of benefits, but the most significant are:
- Add assets to classes and components without needing access to the game’s content manager
- Receive events (via the property setter) when new assets are dropped onto the property in-editor (or set on the property in-code)
- Game code also has direct access to the assets (using SoundEffectAsset.Asset and ModelAsset.Asset)
To expand on the last point: developers frequently ask how to retrieve a scene object’s source model. In the past you’d need to ask the content repository for the model - while this is relatively easy, it’s not obvious when browsing the SceneObject class.
Now, however, it is – the source model can be retrieved using the ModelAsset:
Model model = sceneObject.ModelAsset.Asset;
// do something cool with the scene object’s model...
So how do you use this feature in your own classes and components? Here’s an example:
[Serializable]
[EditorCreatedObject]
public class CustomModel : SceneEntity
{
public ModelAsset ModelAsset
{
get { return _ModelAsset; }
set
{
// This setter is called whenever the model is changed.
_ModelAsset = value;
Model model = value.Asset;
// do something cool with the model...
}
}
private ModelAsset _ModelAsset = ModelAsset.Empty;
}
More on the Way
And of course there’s still another awesome roadmap feature we haven’t covered... but I’ll save that for my next blog. :)
If you have any questions, comments, or thoughts let us know!
-John Kabus
Other SunBurn 2.0 Blogs:
- Announcing the SunBurn 2.0 Game Engine - free upgrade, new editions, and updated features
- SunBurn 2.0 Collisions, Scenegraph, and Components - new collision system, components, and more
- SunBurn 2.0 upgrade for our Torque customers - upgrade path for all of our previous TLK technology customers
- SunBurn 2.0 goes Mobile on Windows Phone 7! - full Windows Phone 7 support, light mapping, and more
- Holiday, Components, and more! - read about the new components and more
- SunBurn 2.0: components, perfabs, and more! - more details about SunBurn's new component system
- Festive SunBurn 2.0 Starter Kits, yum, yum! - first release of the new SunBurn Starter kit
- SunBurn 2.0.10 update available - streamlined user experience and integrated starter kits
- SunBurn Dev Journal: Scenegraph Optimizations - faster scenegraph and City Demo with 10,000 buildings
- SunBurn 2.0.12 Update Now Available! - edit components and custom scene object types in editor
- SunBurn Update: Windows Redistributable - ship Windows games using only the XNA Redistributable
- SunBurn Dev Journal: Workflow Enhancements - background importing, shared materials, Visual Studio templates, and more
- SunBurn 2.0.13 Update: Get it Now! - the latest goodies are now available
- SunBurn 2.0.14 Update Available! - extended materials and sprite rendering on Windows Phone 7
- SunBurn Dev Journal: Reflections and Clipping Planes - the return of the Reflection / Refraction example!

Posted
05-11-2011 9:37 PM
by
JohnK "bobthecbuilder"