# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

skeleton_user.cpp

Go 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 #include "std3d.h"
00027 
00028 #include "3d/skeleton_user.h"
00029 #include "3d/play_list_user.h"
00030 #include "nel/misc/hierarchical_timer.h"
00031 
00032 
00033 namespace NL3D
00034 {
00035 
00036 H_AUTO_DECL( NL3D_UI_Skeleton )
00037 
00038 #define NL3D_HAUTO_UI_SKELETON                                          H_AUTO_USE( NL3D_UI_Skeleton )
00039 
00040 
00041 // ***************************************************************************
00042 uint            CSkeletonUser::getNumBoneComputed() const
00043 {
00044         NL3D_MEM_SKELETON
00045         NL3D_HAUTO_UI_SKELETON;
00046 
00047         return _Skeleton->getNumBoneComputed();
00048 }
00049 
00050 // ***************************************************************************
00051 void            CSkeletonUser::setInterpolationDistance(float dist)
00052 {
00053         NL3D_MEM_SKELETON
00054         NL3D_HAUTO_UI_SKELETON;
00055 
00056         _Skeleton->setInterpolationDistance(dist);
00057 }
00058 
00059 // ***************************************************************************
00060 float           CSkeletonUser::getInterpolationDistance() const
00061 {
00062         NL3D_MEM_SKELETON
00063         NL3D_HAUTO_UI_SKELETON;
00064 
00065         return _Skeleton->getInterpolationDistance();
00066 }
00067 
00068 
00069 // ***************************************************************************
00070 void            CSkeletonUser::setShapeDistMax(float distMax)
00071 {
00072         NL3D_MEM_SKELETON
00073         NL3D_HAUTO_UI_SKELETON;
00074 
00075         if(_Skeleton && _Skeleton->Shape)
00076         {
00077                 _Skeleton->Shape->setDistMax(distMax);
00078         }
00079 }
00080 
00081 // ***************************************************************************
00082 float           CSkeletonUser::getShapeDistMax() const
00083 {
00084         NL3D_MEM_SKELETON
00085         NL3D_HAUTO_UI_SKELETON;
00086 
00087         if(_Skeleton && _Skeleton->Shape)
00088         {
00089                 return _Skeleton->Shape->getDistMax();
00090         }
00091         else
00092                 return -1;
00093 }
00094 
00095 
00096 // ***************************************************************************
00097 bool            CSkeletonUser::bindSkin(UInstance *mi)
00098 {
00099         NL3D_MEM_SKELETON
00100         NL3D_HAUTO_UI_SKELETON;
00101 
00102         if(mi==NULL)
00103         {
00104                 nlerror("USkeleton::bindSkin(): mi is NULL");
00105                 return false;
00106         }
00107         CTransform                      *trans= dynamic_cast<CTransformUser*>(mi)->getTransform();
00108         CMeshBaseInstance       *meshi= dynamic_cast<CMeshBaseInstance*>(trans);
00109         if(meshi==NULL)
00110         {
00111                 nlerror("USkeleton::bindSkin(): mi is not a MeshInstance or MeshMRMInstance");
00112                 return false;
00113         }
00114         return _Skeleton->bindSkin(meshi);
00115 }
00116 
00117 // ***************************************************************************
00118 void            CSkeletonUser::stickObject(UTransform *mi, uint boneId)
00119 {
00120         NL3D_MEM_SKELETON
00121         NL3D_HAUTO_UI_SKELETON;
00122 
00123         if(mi==NULL)
00124                 nlerror("USkeleton::stickObject(): mi is NULL");
00125         CTransform              *trans= (dynamic_cast<CTransformUser*>(mi))->getTransform();
00126         _Skeleton->stickObject(trans, boneId);
00127 }
00128 
00129 // ***************************************************************************
00130 void            CSkeletonUser::stickObjectEx(UTransform *mi, uint boneId, bool forceCLod)
00131 {
00132         NL3D_MEM_SKELETON
00133         NL3D_HAUTO_UI_SKELETON;
00134 
00135         if(mi==NULL)
00136                 nlerror("USkeleton::stickObject(): mi is NULL");
00137         CTransform              *trans= (dynamic_cast<CTransformUser*>(mi))->getTransform();
00138         _Skeleton->stickObjectEx(trans, boneId, forceCLod);
00139 }
00140 
00141 // ***************************************************************************
00142 void            CSkeletonUser::detachSkeletonSon(UTransform *mi)
00143 {
00144         NL3D_MEM_SKELETON
00145         NL3D_HAUTO_UI_SKELETON;
00146 
00147         if(mi==NULL)
00148                 nlerror("USkeleton::detachSkeletonSon(): mi is NULL");
00149         CTransform              *trans= (dynamic_cast<CTransformUser*>(mi))->getTransform();
00150         _Skeleton->detachSkeletonSon(trans);
00151 }
00152 
00153 
00154 // ***************************************************************************
00155 uint            CSkeletonUser::getNumBones() const
00156 {
00157         NL3D_MEM_SKELETON
00158         NL3D_HAUTO_UI_SKELETON;
00159 
00160         return _Bones.size();
00161 }
00162 UBone           &CSkeletonUser::getBone(uint boneId)
00163 {
00164         NL3D_MEM_SKELETON
00165         NL3D_HAUTO_UI_SKELETON;
00166 
00167         if(boneId>=_Bones.size())
00168                 nlerror("getBone(): bad boneId");
00169         return dynamic_cast<UBone&>(_Bones[boneId]);
00170 }
00171 sint            CSkeletonUser::getBoneIdByName(const std::string &boneName) const
00172 {
00173         NL3D_MEM_SKELETON
00174         NL3D_HAUTO_UI_SKELETON;
00175 
00176         return _Skeleton->getBoneIdByName(boneName);
00177 }
00178 bool            CSkeletonUser::isBoneComputed(uint boneId) const
00179 {
00180         NL3D_MEM_SKELETON
00181         NL3D_HAUTO_UI_SKELETON;
00182 
00183         return _Skeleton->isBoneComputed(boneId);
00184 }
00185 
00186 // ***************************************************************************
00187 void            CSkeletonUser::setLodCharacterShape(sint shapeId)
00188 {
00189         NL3D_MEM_SKELETON
00190         NL3D_HAUTO_UI_SKELETON;
00191         _Skeleton->setLodCharacterShape(shapeId);
00192 }
00193 sint            CSkeletonUser::getLodCharacterShape() const
00194 {
00195         NL3D_MEM_SKELETON
00196         NL3D_HAUTO_UI_SKELETON;
00197         return _Skeleton->getLodCharacterShape();
00198 }
00199 void            CSkeletonUser::setLodCharacterAnimId(uint animId)
00200 {
00201         NL3D_MEM_SKELETON
00202         NL3D_HAUTO_UI_SKELETON;
00203         _Skeleton->setLodCharacterAnimId(animId);
00204 }
00205 uint            CSkeletonUser::getLodCharacterAnimId() const
00206 {
00207         NL3D_MEM_SKELETON
00208         NL3D_HAUTO_UI_SKELETON;
00209         return _Skeleton->getLodCharacterAnimId();
00210 }
00211 void            CSkeletonUser::setLodCharacterAnimTime(TGlobalAnimationTime time)
00212 {
00213         NL3D_MEM_SKELETON
00214         NL3D_HAUTO_UI_SKELETON;
00215         _Skeleton->setLodCharacterAnimTime(time);
00216 }
00217 TGlobalAnimationTime    CSkeletonUser::getLodCharacterAnimTime() const
00218 {
00219         NL3D_MEM_SKELETON
00220         NL3D_HAUTO_UI_SKELETON;
00221         return _Skeleton->getLodCharacterAnimTime();
00222 }
00223 bool            CSkeletonUser::isDisplayedAsLodCharacter() const
00224 {
00225         NL3D_MEM_SKELETON
00226         NL3D_HAUTO_UI_SKELETON;
00227         return _Skeleton->isDisplayedAsLodCharacter();
00228 }
00229 void            CSkeletonUser::setLodCharacterDistance(float dist)
00230 {
00231         NL3D_MEM_SKELETON
00232         NL3D_HAUTO_UI_SKELETON;
00233         _Skeleton->setLodCharacterDistance(dist);
00234 }
00235 float           CSkeletonUser::getLodCharacterDistance() const
00236 {
00237         NL3D_MEM_SKELETON
00238         NL3D_HAUTO_UI_SKELETON;
00239         return _Skeleton->getLodCharacterDistance();
00240 }
00241 void            CSkeletonUser::setLodCharacterWrapMode(bool wrapMode)
00242 {
00243         NL3D_MEM_SKELETON
00244         NL3D_HAUTO_UI_SKELETON;
00245         _Skeleton->setLodCharacterWrapMode(wrapMode);
00246 }
00247 bool            CSkeletonUser::getLodCharacterWrapMode() const
00248 {
00249         NL3D_MEM_SKELETON
00250         NL3D_HAUTO_UI_SKELETON;
00251         return _Skeleton->getLodCharacterWrapMode();
00252 }
00253 
00254 
00255 // ***************************************************************************
00256 void            CSkeletonUser::changeMRMDistanceSetup(float distanceFinest, float distanceMiddle, float distanceCoarsest)
00257 {
00258         NL3D_MEM_SKELETON
00259         NL3D_HAUTO_UI_SKELETON;
00260         _Skeleton->changeMRMDistanceSetup(distanceFinest, distanceMiddle, distanceCoarsest);
00261 }
00262 
00263 
00264 // ***************************************************************************
00265 bool            CSkeletonUser::computeRenderedBBox(NLMISC::CAABBox &bbox)
00266 {
00267         NL3D_MEM_SKELETON
00268         NL3D_HAUTO_UI_SKELETON;
00269         return _Skeleton->computeRenderedBBox(bbox);
00270 }
00271 // ***************************************************************************
00272 bool            CSkeletonUser::computeCurrentBBox(NLMISC::CAABBox &bbox, UPlayList *playList, double playTime, bool forceCompute /* = false */)
00273 {
00274         NL3D_MEM_SKELETON
00275         NL3D_HAUTO_UI_SKELETON;
00276 
00277         if(playList!=NULL)
00278         {
00279                 CPlayListUser   *plUser= static_cast<CPlayListUser*>(playList);
00280                 plUser->evalPlayList(playTime);
00281         }
00282 
00283         return _Skeleton->computeCurrentBBox(bbox, forceCompute);
00284 }
00285 // ***************************************************************************
00286 void            CSkeletonUser::computeLodTexture()
00287 {
00288         NL3D_MEM_SKELETON
00289         NL3D_HAUTO_UI_SKELETON;
00290 
00291         _Skeleton->computeLodTexture();
00292 }
00293 
00294 
00295 } // NL3D