#include <skeleton_shape.h>
Inheritance diagram for NL3D::CSkeletonShape:

Nevrax France
Definition at line 48 of file skeleton_shape.h.
Public Member Functions | |
| void | build (const std::vector< CBoneBase > &bones) |
| CSkeletonShape () | |
| Constructor. | |
| sint32 | getBoneIdByName (const std::string &name) const |
| Return the id of a bone, from it's name. -1 if not present. | |
| virtual std::string | getClassName ()=0 |
| float | getDistMax () const |
| const CLod & | getLod (uint lod) const |
| get lod information. | |
| uint | getLodForDistance (float dist) const |
| retrieve the lod to use for a given distance (log(n)). | |
| uint | getNumLods () const |
| const sint & | getRefCount () const |
| virtual void | profileSceneRender (CRenderTrav *rdrTrav, CTransformShape *trans, bool opaquePass) |
| void | retrieve (std::vector< CBoneBase > &bones) const |
| void | setDistMax (float distMax) |
From IShape | |
| virtual bool | clip (const std::vector< CPlane > &pyramid, const CMatrix &worldMatrix) |
| clip this skeleton. | |
| virtual CTransformShape * | createInstance (CScene &scene) |
| Create a CSkeletonModel, which contains bones. | |
| virtual void | flushTextures (IDriver &driver, uint selectedTexture) |
| flush textures used by this shape. | |
| virtual void | getAABBox (NLMISC::CAABBox &bbox) const |
| virtual float | getNumTriangles (float distance) |
| get an approximation of the number of triangles this instance will render for a fixed distance. | |
| NLMISC_DECLARE_CLASS (CSkeletonShape) | |
| clip this skeleton. | |
| virtual void | render (IDriver *drv, CTransformShape *trans, bool opaquePass) |
| render() this skeletonshape in a driver (no-op) | |
| virtual void | serial (NLMISC::IStream &f) throw (NLMISC::EStream) |
| serial this skeletonshape. | |
Data Fields | |
| sint | crefs |
| CPtrInfo * | pinfo |
Static Public Attributes | |
| CPtrInfo | NullPtrInfo |
Protected Attributes | |
| float | _DistMax |
| Default to -1. | |
Private Attributes | |
| NLMISC::CAABBox | _BBox |
| std::map< std::string, uint32 > | _BoneMap |
| std::vector< CBoneBase > | _Bones |
| std::vector< CLod > | _Lods |
Friends | |
| struct | CPtrInfo |
|
|
Constructor.
Definition at line 51 of file skeleton_shape.cpp. References NLMISC::CAABBox::setCenter(), and NLMISC::CAABBox::setSize().
|
|
|
Build a skeletonShape, replacing old. WARNING: bones must be organized in Depth-first order (this is not checked). Bone.LodDisableDistance are minimized such sons have always a distance <= father distance. Definition at line 72 of file skeleton_shape.cpp. References min, sint32, and uint.
00073 {
00074 uint i;
00075
00076 // copy bones.
00077 _Bones= bones;
00078
00079 // for all bones
00080 for(i=0;i<_Bones.size();i++)
00081 {
00082 // build the map.
00083 _BoneMap[_Bones[i].Name]= i;
00084 // validate distances.
00085 _Bones[i].LodDisableDistance= max(0.f, _Bones[i].LodDisableDistance);
00086
00087 // get fahter dist.
00088 sint32 fatherId= _Bones[i].FatherId;
00089 // if father exist and is not "always enabled"
00090 if(fatherId>=0 && _Bones[fatherId].LodDisableDistance!=0)
00091 {
00092 float fatherDist= _Bones[fatherId].LodDisableDistance;
00093 // I must disable me at least before my father (never after).
00094 if(_Bones[i].LodDisableDistance==0)
00095 _Bones[i].LodDisableDistance= fatherDist;
00096 else
00097 _Bones[i].LodDisableDistance= min(_Bones[i].LodDisableDistance, fatherDist);
00098 }
00099 }
00100
00101 // build Lod Information.
00102 //==============
00103 _Lods.clear();
00104
00105 // build all distances used.
00106 set<float> distSet;
00107 for(i=0;i<_Bones.size();i++)
00108 {
00109 float dist= _Bones[i].LodDisableDistance;
00110 // if lod enabled for this bone, add a new distance, or do nothing
00111 if(dist>0)
00112 distSet.insert(dist);
00113 }
00114
00115 // create a lod for each distance used + 1 (the "dist==0" distance).
00116 _Lods.resize(distSet.size() + 1);
00117 // create the default lod: all bones activated.
00118 _Lods[0].Distance=0;
00119 _Lods[0].ActiveBones.resize(_Bones.size(), 0xFF);
00120
00121 // For each lods not 0th.
00122 set<float>::iterator it= distSet.begin();
00123 for(uint j=1; j<_Lods.size(); j++, it++)
00124 {
00125 float lodDist= *it;
00126 // set the distance of activation
00127 _Lods[j].Distance= lodDist;
00128 // resize and default to all enabled.
00129 _Lods[j].ActiveBones.resize(_Bones.size(), 0xFF);
00130
00131 // Search what lod are to be disabled at this distance.
00132 for(i=0;i<_Bones.size();i++)
00133 {
00134 float dist= _Bones[i].LodDisableDistance;
00135 // if the dist of the lod is greater (or equal) to the disableDist of the bone,
00136 // and if the bone is not "always enabled", disable the bone
00137 if(lodDist>=dist && dist!=0 )
00138 _Lods[j].ActiveBones[i]= 0;
00139 }
00140
00141 }
00142
00143 }
|
|
||||||||||||
|
clip this skeleton.
Reimplemented from NL3D::IShape. Definition at line 216 of file skeleton_shape.cpp. References NLMISC::CBSphere::applyTransform(), NLMISC::CBSphere::Center, NLMISC::CAABBox::getCenter(), NLMISC::CAABBox::getRadius(), NLMISC::CBSphere::Radius, and sint.
00217 {
00218 // Speed Clip: clip just the sphere.
00219 CBSphere localSphere(_BBox.getCenter(), _BBox.getRadius());
00220 CBSphere worldSphere;
00221
00222 // transform the sphere in WorldMatrix (with nearly good scale info).
00223 localSphere.applyTransform(worldMatrix, worldSphere);
00224
00225 // if out of only plane, entirely out.
00226 for(sint i=0;i<(sint)pyramid.size();i++)
00227 {
00228 // We are sure that pyramid has normalized plane normals.
00229 // if SpherMax OUT return false.
00230 float d= pyramid[i]*worldSphere.Center;
00231 if(d>worldSphere.Radius)
00232 return false;
00233 }
00234
00235 return true;
00236 }
|
|
|
Create a CSkeletonModel, which contains bones.
Reimplemented from NL3D::IShape. Definition at line 154 of file skeleton_shape.cpp. References NL3D::CSkeletonModel::Bones, NL3D::CScene::createModel(), NL3D::CSkeletonModel::initBoneUsages(), NL3D::CTransform::setLoadBalancingGroup(), NL3D::CTransformShape::Shape, and sint.
00155 {
00156 // Create a CSkeletonModel, an instance of a mesh.
00157 //===============================================
00158 CSkeletonModel *sm= (CSkeletonModel*)scene.createModel(NL3D::SkeletonModelId);
00159 sm->Shape= this;
00160
00161 // setup bones.
00162 //=================
00163 sm->Bones.reserve(_Bones.size());
00164 for(sint i=0;i<(sint)_Bones.size();i++)
00165 {
00166 // Append a new bone.
00167 sm->Bones.push_back( CBone(&_Bones[i]) );
00168
00169 // Must set the Animatable father of the bone (the skeleton model!).
00170 sm->Bones[i].setFather(sm, CSkeletonModel::OwnerBit);
00171 }
00172
00173 // Must create and init skeleton bone usage to 0.
00174 sm->initBoneUsages();
00175
00176 // For skinning: setup skeleton in Skin LoadBalancing group
00177 sm->setLoadBalancingGroup("Skin");
00178
00179 return sm;
00180 }
|
|
||||||||||||
|
flush textures used by this shape.
Implements NL3D::IShape. Definition at line 110 of file skeleton_shape.h. References uint.
00110 {};
|
|
|
return the bounding box of the shape. Default is to return Null bbox. Reimplemented from NL3D::IShape. Definition at line 240 of file skeleton_shape.cpp.
00241 {
00242 bbox= _BBox;
00243 }
|
|
|
Return the id of a bone, from it's name. -1 if not present.
Definition at line 61 of file skeleton_shape.cpp. References sint32. Referenced by NL3D::CSkeletonModel::getBoneIdByName().
|
|
|
Implemented in NLAIAGENT::CNumericIndex, NLAIC::IPointerGestion, NLAIC::CIdentType, and CAutomataDesc. Referenced by NLMISC::CClassRegistry::checkObject(), and NL3D::GetTextureSize(). |
|
|
return the DistMax where the shape is no more displayed. Default is to return -1, meaning DistMax = infinite. Definition at line 112 of file shape.h.
00112 {return _DistMax;}
|
|
|
get lod information.
Definition at line 119 of file skeleton_shape.h. References uint. Referenced by NL3D::CSkeletonModel::traverseAnimDetail(), and NL3D::CSkeletonModel::updateBoneToCompute().
00119 {return _Lods[lod];}
|
|
|
retrieve the lod to use for a given distance (log(n)).
Definition at line 247 of file skeleton_shape.cpp. References uint. Referenced by NL3D::CSkeletonModel::traverseAnimDetail().
00248 {
00249 uint start=0;
00250 uint end= _Lods.size();
00251 // find lower_bound by dichotomy
00252 while(end-1>start)
00253 {
00254 uint pivot= (end+start)/2;
00255 // return the lower_bound, ie return first start with _Lods[pivot].Distance<=dist
00256 if(_Lods[pivot].Distance <= dist)
00257 start= pivot;
00258 else
00259 end= pivot;
00260 }
00261
00262 return start;
00263 }
|
|
|
Definition at line 120 of file skeleton_shape.h. References uint. Referenced by NL3D::CSkeletonModel::traverseAnimDetail(), and NL3D::CSkeletonModel::updateBoneToCompute().
00120 {return _Lods.size();}
|
|
|
get an approximation of the number of triangles this instance will render for a fixed distance.
Implements NL3D::IShape. Definition at line 208 of file skeleton_shape.cpp.
00209 {
00210 // No polygons
00211 return 0;
00212 }
|
|
|
Definition at line 70 of file smart_ptr.h. References NLMISC::CRefCount::crefs, and sint.
00071 {
00072 return crefs;
00073 }
|
|
|
clip this skeleton.
|
|
||||||||||||||||
|
Profiling. Called in RenderPass if Current Frame profiled. No-Op by default Informations must be added in rdrTrav->Scene Reimplemented in NL3D::CMesh, NL3D::CMeshMRM, NL3D::CMeshMRMSkinned, and NL3D::CMeshMultiLod. Definition at line 123 of file shape.h.
00123 {}
|
|
||||||||||||||||
|
render() this skeletonshape in a driver (no-op)
Implements NL3D::IShape. Definition at line 94 of file skeleton_shape.h.
00095 {
00096 }
|
|
|
Retrieve Bones Information. Definition at line 147 of file skeleton_shape.cpp.
00148 {
00149 bones= _Bones;
00150 }
|
|
|
serial this skeletonshape.
Implements NLMISC::IStreamable. Definition at line 183 of file skeleton_shape.cpp. References sint.
00184 {
00185 /*
00186 Version 1:
00187 - _Lods.
00188 */
00189 sint ver= f.serialVersion(1);
00190
00191 f.serialCont(_Bones);
00192 f.serialCont(_BoneMap);
00193
00194 if(ver>=1)
00195 f.serialCont(_Lods);
00196 else
00197 {
00198 // create a skeleton shape with bones activated all the time
00199 _Lods.resize(1);
00200 // create the default lod: all bones activated.
00201 _Lods[0].Distance=0;
00202 _Lods[0].ActiveBones.resize(_Bones.size(), 0xFF);
00203 }
00204 }
|
|
|
setup the DistMax where the shape is no more displayed. Take effect only for the next created instances. setting <0 means -1 and so means DistMax = infinite. Definition at line 66 of file shape.cpp. Referenced by NL3D::CFlareShape::CFlareShape().
|
|
||||||||||||
|
return !NULL if this shape can support MeshBlock rendering for a special instance. NB: Mesh Block render cannot occurs if the Mesh is Skinned/MeshMorphed. NB: Mesh Block render can occurs only in Opaque pass NB: Mesh block render can occurs only for CMeshBase meshes.
Reimplemented in NL3D::CMesh, NL3D::CMeshMRM, NL3D::CMeshMRMSkinned, and NL3D::CMeshMultiLod. Definition at line 158 of file shape.h.
00158 {return NULL;}
|
|
|
tells if the shape wants LocalAttenuation for RealTime lighting. Default is false Reimplemented in NL3D::CMeshBase. Definition at line 142 of file shape.h.
00142 {return false;}
|
|
|
Definition at line 67 of file smart_ptr.h. |
|
|
Definition at line 126 of file skeleton_shape.h. |
|
|
Definition at line 125 of file skeleton_shape.h. |
|
|
Definition at line 124 of file skeleton_shape.h. |
|
|
Default to -1.
|
|
|
Definition at line 128 of file skeleton_shape.h. |
|
|
Definition at line 79 of file smart_ptr.h. Referenced by NLMISC::CRefCount::CRefCount(), NLMISC::CRefCount::getRefCount(), and NLMISC::CRefCount::~CRefCount(). |
|
|
Referenced by NLMISC::CRefCount::CRefCount(). |
|
|
Definition at line 80 of file smart_ptr.h. Referenced by NLMISC::CRefCount::CRefCount(), and NLMISC::CRefCount::~CRefCount(). |
1.3.6