Book Image

Lua Game Development Cookbook

By : Mario Kasuba, Mário Kašuba
Book Image

Lua Game Development Cookbook

By: Mario Kasuba, Mário Kašuba

Overview of this book

Table of Contents (16 chapters)
Lua Game Development Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Moving, rotating, and scaling objects


OpenGL offers you stack-based matrix transformations. These transformations include translating—moving, rotating, and scaling. Stacking means that previous transformations can affect succeeding transformations and they create the hierarchical structure. A typical example may be a human-like arm simulation. The arm consists of several parts connected with joints. Each part's position and orientation is dependent on the position and orientation of the previous part. Similar rules of dependency apply to all parts of the solar system. Planets orbit around stars and moons orbit their planets at the same time.

This recipe will show you how to create a simple scene with your own animated miniature of the solar system.

Getting ready

The core to success with scene animation is to understand how matrix transformations affect parts of your scene. There are four main rules to remember:

  • Each transformation changes the state of the local coordinate system, so the order...