instance_group_user.h

Go to the documentation of this file.
00001 
00005 /* Copyright, 2001 Nevrax Ltd.
00006  *
00007  * This file is part of NEVRAX NEL.
00008  * NEVRAX NEL is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2, or (at your option)
00011  * any later version.
00012 
00013  * NEVRAX NEL is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * General Public License for more details.
00017 
00018  * You should have received a copy of the GNU General Public License
00019  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00020  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00021  * MA 02111-1307, USA.
00022  */
00023 
00024 #ifndef NL_INSTANCE_GROUP_USER_H
00025 #define NL_INSTANCE_GROUP_USER_H
00026 
00027 #include "nel/misc/types_nl.h"
00028 #include "nel/3d/u_instance_group.h"
00029 #include "nel/3d/scene_group.h"
00030 
00031 
00032 namespace NLMISC
00033 {
00034     class CVector;
00035     class CQuat;
00036 }
00037 
00038 namespace NL3D
00039 {
00040 
00041 class UScene;
00042 class UInstanceGroup;
00043 class CInstanceUser;
00044 
00052 class CInstanceGroupUser : public UInstanceGroup
00053 {
00054     /* ***********************************************
00055      *  WARNING: This Class/Method must be thread-safe (ctor/dtor/serial): no static access for instance
00056      *  It can be loaded/called through CAsyncFileManager for instance
00057      * ***********************************************/
00058 
00059 public:
00060     CInstanceGroupUser ();
00061     virtual ~CInstanceGroupUser ();
00062     // Init with a scene.
00063     //bool load (const std::string &instanceGroup);
00064 
00065     // Init without a scene
00066     bool init (const std::string &instanceGroup, bool async= false);
00067 
00068 private:
00069     // From UInstanceGroup
00070     void setTransformNameCallback (ITransformName *pTN);
00071     void setAddRemoveInstanceCallback(IAddRemoveInstance *callback);
00072     void setIGAddBeginCallback(IIGAddBegin *callback);
00073 
00074 
00075     void addToScene (class UScene& scene, UDriver *driver, uint selectedTexture);
00076     void addToScene (class CScene& scene, IDriver *driver, uint selectedTexture);
00077 
00078     void addToSceneAsync (class UScene& scene, UDriver *driver, uint selectedTexture);
00079     TState getAddToSceneState ();
00080     void stopAddToSceneAsync ();
00081 
00082     virtual UInstance       getInstance (uint instanceNb) const;
00083     virtual void            setDistMax(uint instance, float dist);
00084     virtual float           getDistMax(uint instance) const;
00085     virtual void            setCoarseMeshDist(uint instance, float dist);
00086     virtual float           getCoarseMeshDist(uint instance) const;
00087 
00088 
00089     void removeFromScene (class UScene& scene);
00090     uint getNumInstance () const;
00091     const std::string& getShapeName (uint instanceNb) const;
00092     const std::string& getInstanceName (uint instanceNb) const;
00093     virtual void                getInstanceMatrix(uint instanceNb, NLMISC::CMatrix &dest) const;
00094     const NLMISC::CVector& getInstancePos (uint instanceNb) const;
00095     const NLMISC::CQuat& getInstanceRot (uint instanceNb) const;
00096     const NLMISC::CVector& getInstanceScale (uint instanceNb) const;
00097     UInstance getByName (const std::string& name) const;
00098     sint      getIndexByName(const std::string &name) const;
00099 
00100 
00101     void setBlendShapeFactor (const std::string &bsName, float rFactor);
00102 
00103     void createRoot (UScene &scene);
00104     void setClusterSystemForInstances (UInstanceGroup *pClusterSystem);
00105     bool linkToParentCluster(UInstanceGroup *father);
00106     UInstanceGroup *getParentCluster() const;
00107     void getDynamicPortals (std::vector<std::string> &names);
00108     void setDynamicPortal (std::string& name, bool opened);
00109     bool getDynamicPortal (std::string& name);
00110 
00111 
00112     void setPos (const NLMISC::CVector &pos);
00113     void setRotQuat (const NLMISC::CQuat &q);
00114 
00115     bool getStaticLightSetup(NLMISC::CRGBA sunAmbient, uint retrieverIdentifier, sint surfaceId, const NLMISC::CVector &localPos,
00116         std::vector<CPointLightInfluence> &pointLightList, uint8 &sunContribution, NLMISC::CRGBA &localAmbient);
00117 
00118     NLMISC::CVector getPos ();
00119     NLMISC::CQuat   getRotQuat ();
00120 
00121     // The real instance group
00122     CInstanceGroup  _InstanceGroup;
00123     // For access through getInstance() and getByName()
00124     std::map<std::string,CTransformShape*>  _InstanceMap;
00125     // Async stuff
00126     TState _AddToSceneState;
00127     UScene *_AddToSceneTempScene;
00128     UDriver *_AddToSceneTempDriver;
00129 
00130     virtual void            freezeHRC();
00131     virtual void            unfreezeHRC();
00132 
00133     virtual void            displayDebugClusters(UDriver *drv, UTextContext *txtCtx);
00134 
00135     virtual bool            dontCastShadowForInterior(uint instance) const;
00136     virtual bool            dontCastShadowForExterior(uint instance) const;
00137 
00138     friend class CTransformUser;
00139     friend class CSceneUser;
00140 
00141     void        removeInstancesUser();
00142 
00143 public:
00144     // Debug purpose only.
00145     CInstanceGroup  &getInternalIG()
00146     {
00147         return _InstanceGroup;
00148     }
00149 };
00150 
00151 
00152 } // NL3D
00153 
00154 
00155 #endif // NL_INSTANCE_GROUP_USER_H
00156 
00157 /* End of instance_group_user.h */

Generated on Thu Jan 7 08:26:18 2010 for NeL by  doxygen 1.6.1