1 /* 2 --------------------------------------------------------------------------- 3 Open Asset Import Library (ASSIMP) 4 --------------------------------------------------------------------------- 5 6 Copyright (c) 2006-2020, ASSIMP Development Team 7 8 All rights reserved. 9 10 Redistribution and use of this software in source and binary forms, 11 with or without modification, are permitted provided that the following 12 conditions are met: 13 14 * Redistributions of source code must retain the above 15 copyright notice, this list of conditions and the 16 following disclaimer. 17 18 * Redistributions in binary form must reproduce the above 19 copyright notice, this list of conditions and the 20 following disclaimer in the documentation and/or other 21 materials provided with the distribution. 22 23 * Neither the name of the ASSIMP team, nor the names of its 24 contributors may be used to endorse or promote products 25 derived from this software without specific prior 26 written permission of the ASSIMP Development Team. 27 28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 --------------------------------------------------------------------------- 40 */ 41 42 /** 43 * The data structures which are used to store the imported animation data. 44 */ 45 module assimp.animation; 46 47 import assimp.math; 48 import assimp.types; 49 50 extern ( C ) { 51 /** 52 * A time-value pair specifying a certain 3D vector for the given time. 53 */ 54 struct aiVectorKey { 55 /** 56 * The time of this key. 57 */ 58 double mTime; 59 60 /** 61 * The value of this key. 62 */ 63 aiVector3D mValue; 64 } 65 66 /** 67 * A time-value pair specifying a rotation for the given time. For joint 68 * animations, the rotation is usually expressed using a quaternion. 69 */ 70 struct aiQuatKey { 71 /** 72 * The time of this key. 73 */ 74 double mTime; 75 76 /** 77 * The value of this key. 78 */ 79 aiQuaternion mValue; 80 } 81 82 /** 83 * Defines how an animation channel behaves outside the defined time 84 * range. This corresponds to <code>aiNodeAnim.mPreState</code> and 85 * <code>aiNodeAnim.mPostState</code>. 86 */ 87 enum aiAnimBehaviour : uint { 88 /** 89 * The value from the default node transformation is used. 90 */ 91 DEFAULT = 0x0, 92 93 /** 94 * The nearest key value is used without interpolation. 95 */ 96 CONSTANT = 0x1, 97 98 /** 99 * The value of the nearest two keys is linearly extrapolated for the 100 * current time value. 101 */ 102 LINEAR = 0x2, 103 104 /** 105 * The animation is repeated. 106 * 107 * If the animation key go from n to m and the current time is t, use the 108 * value at (t-n) % (|m-n|). 109 */ 110 REPEAT = 0x3 111 } 112 113 /** 114 * Describes the animation of a single node. 115 * 116 * The name specifies the bone/node which is affected by this animation 117 * channel. The keyframes are given in three separate series of values, one 118 * each for position, rotation and scaling. The transformation matrix 119 * computed from these values replaces the node's original transformation 120 * matrix at a specific time. This means all keys are absolute and not 121 * relative to the bone default pose. 122 * 123 * The order in which the transformations are applied is – 124 * as usual – scaling, rotation, translation. 125 * 126 * Note: All keys are returned in their correct, chronological order. 127 * Duplicate keys don't pass the validation step. Most likely there will 128 * be no negative time values, but they are not forbidden (so 129 * implementations need to cope with them!). 130 */ 131 struct aiNodeAnim { 132 /** 133 * The name of the node affected by this animation. The node must exist 134 * and it must be unique. 135 */ 136 aiString mNodeName; 137 138 /** 139 * The number of position keys. 140 */ 141 uint mNumPositionKeys; 142 143 /** 144 * The position keys of this animation channel. Positions are specified 145 * as 3D vectors. The array is <code>mNumPositionKeys</code> in size. 146 * 147 * If there are position keys, there will also be at least one scaling 148 * and one rotation key. 149 */ 150 aiVectorKey* mPositionKeys; 151 152 /** 153 * The number of rotation keys. 154 */ 155 uint mNumRotationKeys; 156 157 /** 158 * The rotation keys of this animation channel. Rotations are given as 159 * quaternions. The array is <code>mNumRotationKeys</code> in size. 160 * 161 * If there are rotation keys, there will also be at least one scaling 162 * and one position key. 163 */ 164 aiQuatKey* mRotationKeys; 165 166 167 /** 168 * The number of scaling keys. 169 */ 170 uint mNumScalingKeys; 171 172 /** 173 * The scaling keys of this animation channel. Scalings are specified as 174 * 3D vectors. The array is <code>mNumScalingKeys</code> in size. 175 * 176 * If there are scaling keys, there will also be at least one position 177 * and one rotation key. 178 */ 179 aiVectorKey* mScalingKeys; 180 181 182 /** 183 * Defines how the animation behaves before the first key is encountered. 184 * 185 * The default value is <code>aiAnimBehaviour.DEFAULT</code> (the original 186 * transformation matrix of the affected node is used). 187 */ 188 aiAnimBehaviour mPreState; 189 190 /** 191 * Defines how the animation behaves after the last key was processed. 192 * 193 * The default value is <code>aiAnimBehaviour.DEFAULT</code> (the original 194 * transformation matrix of the affected node is used). 195 */ 196 aiAnimBehaviour mPostState; 197 } 198 199 /** 200 * An animation consists of keyframe data for a number of nodes. 201 * 202 * For each node affected by the animation, a separate series of data is 203 * given. 204 */ 205 struct aiAnimation { 206 /** 207 * The name of the animation. 208 * 209 * If the modeling package this data was 210 * exported from does support only a single animation channel, this 211 * name is usually empty (length is zero). 212 */ 213 aiString mName; 214 215 /** 216 * Duration of the animation in ticks. 217 */ 218 double mDuration; 219 220 /** 221 * Ticks per second. 0 if not specified in the imported file. 222 */ 223 double mTicksPerSecond; 224 225 /** 226 * The number of bone animation channels. 227 * 228 * Each channel affects a single node. 229 */ 230 uint mNumChannels; 231 232 /** 233 * The node animation channels. The array is <code>mNumChannels</code> 234 * in size. 235 * 236 * Each channel affects a single node. 237 */ 238 aiNodeAnim** mChannels; 239 } 240 }