About

I'm a software engineer who works on game development part time. I teach game development (on gamedev.stackexchange.com and lynda.com). I'm always working on something, and I'll post updates here. Let me know if there's a game development topic you want to know more about, I probably know the answer, or at least where to get one.

Monday, November 26, 2012

The latest changes

Animation System - After getting animation working, I needed to implement a system for displaying animations. That's now in place. The animation system simply uses an event system to pass messages for animation changes. The animations have a few parameters defined, like delayed start amount, maximum play time and whether they should loop or not. It also includes an idle animation pool for each model. When defining animations in the data file I can add "IDLE_ANIMATION" to the name and it will be added to the idle pool. Additionally I define a weighted chance value for that animation. Then, when a entity is idle, it will choose randomly from the idle pool, the animations with a higher weighted chance will be chosen more often. These animation pools can be used for other animation types too! So any animation can have a animation pool. This makes it possible to have multiple animations per action. This way, things don't look so robotic, allowing for subtle changes for the same action. Animation really brings the game to life. It makes the goblins walking around and performing tasks look so much better. I'll show it off in the next video. Along with a few animations (so far I have walking, mining, picking up and dropping. Plus five idle animations).



Model billboards - In Blender I can add an empty object and give it a name. Then, in the entity definition file, I can add a Billboard attribute and tell it to place such and such a sprite and the name defined in the model file. Thus I can add billboard sprites to models, or make a model in blender composed entirely of empty objects and easily define the placement for billboards for an entity. For example:

Adding leaves to an apple tree (billboard + model):


(note the nifty selection box, more on that in a bit)

Or defining the leaf locations for a NiNi Shrub (just using empty positions in Blender)


Arguably the latter type doesn't look too interesting in Blender:

But it's a pretty nifty way for me (and modders) to define the locations of billboards for entities easily.

Entity Picking - When models are read into the game, a bounding box is generated based on the bounds of the vertices read. That works great with static models, however, if the entity is animated with bones, that bounding box quickly becomes obsolete. So how to solve it? One way would be to run through the transformed vertices and calculate the bounds again. That doesn't work so well for me because the model vertices are on the graphics card from the beginning and that's where all the transformations happen. So, a slightly less accurate method. Get the bounds for each bone when the model is loaded. Then transform the bounding boxes by the animated pose.

Then we can just go through all of those bounding boxes and find the maximum and minimum bounds of those bounding boxes. Works great. The bounding boxes of the bones can over represent the model slightly, but it's pretty close. This allows me to not only select the entity with a picking ray, but it also allows me to detect the specific location of the entity that was selected. This means location based damage (useful for the dynamic dismemberment plans). Sweet.

Other - Some miscellaneous completed tasks include:
 - Distant render types: When a model is far away from the camera it can either be rendered with a lower resolution model, a 2D sprite or nothing.
 - GUI work: I added sub radial menus. For expanding radial menus out in a tree like fashion for easy navigation of options.
 - Enemy work: I'm adding a simple entity to work on all the related systems for entities that don't like each other. That includes detecting when an enemy gets near, attacking and fleeing behaviors and plenty of other related work.
 - And more stuff that's insignificant or not complete enough to share yet.

4 comments:

  1. Can you tell me how did you go about importing Blender objects? This is something that I've tried doing myself (using Android's Java and OpenGL APIs) and I found it very difficult. I'm not talking just about the mesh (like vertices, faces and normals), but also (multiple) UV maps, animations, bones etc. What format do you use for exporting from Blender? Did you make your own parser for that format, or did you use an existing library for that?

    ReplyDelete
  2. I'll write up a post on exporting from Blender. Give me a bit to get it done. Thanks for your interest.

    ReplyDelete
  3. Do you think you will eventually write up a post about the planned gameplay in Age of Goblins in greater detail? From what I've read throughout your posts, it sounds like the player will start off with a small group of goblins, use them to gather resources and build some sort of structures(like shuttles), and defend them from unknown enemies. I would love to read more about specific player goals, goblin jobs, resources, structures, and enemies that you plan to have in the game.

    ReplyDelete
    Replies
    1. Sure thing Gigggas. I'll add it to my write queue. Probably be ready within a few weeks. Thanks for the suggestion.

      Delete