Previous Blog Next Blog
Prev/Next Blog
by date

TorqueX Newbie Diary #4

TorqueX Newbie Diary #4
Name:David Everhart 
Date Posted:Dec 12, 2007
Rating:3.5 out of 5
Public:YES
Comments:YES
RSS Feed:GarageGames Blog feedor Subscribe with .
Profile Page:View profile page for David Everhart

Blog post
Well, this has been a busy period , but I have been able to make a lot of strides recently. I am currently learning Poser 7,3DSMax, and WorldCreator. I am thinking that my toolset will be:

Poser 7 - character animation sprite maps
3DSMax - Prop creation (clothes, weapons, etc)
Photoshop - sprite strip maker
WorldCreator 2.5 - Tiles, Environment, World Objects (awesome 2D world engine)
TorqueX 1.5 - Game Engine

I am still learning on all of them minus photoshop which I have used for the last 5 years.


Animation Creator

I have retooled the AnimationCreator and stripped it down to several classes. I now have an AnimationLayer class, which BodyAnimationLayer inherits from, and ItemAnimationLayer inherits from BodyAnimationLayer. The AnimationManager singleton can cache them, preload animation layers, and of course merge them into a T2DAnimatedData, and then cache it for reuse. I also have an AnimationHelper which has generic image support functions and an AnimationConfiguration class which houses a configuration of animation layers(both body and item). I was also able to get the T2dAnimationData conversion working like a champ (Thanks to John Kanalkis). The 1.5 release offered a SimpleMaterial object that allowed me to set my texture directly.

I realized halfway through developing it, that I only really will use imagestrips. That is what the animation layer is, literally, just a class that houses the image path, an ID, and a sort. The Body Animation Layer inherits from that, and has 4 variables: Race, Mode, WeaponClass, and Direction. Regardless of the character animation, every single frame requires this essential set of 4 variables, hence they are put in a class. The Item Animation Layer inherits from the Body Animation Layer and adds Item specific things, such as the Itemtype.

I have figured for my testing purposes, I will use 1 Race , that being Human for now For the modes, I have defined them as :


  public enum Mode
{
Attack1 = 1,
Attack2 = 2,
Attack3 = 3,
Block = 4,
CautiousIdle = 5,
Cast = 6,
GetHit = 7,
Idle = 8,
Kick = 9,
Run = 10,
Walk = 11
}


These modes represent the action that is occuring. For example, a character can be attacking, blocking, idling, casting, running, etc. You get the idea. Each one of those modes causes the animation to behave differently. For my WeaponClass, the values are:


   public enum WeaponClass
{
Bow = 0,
ClawsAndShield = 1,
CrossBow = 2,
DualClaws = 3,
HandToHand = 4,
HandAndShield = 5,
OneHandedSwing = 6,
OneHandThrust = 7,
LeftSwingRightSwing = 8,
LeftSwingRightJab = 9,
LeftJabRightSwing = 10,
LeftJabRightJab = 11,
Staff = 12,
TwoHandedSwing = 13,
TwoHandedThrust = 14
}


These weaponclasses further represent how the animation needs to play by defining the way they hold the weapons (a staff is different from a claw for instannce) . The last of the four is direction, which is pretty easy to define:


  public enum Direction
{
South,
SouthWest,
West,
NorthWest,
North,
NorthEast,
East,
SouthEast
}


So to do an example, you could have a human that is running, with dual swords, and headed Southeast. If you figure (for my test), 1 race, 11 modes , 14 weaponclasses, and 8 directions, thats a ton of sprites (1232 to be exact). However, we know that we can flip at least 3 of them, so now we are down to 5 directions (770 sprites). Keep in mind, this is only for a naked character with no armor or weapons. Now in my preload, I only load the configuration (not the images). The images are merged on demand, then cached. I am still unit testing this at the moment and will get some numbers on the runtime merge(I am thinking less than a 100 milliseconds more than likely based on my past tests). Since I have optimized the code some, It should be pretty quick.

As for the Armor and Weapons, those all have the same as the body, but I can reuse a lot of the same strips. For instance, the helm strip for a human running with dual swords southeast is the same for a human walking with dual swords goung southeast. Also, if a character is only switching weapons, the animation that is cached only really needs to change one peice of it, so caching the animation in various merge states is ideal (Aka cache the body, then cache the body with armor on, then cache the body with armor and weapons). That way if they switch weapons, we just call the second one we stored, swap in the new itemanimationlayer, merge, recache, and we are on our way. This can be also based on what I think will change the most. For instance, gloves usually get swapped more than say a chest peice.


Core Game Objects

I have also created a Player singleton, that houses (for the moment) an Equipment Object that houses everything he is wearing. It will manage the state of the player , and also contain a List<InventoryItem>. I also built an ItemManager singleton, that stores Items. I have a base Item class, and classes that inherit from it like EquippableItem have inventory images, a List<ItemAnimationLayer>, etc. I can actually pass a BodyAnimationLayer to the List<ItemAnimationLayer> in the item and have it pull out the correct Item animation layer.


public ItemAnimationLayer GetAnimation(BodyAnimationLayer bodyLayer)
{
return _itemAnimationLayers.Find(delegate(ItemAnimationLayer itemlayer) { return itemlayer.BodyLayer.Equals(bodyLayer); });
}



The ItemLayer exposes a reference to the baseclass for searching purposes. Well, looks like I have written a ton of stuff. I will continue learning on Poser 7, WorldCreator 2.5, 3DS Max, and of course our good friend Mr Torque X 1.5. Until then!!

Recent Blog Posts
List:09/03/08 - TorqueX 3D Hiding Meshes Part 2
07/09/08 - TorqueX - First Stab at Hiding Mesh Resource
06/22/08 - Journey Into 3D
01/28/08 - TorqueX Newbie Diary #6
01/07/08 - TorqueX Newbie Diary #5
12/12/07 - TorqueX Newbie Diary #4
12/07/07 - TorqueX Newbie Diary #3
12/01/07 - TorqueX Newbie Diary #2

Submit ResourceSubmit your own resources!

You must be a member and be logged in to either append comments or rate this resource.