Home | nevrax.com |
|
animatable.hGo to the documentation of this file.00001 00007 /* Copyright, 2001 Nevrax Ltd. 00008 * 00009 * This file is part of NEVRAX NEL. 00010 * NEVRAX NEL is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2, or (at your option) 00013 * any later version. 00014 00015 * NEVRAX NEL is distributed in the hope that it will be useful, but 00016 * WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * General Public License for more details. 00019 00020 * You should have received a copy of the GNU General Public License 00021 * along with NEVRAX NEL; see the file COPYING. If not, write to the 00022 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00023 * MA 02111-1307, USA. 00024 */ 00025 00026 #ifndef NL_ANIMATABLE_H 00027 #define NL_ANIMATABLE_H 00028 00029 #include "nel/misc/types_nl.h" 00030 #include "nel/misc/bit_set.h" 00031 #include <string> 00032 #include <vector> 00033 #include <map> 00034 00035 00036 namespace NL3D 00037 { 00038 00039 class ITrack; 00040 class CChannelMixer; 00041 00042 00073 class IAnimatable 00074 { 00075 friend class IAnimatedValue; 00076 public: 00077 00083 IAnimatable () 00084 { 00085 _Father= NULL; 00086 } 00087 00088 virtual ~IAnimatable() {} 00090 // @{ 00096 enum TAnimValues 00097 { 00098 AnimValueLast=0, 00099 }; 00100 00107 virtual IAnimatedValue* getValue (uint valueId) =0; 00108 00115 virtual const char *getValueName (uint valueId) const =0; 00116 00123 virtual ITrack* getDefaultTrack (uint valueId) =0; 00124 00135 virtual void registerToChannelMixer(CChannelMixer *chanMixer, const std::string &prefix=std::string()) =0; 00136 00137 // @} 00138 00139 00140 00142 // @{ 00143 00151 void setFather(IAnimatable *father, uint fatherOwnerBit) 00152 { 00153 _Father= father; _FatherOwnerBit= fatherOwnerBit; 00154 00155 // propagate the touch to the fathers. 00156 propagateTouch(); 00157 } 00158 00159 00166 void touch (uint valueId, uint ownerValueId) 00167 { 00168 // Set the bit 00169 bitSet.set (valueId); 00170 // Set the owner bit 00171 bitSet.set (ownerValueId); 00172 00173 // propagate the touch to the fathers. 00174 propagateTouch(); 00175 } 00176 00182 bool isTouched (uint valueId) const 00183 { 00184 return bitSet[valueId]; 00185 } 00186 00187 00193 void resize (uint count) 00194 { 00195 // Bit are reseted after resize (doc), nothing invalidate 00196 bitSet.resizeNoReset (count); 00197 } 00198 // @} 00199 00200 00201 private: 00202 00203 // Use a CBitSet to manage the flags 00204 NLMISC::CBitSet bitSet; 00205 // The owner of this IAnimatable. 00206 IAnimatable *_Father; 00207 // What bit of father which must set when we are updated. 00208 uint _FatherOwnerBit; 00209 00210 void propagateTouch() 00211 { 00212 IAnimatable *pCur= this; 00213 // Stop when no father, or when father is already touched (and so the grandfather...!!!). 00214 while(pCur->_Father && !pCur->_Father->isTouched(_FatherOwnerBit)) 00215 { 00216 // The Owner bit is the "something is touched" flag. touch it. 00217 pCur->_Father->bitSet.set (pCur->_FatherOwnerBit); 00218 pCur= pCur->_Father; 00219 } 00220 } 00221 00222 00223 protected: 00228 sint addValue(CChannelMixer *chanMixer, uint valueId, uint ownerValueId, const std::string &prefix, bool detail); 00229 00231 void clearFlag(uint valueId) 00232 { 00233 bitSet.clear(valueId); 00234 } 00235 00236 }; 00237 00238 00239 } // NL3D 00240 00241 #endif // NL_ANIMATABLE_H 00242 00243 /* End of animatable.h */ |