dev in the making

game development, maya and code by brainzizi

Things learned the hard way

with one comment

Decided to write a post. And possibly a helpful one! What a day!

I present – lessons learned the hard way in game programming:

Do not write your own physics for games.

Use for 2D and for 3D physics. Do not write you’re own just because you need a simple physics engine in your game – even if you do have the neccessary knowledge. It’s too big to finish in a reasonable time and there are far better engines out there.

Learn to use some paint software and a 3d modelling package

You will need art for your game. Lots and lots of art if you’re making anything bigger than puzzle games. Learn how to use Photoshop, Gimp or whatever to create basic game 2D game art. Also learn a 3D modelling package like Maya or Blender because – if you can handle the math – you will want to do something in 3 dimensions. Also learn Mudbox or some other free sculpting package if you don’t want to totally devote to 3D with learning how to uv map / texture. Also to touch UV mapping: Do not UV map a model manually using plane, sphere, … projections. Use something called LSCM mapping. Blender has it by default and most packages have a plugin that handles that (Maya has RoadKill)

Learn about view and projection transforms and object, view, world coordinate systems

Not knowing how to handle transformations between different coordinate systems turns out to be quite a bummer when trying to do anything a bit more complex with graphics. You need to know the maths so you can do a whole lot of cool stuff like shadow mapping and camera effects… Start with Vector math, and go on with Matrix math and View, Projection, Transformation matrices. It’s really practical math, ready-to-use math, not something abstract with a lot of theory behind.

Well, that’s it for now. What did you learn the hard way in game programming?

Written by brainzizizi

10.30.2010 at 15:56

Export Maya’s custom attributes to XNA

leave a comment »

If I only knew it was this easy…

I’m doing a spaceship shooter game, and I encountered a situation where the only solution was to write a custom xml file next to every one of my models. So I started a content pipeline extension project and began twiddling. I inherited the ModelProcessor to load info from my custom xml file, and I saw a OpaqueData dictionary in the NodeContents so I decided to google it.

With some help from I got exactly what I wanted without the xml info file – getting extra information from Maya to XNA.

As the link says, soo

  • 1. Add a custom attribute to a mesh in Maya
  • 2. Read it in the OpaqueData
  • 3. ???
  • 4. Profit!

Simple as that! What you actually want to do in step 3 is pass on that extra information in a Model.Tag, or Mesh.Tag from the content pipeline to your game.

Written by brainzizizi

07.16.2010 at 13:45

Spaceships and news

leave a comment »

Been doing some really simple geometry in Maya, spaceships mostly.

As you can see none of them still textured, and I probably won’t be spending much time texturing any of them as I feel so helpless doing that. I’m really not an artistic guy (I couldn’t draw a bicycle on a piece of paper), as I ventured into 3D for my own personal needs , and I feel that texturing non-organics is my limit.

So yeah, now I’m stuck with a couple of untextured spaceship models so I decided to do a little 3D top-down space arcade / roguelike kinda action RPG where the textures won’t stand out as totally bad. And I said I’d finish it by the end of summer. We’ll see…

In other news:

  • XNA 4.0 Beta – If you got the CTP version installed you have to uninstall it, but do uninstall the whole product (not piece by piece) as you’re quickly going to find a lot of problems if you try uninstalling piece by piece. I fixed my problems using the MSI Cleanup Utility.
  • Goblin Camp v001 is out. You can call it a Dwarf Fortress killer, I call it cool. Anyhow it’s anonuncing the next generation of ascii graphics city builders. If you’re so confused right now, check and Dwarf fortress. Only for hardcore people who play hardcore games.

Written by brainzizizi

07.15.2010 at 17:48

Shawn writes about randoms

leave a comment »

Shawn has a nice little article about the way people think about random numbers. Take a look here.

I think the only way you need a better random number generator than the .NET Random is when your game is totally relying on random numbers. Games like Roguelikes or Diablo style hack n slash with lots of item drops and random dungeon generation probably use their own random number generator because the built in ones often give a pattern over a large number of samples. In fact I don’t know that much about random numbers, so just read Shawn’s article.

Written by brainzizizi

12.18.2009 at 07:22

Posted in game programming

zAnimation – exporting models from Maya

leave a comment »

This is a short tutorial which I’m also posting on the zAnimation codeplex wiki. The next one should be about building a new project with zAnimation. This was going to be a video tutorial, but my english speaking abilities sock. As well as my english writing abilities. Also I suck at modeling/animating, so this shouldn’t be taken as a modeling tutorial. It’s a tutorial on how to export stuff.  So let’s get started. Read the rest of this entry »

Written by brainzizizi

12.10.2009 at 12:57

Posted in xna

Tagged with , , ,

zAnimation – on codeplex

with one comment

zAnimation is finally on codeplex. You can find it here:

It’s all very basic for now, no samples or documentation yet. The code is somewhat documented. I believe experienced people will have no problem using it. It’s just a matter of selecting the right content processor, checking out my past blog entry to write a definitions file, and writing model.Play(“Walk”); I won’t be working on the documentation or samples the next 2 weeks, my exams are still more important.

Written by brainzizizi

11.22.2009 at 12:57

zAnimation – a simple XNA animation library

with 3 comments

Before XNA 3.1, there was a bunch of animation frameworks which could to tons of stuff like interpolation between animations and stuff like that. When the 3.1 came out all of these became obsolete – except kw animation which comes with a 3ds max exporter and is great if you’re using max, but I’m using Maya and I needed to write my own animation foundation. zAnimation is a XNA library for animating skinned models exported from Maya. It supports customizable pre-clip interpolation, and per-bone animation. No interpolation between frames or animations yet.

Pre-clip interpolation:

Before a clip is played, the model interpolates over a customizable number of frames to the starting position. It delays an animation a bit but removes jerky transitions between animations.

Per-bone animation:

When defining a clip within the animation, you also define what bones does the clip affect. Based on that you can play an animation that animates all the bones in a model, and easily override the animation on one or more bones to make them move in a different way.

Below I’m listing a couple of things that I encountered while writing zAnimation:

Maya gets all your animation keyframes and exports it in a single take called “Take 001”.

To deal with this I introduced another file (the take definition file) which contains where does a certain animation start and end, and also what bones does it affect.

XNA FBX Importer removes redundant bones.

If a bone has no weights defined on a skin it gets deleted. The same thing happens if the bone doesn’t move (change) in the keyframes. So I introduced 2 special parts of the animation, the “Bind” part and the “Init” part. The bind part acts like a starting transform, and the init part is just there so you don’t forget that you have to animate a bone if you want to have it.

So based on that there are a few rules and limitations to zAnimation:

– smooth binding only

– each bone in each skin has to have some weights, so no root bones with no weights (or it won’t be imported as a bone)

– each bone has to have at least 2 keyframes that are not the same (or it won’t show up in the keyframes at all)

– strictly defined animation timeline:

-at frames 0 and 1 keyframe every bone at its bind pose position. This is the position your animation starts with.

-at frame 3 you should keyframe every bone it any position other than its bind pose. I select all my bones and rotate them in the x-axis about 45 deg.

-at frame 4 you should keyframe your bind pose again.

– after frame 4 animate your model as you wish

– when importing a model create a takes.def file in the same directory as your exported fbx is in the XNA content folders, set its build action to none from Visual Studio

– takes.def file has a specific structure that is line delimited, so the first line should look like this:

Bind, 0, 2, AffectedBone0, AffectedBone1, AffectedBone2

and each line after that should look like this:

AnimationName, StartFrame, EndFrame, AffectedBone0, AffectedBone1, AffectedBone2

here’s an example of a takes file

Bind, 0, 2, root, door
Open, 4, 34, door
Opened, 34, 36, door
Close, 36, 66, door

That’s more or less it. I’ll release it on codeplex in a couple of days. Check it out if you’re a XNA developer working with Maya.

Written by brainzizizi

11.05.2009 at 08:52

Posted in xna

Tagged with , , , ,