/* Copyright (c) 2018 Alex Diener This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Alex Diener alex@ludobloom.com */ #ifndef __Armature_H__ #define __Armature_H__ #ifdef __cplusplus extern "C" { #endif typedef struct Armature Armature; #define Armature_superclass StemObject #include "gamemath/Quaternionf.h" #include "gamemath/Vector3f.h" #include "stemobject/StemObject.h" #include #include typedef uint32_t ArmatureBoneID; #define BONE_ID_NONE ((ArmatureBoneID) -1) #define BONE_INDEX_NOT_FOUND UINT_MAX typedef struct ArmatureBone { ArmatureBoneID boneID; ArmatureBoneID parentID; Vector3f position; Vector3f endpoint; // Animation quaternions are relative to this. Absolute for relaxed pose. Quaternionf baseOrientation; unsigned int parentIndex; // Runtime only; set by resolveParentBoneIndexes() } ArmatureBone; #define Armature_ivars \ StemObject_ivars \ \ unsigned int boneCount; \ ArmatureBone * bones; #define Armature_vtable(self_type) \ StemObject_vtable(self_type) stemobject_declare(Armature) // bones is copied Armature * Armature_create(unsigned int boneCount, const ArmatureBone * bones); bool Armature_init(Armature * self, unsigned int boneCount, const ArmatureBone * bones); void Armature_dispose(Armature * self); Armature * Armature_copy(Armature * self); void Armature_resolveParentBoneIndexes(Armature * self); void Armature_addBone(Armature * self, ArmatureBone bone); void Armature_insertBone(Armature * self, unsigned int boneIndex, ArmatureBone bone); ArmatureBone * Armature_getBone(Armature * self, ArmatureBoneID boneID); unsigned int Armature_getBoneIndex(Armature * self, ArmatureBoneID boneID); void Armature_removeBoneAtIndex(Armature * self, unsigned int boneIndex); #ifdef __cplusplus } #endif #endif