Thursday, January 31, 2013

Hybrid 2d/3d

All of this time we have been referring to our game by it's codename - Attraction. I am now pleased to announce the official title of the game - Magnetic by Nature! Not only does this get around an unfortunate amount of SSO issues (Google is convinced anybody googling 'attraction' wants dating sites, for some reason) - it's also a nod to the story behind the game. The robot is thrust into this dead world with only small bits of life. These act as checkpoints and guide the player through the game.

I have also been busy dealing with an unexpected issue. We originally settled on spritesheet animations with the expectation that they would be smaller, more expressive, and simpler to deal with. After looking at the HUGE number of animations that would be needed for the main player alone it became apparent that we needed to make a change.

Our choices were to either switch to keyframe-based sprite animation (found in most flash games) or render the main character in 3d. Because our artists are all more familiar with Maya than Flash we chose the latter. For the past several weeks I've been struggling through the content pipeline, differences in how XNA renders sprites and models, and animation issues.

One of the first problems I ran into is that the FBX importer is frustratingly undocumented. Models must have a single root joint with all other joints under that hierarchy. This hierarchy cannot include any groups (or the import fails). For about a week I worked with Kyle, our main rigger & 3d modeler, to get all of the issues fixed and the model importing & rendering properly.

Once that was done I had to figure out a way to animate it. While the FBX format supports exporting multiple animations in a single file neither Maya nor XNA seems to like working with the result. To work around this I modified the Skinned Model Extensions sample to merge animations from a subfolder as part of the pipeline. For instance, I can place a 'player.fbx' file in my Models folder, then place all of the animations (player_walk.fbx, player_jump.fbx, etc) in a subfolder named player.

Unfortunately in the process I discovered an issue with the sample code. If you set the scale of your model to anything other than 1 the animations become distorted. What is probably happening is that the mesh is being scaled by the keyframes are not - or maybe they're being scaled improperly. To work around this I either have the artists scale the model before generating the FBX or I set a constant scale within our engine.

I hope to post my modifications to the pipeline as a github project for future projects that have similar needs. If you have any suggestions or requests for additional features feel free to post them in the comments!

No comments:

Post a Comment