Game Development Reference
In-Depth Information
In our example, we will use B-spline to generate the path of a grenade ( 06-Grenade-
Action.html ). We have added an implementation of B-spline interpolation in the
BSplineIterpolation.js file from the primitive folder of the code bundle. We will
not cover the code of its implementation, but we will discuss how to use the class.
var grenadeControlPoints=[[-1.5,-2,-10],[-1.5,10,-30],[-1.5,15,-40],
[-1.5,10,-60],[-1.5,0,-80]];
var splineInterpolation=new BSplineInterpolation(grenadeControlPoin
ts);
var grenadePositions=splineInterpolation.position;
In the first line of the preceding code, we defined a set of control points
( grenadeControlPoints ). Notice that for the control points, x ( -1.5 ) remains
constant and z ( -10,-30,-40,-60,-80 ) decreases, while y first increases ( -2,10,15 )
and then decreases ( 10,0 ). So, we are simulating a throwing action. With the grenade
being thrown in the z direction, it first goes up and then comes down. The constructor
of the class takes control points, interpolates all the positions between the control
points, and stores the interpolated path in the position array of the class. We take all
those positions and store them in our variable grenadePositions for future use.
In a nutshell, we interpolate positions between the given
points, and then change our object's location as per
these points over a period of time. This creates an effect
of animation. To calculate these points, we can use any
interpolation technique (linear, polynomial, and B-spline).
A briefing on skinned animation
Skeletal animation is a technique in games in which a model is represented in two
parts: mesh (vertices) and a hierarchical set of interconnected bones (called the
skeleton or rig) that is used to animate (pose and keyframe) the mesh. Although
this technique is often used for organic modeling, it only serves to make the
animation process more intuitive, and the same technique can be used to control the
deformation of any object—a door, a spoon, a building, or a galaxy. When we say
hierarchical set, we mean that we move one parent bone, and then the subsequent
child bones will also move.
We will also discuss inverse kinematics where we use the kinematics equations of a
rigged model to determine the joint parameters that provide a desired position of the
child bone. For example, if we have a rigged model of a human being and we move the
backbone, kinematics will help us calculate the effect on each bone up to the fingers.
We will discuss these animations in depth in Chapter 8 , Skinning and Animations .
 
Search WWH ::




Custom Search