Wednesday, January 30, 2008

The Road to Normal Mapping

I started to work on this guy today, and think it has turned out pretty decent. I wanted a cleanly modeled object to try normal mapping on, and just using a cube seemed lazy and boring.

Next step is take it to Mudbox and sculpt all the details there. I have only created normal maps for simple flat surfaces with Photoshop before, so I'm viewing all this as a workflow learning experience.

I have no idea what to do with his face, maybe I'll leave it as it is. I'm hoping to get inspired once I'm sculpting the detail in.

For those with a 3D fetish just like me, here's a wireframe screenshot ( the model ended up at 2588 triangles ).

It was my first time trying to keep everything as quads, and it can be a frustrating experience sometimes. It sure looks more tidy though :)

Bonus image:


This is the face of the main character of our game ( The Teddy Incident ). You can see some concept art featuring him in previous posts.

I've been working on the character head together with one of our artists ( he has done the whole body too, but I don't have images on that ).

...I can't wait to see the little dude alive with animations, running and jumping and chopping off heads.

Friday, January 25, 2008

Dead Sketchbook Back to Life

I was looking for some pictures to post here, and I've noticed that I haven't been drawing much lately... Pretend you've never seen the following drawing before :)



Bonus picture:


It's a concept sketch of the main character of the game mindlessly slaughtering zombies ( He's such a sweet child ). I doubt the zombies will make it into the final game version, but it was a fun drawing to do.

I promise that next drawing will be something new and original ( at least new ).

Thursday, January 24, 2008

Serialize Me

I've been updating the animation system editor lately. More precisely on the saving/loading of nodes and connections.

The first thing that came to mind for the job was to use C# default xml serialization to do the work for me.

The animation engine has a diagram that contains all of it's nodes stored in a list of generic nodes. All nodes inherit from a base node class. I thought that the serializer would choose to write the subclass by default, but it has proven a little bit more complicated than that.

Disclaimer: Maybe I'm missing something out and doing it wrong. If anyone knows a better way to do this I'm really interested in knowing, so please contact me.

As it seems, a class that has subclasses that you may want to serialize needs to use the XmlInclude attribute and define what other classes it may represent...

e.g.

public class SubClass : SuperClass
{
//blah blah blah
}

[XmlInclude( typeof( SubClass ) )]
public class SuperClass
{
//etc etc etc
}


Any OO programmer should be running in circles, screaming and trying to pull out his eyes by now. Since when a superclass should have knowledge of all of its subclasses!?!

That's why I think I may be approaching this the wrong way. C# is too nice a language to have a shortcoming such as this one.

I'd also like to point out that my base node class resides in a separate assembly than my node subclasses, so even using that horrible solution is tricky.

In the end, I was wasting more time trying to get around this than doing real work, so I've used XmlReader and XmlWriter to save and load the node diagram manually.

How have I've solved the node type instantiation then?

When saving nodes I write a string with its type name.


BaseNode node = ( BaseNode ) diagram.Nodes[ nodeId ];

String type = node.GetType().ToString();

...

writer.WriteStartAttribute( "type" );
writer.WriteString( type );
writer.WriteEndAttribute();


And when reading them I use that string to instantiate the correct subclass dynamically. The only assumption I'm making here is that it has a default constructor.


reader.MoveToAttribute( "type" );
String typeString = reader.Value;

Type type = Type.GetType( typeString );
BaseNode node = ( BaseNode ) Activator.CreateInstance( type );


As nodes can have custom data, I've also created virtual functions in the base node class that subclasses can override to deal with that data. It may not be the most elegant solution, but it's quite flexible (and it works).

I think that the editor will soon be in a distributable (although feature limited, and nowhere near final) state and I'll be able to get some real feedback.

Next post I'll put some pretty drawings for my nonprogrammer friends :)

Wednesday, January 23, 2008

The right side of my brain

Because I've scared some of my friends with my first post, I'll try to bring equilibrium to this blog.

Let me introduce you some of the characters that will be part of the game I'm working on.



Although I'm mainly programmer on the team, I enjoy working on art. The picture above is taken from my current sketchbook and is a little bit old.

I wish I was good at painting, but I never seem able to choose the right colours... for a confirmation on that you'll have to wait for another post :)

Drawing is a part of who I am as much as the programming work I like to do. I'll try to touch both subjects often.

Monday, January 21, 2008

The Beginning

It's about time I started this blog, and at the expense of alienating some of my friends by showing my geekier side, I'll begin with a screenshot from a project I'm working on:



It started out as a "learn C# project", but things like this tend to snowball and before long you're working on something quite big.

So, for all of you not into 3D or who I haven't been boring to death lately with the topic: It's a tree based high-level animation blender engine for my favourite 3D engine ( + Editor!! ).

After the Google Summer of Code project that was to provide some higher level animation support to Ogre failed without much to show for it except some interesting comments, I thought that it would be nice to contribute to the community.

This will be a simple implementation of some of the topics discussed there though. No IK, sorry. Just an implementation with blend ( or mix ) nodes and transition nodes ( e.g. State Machines ). This Gamasutra article is probably closer to what I'm trying to achieve.

Currently I have a very simple working version for the editor, but does everything that it should, like create different kinds of nodes, connections, etc. You can also watch the results in a viewport as you interactively update the parameters. It's quite nice really.

My main objective is to be able to control a character animation via a reduced set of parameters. For example, in the screenshot above the whole animation tree can be controlled by only two values.

The C++ implementation will start soon( ish ). It will be a cleaned up version of the C# code. A prettier version that doesn't have to deal with user screw ups.

So, when a usable C++ implementation is available, and I write code to save and load animation trees, I will be releasing everything.