 |
|
 |
|
|
Author: |
host |
Created: |
3/6/2006 9:55 PM |
 |
|
Adventures in .NET |
|
Silverlight 5: 3D Physics Demo |
|
|
By Andy Beaulieu on
4/12/2011 1:18 AM
|
|
|
|
Silverlight 5 introduces new support for hardware accelerated 3D which makes it possible to create truly unique experiences. Unfortunately, the 3D API provided is very low-level, and probably not easily picked up by the average developer.
In this blog post, I’ll show you how to leverage existing libraries and tools to (relatively) easily create a 3D Physics based game or simulation using the new 3D features of Silverlight 5.
[DOWNLOAD SOURCE] [VIEW DEMO] * REQUIRES SILVERLIGHT 5 BETA 1 *
To accomplish our 3d scene and physics, we’ll be using two open source libraries:
1. Balder 3D Engine: this engine was created by Einar Ingebrigtsen and allows Silverlight to load and display 3D models. Balder has been around for quite some time, but because of the lack of native 3D support in previous versions of Silverlight, performance was very limited. With the addition of native 3D support in Silverlight 5, much more is possible with Balder.
2. JigLibX Physics library: this 3D physics engine has had many incarnations. It started as a C++ physics library, and was later ported to C# and XNA. Since there is no official Silverlight version of JigLibX, I created a slightly modified version of JigLibX with thanks to the great start on this work item.
Creating the 3D Models
There are so many different 3D model formats out there, it can be quite overwhelming. 3D Studio (.3DS), Wavefront (.OBJ) and Lightwave (.MDD) are just a few. Balder requires a model be in an ASE format (ASCII Scene Exporter), which is a popular format for 3D game frameworks.
Many tools can convert to ASE format, including the free Blender modeling software. You can download Blender 2.5 Beta here, and there is a Python script for Blender which enables ASE exports here. Also, MilkShape exports to ASE and can import a bunch of different formats and is just $35 US.
Balder also supports texture mapping of ASE models, but just be sure the texture is in either JPG or PNG format (often, modeling software uses a BMP format which Balder cannot display). You also need to make sure the reference inside the ASE file is correct for the texture file. ASE files are just plain text, so you can open up the file in an editor and look for any BITMAP references like this:
*BITMAP "crate.jpg"
Displaying the Model
Once you have a model in ASE format, we can display this in Silverlight using Balder. The author of Balder has a great Getting Started Video which I recommend you watch if you are new to Balder. This video was created for Silverlight 4, so there are a couple of notes to keep in mind when using Silverlight 5 and the new version of Balder:
· Be sure to Enable GPU Acceleration. This is required for Silverlight 5 to display 3D scenes. Add the following to the parameters of the Silverlight plug-in object:
<param name="enableGPUAcceleration" value="true" />
· Sometimes you may see a “white screen of death” – that is, nothing is rendered to the window when using 3D. You can use the following properties to determine what’s up when that happens (but usually it is because you didn’t enable GPU acceleration as above).
Microsoft.Xna.Framework.Silverlight.GraphicsDeviceManager.Current.RenderMode Microsoft.Xna.Framework.Silverlight.GraphicsDeviceManager.Current.RenderModeReason
Adding Physics
The job of the physics engine is to determine collisions, position, rotation, and the forces upon an object. We then take that position and rotation information and update our Balder 3D objects each frame.
I chose to use JiglibX as the physics engine, but there are several others that will no doubt make their way to Silverlight 5 in the near future. To get a quick overview of how JiglibX works, I recommend using the Basic World Tutorial.
If you take a look at the sample code, you will see that I sub-classed several of the Balder Geometries into Physics based classes. These wrap together both the visual Balder model and the JiglibX physics logic:
· PhysicsBox displays a cube shape and is based on Balder.Objects.Geometries.Box. On the physics side, this uses the JigLibX.Geometry.Box class.
· PhysicsCapsule displays a capsule model, like a pill shape. There is a special model for this, Capsule.ase. On the physics side, this uses the JigLibX.Geometry.Capsule class.
· PhysicsRagDoll is the most complicated class, and creates a rag doll based on a whole bunch of other primitive objects including sphere, capsule, and box. This class was ported from the original JiglibX demo game.
· PhysicsSphere displays a sphere model, using the sphere.ASE model. Note that Balder does not have a sphere primitive at this time, so that is why we need to bring in a custom model. On the physics side, this uses the JigLibX.Geometry.Sphere class.
Each of these classes implements an IPhysicsObject interface, which provides a Draw() method. This way we have a common way of updating the visual model with the underlying physics library data.
Adding Camera Control
For controlling the camera, I converted a class provided in this XNA Tutorial. This tutorial by Pete Street walks through basic camera control, so I suggest you read through it for the details. After the Camera class does its magic, we simply need to tell the Balder Camera where to move and point towards. This is done in the UpdateViewMatrix method of the Camera class:
_gameCamera.Position = Utils.VectorXnaToBalder(position); _gameCamera.Target = Utils.VectorXnaToBalder(target);
Terrain Mapping
Terrains in a 3D physics game are often created using a Heightmap. A heightmap is just a 2D bitmap image, where brighter pixel values represent higher elevation than dimmer pixel values. This 2D image data is then handed off to a 3D engine (or physics engine), and a corresponding model is created from the map. If you want to try creating a random heightmap, you can use a tool like Paint.NET to render clouds (in Paint.NET, just create a new image and select Effects/Render/Clouds).
Both Balder and JiglibX have support for heightmaps, so we are in luck! In the sample code you can see there is a PhysicsHeightMap class to handle feeding height data to a JiglibX Heightmap Collision Skin. The Balder Heightmap object is fed the same data through its HeightInput event in the MyGame class. I had some issues instantiating a Balder heightmap from code, so I designed the PhysicsHeightMap class to instead accept an existing visual heightmap object.
Summary
Although 3D in Silverlight 5 is very low level, we don’t have to be 3D experts to implement fantastic experiences using this new API. Instead, we can leverage existing open source libraries to get a quick start on 3D applications.
These basic 3D capabilities of Silverlight 5 borrow a great deal from the XNA Game Library. One has to wonder if all of XNA will eventually be implemented in Silverlight, making it a powerful development framework for everything from 3D games to business applications!
|
 |
|
Comments (10)
|
|
|
|
|
Boss Launch 2 Released! |
|
|
By Andy Beaulieu on
2/18/2011 6:27 AM
|
|
|
|
Boss Launch 2: Zombie Attack is now available on the Windows Phone Marketplace.
It's the zombie apocalypse, and your only ammunition against the walking dead is an office chair and your fat, lazy boss. Launch your obnoxious leader at waves of oncoming flesh eaters in this fun physics game. Three episodes containing 42 total levels take you through office, city, and country environments. Launch your boss onto vehicles to crush your enemies, and use grenade power-ups for that extra touch of destruction.
Boss Launch 2 is FREE, but this may change in the future, so go out and grab your copy now!



|
 |
|
Comments (2)
|
|
|
|
My WP7 Monetization Numbers |
|
|
By Andy Beaulieu on
2/10/2011 11:31 AM
|
|
|
|
Last night at the CNY .NET Developers Group, I presented a talk titled "Windows Phone 7: Monetize your Apps" where I detailed my WP7 revenue numbers and tips on monetization. Many of my fellow WP7 developers such as Farseer Games, Occasional Gamer, and many others have shared their sales as well.
In this blog post, I'll repeat my sales and ad revenue for my apps that I have on the marketplace. You can also download the slide deck for my presentation.
TALKING RAGDOLL
"Talking Ragdoll" has been in the Top 100 paid apps for awhile, it now hovers around #82. This is a little physics toy that allows you to import your enemy's face onto a ragdoll and then throw various objects at it, dress it up, and place it in different scenes. The ragdoll will also repeat what you say in a funny voice. This app was selected for LG's hAppiness campaign, and while I'm sorry I can't share the numbers for that particular opportunity, I will share the numbers for Marketplace sales below.
|
TALKING RAGDOLL STATS 11/8/2010 thru 1/24/2011 |
|
Type |
Paid with Trial |
|
Category |
Entertainment |
|
Trial Downloads |
4274 |
|
Number Purchased |
1280 |
|
Conversion Rate |
30% |
|
Developer Take |
$896 |
PAINT TO LIFE
Paint to Life is another little physics toy that lets you draw things out with your finger which are then translated into physics objects. There are various tools for changing color and erasing, and you can tilt your phone to change gravity.
This app is ad-driven and there was something very peculiar about the ad revenue for December. It was initially reported as $305 for 25,780 impressions. But later on, I received an email saying there was a "miscalculation in the revenue share owed to you" which made my final Ad Revenue shape up like below. This is quite hard to believe and I emailed pubcenter support to verify this error, which they said was indeed correct. UPDATE 2/10/2011: I had a few folks ask about what Ad Categories I selected, and what eCPM I am getting now. My categories are Technology & Computing, Hobbies & Interest, and Education. My eCPM for Paint to Life is now around $10 - a far cry from the eCPM for December.
|
PAINT TO LIFE STATS 11/8/2010 thru 1/24/2011 |
|
Type |
Free with Ads |
|
Category |
Entertainment |
|
# Downloads |
3,733 |
|
# of Ad Impressions |
25,782 |
|
eCPM |
$115.62 |
|
Developer Take |
$2,981 |
FREE DROP
I initally created a Paid app named "DroppyPop" but it absolutely tanked horribly. I had only 12 sales over the first 2 months on the Marketplace.
Out of frustration, I changed the app to free and added in Ads. Immediately, I saw the number of downloads increase by 100 times. But after 6,318 downloads and 66,169 impressions, I had only made $12 with an eCPM of 18 cents.
What?! Was this game cursed or something? After an email exchange with PubCenter support, I found that the Ad Control I placed inside Free Drop wasn't clickable! That's right, if a user clicked the ad, then no ad details popped up! And it turns out that each click-thru on your Ad control increases the potential eCPM! This is where your revenue goes up - from clicks, NOT from impressions. This was a frustrating exercise in learning how eCPM and click-thru's are related. It would be great if PubCenter showed us the # of click-thru's on our ad units, wouldn't it?
So note that the below stats are for just the 9 days so far with the fixed ad control that is now clickable:
|
FREE DROP STATS
2/1/2011 thru 2/9/2011 |
|
Type |
Free with Ads |
|
Category |
Games |
|
# Downloads |
6,318 |
|
# of Ad Impressions |
6,353 |
|
eCPM |
$5.88 |
|
Developer Take |
$37.36 |
SUMMARY
I am quite pleased about the initial opportunities for monetization on Windows Phone 7. I've been a hobbyist game developer for quite some time, and while I won't quit my day job anytime soon, I do see a bright future ahead for creating and sharing fun little apps!
|
 |
|
Comments (6)
|
|
|
|
LG Chooses "Talking Ragdoll" for hAPPiness |
|
|
By Andy Beaulieu on
1/8/2011 7:53 PM
|
|
|
|
As a "thank you" to its Windows Phone customers, LG is giving away 10 different apps every 60 days. The aptly named "hAPPiness" campaign has its own Facebook page which showcases the selected apps.
I'm happy to announce that "Talking Ragdoll" was selected for the recent group of apps!
If you own an LG Windows Phone 7 device, you can go to the LG app store and download Talking Ragdoll for free, for the next 60 days.
See here for a full list of the other apps offered in this round, including the challenging physics game Krashlander by Jeff Weber.
In the coming weeks we should hear some more promotions centering around LG's "hAPPiness" campaign. For now, if you're an LG device owner, go out and have some fun, complements of LG!
UPDATE 1/9/2011: 1800POCKETPC has a nice video walkthrough of most of the apps featured in this promotion from LG.
|
 |
|
Comments (2)
|
|
|
|
Physics Helper 4.2 using Farseer 3.2 |
|
|
By Andy Beaulieu on
1/2/2011 8:55 PM
|
|
|
Today I updated the Physics Helper Library so that it uses the latest release (v3.2) of the Farseer Physics Engine.
Note that if you are alreay using the Physics Helper and upgrading to 4.2, you may encounter a few minor breaking changes in the Farseer Physics Engine. These are outlined on the Farseer download page under the Breaking Changes section.
Also check out all of the great New Features that the Farseer team has introduced in this version, including great performance enhancements!
If you are new to the Physics Helper, be sure to view the Intro Video and read through the Docs to get started.
|
 |
|
Comments (1)
|
|
|
|
Windows 7 Slate: The EXOPC |
|
|
By Andy Beaulieu on
12/4/2010 9:17 AM
|
|
|
|
Earlier this week I was sent a fun new toy – an EXOPC Slate running Windows 7. I was a bit skeptical about how well Windows 7 would work in a tablet form, but I was pleasantly surprised to find this is a great little device. Don’t get me wrong, there are a few quirks that come along with Win7 on a slate, but overall the experience is fun.
Unboxing the EXOPC
The EXOPC comes in simple, attractive packaging and includes a power adapter and Getting Started Manual. The device itself weighs just over 2 pounds and has an 11.6” capacitive touch display. It might be a little bulky for an e-reader, but I did find it very comfortable to handle.
The Good
The biggest benefit of a Win7 Slate – and it is a big one – is compatibility. You can run whatever Windows applications you’re familiar with, and also get the full experience of browsing the web with both Silverlight and Flash available. Heck you could even install Unity 3D or whatever else you want, it’s Windows. The EXOPC comes with 2 USB slots as well, so if you want to add a keyboard and mouse, you can dig up whatever old USB device you want and plug it in, and you can bet the drivers will be available. 2 GB of RAM and a 32 GB SSD Drive are standard to the device as well, offering ample space and good performance.
The Bad
There were two things that I was concerned about most with a Win7 based slate: Battery Life and Boot-up Time. And yes, these are legitimate concerns with the EXOPC Slate, but honestly I don’t think they are deal breakers. The manufacturer estimates a 4-hour battery life on full charge, and I think that is pretty realistic from my experiences so far. The boot-up time from sleep is 10 to 15 seconds, and the screen does go into a standby mode to save power, which it can immediately wake from on a touch. On a cold boot, of course, you should expect a much longer boot time, but I wouldn’t expect to do that too much.
There is also some wonkiness with Windows 7 in a slate form, for example the EXOPC has wired the accelerometer so that rotating the device changes the page orientation. But as you can see from the video below, the transition is not very pretty (the screen just blacks out for a few seconds).
Developing for the EXOPC
Another huge advantage of a Win7 slate over other tablet devices is the huge array of development tools. There is no compromise at all in this area because you can use Silverlight, Flash, WPF, or whatever other tool you’re used to.
The EXOPC device also ships with an “EXOPC UI Layer” which is sort of like a little App Store with applications tuned for the device. It’s a great concept and I assume there will be some manner of monetization for developers in the future. I ported one of my Silverlight physics demos to the device which took a matter of minutes. Deployment to the UI Layer consisted of creating an icon and XML description file, after which you just place the files into a special directory on the device. You can read the full documentation on the development process on this page.
Summary
Slates, Tablets, call them what you will, but this form factor is all the rage. If you want to tote along one of these trendy new devices without sacrificing the applications you’re used to, then maybe a Windows 7 based slate such as the EXOPC will work for you.
|
 |
|
Comments (2)
|
|
|
|
Important Silverlight Event!? |
|
|
By Andy Beaulieu on
11/12/2010 7:20 AM
|
|
|
|
We all know that MIX and PDC are historically premiere venues for unveiling important new Silverlight features, but it looks like Microsoft is really promoting the Silverlight Firestarter on Thursday, December 2nd 2010 - including a keynote by ScottGu and online streaming of the entire event!
[REGISTER FOR ONLINE EVENT]
So if you are interested in the Future of Silverlight, I have it under good authority that this is not to be missed!

|
 |
|
Comments (0)
|
|
|
|
Physics Helper 4 Released |
|
|
By Andy Beaulieu on
10/21/2010 1:16 PM
|
|
|
|
Today I released a new version of the Physics Helper Library, which makes it easier to create Silverlight 4 and Windows Phone 7 games using the Farseer Physics Engine.
Here are the highlights for this release:
- Now supports Version 3 of the Farseer Physics Engine
- Bullets
- Continuous Collision Detection
- Resting Bodies
- see the Farseer project page for more details on this release of the Farseer Engine!
- Installer (msi) makes setup easier
I am very excited about the great work that the Farseer team did on version 3 of their engine. They sort of went back to the drawing board and brought in enhancements from the Box2D Physics Engine, which Farseer spawned off from long ago.
In the past, it was possible to hit tunneling problems (objects colliding and sticking together) with Farseer, and lack of support for resting bodies made large worlds difficult. But with the new enhancements, these issues have been resolved!
Please note that this is an initial Alpha version of the Physics Helper 4.0, and given the big change in the Farseer Engine, you can bet that there are some bugs and things yet to be implemented. But I have been using it for my latest creations and feeling quite productive with it. Be sure to view the Intro Video and read through the Docs to get started.
|
 |
|
Comments (12)
|
|
|
|
Marketplace and the App Hub |
|
|
By Andy Beaulieu on
10/14/2010 4:53 AM
|
|
|
|
My first two apps for Windows Phone 7 are now on the Marketplace!
|
 |
Talking Ragdoll Available in "Entertainment"
App Details
Marketplace Link (requires Zune + IE)
This is a fun little physics toy that repeats what you say in a funny voice, and also acts like a little voodoo doll. You can put your friends head on the ragdoll and then have your way with them - throw beer bottles, eggs, tomatoes, etc. |
 |
DroppyPop Available in "Games"
App Details
Marketplace Link (requires Zune + IE)
This is a fun physics game where you control a ragdoll falling through a sky full of balloons. You can grab balloons above you by tapping and holding on the screen, and change gravity by tilting the device. It has some nicely rendered graphics and parallax backdrop, and local and world high scores service. |
My Experiences with the App Hub
This past Monday (Oct 11, 2010) Microsoft unveiled its new developer portal for submitting applications for Windows Phone and Xbox 360 Indie Games, http://create.msdn.com. I was lucky enough to get early access to Marketplace Submission, and wanted to share some of my experiences.
Ian Walker has posted some great tips on his blog as well, so be sure to check those out.
While the process was pretty simple and smooth, it wasn’t without issues – in fact, as I write this the portal is down entirely! But keep in mind that this is the first real world test of the App Hub and they are most likely shaking out the bugs.
Icons + Panorama Image
Be sure you have all of your icons ready as specified in the Marketplace Submission Guidelines. You'll need 99x99, 173x173, and 200x200 PNG format Icons, and they need to be the same image. Folks have had their submissions rejected because of different icon imagery. Also, avoid any transparency in your icons, because they will show up as white in the Zune client until the user hovers over them (thanks to Rene Schulte for that tip)
The Panorama Image should be 1000x800 pixels (there is still some old docs lying around that state otherwise, ignore them). The pano image is shown as your background in the Zune client when the user drills into your app using a link like this: http://social.zune.net/External/LaunchZuneProtocol.aspx?pathuri=navigate%3FphoneAppID%3D74e401d0-8ad5-df11-a844-00237de2db9e
If you are lucky enough to have a "featured app" (which I think equates to a top seller in a category), then your Pano image will also be featured as the Marketplace background for that category. Be sure that you do not include any text or title in your Pano image. The Marketplace UI does that for you.
Watch Your App Sub-category
This is something I hosed up when submitting my game. When you select the Category, it is easy to miss the Sub-Category drop-down next to it. Be sure to select this because even changing something as simple as this requires a full re-submission! 
Take Your Time and Plan
Really be sure that you take your time and get your verbiage right for your app description. Note that the app description CANNOT contain any formatting such as CR/LF or HTML breaks. This is a reall bummer and I hope they fix that soon because you can't really list out your app highlights in a bulletted list.
Same thing for your icons and images. Currently any tweaks at all to an image or text requires a full resubmital.
Turn-Around Time
Microsoft is shooting for "5 days or less" for approval of your apps. Because I participated in the early access program, my turn-around times might not be typical. But both my apps were approved in less than 2 days.
Get Ready for Feedback
This is something that many developers might not be used to: Immediate feedback on your creation! Once your app is on the marketplace, people can add reviews which I find can cause huge mood swings. For example, when I submitted my first game I saw this review come up:

Woohoo! Thank you. I did a little jig around the house. But then, some more reviews started popping up:

What is really frustrating here is that you cannot reach out to these people and help them, or ask them for more details. Why is the app taking too long to load? Do they know that the game has a "How to Play" tutorial in the Option screen? You'll never know because reviews are a one-way street.
Also note that there are very few WP7 devices out there in the world right now (I've heard just 2000 or so?), and guess who has those devices? Fellow developers --- probably your harshest critics!
Get Help
To be honest, I saw little or no help coming from Microsoft on the App Hub Forums, which was a bit frustrating. Maybe their hands are full with the App Hub early trial. But it did help to commiserate with fellow devs on the Forums who were having the same issues you were. It's great to know that you are not alone when something is awry!
Summary: Have Fun!
I have had a total blast since I first heard of Silverlight being the premier development platform for Windows Phone 7! If you've followed my blog, you know that I am a hobbyist game developer and have been creating casual games in Silverlight since the SL 1.1 Alpha (see them here). Like me, I hope you concentrate on having fun with WP7 and sharing your apps with others. And who knows, you might make a little money, 99 cents at a time!
|
 |
|
Comments (7)
|
|
|
|
|
 |
|
 |
|
|