Posts Tagged ‘xna’

Space Simulator Rewrite via Unity

2012/10/23 2 comments

I’ve switched to Unity 3D, both a game engine and game development environment for my humble Space Simulator hobby project.  Thus far I’m most impressed with the speed that Unity allows me to realise ideas and focus on what is more important – what the game is about. Far more sensible than spending time in other 3D APIs trying to implement a mini-map which may break in the next release of the API.

Unity’s asset and scene browsers allow you to organise your project logically and visually.  Setting up a scene is an absolute joy as opposed to attempting the same in code.   Files that have been created externally in say Blender, 3ds Max or Photoshop for example do not require subsequent import steps, Unity immediately displays changes.

Unity Pro also comes with some nice features such as:

  • Pro Image Effects including shadows; screen-space ambient occlusion (SSAO); bloom
  • Occlusion culling
  • Extended light-mapping (radiosity)
  • Deferred rendering with unlimited lights
  • HDR
  • A pretty dark-grey theme

I did feel guilty about the idea of using a tool such as this but that was quickly laid to rest.  For instance, we use nHibernate, StructureMap, Entity Framework, ASP.NET MVC and IDE’s such as Visual Studio and Xcode so the concept is not new.

Why re-invent the wheel?


You Mean I’ve Been on the Dark Side All Along?

2012/04/22 1 comment

This is how I felt earlier this week after my initial forays into OpenGL, an open standard graphics library for multiple platforms.  From the books I was reading, I had come to realise that XNA is perhaps an immature API from both age and sensibility viewpoints, particularly where one is concerned with cross-platform and backwards compatibility and DirectX was just too hard.  I was already aware of the last point from personal experience.

I quite like how OpenGL has its extension system to expand the API without breaking other peoples code.  XNA and DirectX could learn a lesson here.

The XNA team have had a history of breaking backwards compatibility for “reasons” of motivation.  There were major breaking changes between XNA 3 and XNA 4.  The future of XNA to me is uncertain.  Microsoft’s next OS Windows 8 has XNA no where to be seen. XNA can be found on Windows Phone 7 devices but they are quite rare.  There is XNA on XBOX for end-users, but it has fewer features than what a proper XBOX game has access to hardware-wise. XNA was not the first Microsoft managed DirectX wrapper.  Before XNA there was MDX and sadly it went the way of the Dodo bird.

Just a few lines is all it takes to display a 3D window

OpenGL is reportedly easy to learn and thus far I agree with what I have been told.  Just a few lines is all it takes to display a 3D window.  It’s also good to know that no bloatware, no mammoth class libraries, no over-the-top OO-style programming – just pure, nice and clean c-style methods.   Contrast this with DirectX – now I would like to think I know something when it comes to COM, but trying to learn DirectX is quite challenging.   DirectX did come out later with c++ helper classes but they were perhaps rather limited and let’s face it – too late!

XNA is a lot easier than DirectX but its way harder than OpenGL, however XNA is slightly bloaty compared to OpenGL.  Plus unlike XNA, OpenGL doesn’t have ridiculous legal restrictions on what you can do or how you distribute your application.   Want to give your buddy your game to try out?  He may need Visual Studio 2010; XNA Game Studio installed; and know how to compile your program.   Not fun.

…we still have point sprites on OpenGL using the same modern-day video card!

The worst bit about learning XNA, was how unprofessional some of the key representatives and tutors were on certain forums and blogs.  No, these were not fan forums.  Forum manners were atrocious; people with perceived ulterior motives; and some cases of propaganda.  One was to do with the elimination of point sprites from the API, another over not to use the FBX file format and the bizarre recommendation for people not to use sky domes.  Funny, we still have point sprites on Windows via OpenGL using the same modern-day video card!   Even iPads can use point sprites via OpenGL ES.  Sure, point sprites may be old hat but we were lead to believe that modern hardware doesn’t support it when the truth is is that latter DirectX doesn’t.

The point is, if my legacy app wants to use some ancient deprecated feature, the API should damn well let it have it, even if it means it runs like a pig.  This is why OpenGL is so much better.  OpenGL is kinder to you – it gives you the opportunity to run your legacy app whilst allowing you to gradually upgrade to newer discipline.

You were told to do things a certain way in XNA either with no explanation, or if one was given, was perhaps a half-truth in hind-sight.  I was reminded of how I felt when I first heard of OpenGL back in the days of Windows NT 4 and basically dismissed OpenGL most likely due to at the time being influenced by others in the know.  Back then, I suspect I didn’t hear both sides of the story, like the point spites half-truth.

Now I don’t profess to be an expert in XNA, let alone DirectX, but my experiences in both of these has made me come to the realisation that I have more important things to worry about – what my application is about and how the tools or APIs can help me.

Hello OpenGL, so nice to be in the light with you!

Categories: Development Tags: , , ,

Golly…Macs Really Do “Just Work”!

2011/03/13 Leave a comment

I was recently lucky enough to grab myself an iMac; in that time it has solved more problems than the time I have spent trying to solve a single problem on Windows.

Computer Specs

Memory Windows= iMac =4GB
CPU Windows=Intel Core 2 Extreme Quad @ 3GHz,  iMac=2.8GHz Quad-Core Intel Core i5
Video Windows=dual nVidia 8800 GTX,   iMac=ATI Radeon HD 5670


Here is a list of my prior issues:

  • iTunes on PC and generation 1 Apple TV would “forget” their network connection
    • meaning my Apple TV could no longer sync/stream TV shows and movies from my PC
    • typically you buy on the Apple TV and after watching it is “archived” on your PC to make room for other purchases
    • I had lost a few purchases because of this.  Apple does not allow you to download to Apple TV again
  • Could not connect to a Canon MX850 printer via the network if it was connected to one PC via USB
    • basically allows you to share the printer over a single USB cable instead of a network cable
    • USB allows you to do certain things network cable cant
  • Lacie 4big Quadra 4TB RAID “big blue button” not recognized
    • allows for quick backup
    • Windows Backup is inefficient, slow and poorly designed
  • Access to Apple’s MobileMe email via Microsoft Outlook/Windows Live Essentials IMAP is incredibly slow – 5 seconds to delete a message
  • Opening the majority of any document takes considerable time on Windows
    • PDF
    • videos
    • Word/Excel documents
  • MSN Messenger takes considerable time to load; consumes excessive computer resources
  • Games such as the recent Civilization V consume excessive resources; takes considerable time to load considering nature of application – “its no Crysis!”
  • Windows Phone developer registration is more complex than applying for a home mortgage.  Took approximately 7 days to complete including various to and throw e-mails to Microsoft
  • Visual Studio has historically shown that with each new version requires a level of magnitude more computer memory and CPU resources.   VS is very expensive to buy for the Pro version. Express as a tool for serious development is questionable


  • Apple TV and iTunes on iMac just work; do not forget each other
  • Canon MX850 was automatically detected over wi-fi when plugged into Airport Extreme Base Station USB socket
  • Lacie 4big Quadra 4TB RAID was automatically detected and iMac kindly asked if I wished to use it for TimeMachine
    • Pressing big blue button on Lacie launched the brilliant TimeMachine app
    • TimeMachine is fast, intuitive, reliable
  • Apple’s iMail automatically configured e-mail server settings just by me typing in my address
    • iMail is fast
    • Like the central inbox
  • iMacs have a Preview application that very quickly opens a document for reading rather than loading bloatware Acrobat, Microsoft Word, Excel or similar
  • MS Messenger for iMac (via Office Mac) is much like pre-Windows Live Essentials meaning it doesn’t have the annoying ads but more importantly, uses less computer resources like memory and CPU in wlcomm.exe
  • Civilization V for iMac loads considerably quicker and exits to mac desktop much faster than Windows
  • Apple’s Mac Developer MacOS/iOS registration completed in 12 hours
  • Apple’s Xcode IDE is only $5.00 and uses minimal CPU and memory
  • Though Apple may make use of seemingly vertical standards such as Bonjour, historically it can be shown that Apple is more likely to adopt more popular standards with more realized use cases than say MS.  Calendering is a good example.

In summary, in only a short time does one really appreciate the high quality of the iMac, but also comes to the realization that pretty much everything PC is by way of poorly designed, badly integrating bloatware produced by capitalist-corporate-hugging software houses.   Take Microsoft Office 2010 is not only bloated but is also unintuitive and bloated; similarly for VS2010 as mentioned.

Don’t Move Your Viewpoint–Move the Universe Instead

2010/12/28 10 comments

In my space simulator project I wanted to model the Solar System but sadly this led to a rather annoying limitation because of restrictions of single-precision floating point. Flying about near “Earth” and the moon seemed OK but flying to Jupiter proved another story. If I tried to place say Jupiter at a scaled-distance from my in-game “Sun”, flying my ship to the Jupiter region caused all sorts of floating point truncations which were very much visible in ship rotations – it all became quite “jumpy”.

After a bit of reading by posts from other devs in my predicament, it seemed that the best approach was not to move the in-game first-person camera based on ship motion but rather to always keep the camera at (0,0,0) and to move everything else instead! In other words – you don’t move, the Universe does. Reminds me of a Greg Bear novel. Winking smile

Also, it makes no sense at this stage to store everything in absolute coordinates when you are dealing with the very large.  I think that storing everything relative to it’s immediate stellar parent makes more sense.  e.g. planets to stars, moons to planets and so-on.  By using octrees I can partition objects relative to the node in which they live thus cutting down large values.  e.g. at least one of the Jupiter nodes should contain the planet and all its moons while other nodes just take into account the planet.

So with this in mind I:

  1. placed the scene origin (0,0,0)
  2. placed the sun at the origin
  3. distributed the planets and moons scaled down and relative to each octree node
  4. placed the camera at some nice location
  5. translate octree nodes based on the camera’s logical position (move the planets not the camera)
  6. when rendering, just draw those models in octree nodes that intersect with the view frustrum
  7. eventually this can lead to dynamic scene content streaming based on the contents of an octree node

Anyway here’s a video.  It’s a test video where the maximum viewable distance is shorter than normal hence the planets vanishing only to be replaced with “crosses” so as to indicate “not viewable”.  If an octree node is too far away it turns blue.

Categories: SpaceSim Tags: , ,

XNA Planet Custom Shader

2010/12/18 2 comments

Well I’ve been working on making my planet shaders to be something a bit more colourful.

Day and Night

First of all I wanted to map two diffuse textures that are alpha blended depending on whether the planet’s side is in the Sun’s shadow or not.  When it is you’ll see the city lights twinkle on.


Next I wanted to do some sort of atmospheric effect.  This was tricky and I’m still not absolutely happy with it – I think I need to read more on subsurface scattering.  Geometry-wise, it’s just a slightly larger sphere.  To shade it the atmospheric shell only renders when the surface normal is nearly perpendicular to the eye – in other words it only shades around the edges of the planet.  The dot product is raised to the 4th power or so to be used during the calculation for the alpha value.  The atmosphere is also emissive so as to illuminate when in shadow.

2010-12-18 vanquish planet atmosphere 1

2010-12-18 vanquish planet atmosphere 2

2010-12-18 vanquish planet atmosphere 3

2010-12-18 15-35 vanquish planet atmosphere

Categories: SpaceSim Tags: , , ,

XNA Cruiser? One “Bump” or Two?

2010/11/28 Leave a comment

I just love pipelines and Lumonix Shader FX makes no exception.  Yesterday I started off with a rather humble shader but today let’s beef it up a bit with a bump map to give it more of a 3-D look.  Here is the shader as seen in 3DS Max and Shader FX:


…and here it is in my space simulator:


That’s looking a bit better, though I must admit it needs a bit of colour and perhaps some glass effects – something for a future project. We noobies have to start somewhere.

Categories: SpaceSim Tags: , , , ,

Be Gone Wireframe – Hello Space Cruiser!

2010/11/27 2 comments

Vanquish 2010-11-27 15-44-45-87Today I spent time on my scene mechanics and imported a new space ship model to replace the test ring place-holder that I was using for the autonomous steering behaviour programming.  It served it’s purpose by indicating the steering, velocity and normal vectors but I know those around me were wanting to see a spiffy model. Anyway I found a rather nice free 3DS model by Mace24de (thanks buddy) on TurboSquid. Loading this into Max it was just a case of giving it a good paint job via Lumonix Shader FX via an interactive pipeline building process. Gotta love Shader FX. 


As you recall in a previous post, Shader FX is a must have for the generation of HLSL GPU shaders in the form of .FX files for use in the likes of XNA.  I’ll just do something fairly simple for now though – a diffuse texture map with a touch of glossiness should be a good start.  Later I’ll plonk in a normal map to make it more interesting.  Here’s a shot of Shader FX in 3DS Max.


…now let’s apply that to our model via Tools/Apply to Selection in Shader FX:


That’s more like it. Now let’s export the shader for XNA. In Shader FX choose File/Export FX…


Select XNA from the appearing dialog.  Make sure you pick Y-Up too – that is a requirement for XNA.


Remember that the XNA shader must be a different filename to the one being used in 3DSMax.  I like to merely give the XNA files a “XNA” suffix.  A no brainer Winking smile


…export your model. Make sure just your model is selected, no lights/cameras/etc. please unless your pipeline can handle that. Choose File/Export/Export Selected in 3DSMax:


Export as a FBX using Autodesk’s FBX export tool (its a free download from their site). My settings is pretty much the defaults except I’ve deselected cameras, animations etc. for now as I can’t handle them anyway). We don’t want cameras or lights because we’ll be doing that in game.


Eventually this gets into my game using my custom content importer pipeline for FBX that reattaches textures, FX etc. to achieve the following result. I only have to include the .FBX file in my Visual Studio project – there is no need to directly specify the FX, textures or other files because my custom pipeline finds them by reading the info in the original FBX file.  This is handy because I can leave shared art on a different drive and use it in other projects.  Yippee!

Here we are just to the side:

Vanquish 2010-11-27 15-31-53-11


Coming in for the kill!

Vanquish 2010-11-27 15-44-45-87


From above:

Vanquish 2010-11-27 15-47-24-01

Categories: SpaceSim Tags: , , , ,