00001 /* 00002 * bvh.h 00003 * 00004 * Copyright (C) 2009 Thomas A. Vaughan 00005 * All rights reserved. 00006 * 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions are met: 00010 * * Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * * Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * * Neither the name of the <organization> nor the 00016 * names of its contributors may be used to endorse or promote products 00017 * derived from this software without specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THOMAS A. VAUGHAN ''AS IS'' AND ANY 00020 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00021 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00022 * DISCLAIMED. IN NO EVENT SHALL THOMAS A. VAUGHAN BE LIABLE FOR ANY 00023 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00026 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00028 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 * 00030 * 00031 * Basic support for skeletal animations (the BVH format) 00032 */ 00033 00034 #ifndef WAVE_GLUT_BVH_H__ 00035 #define WAVE_GLUT_BVH_H__ 00036 00037 // includes -------------------------------------------------------------------- 00038 #include "common/common.h" 00039 00040 #include "geometry/matrix_4.h" 00041 #include "threadsafe/smart_ptr.h" 00042 00043 00044 namespace bvh { 00045 00046 00047 //////////////////////////////////////////////////////////////////////////////// 00048 /// 00049 /// \ingroup models 00050 /// \defgroup bvh The BVH Format - Motion Capture (Animation) 00051 /// 00052 /// Simple reference implementation for the BioVision Hierarchical data file 00053 /// format. See http://en.wikipedia.org/wiki/Biovision_Hierarchy 00054 /// 00055 /// 00056 //////////////////////////////////////////////////////////////////////////////// 00057 /*@{*/ 00058 00059 00060 struct node_position_t { 00061 // public enums 00062 enum eConstants { 00063 eMaxNameSize = 32 00064 }; 00065 00066 // constructor, manipulators 00067 node_position_t(void) throw() { this->clear(); } 00068 void clear(void) throw() { 00069 parent = NULL; 00070 name[0] = 0; 00071 } 00072 00073 // data fields 00074 char name[eMaxNameSize]; 00075 point3d_t pos; 00076 node_position_t * parent; 00077 matrix4_t T; // total transform 00078 }; 00079 00080 00081 00082 /// basic class containing a skeleton and a single animation 00083 class Skeleton { 00084 public: 00085 // virtual destructor -------------------------------------------------- 00086 virtual ~Skeleton(void) throw(); 00087 00088 // bvh::Skeleton class interface methods ------------------------------- 00089 00090 /// number of objects (root skeleton nodes) 00091 virtual int getObjectCount(void) const throw() = 0; 00092 00093 /// get count of nodes (vertices) for this object 00094 virtual int getNodeCount(IN int objIndex) const throw() = 0; 00095 00096 /// Get the positions of all nodes for this object at the given time. 00097 /// \b NOTE: the caller must provide a pre-allocated array of 00098 /// node_position_t objects, of size getNodeCount(objIndex). 00099 virtual void getNodePositions(IN int objIndex, 00100 IN float time, 00101 OUT node_position_t * p) const throw() = 0; 00102 00103 /// helper method for debugging 00104 virtual void dump(IN const char * title) const throw() = 0; 00105 00106 // static factory methods ---------------------------------------------- 00107 static smart_ptr<Skeleton> load(IN const char * filename); 00108 }; 00109 00110 00111 00112 //////////////////////////////////////////////////////////////////////////////// 00113 // 00114 // public API 00115 // 00116 //////////////////////////////////////////////////////////////////////////////// 00117 00118 00119 }; // bvh namespace 00120 00121 00122 #endif // WAVE_GLUT_BVH_H__ 00123