SpriteHand
Module Border
  Most recent blog entries
Module Border
"Physamajig" for Windows 8
Andy's Blog By Andy Beaulieu on 1/6/2012 1:24 PM


UPDATE 1/16/11: Physamajig has been selected as a finalist in the Windows 8 First Apps Contest!

I am not one to shy away from programming contests. So with the announcement of the Windows 8 First Apps Contest, I wanted to try and do something fun and at the same time refine my Physics Helper XAML project.

What I came up with is "Physamajig" - a Metro style app that allows you to interactively create physics simulations in Windows 8!

Physamajig is similar to a WP7 app I created called "Paint to Life" - but it takes things much further by including many new tools, joints, physics properties, file options, and more! And I have to say that the Windows 8 Metro version of this app looks much more slick than the WP7 version.

The app comes with several sample creations pre-installed, and one of the next features I am working on is a web service so that users can share their creations online.

There are definitely some gotchas with working with the Developer Preview bits for Windows 8, but for such an early release it is quite productive really. I found the Community Forums quite helpful when I hit issues, if nothing else to know that I was not alone :) 

If you're building any apps for the Windows 8 Contest, I'd be happy to know more about them - please share!

 

Comments (27)

Physics Games: Multi-targeting Windows 8 + Windows Phone 7
Andy's Blog By Andy Beaulieu on 11/3/2011 8:19 AM


DISCLAIMER: THIS BLOG POST DISCUSSES DEVELOPMENT UNDER A PRE-BETA VERSION OF WINDOWS 8! THINGS CAN AND WILL CHANGE IN THE FUTURE.

With the release of Windows 8 Developer Preview, one seemingly simple goal I had was to port my 2D physics apps that run on Windows Phone 7 and Silverlight to Windows 8. Since many of my games use vector graphics, they could scale up or down cleanly depending on the device they were deployed to.

Today I am a bit closer to my goal with an updated version of the Physics Helper XAML project - which now supports both Windows 8 Metro and Windows Phone 7 development, using a single set of XAML design files and logic.

[HOME]    [DOWNLOAD]    [DOCUMENTATION]

Multi-targeting WP7 + Windows 8 Metro

You would think this would be a simple thing to do, right? I mean these platforms are both properties of a single company, and you use Visual Studio to create apps for both of them. And when WP7 was released, it was a cinch to port Silverlight Web applications to the phone - in some cases you didn't even need to recompile your assemblies!

Well, with Windows 8 Metro, it's unfortunately not so simple. Microsoft is a huge company and it is apparently impossible for all divisions to agree on a single development framework that allows creation of client solutions across all of their properties. So we have fragmentation and breaking changes with Windows 8 Metro. Lots of them.

But with a little work, it is certainly possible to support both Windows 8 and Windows Phone 7 apps with a single set of design files and code. Here is a list of some of the issues I ran into while trying to multi-target these two platforms with a single code base:

  • xmlns changes
    To reference an external library in XAML, we need to use the xmlns attribute. WP7 and Win8/Metro handle this differently right now (hopefully this is remedied in the future!)

    WP7 and Silverlight look like this:
    xmlns:xx="clr-namespace:xx"

    While Win8/Metro looks like this:
    xmlns:xx="using:xx"

    This was a problem in my apps because I wanted to maintain one set of resources for both platforms. My solution was to create a utility named CleanUsingXmlns which can be added to the prebuild step of your projects to change. Note that CleanUsingXmlns was thrown together very quickly and is not the most elegant solution, but it gets the job done.

    To use CleanUsingXmlns, go to the Build Events tab and add a call to the utility in the format:

CleanUsingXmlns [addusing|removeusing] [folder] [namespace1,namespace2]

... where [addusing] will add in the using clause for Metro, and [removeusing] will add in the clr-namespace syntax for WP7 and Silverlight. [folder] is the directory containing XAML files you wish to add and [namespaceX] is a list of namespaces you wish to be involved in the replacement.

As an example, the Metro demo projects contain the following in their prebuild steps to add the "using" clause into XAML files:

$(ProjectDir)..\..\CleanUsingXmlns\bin\Debug\CleanUsingXmlns addusing $(ProjectDir) Demo.Advanced,Spritehand


  • Namespace Changes
    Somtimes you wonder if the architects over at Microsoft are just trying to push your buttons, you know what I mean? Take for example the shuffling of all of the Silverlight namespaces we know and love. This forces us to write code like the following when we try to multi-target:

#if METRO
    using System.Threading.Tasks;
    using Windows.Foundation;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Input;
    using Windows.UI.Xaml.Media;
    using Windows.UI.Xaml.Media.Animation;
    using Windows.UI.Xaml.Shapes;
#else
    
   
using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Media.Imaging;
#endif

... but with Win8/Metro, this is just the beginning. There are lots of little breaking changes all over the place which mostly seem to be there to bang your head on the keyboard and force you to litter compiler directives all over your code.

Which brings me to my final note:

  • HINT: Target Lowest Profile!
    If you find yourself like me, trying to create a project that targets both Win8/Metro and Windows Phone/Silverlight, one important strategy is to target the lowest common profile. In this case, that lowest profile is Metro. By doing this, you have a much lower chance of introducing unsupported API's into your code.

    This table, from the BUILD conference, gives a good overview of the size of three .NET profiles:


Conclusion

While it isn't as easy as you might expect, it is certainly possible to create apps with a single set of design and code files that multi-target WP7 and Win8/Metro. Remember that this is a pre-beta release of Windows 8, and perhaps this story will improve in the beta.

If you're interested in creating your own 2D physics apps for WP7 and Win8/Metro, check out the Physics Helper XAML project on codeplex.

Comments (4)

Physics Helper XAML for Metro WinRT
Andy's Blog By Andy Beaulieu on 9/24/2011 8:40 AM

Today I released an initial Alpha version of Physics Helper XAML - which allows you to easily create 2D physics based games and simulations for Windows 8 Metro Apps using C# or VB. It is a port of my previous Physics Helper project and uses the Farseer Physics Engine

[HOME]    [DOWNLOAD]    [DOCUMENTATION] 

As you'll see, Physics Helper XAML is a rewrite of the Physics Helper project for the following reasons:

  • When I initially started porting the Physics Helper to Metro, I assumed I would be able to fix any compatibility issues by using compiler directives as I have done in the past with WPF, Silverlight, and WP7. But as I quickly found out, there are so many little differences that the code quickly became cluttered. Additionally, there are changes on the XAML side which are not easily danced around because there are no compiler directives for XAML at this time.
  • Behaviors were used extensively in the original Physics Helper, but are not yet available for Metro app development. In fact, there is no version of Blend available yet for Metro apps - so who knows for sure if Behaviors will make the cut for Blend 5?
  • This gave me a great opportunity to clean up and simplify the code! The Physics Helper has been around since Silverlight 2 and has gathered some baggage through the addition of Behaviors, changes to Silverlight, and the addition of other platforms. So this was a great chance to... er.. "re-imagine" the code.

Getting Started

I encourage you to read the Documentation for details on using the new Physics Helper XAML classes. I think you'll find them very simple to use and quite performant.

What's Next

My personal goals are to port some of my Windows Phone 7 Silverlight Games to Metro using this new version of the Physics Helper. A secondary goal I have is to back port Physics Helper XAML to Windows Phone 7 and Silverlight, with the hopes of having a single code base again to support these other platforms. Again, because of all of the changes in Metro and WinRT, I am not positive this will have a great outcome - but it is definitely a goal I will strive for!

In the meantime, I hope you have some fun with this new set of controls!!

Comments (5)

Windows 8 Remote Debugging + Setup
Andy's Blog By Andy Beaulieu on 9/15/2011 6:34 AM

At the Build Conference this week, Microsoft handed out 5000 pre-configured Samsung tablets which included Windows 8 Developer Preview plus the development tools for building Metro style apps. They also made available an ISO containing the same bits.

I suppose in a pinch you could develop apps on an underpowered tablet, but does anyone really want to write code on a tiny screen with an underpowered CPU?

No worries though. We can still use a more powerful dev machine to run Visual Studio 11 and then use Remote Debugging to deploy and debug on the tablet. Here is a pic of my current environment I set up -

To the left is an ExoPC slate running Windows 8, sitting on some handy tablet stands, with bluetooth keyboard and mouse. On the right is one of my dev machines which has been booted to a VHD image of Windows 8.

We can use Remote Debugging inside VS11 by select Project Properties and entering the name of the slate machine on the network:

Here are some helpful hints to get an environment like this set up:

  1. If you were not lucky enough to go to Build and get one of the Samsung tablets, think about buying a Windows 7 slate. This blog post lists a bunch that have been tested in Microsoft's labs with Windows 8. I would look for something with a min display res of 1366x768, 2GB ram and at least a 32GB SSD.

  2. To install Windows 8 on your slate, you can create a bootable USB flash drive and copy the Windows 8 Dev Preview to it. I outlined the steps for the ExoPC slate here, but other slates will be similar and you can search around for blog posts where people have set up their slate for Windows 8.

  3. To install Windows 8 on my development machine, I created a bootable VHD by following this great guide here by Mister Goodcat. As far as I know, this is the only way to get the intial release of Visual Studio 11 and Blend 5 for Metro app development.

  4. On the Windows 8 slate, there is an included Remote Debugging Monitor - you'll find this under the Metro UI icons next to VS and Blend. Fire that up, because it will tell you if remote debugging is working.

  5. Make sure you can Ping your slate on the network from your dev machine. Then on the dev machine, set up the project properties for debugging by entering the slate's network name (see screenshot above).

  6. That's it - you should now have a bit more powerful dev environment for playing with the Windows 8 dev tools.

 

Comments (3)

Installing Windows 8 on the ExoPC Slate
Andy's Blog By Andy Beaulieu on 9/14/2011 6:53 AM

Late last year I was given an ExoPC Slate as a development device in order to port some of my Silverlight physics games. I did a little unboxing and hands-on with the device back then, and it was quite easy to port my Silverlight games to their app store. Note that the ExoPC has an Intel Atom 1.66 GHz processor, which makes it a bit short on battery life (less than 4 hours). However, it does support 64-bit Windows and has the minimum 1366x768 resolution to support the new "snap" feature.

So given yesterday's release of the Windows 8 Developer Preview, I wanted to see how the new multi-touch based version of Windows would work on the ExoPC.

Steps to Install

These steps are for installing Windows 8 on the ExoPC slate, but you could likely use these steps for other Windows 7 slates as well.

  1. Download the Windows 8 Developer Preview with Developer Tools for 64-bit (x64). The ExoPC has at least a 32 GB SSD drive, so you can go for the larger ISO (4.8 GB). You'll have about 14 GB of disk space left after the install.
  2. Find an 8 GB or bigger USB Flash Drive. A 4 GB won't be big enough if you are choosing to install the larger ISO with the developer tools.
  3. Following  the basic steps outlined here, make the USB Drive bootable and copy the contents of the Windows 8 ISO to the USB drive. When you get to Step 7 (using BOOTSECT), you will need to run BOOTSECT from a 64-bit install of Windows 7, since we downloaded the 64-bit version of Windows 8.
  4. Now that you have a bootable USB drive with Windows 8, we can go to the ExoPC slate and plug it in. Reboot the slate and enter the BIOS by tapping on the "Setup" button on the boot screen:


  5. Inside the BIOS, we need to set the boot device to the USB key. Go to the "Save and Exit" menu and select the USB key under Boot Override. Then Save and Exit.


  6. That's it! You should now see the Windows 8 Setup screen, and you can progress through as usual to setup Windows.


Impressions

Windows 8 touch performance on the ExoPC feels great compared to how it was under Windows 7. The on-screen keyboard and web browsing are fantastic when compared to the old Windows 7 install on the salte. The start-up time from cold boot is about 15 seconds (much better than it was under Windows 7). My next task is to port some of my Silverlight apps to this new platform, so I'll post some of my experiences on that in the future.

Comments (20)

My List of Build Windows Sessions
Andy's Blog By Andy Beaulieu on 9/13/2011 1:57 PM


Wow, tremendous excitement in the Microsoft dev universe today with the Build conference kicking off! For those who missed the details, we will be able to download the Developer Preview bits for Windows 8 after 11:00pm EST tonight (9/13).

Additionally, all of the tech sessions at build are being recorded and will be available on Channel9 within 24 hours after recording.

I browsed through the list of great content being provided and put together my own video queue of training - posted below. My day job is Silverlight development and training, so I think the XAML/C# sessions will be a great fit. And I need to do my share of HTML/js development as well, so I am curious how good the design/develop/debug story is for HTMl5/js. But I also moonlight as a WP7 app developer, so the Gaming/Graphics sessions will be great.

XAML/C#

You’ve built your first basic Metro style app in XAML and now you’re ready to dive into the specifics of deeply integrating it with Windows. Come discover how you can deliver a first-class experience using new Windows 8 concepts. You’ll learn about the new activation model, how to incorporate…

Get the knowledge and guidance needed to build an app for an intuitive, powerful touch experience. Understand how touch design principles are firmly grounded in customer needs of comfort and utility. Discover how your app can use Windows 8 touch language and patterns, capabilities like smart…

C#, Visual Basic and the .NET tools have first-class support for the Windows Runtime. Learn about this integration and how to use C# and Visual Basic to write Metro style apps that call the Windows Runtime and how to build libraries that integrate with your Metro style apps using HTML.

Windows runs on a broad array of devices and form factors. Get your app on all the devices your customers use by building a great user experience that adapts to different screen sizes, aspect ratios and pixel densities using XAML. Learn how your app can take advantage of new multi-tasking views and…

A great Windows 8 app starts with a great user experience. Come to this session to see how Visual Studio 11 Express enables you to take full advantage of the rich platform features, efficient workflow and tools that maximize your productivity and creativity when designing Metro style apps using XAML.

This talk will cover how to bring existing C# or Visual Basic code into your Windows Metro style apps, enabling you to speed development through reuse. We will walk through the process of porting an app from Windows Phone to Metro style. You will see common issues that you may run into when bringing…

Does building a new Metro style app for Windows 8 mean you have to start from scratch? Absolutely not! Come learn how you can leverage existing code when developing Metro style apps for Windows 8. In this session, you will get an opportunity to learn directly from developers who have already…

 

HTML5/JS

Get started writing Metro style apps using your HTML5, JavaScript, and CSS skills today! Come dive into the specifics of this exciting platform and see how you can use your Web skills to build deeply-integrated Windows apps. You’ll discover how this mirrors or differs from traditional Web…

Get your app on all the devices your customers use by building a great user experience that adapts to different screen sizes, aspect ratios and pixel densities using HTML5, JavaScript and CSS. Through this session, learn how your app can take advantage of new multi-tasking views and orientations and…

Metro style apps using JavaScript allow developers to combine the powerful and vibrant Web platform with the rich capabilities of Windows, to build exciting apps for Windows 8. JavaScript developers building Metro style apps have access to not just all of the Web platform, but also hundreds of…

Data-centric apps with rich user experience often require significant plumbing across multiple tiers. We simplify n-tier apps by bridging Web client technologies with services – using WCF RIA Services, rich JavaScript client cache, OData, jQuery and effective data binding to UI elements. We will…

Combine your own app’s style with the familiar Windows personality. Use Blend and the power of CSS to customize the look and feel of your app, style the individual HTML and WinJS controls, and the elements within them. Infuse your app with your distinct character while keeping Windows' great touch…

Animations are fundamental in making Metro style apps lively and beautiful. Discover the animation library in Windows 8 and see how to bring these great animations to your apps with standard CSS 3.0 transitions and animations. In this session, you will learn how using standard templates and controls…

Learn how to use Expression Blend to visually construct, style and layout Metro style apps using HTML for Windows 8. In this session, we will demonstrate how Expression Blend makes it possible to create a better user experience with greater productivity. We’ll start with semantic markup and…

Create and build accessible Metro style apps to reach more customers. Accessibility support is built into each stage of creating an app and includes accessible templates, samples, controls and accessibility testing tools. Come learn how to make your apps accessible in screen reading, keyboard…

Come to this session to learn more about JavaScript, the language of Metro style apps using HTML, which provides the features you need to build real-world, full-featured Windows 8 apps. In this talk, you'll learn how to organize your code using the same coding standards we used to build Windows…

Gaming and Graphics

  • Introduction to DirectX for Metro style apps

    Learn how you can harness the power of DirectX for your app! As the foundation for all graphics on Windows 8, DirectX enables you to create the most compelling apps for connecting to people, visualizing information, storytelling, entertainment and creativity. Attend this session for a comprehensive…

Games are undoubtedly one of the most popular style of apps with users today and one of the largest money makers as well! If you have ever thought of writing a game, this session is for you! Windows 8 offers an end-to-end platform for developing games. Come to this session to learn how Windows 8…

Visual Studio 11 brings the most significant set of improvements for developing graphics-intensive apps in over a decade. Whether you are just getting started with 2D/3D games or a self-proclaimed "guru," there's something for you in this talk. We will walkthrough a slew of new tools integrated into…

3D graphics enable you to create the most immersive and impressive games around. But developers often think that creating 3D graphics is hard. In Windows 8, creating 3D graphics is easier than you think! You can write a Metro style game that uses the Direct3D API for high-performance 3D experiences.…

Make it fast! Great performance is a huge motivator of satisfaction and user preference with apps. Direct 2D powers high-performance 2D graphics rendering in Windows 8. In this session, you will learn advanced techniques for optimizing your Direct2D code for maximum speed and efficiency in your apps.

Every day, people are using apps that process images to create a variety of effects. The new image processing infrastructure in Windows 8 enables apps to perform high-performance image enhancements, transformation and composition using the GPU for photos, vector graphics and UI elements. In this…

Building a great social gaming experience for your users can be a challenging task. Your game has to be well designed, have a great user interface and perform under the most demanding conditions. This session will show how Windows 8 empowers you to build great user experiences with languages and…

Xbox LIVE, Microsoft's premier entertainment service, is coming to Windows 8. Whether you are developing a game or another kind of entertainment app for Windows 8, Xbox LIVE can help your app stand out in the crowd and help engage and delight users. You will learn about how to implement our…

Compelling audio and video are no longer optional enhancements in games; they are a requirement! Windows provides a spectrum of technologies you can use to create exhilarating experiences for your players. This session will profile the audio and video technologies available in Windows for Metro…

Windows offers a wide variety of input mechanisms for players to control your Metro style game, from touch, to gamepads, to classics like the keyboard and mouse, or even device sensors such as an accelerometer. At first glance, it may seem challenging to handle it all, but the input and sensor APIs…

Other

Microsoft Visual Studio 11 enable developers to take full advantage of the capability of Windows using the skills and technologies developers already know and love to deliver exceptional and compelling apps. Whether working individually or in a small, medium or large development team the Visual…

Come join Mark Russinovich for an overview of Microsoft’s new cloud OS. Assuming no prior knowledge of Windows Azure, this session will start by explaining the Windows Azure Platform-as-a-Service (PaaS) app philosophy and how it differs from that of traditional server apps. Then, demonstrating key…

The Windows Runtime (WinRT) is a key piece of technology used by all Metro style apps in Windows. What actually is the Windows Runtime though? This session explores this key question by digging into the concepts of language projections, the WinRT type system and advanced API patterns included in the… 

Windows 8 enables users to log into any device with a single Microsoft account and continuously interact with your app on all of their devices. Your customers will expect the ability to bring their documents, photos, videos, and contacts with them as they move between their devices. Come see how you…

More and more users are becoming familiar with the concept of "the Cloud." More than ever, users are storing their data in the Cloud. SkyDrive is one of the world's leading cloud storage and document collaboration services. Learn how you can easily allow your users to read and write documents,…

Comments (0)

Bouncy McFuzzin for Windows Phone 7
Andy's Blog By Andy Beaulieu on 6/22/2011 9:50 AM


UPDATE 6/28/2011: Bouncy McFuzzin is now available on the Marketplace!

[DOWNLOAD McFUZZIN]*

*Zune Software Required

Here is a sneak peek of another little physics game I'm working on for Windows Phone 7.

Help McFuzzin escape from the evil witch's lint jar in this fun physics game. Use your finger to draw trampolines for McFuzzin to bounce on. You'll encounter many strange creatures and obstacles along the way, as well as power-ups to help you along.

Wanna Beta Test?

Many thanks to everyone who gave McFuzzin a test run!!

Comments (0)

Silverlight 5: 3D Physics Demo
Andy's Blog 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)

Air Hockey for Windows Phone 7
Andy's Blog By Andy Beaulieu on 3/14/2011 8:01 AM


If you are interested in creating physics based Games for Windows Phone 7, you might find this useful:

Creating an Air Hockey Game for Windows Phone 7

I created this tutorial for the Expression Toolbox Site, using the Physics Helper Library and the Farseer Physics Engine. The design assets for the game were created by Pixel Lab. The tutorial consists of several videos and source download which walk you through creating this fun physics game!

There are also some other great Windows Phone 7 Tutorials available on the .toolbox site:

Calculator and Daily Awesome show you some of the design-side of Expression Blend. And Golf Tracker shows you how to creatively display and handle data.

 

 

Comments (0)

Boss Launch 2 Released!
Andy's Blog 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)

Module Border Module Border
Module Border
  Subscribe
Module Border
RSS   Twitter
Module Border Module Border
Module Border
  Diversions
Module Border

TALKING RAGDOLL
This Windows Phone 7 App was created using Silverlight, the  Physics Helper Library,  and the Farseer Physics Engine. It gets interesting when you import your friends photos and have your way with them!

MORE INFO



DROPPYPOP
This Windows Phone 7 game was created using Silverlight, the  Physics Helper Library,  and the Farseer Physics Engine.
DEMO

MORE INFO



BOSS LAUNCH
This physics game won first place in the Server Quest Contest. Created using Silverlight 2, the Physics Helper Library,  and the Farseer Physics Engine.
PLAY IT

MORE INFO



DESTROY ALL INVADERS
A scrolling shooter game where the objective is to destroy the invading UFO's flying over a neighborhood of your choosing. Imagery provided by Microsoft Virtual Earth. Created using Silverlight 2.
PLAY IT

INFO AND CODE



PHYSICS HELPER DEMOS
These demos were created for the Physics Helper Library, which makes it easy to create physics games and simulations using Expression Blend, Silverlight, and the Farseer Physics Engine.
PLAY IT

INFO AND CODE



HOOK SHOT
This little basketball game took first place in the TeamZoneSports Silverlight Contest. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



SORT THE FOOBARS
A game where you need to sort the good foobars from the bad ones. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



POLYGON PHYSICS DEMO
A demo showing polygon physics where the user draws physics objects with the mouse. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



SILVERLIGHT ROCKS!
Destroy the asteroids before they destroy your ship! Created using Silverlight 2.
PLAY IT

INFO AND CODE



FISH GAME
A simple game of harpoon-the-fish. Written using the AJAX Sprite Toolkit.
PLAY IT

INFO AND CODE

Module Border Module Border
Module Border
  Search_Blog
Module Border
Module Border Module Border
Module Border
  Blog_Archive
Module Border
Module Border Module Border
Copyright (c) 2013 andy.beaulieu.com - Login