I’ve created a small XBAP 3D physics demo for pure geeky delight. It’s got a long way to go, but it’s got a nice button that lets you drop beachballs on to each other, so I think that makes it morally OK ![]()
It’s built on a managed version of the Bullet Physics Library, tweaked slightly for WPF (so it’ll run locally as an XBAP). Give it a try and see what you think. Some general notes:
- Performance is fair; it could struggle on slow machines. There are loads of optimizations we can do with WPF 3D (merging models into one GeometryModel3D can give huge improvements) but I’ll save that for another post
- Dropping too many objects will bring any system to its knees pretty quickly. It’s not culling anything to a view frustum yet and the sphere models probably have too many vertices, so even if objects roll off screen they’ll still suck your CPU dry. Just don’t do it
- You’ll get better performance with spheres than boxes. They generally come to a rest more decisively (the physics engine marks objects as inactive when they’re at rest, at least until something hits them). Boxes can currently ‘jitter’ a while before they settle down.
I’ve published the source on CodePlex. Let me know if you’d be interested in contributing!
UPDATE: Did a couple of rendering tweaks and enabled camera movements (drag mouse to move, right-drag to zoom). Also, thanks for the great feedback!
UPDATE 2: Fixed earlier ‘rolling’ issue (my bad) and added a ‘drop box’ button. Boxes don’t behave quite as nicely as the beachballs yet (they act like jello cubes) but they’re still a lot of fun ![]()



38 comments
Comments feed for this article
April 8, 2007 at 4:03 am
NakedCleaner.com » Blog Archive » XBAP and 3D
[...] of my mates has been playing about with XBAP, Pop Along and have a play. Technorati Tags: 3D, Computing, Gaming, PC, XBAP Possibly Related : No related [...]
April 9, 2007 at 10:38 am
Josh Smith
Nice! This is very cool. In case you’re interested in some feedback from the community, here’s my 2 cents. I think it would be awesome if:
1) Larger planets had stronger gravitational attraction.
2) Planets could have one or more moon which orbits it.
3) The moons could collide with other objects in the scene and shatter. (That would be sooo cool!)
Anyways, thanks for the cool app.
Josh
February 28, 2011 at 3:26 am
Halyna Shashyna
Hi Chris !
I looked at your coll project and thought that you might be interested in looking to my project as it also 3D one
http://galka-vorona.com/bouncingballsin3d.xbap
Thank you!
February 28, 2011 at 3:28 am
Halyna Shashyna
I am sorry, I posted it in wrong place…
April 14, 2007 at 5:03 am
Ruurd Boeke
I don’t know what Josh is talking about (moons?), but this is absurdly cool.
April 14, 2007 at 11:13 am
Chris Cavanagh
Ruurd – Thanks! But sorry for the confusion. My original demo had planets rolling around (Jupiter actually; was the only bitmap I had to hand!). The problem was gas giants don’t usually bounce and roll so well, so when I updated it (for some performance improvements and fix to how the physics engine was used) I threw in some beachballs instead
I was going to leave the post unedited (with just updates at the bottom) but didn’t want it to be too confusing for newer readers. I really like Josh’s suggestion of a planetary demo though, so I might just make one
April 21, 2007 at 9:22 am
Ruurd Boeke
You’re really on to something here. There is probably going to be great demand for 2d and 3d engines for wpf.
I was looking in to some of the examples of Kevin Moore where he is doing funky 2d physics, and I definitely see opportunities for animations even in business applications.
April 21, 2007 at 11:57 am
Tonko
It would be great if Codeplex site actually contained something downloadable . Not your fault though, I know.
April 21, 2007 at 5:02 pm
Chris Cavanagh
Tonko – Yeah CodePlex has been down a while (sabout 10 days I think). I’ll probably upload the source to my server too, in case it’s lost for good ;o)
April 24, 2007 at 3:23 am
Suite et fin du WPF Challenge , alex#
[...] :Quixotry par Johnny TurpinMoteur physique WPF (2 D) vraiment impressionnant, à noter la version 3D. WPF Physics par Chris Cavanagh Un srabble-like en WPF avec du glisser-déposéRSS Reader par [...]
May 15, 2007 at 8:06 pm
theWPFblog » WPF 3D Physics Poopr Application
[...] Cavanagh has created some excellent 3D physics examples which utilizes the XNA game framework. I decided to take his code and build a truly innovative WPF [...]
May 15, 2007 at 11:25 pm
Jose
how did you created the 3d scenes? the sames objects that are used in wpf? how do you manage to create the 3d objects for the browser?
May 16, 2007 at 6:54 am
Chris Cavanagh
Jose – The objects are just regular WPF 3D meshes. I cheated a little on the spheres and used some code by Daniel Lehenbauer (there’s also some code for cones and cylinders I think). It calculated all the texture co-ordinates and vertex normals. The boxes (including the ground) are made from 24 vertices to prevent the [Gouraud] shading blending the corners away (none of the faces share vertices). Hope this helps!
May 16, 2007 at 7:39 am
Fábio Pedrosa » 3D Physics XBAP
[...] Cavanagh some weeks ago created a very nice 3D Physics XBAP (Windows WPF) example just to show the WPF/XNA [...]
May 16, 2007 at 9:35 am
Joku
Try piling up 3 boxes (possible but takes a bit of trying), the ones already on ground tend to stay wobbling really long as if the surfaces had no friction to stop the wobble sooner.
May 16, 2007 at 10:21 am
Chris Cavanagh
Joku – Yeah I’ve noticed that; it’s something I’ve been meaning to fix! I don’t think it’s a problem with the physics engine though (unless I did a sloppy port to WPF). Right now the cubes bounce like jello, which is still kinda fun
July 25, 2007 at 3:39 am
John Davis
If your’re interested, I’ve got a 3D terrain XBAP at http://www.lunchgamer.com Make sure you’re running a tier 2 graphics card, otherwise it may appear slow. Enjoy!
July 29, 2007 at 5:02 pm
Chris Cavanagh
John – I’d love to take a look at the terrain XBAP but I’m getting an error
Here are the details (edited for length):
ERROR SUMMARY
Below is a summary of the errors, details of these errors are listed later in the log.
* An exception occurred while downloading the manifest. Following failure messages were detected:
+ Downloading http://www.lunchgamer.com/ did not succeed.
+ The remote server returned an error: (500) Internal Server Error.
COMPONENT STORE TRANSACTION FAILURE SUMMARY
No transaction error was detected.
…
ERROR DETAILS
Following errors were detected during this operation.
* [7/29/2007 5:58:44 PM] System.Deployment.Application.DeploymentDownloadException (Unknown subtype)
- Downloading http://www.lunchgamer.com/ did not succeed.
- Source: System.Deployment
- Stack trace:
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)
at System.Deployment.Application.DownloadManager.DownloadManifestAsRawFile(Uri& sourceUri, String targetPath, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation)
at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestDirect(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation)
at System.Deployment.Application.DownloadManager.DownloadDeploymentManifest(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, IDownloadNotification notification, DownloadOptions options)
at System.Deployment.Application.DeploymentManager.BindCore(Boolean blocking, TempFile& tempDeploy, TempDirectory& tempAppDir, FileStream& refTransaction, String& productName)
at System.Deployment.Application.DeploymentManager.BindAsyncWorker()
— Inner Exception —
System.Net.WebException
- The remote server returned an error: (500) Internal Server Error.
- Source: System
- Stack trace:
at System.Net.HttpWebRequest.GetResponse()
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
August 3, 2007 at 1:42 am
John Davis
Try this one and let me know if it works. It’s deployed on IIS7
http://208.106.245.119/xbap/publish.htm
August 3, 2007 at 1:50 am
Chris Cavanagh
Hey John – That works great now! Very cool and runs nice & smooth
Would it be tricky to make it hit Virtual Earth or Google maps? (Virtual Earth has height data too I think; just a thought!).
August 3, 2007 at 4:58 am
John Davis
I have http://www.lunchgamer.com redirecting to the IIS7 server now as well. Strange, lots of people were accessing to old one fine. But Lutz Roeder was having the same problem as you. Hopefully this will work for everyone. If anyone has an issue please let me know.
August 3, 2007 at 5:01 am
John Davis
Tell me where to get the height map data and I’ll see what I can do. Do they have something that can be used as surface texture?
August 3, 2007 at 7:05 am
Chris Cavanagh
I’d have to dig into their API a bit. Certainly the map images themselves would be the surface texture. I’m assuming the height map data is accessible as Virtual Earth 3D uses it (but I don’t know if it’s public). They also now do “hill shading” (there’s probably a better name, but I think that’s what they called it) where it applies some shading as an overlay on 2D maps (that’s probably done on the server through).
Maybe this could help: http://blogs.msdn.com/publicsector/archive/2007/05/08/update-virtual-earth-with-silverlight-sample.aspx.
August 4, 2007 at 3:42 am
John Davis
That link doesn’t seem to work anymore.
August 4, 2007 at 5:15 pm
Chris Cavanagh
John – What error/message do you get? For some errors (related to old cached versions) clearing any cached XBAPs may help… Copy the following into a batch file and just run it if things get weird (replace with your Windows account name).:
@echo off
rundll32 %windir%\system32\dfshim.dll CleanOnlineAppCache
del /S /Q /F “C:\Documents and Settings\\Local Settings\Apps\2.0\*.*”
(I can’t remember where I dug this up from, but maybe it’ll help)
August 5, 2007 at 2:54 am
John Davis
“The page cannot be found” error is what I’m getting. I don’t think this is related to the OnlineAppCache?
August 5, 2007 at 8:28 am
Chris Cavanagh
John – Can you send me the full URL you’re trying? (just paste it in a comment). Could you let me know if you can reach the other links on my blog? (source code etc, particularly things on the chriscavanagh.com domain; also, give http://65.166.200.182/Chris/CJC.Bullet/BulletDemo1.xbap a try).
August 7, 2007 at 5:06 am
Martin Cook
sorry, i broke this one to….
PLATFORM VERSION INFO
Windows : 6.0.6000.0 (Win32NT)
Common Language Runtime : 2.0.50727.1318
System.Deployment.dll : 2.0.50727.1318 (redbitsb1.050727-1300)
mscorwks.dll : 2.0.50727.1318 (redbitsb1.050727-1300)
dfshim.dll : 2.0.50727.1318 (redbitsb1.050727-1300)
SOURCES
Deployment url : http://www.chriscavanagh.com/Chris/CJC.Bullet/BulletDemo1.xbap
ERROR SUMMARY
Below is a summary of the errors, details of these errors are listed later in the log.
* An exception occurred while downloading the manifest. Following failure messages were detected:
+ Downloading http://www.chriscavanagh.com/Chris/CJC.Bullet/BulletDemo1.xbap did not succeed.
+ The remote server returned an error: (407) Proxy Authentication Required.
COMPONENT STORE TRANSACTION FAILURE SUMMARY
No transaction error was detected.
WARNINGS
There were no warnings during this operation.
OPERATION PROGRESS STATUS
No phase information is available.
ERROR DETAILS
Following errors were detected during this operation.
* [07/08/2007 12:05:08] System.Deployment.Application.DeploymentDownloadException (Unknown subtype)
- Downloading http://www.chriscavanagh.com/Chris/CJC.Bullet/BulletDemo1.xbap did not succeed.
- Source: System.Deployment
- Stack trace:
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)
at System.Deployment.Application.DownloadManager.DownloadManifestAsRawFile(Uri& sourceUri, String targetPath, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation)
at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestDirect(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation)
at System.Deployment.Application.DownloadManager.DownloadDeploymentManifest(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, IDownloadNotification notification, DownloadOptions options)
at System.Deployment.Application.DeploymentManager.BindCore(Boolean blocking, TempFile& tempDeploy, TempDirectory& tempAppDir, FileStream& refTransaction, String& productName)
at System.Deployment.Application.DeploymentManager.BindAsyncWorker()
— Inner Exception —
System.Net.WebException
- The remote server returned an error: (407) Proxy Authentication Required.
- Source: System
- Stack trace:
at System.Net.HttpWebRequest.GetResponse()
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
COMPONENT STORE TRANSACTION DETAILS
No transaction information is available.
Martin
August 7, 2007 at 7:10 am
Chris Cavanagh
Martin – Can you browse other XBAPs (on other servers) ok?
August 10, 2007 at 8:58 pm
John Davis
That last one worked.
August 11, 2007 at 10:53 am
Chris Cavanagh
John – Interesting; maybe some kind of DNS issue. Glad it’s working
February 1, 2008 at 11:52 pm
Scott Hanselman's Computer Zen - Firefox, WPF and XBAP
[...] 3D Physics XBAP by Chris Cavanagh and Source [...]
February 19, 2008 at 4:47 am
ahndunk
Cool application, but I think you can give a lot of ball to make it more interesting.
July 7, 2008 at 7:55 pm
Ryan
Wow. Too cool. I never cease to be amazed at what’s possible with the framework. I’ve really got to stop making boring business apps and play with some of this stuff.
March 19, 2009 at 8:52 am
Flashbot » Blog Archive » Xbap, Silverlight’s Forgotten Big Brother - Developing interactive advertising, entertainment and applications
[...] haven’t heard a thing about XBAP since then. There are a few nice examples around the blogosphere (if you look hard enough), but Silverlight has since stolen the show and the [...]
August 17, 2009 at 8:17 am
Takuan Daikon
This looks very cool from the description, and is something I’ve been interested in some time. Unfortunately, like most year-old Web content, it doesn’t actually work. I get exceptions when trying to run the online demo.
I’ll have to check out the code, I guess
August 17, 2009 at 9:47 am
Chris Cavanagh
Takuan – Are you using .NET 3.5 SP1? Which browser are you using? The XBAP runs ok for me… (should be fine in FF or Safari on Windows).
February 28, 2011 at 3:30 am
Halyna Shashyna
Hi Chris !
I looked at your cool project and thought that you might be interested in looking to my project as it is also a 3D one
http://galka-vorona.com/bouncingballsin3d.xbap