Panda3D
 All Classes Functions Variables Enumerations
geomVertexAnimationSpec.I
00001 // Filename: geomVertexAnimationSpec.I
00002 // Created by:  drose (29Mar05)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: GeomVertexAnimationSpec::Constructor
00018 //       Access: Published
00019 //  Description: 
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE GeomVertexAnimationSpec::
00022 GeomVertexAnimationSpec() :
00023   _animation_type(AT_none),
00024   _num_transforms(0),
00025   _indexed_transforms(0)
00026 {
00027 }
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //     Function: GeomVertexAnimationSpec::Copy Constructor
00031 //       Access: Published
00032 //  Description: 
00033 ////////////////////////////////////////////////////////////////////
00034 INLINE GeomVertexAnimationSpec::
00035 GeomVertexAnimationSpec(const GeomVertexAnimationSpec &other) :
00036   _animation_type(other._animation_type),
00037   _num_transforms(other._num_transforms),
00038   _indexed_transforms(other._indexed_transforms)
00039 {
00040 }
00041 
00042 ////////////////////////////////////////////////////////////////////
00043 //     Function: GeomVertexAnimationSpec::Copy Assignment Operator
00044 //       Access: Published
00045 //  Description: 
00046 ////////////////////////////////////////////////////////////////////
00047 INLINE void GeomVertexAnimationSpec::
00048 operator = (const GeomVertexAnimationSpec &other) {
00049   _animation_type = other._animation_type;
00050   _num_transforms = other._num_transforms;
00051   _indexed_transforms = other._indexed_transforms;
00052 }
00053 
00054 ////////////////////////////////////////////////////////////////////
00055 //     Function: GeomVertexAnimationSpec::get_animation_type
00056 //       Access: Published
00057 //  Description: Returns the type of animation represented by this
00058 //               spec.
00059 ////////////////////////////////////////////////////////////////////
00060 INLINE GeomVertexAnimationSpec::AnimationType GeomVertexAnimationSpec::
00061 get_animation_type() const {
00062   return _animation_type;
00063 }
00064 
00065 ////////////////////////////////////////////////////////////////////
00066 //     Function: GeomVertexAnimationSpec::get_num_transforms
00067 //       Access: Published
00068 //  Description: This is only meaningful for animation_type
00069 //               AT_hardware.  It specifies the maximum number of
00070 //               transforms that might be simultaneously applied to
00071 //               any one vertex by the data in this format.
00072 ////////////////////////////////////////////////////////////////////
00073 INLINE int GeomVertexAnimationSpec::
00074 get_num_transforms() const {
00075   return _num_transforms;
00076 }
00077 
00078 ////////////////////////////////////////////////////////////////////
00079 //     Function: GeomVertexAnimationSpec::get_indexed_transforms
00080 //       Access: Published
00081 //  Description: This is only meaningful for animation_type
00082 //               AT_hardware.  If true, it indicates that the format
00083 //               uses indexed animation tables.  It is false if each
00084 //               vertex will reference the first _num_transforms
00085 //               table entries only.
00086 ////////////////////////////////////////////////////////////////////
00087 INLINE bool GeomVertexAnimationSpec::
00088 get_indexed_transforms() const {
00089   return _indexed_transforms;
00090 }
00091 
00092 ////////////////////////////////////////////////////////////////////
00093 //     Function: GeomVertexAnimationSpec::set_none
00094 //       Access: Published
00095 //  Description: Specifies that no vertex animation is represented by
00096 //               this spec.
00097 ////////////////////////////////////////////////////////////////////
00098 INLINE void GeomVertexAnimationSpec::
00099 set_none() {
00100   _animation_type = AT_none;
00101 }
00102 
00103 ////////////////////////////////////////////////////////////////////
00104 //     Function: GeomVertexAnimationSpec::set_panda
00105 //       Access: Published
00106 //  Description: Specifies that vertex animation is to be performed by
00107 //               Panda.  This is the most general setting and can
00108 //               handle any kind of vertex animation represented.
00109 ////////////////////////////////////////////////////////////////////
00110 INLINE void GeomVertexAnimationSpec::
00111 set_panda() {
00112   _animation_type = AT_panda;
00113 }
00114 
00115 ////////////////////////////////////////////////////////////////////
00116 //     Function: GeomVertexAnimationSpec::set_hardware
00117 //       Access: Published
00118 //  Description: Specifies that vertex animation is to be performed by
00119 //               the graphics hardware (or at least by the graphics
00120 //               backend API, which is actually still free to animate
00121 //               the vertices on the CPU).
00122 //
00123 //               This is only legal if the graphics hardware can
00124 //               support the specified limits on number of transforms
00125 //               and/or indexed transforms.  Also, no current graphics
00126 //               API's support morphing.
00127 ////////////////////////////////////////////////////////////////////
00128 INLINE void GeomVertexAnimationSpec::
00129 set_hardware(int num_transforms, bool indexed_transforms) {
00130   _animation_type = AT_hardware;
00131   _num_transforms = num_transforms;
00132   _indexed_transforms = indexed_transforms;
00133 }
00134 
00135 ////////////////////////////////////////////////////////////////////
00136 //     Function: GeomVertexAnimationSpec::operator <
00137 //       Access: Public
00138 //  Description: Provides an arbitrary ordering between different
00139 //               animation specs.
00140 ////////////////////////////////////////////////////////////////////
00141 INLINE bool GeomVertexAnimationSpec::
00142 operator < (const GeomVertexAnimationSpec &other) const {
00143   return (compare_to(other) < 0);
00144 }
00145 
00146 ////////////////////////////////////////////////////////////////////
00147 //     Function: GeomVertexAnimationSpec::operator ==
00148 //       Access: Public
00149 //  Description: 
00150 ////////////////////////////////////////////////////////////////////
00151 INLINE bool GeomVertexAnimationSpec::
00152 operator == (const GeomVertexAnimationSpec &other) const {
00153   return (compare_to(other) == 0);
00154 }
00155 
00156 ////////////////////////////////////////////////////////////////////
00157 //     Function: GeomVertexAnimationSpec::operator !=
00158 //       Access: Public
00159 //  Description: 
00160 ////////////////////////////////////////////////////////////////////
00161 INLINE bool GeomVertexAnimationSpec::
00162 operator != (const GeomVertexAnimationSpec &other) const {
00163   return (compare_to(other) != 0);
00164 }
00165 
00166 ////////////////////////////////////////////////////////////////////
00167 //     Function: GeomVertexAnimationSpec::compare_to
00168 //       Access: Public
00169 //  Description: Provides an arbitrary ordering between different
00170 //               animation specs.
00171 ////////////////////////////////////////////////////////////////////
00172 INLINE int GeomVertexAnimationSpec::
00173 compare_to(const GeomVertexAnimationSpec &other) const {
00174   if (_animation_type != other._animation_type) {
00175     return (int)_animation_type - (int)other._animation_type;
00176   }
00177 
00178   if (_animation_type == AT_hardware) {
00179     if (_num_transforms != other._num_transforms) {
00180       return _num_transforms - other._num_transforms;
00181     }
00182     if (_indexed_transforms != other._indexed_transforms) {
00183       return (int)_indexed_transforms - (int)other._indexed_transforms;
00184     }
00185   }
00186   
00187   return 0;
00188 }
00189 
00190 INLINE ostream &
00191 operator << (ostream &out, const GeomVertexAnimationSpec &animation) {
00192   animation.output(out);
00193   return out;
00194 }
 All Classes Functions Variables Enumerations