Book Image

Learning Game AI Programming with Lua

By : David Young
Book Image

Learning Game AI Programming with Lua

By: David Young

Overview of this book

Table of Contents (16 chapters)
Learning Game AI Programming with Lua
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Getting Started with AI Sandbox
Index

Skeletons and meshes


First, we need to cover some basics on how animations are represented and used by the sandbox.

Mesh skeletons

So far, we've learned how to create mesh representations within the sandbox. We're now going to deal with an additional asset called a skeleton. Ogre, which is the underlying renderer for the sandbox, stores the skeleton and animations within a single .skeleton file. Any animated Ogre mesh within the sandbox references its animations from the media/animations folder, and in the case of our soldier, animations are located at media/animations/futuristic_soldier/futuristic_soldier.skeleton.

Loading an animated mesh

Loading an animated mesh is exactly the same as loading a normal mesh within the sandbox. Simply create an animated mesh with the Core.CreateMesh function:

Sandbox.lua:

function Sandbox_Initialize(sandbox)
    local soldier = Core.CreateMesh(
        sandbox,
        "models/futuristic_soldier/" ..
        "futuristic_soldier_dark_anim.mesh");

Showing a skeleton...