Jul 10 2011

XNA Animated Sprite code uploaded to CodeProject.com

Category: Desktop and ServerJoel Ivory Johnson @ 06:51

I've uploaded some code I was working on to animate sprites in XNA.

Animating a sprite isn't difficult, but I wanted some way to animate them but reduce the coupling between code and the animation. The Content Pipeline is perfect for this. So I created a component that will handle the animation scenarios that I need along with a content extension so that I could load these animations as content. Right now the animation information is in an XML file. This is a stepping point towards having a graphical tool for handling this.

You can read about the code here or see a brief description of it in the video below

Tags: , , ,

Feb 10 2011

Double Precision Vector3

Category: Desktop and Server | MobileJoel Ivory Johnson @ 03:29

Download the code (2.90 KB)

 

I was working on an educational project using Windows Phone and XNA on the desktop (the phone will be controlling the desktop). The project involves demonstrating the laws of celestial mechanics. So the modeled entities have attributes with large values (ex: the mass of a planet in kilograms, the distance the planet is from its sun in meters, so on). In the Xna portion of the program the Vector3 class appeared to be a good fit for modeling a planet's position, velocity, acceleration, and so on. My only concern with Vector3 is the precision of the numeric type that it uses. It uses a single precision number. When I started my initial test I was seeing how small objects reacted on the earth's surface just to make sure that my gravity calculations were correct. Everything worked fine; the object would fall toward the earth with the expected acceleration. So I went straight from modeling a small object on the earth's surface to modeling the Earth's moon. That's when things broke down. The numbers coming back from the gravity calculations were all wrong. 

It turns out I was running into a precision problem. Floating point types have enough precision to hold the final results of my calculations, but not enough prevision to hold the large intermediate values during the calculations. There are three ways to solve this:

  1. Use a Vector class with a higher precision numeric type
  2. Copy values from Vector3 to doubles, perform calculations, copy results back to Vector3
  3. Perform my calculations using Astronomical Units (AU) instead of meters. 
I started with trying to copy values to double types before doing calculations first. That works, but I had concerns with the code getting messy and the overhead in coding that way. I thought about using astronomical units. But that would add an extra mental layer of complication. I think of calculations for gravity in terms of meters and trying to work in some other unit would likely lead to problems. There was no higher precision Vector3 class available. So last night I converted the Vector3 class to a double-precision version of itself that I named Vector3D.  A majority of the methods available on Vector3 are available on the Vector3D class. 
I replaced the Vector3 with the Vector3D class and everything worked as expected. 

I figure at some point some one else will run into this problem so I've posted a copy of this class (link at the top of this entry). If I need to add more functionality to this class I'll be updating the version at the above link to. 

Tags: ,

Mar 14 2010

What do I need to Make XNA 4.0 Games

Category: Mobile | XNAJoel Ivory Johnson @ 01:58

This is from one of the slides shared at GDC

  • Visual Studio 2010
  • XNA Game Studio 4.0
    • Silverlight and XNA Framework
    • Windows Phone 7 Series, Xbox, and Windows Project Templates
    • Debugging Support
  • C# Development
    • .Net Framework (Windows)
    • .Net Compact Framework (Xbox, Windows Phone 7 Series)

I can't help but notice VB.Net is missing (note: that is in no way a complaint, VB.Net was also unsupported in previous XNA versions). To use the Xbox Live APIs you must be partnered with Microsoft and meet additional certification requirements. So I won't talk much about Xbox Live services in the future. Most of us (including myself) won't have access to it.

Tags: , ,

Mar 13 2010

What to Expect from XNA Game Studio 4.0

Category: Desktop and Server | Mobile | XNAJoel Ivory Johnson @ 04:12

XNA Game Studio will be made public within the next one to two months. Here's a few of the updates

  • You'll be able to use the Mouse APIs on Windows Phones. The Mouse API will actually use the Multitouch functionality and return the position of rhte first point.
  • There are two XNA Profiles, Reach and HighDef
    • The Reach profile prvide maximum compatibility across the three screens
    • The HighDef profile is for Xbox/PC. While it lacks WP7S Compatibility it lets you take advantage of the device's capabiities
  • The Multitouch APIs are now available to Windows targets
  • The ZuneHD won't be getting XNA 4.0
  • XNA 4.0 isn't designed to be backwards compatibile with XNA 3.1. Compatibility was sacrificed in the interest of progress.
  • Windows Phones will have the Same aspect ratio but different screen resolutions
    • To the developer both devices have the same resolution. WP7S contains hardware scaling
    • WP7S also contains hardware functionality for scree rotation
  • Custom effects are not available on Windows Phone 7 Series
  • Emulator will be available. You don't need to own a Windows 7 Phone.

 

Tags: , , ,

Mar 10 2010

Why Haven't You Downloaded the XNA SDK Yet?

Category: Mobile | XNAJoel Ivory Johnson @ 11:50

On a podcast the other day one of the members was a little upset that a Windows Phone 7 Series SDK isn't yet available. While the SDK will be welcomed I'm not completly convinced that its curreny lack of availability is a road block for developers

XNA Game Studio 3.1 is available right now and if you download it you can start getting used to the SDK on your PC. If you have a ZuneHD or an Xbox 360 you can use those too. The SDK is really easy to use. You can grab it from http://creators.xna.com

While you are at it check out the 800+ games that are currently available that were written in XNA. There are some pretty cool looking games in the catalogue.

Tags: ,

Mar 9 2010

Coming Soon, XNA Game Studio 4.0

Category: Mobile | XNAJoel Ivory Johnson @ 11:08

Today Microsoft announced XNA Game Studio 4.0. New to XNA Game Studio is support for Windows Phone 7 Series, the Xbox Live APIs, access to the WAVE devices, and the notion of a managed and non-managed developer.

Where Microsoft technologies are concerned I'm used to managed being almost synonymous with developers targetting the .Net CLR. It means something different in this context. A managed developer is one with which Microsoft has partnered. Developers with Managed status have access to the Xbox Live APIs. non-managed developers would include hobiest and any one else not partnered with Microsoft.

Tags: ,

Feb 25 2010

Windows Graphic and UI APIs

Category: Mobile | XNAJoel Ivory Johnson @ 06:14

After having another conversation in which I was explaining some of the various graphic APIs available to Windows I ended up pulling some information out of my personal notes to make a list of the most populate Windows graphic APIs and their availability on Windows Phones. I gave the information to some one at MSMobiles.com and he has posted it on his site.

That being said, I think that's the third reference to MSMobiles I've made in the past month or two. As you may guess I am a regular reader of that site and listener of the podcast. I'm not quite sure if I would classify it as a pro Windows or anti-Windows site yet though :-). Calling itself the "Fox News of Microsoft Mobile News" I have to say it's an interesting site and the primary author is talented at wording things in a way to invoke reactions.

Tags: , , ,

Feb 21 2010

Connecting Xbox 360/Zune to Xna Game Studio

Category: XNAJoel Ivory Johnson @ 11:13

Some one was asking questions about how to connect the Xbox 360 or Zune to Xna Game Studio Express. It's much easier to show than to just tell. So I made a video where I went through the process. You an find it on YouTube.com

BTW: I've never mentioned this before but I have a YouTube.com channel to which I occasionally upload videos. You can fnd it at http://www.youtube.com/user/j2inet

 

Tags: , ,

Apr 1 2009

After a year of XNA

Category: Desktop and ServerJoel Ivory Johnson @ 22:14

I just got an e-mail notifying me that renewal time for my XNA subscription is in another month.  I signed up for XNA development a year ago.  It cost 99 USD/year.  After paying the 99 USD one is able to debug and run .Net based XNA games on the Xbox 360.  I signed up not because I was interested in making games but because the Xbox 360 is a nice piece of hardware.  It's got 6 cores, 2 of which are dedicated to the operating system leaving 4 cores for the developer to use as he or she sees fit.  I had planed to try out some graphic and AI algorithms on the 360 and experiment with some multiprocessor programming techniques (not to be confused with multithreading).

So what have I done in the past year?  Nothing. A shortcoming of the development tools for the XNA framework is that they don't work on multihomed computers (computers with more than one active network card).  Conventional thinking may lead one to try to disable the other network cards that are not being used.  Unfortunatly that wasn't an option for me.  The VM software that I have installed creates several virtual network adapters, none of which can be disabled.  So for the past year my 99 USD has given me very little.

This year will be different.  I purchased a new computer that I only plan to use for recreational computing (which will include programming the xbox 360). I won't be installing any VM software on the new machine.  Hopefully I'll be able to get started with something this weekend.

Tags: