-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblog_animation_transformtracks.html
64 lines (50 loc) · 6.19 KB
/
blog_animation_transformtracks.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Gabor Makes Games</title>
<meta name="author" content="Gabor Szauer">
<link rel="stylesheet" type="text/css" href="css/shared.css"><link rel="stylesheet" type="text/css" href="css/navigation.css"><link rel="stylesheet" type="text/css" href="css/font-raleway.css"><link rel="stylesheet" type="text/css" href="css/font-oxygen.css"><link rel="stylesheet" type="text/css" href="css/font-worksans.css"><link rel="stylesheet" type="text/css" href="css/codepretty/skins/desert.css"><script type="text/javascript" src="js/codepretty/prettify.js"></script><script type="text/javascript" src="js/navigation.js"></script><!-- Global site tag (gtag.js) - Google Analytics --><script async src="https://www.googletagmanager.com/gtag/js?id=UA-96941899-3"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'UA-96941899-3');</script> <link rel="stylesheet" type="text/css" href="css/blog.css">
</head>
<body onload="MainNavOnLoad();PR.prettyPrint();"> <div class="nav"> <ul class="menu"> <li class="logo"><a href="https://gabormakesgames.com">Gabor Makes Games</a></li> <li class="item"><a id="main-nav-active" href="blog.html">Blog</a></li> <li class="item"><a href="books.html">Books</a></li> <li class="item"><a href="https://github.com/gszauer/">Github</a></li> <li class="item"><a href="https://twitter.com/gszauer">@gszauer</a></li> <li class="toggle"><a href="#">Open Menu</a></li> </ul></div>
<div id="blog">
<div id="sidebar"><a class="sidebar-item sidebar-first sidebar-gap" href="blog.html">Back to blog</a></li><a class="sidebar-item sidebar-first" href="animation.html">Introduction</a><a class="sidebar-item" href="blog_animation_curves.html">Curves</a><a class="sidebar-item" href="blog_animation_pose.html">Pose Generation</a><a class="sidebar-item sidebar-tab" href="blog_animation_frames.html">Frames</a><a class="sidebar-item sidebar-tab" href="blog_animation_tracks.html">Tracks</a><a class="sidebar-item sidebar-tab sidebar-active " href="blog_animation_transformtracks.html">Transform Track</a><a class="sidebar-item sidebar-tab" href="blog_animation_poses.html">Poses</a><a class="sidebar-item sidebar-tab" href="blog_animation_clips.html">Clips</a><a class="sidebar-item sidebar-tab" href="blog_animation_sample.html">Sample</a><a class="sidebar-item" href="blog_animation_skin.html">Skinning</a><a class="sidebar-item sidebar-tab" href="blog_animation_skinspace.html">Skin Space</a><a class="sidebar-item sidebar-tab" href="blog_animation_smoothskin.html">Smooth Skinning</a><a class="sidebar-item" href="blog_animation_blend.html">Pose Modification</a></div>
<div id="content">
<h1>Transform Tracks</h1>
<p>With our current setup, there exists tracks for scalars, vectors and quaternions. Next we need a higher order track, one that can encode the change of a <code>Transform</code> object over time. In this context, a <code>Transform</code> object is made up of three components: position, rotation and scale.</p>
<pre class="prettyprint linenums">struct Transform {
vec3 position;
quat rotation;
vec3 scale;
}</pre>
<p>If we where to template the <code>Track</code> class to represent a <code>Transform</code> it would look something like this <code>typedef Track<Transform, 10> TransformTrack_BAD;</code> Not all transform tracks will animate every component of a transform object. Some animation might only animate the rotation for example. Because not all transform components need to be animated, making a frame that has 10 unique floats for every value and tangent is wasteful.</p>
<p>There is an additional piece of data that must be kept somewhere, a reference to the transform object that the transform track is animating. Typically, this type of reference is expressed as an index into the array that contains the scene hierarchy, or sometimes using a pointer. A transform track will always have a target object. Embedding this information in the transform track class would be very useful. The <code>TransformTrack</code> covered in the book has the following member variables:</p>
<pre class="prettyprint linenums">class TransformTrack {
protected:
unsigned int mId;
VectorTrack mPosition;
QuaternionTrack mRotation;
VectorTrack mScale;
float mStartTime;
float mEndTime;
protected:
void RecalculateDuration();
pulic:
Transform Sample(const Transform& t, float time, bool looping);
// Rest of the class
}</pre>
<p>The <code>TransformTrack</code> class does not need to be templated. It contains the following data:</p>
<ul>
<li>An id, that represents the index of the transform this track is affecting.</li>
<li>A vector track for the position component.</li>
<li>A quaternion track for the rotation component.</li>
<li>A vector track for the scale component.</li>
<li>Cached start and end times.</li>
</ul>
<p>Any of the component tracks (position, rotation or scale) could be empty. When the <code>Sample</code> function is called it must be provided a default <code>Transform</code>. If a <code>TransformTrack</code> has an empty component track, the missing value is taken from the passed in default <code>Transform</code> object.</p>
<p>The <code>TransformTrack</code> class caches start and end times. Any time one of the tracks changes, the cached times must be re-calculated. The start time is the lowest of the component track start times. The end time is the highest of the component track end times.</p>
<p>The <code>TransformTrack</code> only animates the values of one <code>Transform</code> object over time. Typically a character is made up of many transforms, not all of which are animated. Before exploring how to combine <code>TransformTrack</code> objects into an animation clip, let's explore how the hierarchy that transform tracks animate works.</p>
</div>
</div>
</body>
</html>