From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a02671.html | 4459 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 4459 insertions(+) create mode 100644 docs/doxygen/nel/a02671.html (limited to 'docs/doxygen/nel/a02671.html') diff --git a/docs/doxygen/nel/a02671.html b/docs/doxygen/nel/a02671.html new file mode 100644 index 00000000..186418cf --- /dev/null +++ b/docs/doxygen/nel/a02671.html @@ -0,0 +1,4459 @@ + + +NeL: NL3D::CInstanceGroup class Reference + + + +
+

NL3D::CInstanceGroup Class Reference

#include <scene_group.h> +

+


Detailed Description

+A CInstanceGroup is a group of mesh instance and so composed by +

+This class can initialize a scene and be serialized.

+

Author:
Matthieu Besson

+Nevrax France

+
Date:
2001
+ +

+ +

+Definition at line 70 of file scene_group.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

PointLight part

void buildPointLightList (const std::vector< CPointLightNamed > &pointLightList, std::vector< uint > &plRemap)
 Build the list of light. NB: sort by LightGroupName the array, and return index remap.

CIGSurfaceLight _IGSurfaceLight
 The object used to light dynamic models in town and buildings.

CPointLightNamedArray _PointLightArray
 Array of pointLights.

bool _RealTimeSunContribution
 RealTimeSunContribution. Used for ig_lighter and zone_ig_lighter.


Public Types

enum  { NumStaticLightPerInstance = 2 + }
 Should Never be changed. More...

typedef std::vector< CInstanceTInstanceArray
 A vector of instance.

enum  TState { StateNotAdded = 0, +StateAdding, +StateAdded, +StateError + }

Public Member Functions

void addCluster (CCluster *pCluster)
 To construct the cluster system by hand.

bool addToScene (CScene &scene, IDriver *driver=NULL, uint selectedTexture=0)
bool addToSceneAsync (CScene &scene, IDriver *driver=NULL, uint selectedTexture=0)
void build (const CVector &vGlobalPos, const TInstanceArray &array, const std::vector< CCluster > &Clusters, const std::vector< CPortal > &Portals, const std::vector< CPointLightNamed > &pointLightList, const CIGSurfaceLight::TRetrieverGridMap *retrieverGridMap=NULL, float igSurfaceLightCellSize=0)
void build (const CVector &vGlobalPos, const TInstanceArray &array, const std::vector< CCluster > &Clusters, const std::vector< CPortal > &Portals)
 CInstanceGroup ()
void createRoot (CScene &scene)
 Add all the instances to the scene.

void displayDebugClusters (IDriver *drv, class CTextContext *txtCtx)
void freezeHRC ()
 see CTransform::freezeHRC(). Do it for all instances (not clusters), and for the root of the IG.

TState getAddToSceneState ()
void getBlendShapes (std::set< std::string > &BlendShapeNames)
 Get all the blendshapes from an instance group.

bool getDynamicPortal (std::string &name)
 Get the state of a dynamic portal (true=opened, false=closed).

void getDynamicPortals (std::vector< std::string > &names)
 Get all dynamic portals of an instance group.

const NLMISC::CVectorgetGlobalPos () const
CInstancegetInstance (uint instanceNb)
const CInstancegetInstance (uint instanceNb) const
void getInstanceMatrix (uint instanceNb, NLMISC::CMatrix &dest) const
const std::string & getInstanceName (uint instanceNb) const
 Get the instance name.

const sint32 getInstanceParent (uint instanceNb) const
const NLMISC::CVectorgetInstancePos (uint instanceNb) const
 Get an instance position.

const NLMISC::CQuatgetInstanceRot (uint instanceNb) const
 Get an instance rotation.

const NLMISC::CVectorgetInstanceScale (uint instanceNb) const
void getLights (std::set< std::string > &LightNames)
 Get all lights (lightmaps) from an instance group.

uint getNumInstance () const
 Get number of instance in this group.

CInstanceGroupgetParentClusterSystem () const
CVector getPos ()
 Get the position of the IG.

CQuat getRotQuat ()
 Get the rotation of the IG.

void getShapeName (uint instanceIndex, std::string &shapeName) const
const std::string & getShapeName (uint instanceNb) const
 Get the name of the mesh referenced.

CTransformShapegetTransformShape (uint instanceNb) const
UInstanceGroupgetUserInterface () const
void linkRoot (CScene &scene, CTransform *father)
 link the root of the ig to a node. No-op if not added to scene. Pass NULL to reset by default

bool linkToParent (CInstanceGroup *pFather)
bool removeFromScene (CScene &scene)
 Remove all the instances from the scene.

void retrieve (CVector &vGlobalPos, TInstanceArray &array, std::vector< CCluster > &Clusters, std::vector< CPortal > &Portals, std::vector< CPointLightNamed > &pointLightList) const
void serial (NLMISC::IStream &f)
 Serial the group.

void setAddRemoveInstanceCallback (IAddRemoveInstance *callback)
 Set a callback to know when an instance has been added / removed.

void setBlendShapeFactor (const std::string &BlendShapeName, float rFactor)
 Set the blendshape factor for the whole instance group (-100 -> 100).

void setClusterSystemForInstances (CInstanceGroup *pIG)
 Set the cluster system to test for instances that are not in a cluster of this IG.

void setDynamicPortal (std::string &name, bool opened)
 Set the state of a dynamic portal (true=opened, false=closed).

void setIGAddBeginCallback (IIGAddBegin *callback)
 Set a callback to know when an instance group is being created, and how many instances it contains.

void setPos (const CVector &pos)
 Set the position of the IG.

void setRotQuat (const CQuat &quat)
 Set the rotation of the IG.

void setTransformNameCallback (ITransformName *pTN)
 Setup the callback in charge of changing name at the addToScene moment.

void setUserInterface (class UInstanceGroup *uig)
 User Interface related: yes it is ugly....

void stopAddToSceneAsync ()
void unfreezeHRC ()
 see CTransform::unfreezeHRC(). Do it for all instances (not clusters), and for the root of the IG.

 ~CInstanceGroup ()
RealTime lighting part
void enableRealTimeSunContribution (bool enable)
 Setuped at export, tells if the ig is touched by the sun. true by default.

const CIGSurfaceLightgetIGSurfaceLight () const
 Get the SurfaceLight info, for debug purposes.

uint getNumPointLights () const
 Get the number of point lights.

const std::vector< CPointLightNamed > & getPointLightList () const
 get the list of light. NB: the array is sorted by LightGroupName.

CPointLightNamedgetPointLightNamed (uint index)
 Get a mutable ref on a point light named.

bool getRealTimeSunContribution () const
 Setuped at export, tells if the ig is touched by the sun. true by default.

bool getStaticLightSetup (uint retrieverIdentifier, sint surfaceId, const CVector &localPos, std::vector< CPointLightInfluence > &pointLightList, uint8 &sunContribution, NLMISC::CRGBA &localAmbient)
 See CIGSurfaceLight::getStaticLightSetup().

void setPointLightFactor (const CScene &scene)
 set the Light factor for all pointLights "lightGroupName".


Data Fields

CClipTrav_ClipTrav
std::vector< CCluster_ClusterInfos
std::vector< CCluster * > _ClusterInstances
CInstanceGroup_ClusterSystemForInstances
NLMISC::CVector _GlobalPos
std::vector< CTransformShape * > _Instances
TInstanceArray _InstancesInfos
CInstanceGroup_ParentClusterSystem
std::vector< CPortal_Portals
CTransform_Root

Private Member Functions

bool addToSceneWhenAllShapesLoaded (CScene &scene, IDriver *driver, uint selectedTexture)

Private Attributes

IAddRemoveInstance_AddRemoveInstance
IIGAddBegin_IGAddBeginCallback
ITransformName_TransformName
UInstanceGroup_UserIg
Async loading part
bool _AddToSceneSignal
TState _AddToSceneState
IDriver_AddToSceneTempDriver
CScene_AddToSceneTempScene
uint _AddToSceneTempSelectTexture
+


Member Typedef Documentation

+

+ + + + +
+ + +
typedef std::vector<CInstance> NL3D::CInstanceGroup::TInstanceArray +
+
+ + + + + +
+   + + +

+A vector of instance. +

+ +

+Definition at line 140 of file scene_group.h. +

+Referenced by build(), and retrieve().

+


Member Enumeration Documentation

+

+ + + + +
+ + +
anonymous enum +
+
+ + + + + +
+   + + +

+Should Never be changed. +

+

Enumeration values:
+ + +
NumStaticLightPerInstance  +
+
+ +

+Definition at line 75 of file scene_group.h. +

+

+

+ + + + +
+ + +
enum NL3D::CInstanceGroup::TState +
+
+ + + + + +
+   + + +

+

Enumeration values:
+ + + + + +
StateNotAdded  +
StateAdding  +
StateAdded  +
StateError  +
+
+ +

+Definition at line 76 of file scene_group.h. +

+

+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + +
NL3D::CInstanceGroup::CInstanceGroup  ) 
+
+ + + + + +
+   + + +

+Construct, serialize and link to scene +

+Definition at line 245 of file scene_group.cpp. +

+References _AddRemoveInstance, _ClusterSystemForInstances, _GlobalPos, _IGAddBeginCallback, _IGSurfaceLight, _ParentClusterSystem, _RealTimeSunContribution, _TransformName, _UserIg, NL3D::CIGSurfaceLight::setOwner(), and StateNotAdded. +

+

00246 {
+00247         _IGSurfaceLight.setOwner(this);
+00248         _GlobalPos = CVector(0,0,0);
+00249         _Root = NULL;
+00250         _ClusterSystemForInstances = NULL;
+00251         _ParentClusterSystem = NULL;
+00252         _RealTimeSunContribution= true;
+00253         _AddToSceneState = StateNotAdded;
+00254         _TransformName = NULL;
+00255         _AddRemoveInstance = NULL;
+00256         _IGAddBeginCallback = NULL;
+00257         _UserIg= NULL;
+00258 }
+
+

+ + + + +
+ + + + + + + + + +
NL3D::CInstanceGroup::~CInstanceGroup  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 261 of file scene_group.cpp. +

+

00262 {
+00263 }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + +
void NL3D::CInstanceGroup::addCluster CCluster pCluster  ) 
+
+ + + + + +
+   + + +

+To construct the cluster system by hand. +

+Cluster/Portal system part +

+Definition at line 1050 of file scene_group.cpp. +

+References _ClusterInstances. +

+Referenced by NL3D::CScene::initDefaultRoots(). +

+

01051 {
+01052         _ClusterInstances.push_back(pCluster);
+01053 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
bool NL3D::CInstanceGroup::addToScene CScene scene,
IDriver driver = NULL,
uint  selectedTexture = 0
+
+ + + + + +
+   + + +

+Add all the instances to the scene. By default, freezeHRC() those instances and the root.

+

Parameters:
+ + + +
scene is the scene in which you want to add the instance group.
driver is a pointer to a driver. If this pointer is not NULL, the textures used by the shapes will be preloaded in this driver. If the pointer is NULL (default), textures will ve loaded when the shape will be used.
+
+ +

+Definition at line 503 of file scene_group.cpp. +

+References _IGAddBeginCallback, _InstancesInfos, _PointLightArray, addToSceneWhenAllShapesLoaded(), NL3D::CScene::createInstance(), getName(), getShapeName(), NL3D::CPointLightNamedArray::initAnimatedLightIndex(), nlwarning, NL3D::IIGAddBegin::startAddingIG(), uint, and uint32. +

+Referenced by NL3D::CInstanceGroupUser::addToScene(), and getAddToSceneState(). +

+

00504 {
+00505         // Init the scene lights
+00506         _PointLightArray.initAnimatedLightIndex (scene);
+00507 
+00508         uint32 i, j;
+00509 
+00510         // Test if portals are linked to their 2 clusters 
+00511         for (i = 0; i < _Portals.size(); ++i)
+00512         for (j = 0; j < 2; ++j)
+00513         {
+00514                 if (_Portals[i]._Clusters[j] == NULL)
+00515                 {
+00516                         nlwarning("Portal %d (name:%s) is not linked to 2 clusters. Instance Group Not Added To Scene.", i, _Portals[i].getName().c_str());
+00517                 }
+00518         }
+00519         
+00520         _Instances.resize (_InstancesInfos.size(), NULL);
+00521 
+00522         if (_IGAddBeginCallback)
+00523                 _IGAddBeginCallback->startAddingIG(_InstancesInfos.size());
+00524 
+00525         // Creation and positionning of the new instance
+00526 
+00527         vector<CInstance>::iterator it = _InstancesInfos.begin();
+00528 
+00529         for (i = 0; i < _InstancesInfos.size(); ++i, ++it)
+00530         {
+00531                 // Get the shape name
+00532                 string shapeName;
+00533                 getShapeName (i, shapeName);
+00534                 if (!shapeName.empty ())
+00535                 {
+00536                         if (!_InstancesInfos[i].DontAddToScene)
+00537                         {
+00538                                 _Instances[i] = scene.createInstance (shapeName);
+00539                                 if( _Instances[i] == NULL )
+00540                                 {
+00541                                         nlwarning("Not found '%s' file\n", shapeName.c_str());
+00542                                 }
+00543                         }
+00544                 }
+00545         }
+00546 
+00547         return addToSceneWhenAllShapesLoaded (scene, driver, selectedTexture);
+00548 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
bool NL3D::CInstanceGroup::addToSceneAsync CScene scene,
IDriver driver = NULL,
uint  selectedTexture = 0
+
+ + + + + +
+   + + +

+ +

+Definition at line 766 of file scene_group.cpp. +

+References _AddToSceneSignal, _AddToSceneTempSelectTexture, _IGAddBeginCallback, _InstancesInfos, _PointLightArray, _TransformName, NL3D::CInstanceGroup::CInstance::DontAddToScene, NL3D::CPointLightNamedArray::initAnimatedLightIndex(), NL3D::CInstanceGroup::CInstance::InstanceName, NL3D::CInstanceGroup::CInstance::Name, NL3D::CInstanceGroup::CInstance::Pos, NL3D::IIGAddBegin::startAddingIG(), StateAdding, NLMISC::strlwr(), NL3D::ITransformName::transformName(), uint, and uint32. +

+Referenced by NL3D::CInstanceGroupUser::addToSceneAsync(). +

+

00767 {
+00768         // Init the scene lights
+00769         _PointLightArray.initAnimatedLightIndex (scene);
+00770 
+00771         uint32 i;
+00772 
+00773         _AddToSceneState = StateAdding;
+00774         _AddToSceneTempScene = &scene;
+00775         _AddToSceneTempDriver = driver;
+00776         _AddToSceneTempSelectTexture = selectedTexture;
+00777 
+00778         _Instances.resize (_InstancesInfos.size(), NULL);
+00779 
+00780         if (_IGAddBeginCallback)
+00781                 _IGAddBeginCallback->startAddingIG(_InstancesInfos.size());
+00782 
+00783         // Creation and positionning of the new instance
+00784 
+00785         vector<CInstance>::iterator it = _InstancesInfos.begin();
+00786         set<string> allShapesToLoad;
+00787         _AddToSceneSignal = false;
+00788         bool loadAsyncStarted = false;
+00789         for (i = 0; i < _InstancesInfos.size(); ++i, ++it)
+00790         {
+00791                 CInstance &rInstanceInfo = *it;
+00792                 if (!rInstanceInfo.DontAddToScene)
+00793                 {
+00794                         string shapeName = rInstanceInfo.Name;
+00795                         if (_TransformName != NULL && !rInstanceInfo.InstanceName.empty())
+00796                         {                                                                                               
+00797                                 shapeName = _TransformName->transformName (i, rInstanceInfo.InstanceName, rInstanceInfo.Name);
+00798                         }
+00799                         
+00800                         shapeName = strlwr (shapeName);
+00801 
+00802                         if (!shapeName.empty() && shapeName.find('.') == std::string::npos)
+00803                                 shapeName += ".shape";
+00804                         
+00805 
+00806                         if (allShapesToLoad.find(shapeName) == allShapesToLoad.end())
+00807                         {
+00808                                 allShapesToLoad.insert (shapeName);
+00809                                 if (scene.getShapeBank()->isPresent(shapeName) != CShapeBank::Present)
+00810                                 {
+00811                                         // Load it from file asynchronously
+00812                                         scene.getShapeBank()->loadAsync (shapeName, scene.getDriver(), rInstanceInfo.Pos, &_AddToSceneSignal, selectedTexture);
+00813                                         loadAsyncStarted = true;
+00814                                 }
+00815                         }
+00816                 }
+00817         }
+00818         if (!loadAsyncStarted)
+00819                 _AddToSceneSignal = true;
+00820         else
+00821                 _AddToSceneSignal = false;
+00822         //CAsyncFileManager::getInstance().signal (&_AddToSceneSignal);
+00823 
+00824         return true;
+00825 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
bool NL3D::CInstanceGroup::addToSceneWhenAllShapesLoaded CScene scene,
IDriver driver,
uint  selectedTexture
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 571 of file scene_group.cpp. +

+References _AddRemoveInstance, _ClipTrav, _ClusterInfos, _ClusterInstances, _ClusterSystemForInstances, _InstancesInfos, _PointLightArray, NL3D::CClipTrav::Accel, NL3D::CScene::addInstanceGroupForLightAnimation(), NL3D::ClusterId, NL3D::CScene::createModel(), createRoot(), NL3D::CInstanceGroup::CInstance::DontAddToScene, NL3D::CQuadGrid< CCluster * >::erase(), NL3D::CTransform::freeze(), freezeHRC(), NL3D::CScene::getClipTrav(), NL3D::CScene::getGlobalInstanceGroup(), NL3D::CScene::getHrcTrav(), NL3D::ITransformable::getMatrix(), NL3D::CPointLightNamedArray::getPointLights(), NL3D::CScene::getRoot(), NL3D::CTransform::hrcLinkSon(), NL3D::IAddRemoveInstance::instanceGroupAdded(), NL3D::CInstanceGroup::CInstance::Light, linkToParent(), NL3D::CInstanceGroup::CInstance::LocalAmbientId, min, NL3D_MAX_LIGHT_CONTRIBUTION, NL3D::CInstanceGroup::CInstance::nParent, NL3D::CInstanceGroup::CInstance::Pos, NL3D::CClipTrav::registerCluster(), NL3D::CInstanceGroup::CInstance::Rot, NL3D::CInstanceGroup::CInstance::Scale, NL3D::CPortal::setWorldMatrix(), sint32, StateAdded, NL3D::CInstanceGroup::CInstance::StaticLightEnabled, NL3D::CInstanceGroup::CInstance::SunContribution, uint, and uint32. +

+Referenced by addToScene(). +

+

00572 {
+00573         uint32 i, j;
+00574 
+00575         vector<CInstance>::iterator it = _InstancesInfos.begin();
+00576         for (i = 0; i < _InstancesInfos.size(); ++i, ++it)
+00577         {
+00578                 CInstance &rInstanceInfo = *it;
+00579 
+00580                 if (!rInstanceInfo.DontAddToScene)
+00581                 {
+00582                         if (_Instances[i])
+00583                         {
+00584                                 _Instances[i]->setPos (rInstanceInfo.Pos);
+00585                                 _Instances[i]->setRotQuat (rInstanceInfo.Rot);
+00586                                 _Instances[i]->setScale (rInstanceInfo.Scale);
+00587                                 _Instances[i]->setPivot (CVector::Null);
+00588 
+00589                                 // Static Light Setup
+00590                                 if( rInstanceInfo.StaticLightEnabled )
+00591                                 {
+00592                                         // Count lights.
+00593                                         uint numPointLights;
+00594                                         for(numPointLights= 0; numPointLights<CInstanceGroup::NumStaticLightPerInstance; numPointLights++)
+00595                                         {
+00596                                                 if(rInstanceInfo.Light[numPointLights]==0xFF)
+00597                                                         break;
+00598                                         }
+00599                                         // Max allowed.
+00600                                         numPointLights= min(numPointLights, (uint)NL3D_MAX_LIGHT_CONTRIBUTION);
+00601 
+00602                                         // Get pl ptrs.
+00603                                         CPointLight             *pls[CInstanceGroup::NumStaticLightPerInstance];
+00604                                         for(uint j=0; j<numPointLights;j++)
+00605                                         {
+00606                                                 uint    plId= rInstanceInfo.Light[j];
+00607                                                 pls[j]= (CPointLight*)(&_PointLightArray.getPointLights()[plId]);
+00608                                         }
+00609 
+00610                                         // get frozenAmbientlight.
+00611                                         CPointLight *frozenAmbientlight;
+00612                                         if(rInstanceInfo.LocalAmbientId == 0xFF)
+00613                                                 // must take the sun one.
+00614                                                 frozenAmbientlight= NULL;
+00615                                         else
+00616                                                 // ok, take the local ambient one.
+00617                                                 frozenAmbientlight= (CPointLight*)(&_PointLightArray.getPointLights()[rInstanceInfo.LocalAmbientId]);
+00618 
+00619                                         // Setup the instance.
+00620                                         _Instances[i]->freezeStaticLightSetup(pls, numPointLights, rInstanceInfo.SunContribution, frozenAmbientlight);
+00621                                 }
+00622 
+00623                                 // Driver not NULL ?
+00624                                 if (driver)
+00625                                 {
+00626                                         // Flush shape's texture with this driver
+00627                                         _Instances[i]->Shape->flushTextures (*driver, selectedTexture);
+00628                                 }
+00629                         }
+00630                 }
+00631                 else
+00632                 {
+00633                         _Instances[i] = NULL;
+00634                 }
+00635         }
+00636 
+00637         // Setup the hierarchy
+00638         // We just have to set the traversal HRC (Hierarchy)
+00639         CHrcTrav        &hrcTrav = scene.getHrcTrav();
+00640 
+00641         if (_Root == NULL)
+00642         {
+00643                 createRoot (scene);
+00644         }
+00645         it = _InstancesInfos.begin();
+00646         for (i = 0; i < _InstancesInfos.size(); ++i, ++it)
+00647         if (!_InstancesInfos[i].DontAddToScene && _Instances[i] != NULL)
+00648         {
+00649                 CInstance &rInstanceInfo = *it;
+00650                 if( rInstanceInfo.nParent != -1 ) // Is the instance get a parent
+00651                         _Instances[rInstanceInfo.nParent]->hrcLinkSon( _Instances[i] );
+00652                 else
+00653                         _Root->hrcLinkSon( _Instances[i] );
+00654         }
+00655         // Attach the root of the instance group to the root of the hierarchy traversal
+00656         scene.getRoot()->hrcLinkSon( _Root );
+00657 
+00658         // Cluster / Portals
+00659         // -----------------
+00660 
+00661         CClipTrav *pClipTrav = &scene.getClipTrav();
+00662         _ClipTrav = pClipTrav;
+00663 
+00664         // Create the MOT links (create the physical clusters)
+00665         _ClusterInstances.resize (_ClusterInfos.size());
+00666         for (i = 0; i < _ClusterInstances.size(); ++i)
+00667         {
+00668                 _ClusterInstances[i] = (CCluster*)scene.createModel (ClusterId);
+00669                 _ClusterInstances[i]->Group = this;
+00670                 _ClusterInstances[i]->_Portals = _ClusterInfos[i]._Portals;
+00671                 _ClusterInstances[i]->_LocalVolume = _ClusterInfos[i]._LocalVolume;
+00672                 _ClusterInstances[i]->_LocalBBox = _ClusterInfos[i]._LocalBBox;
+00673                 _ClusterInstances[i]->_Volume = _ClusterInfos[i]._Volume;
+00674                 _ClusterInstances[i]->_BBox = _ClusterInfos[i]._BBox;
+00675                 _ClusterInstances[i]->FatherVisible = _ClusterInfos[i].FatherVisible;
+00676                 _ClusterInstances[i]->VisibleFromFather = _ClusterInfos[i].VisibleFromFather;
+00677                 _ClusterInstances[i]->FatherAudible = _ClusterInfos[i].FatherAudible;
+00678                 _ClusterInstances[i]->AudibleFromFather = _ClusterInfos[i].AudibleFromFather;
+00679                 _ClusterInstances[i]->Name = _ClusterInfos[i].Name;
+00680                 _ClusterInstances[i]->setSoundGroup(_ClusterInfos[i].getSoundGroup());
+00681                 _ClusterInstances[i]->setEnvironmentFx(_ClusterInfos[i].getEnvironmentFx());
+00682                 pClipTrav->registerCluster (_ClusterInstances[i]);
+00683                 _ClusterInstances[i]->clipUnlinkFromAll();
+00684         }
+00685 
+00686         // Relink portals with newly created clusters
+00687         for (i = 0; i < _Portals.size(); ++i)
+00688         for (j = 0; j < 2; ++j)
+00689         {
+00690                 if (_Portals[i]._Clusters[j])
+00691                 {
+00692                         sint32 nClusterNb;
+00693                         nClusterNb = (_Portals[i]._Clusters[j] - &_ClusterInfos[0]);
+00694                         _Portals[i]._Clusters[j] = _ClusterInstances[nClusterNb];
+00695                 }
+00696         }
+00697 
+00698         // Link shapes to clusters
+00699         for (i = 0; i < _Instances.size(); ++i)
+00700         if (_Instances[i] != NULL && !_InstancesInfos[i].DontAddToScene)
+00701         {
+00702                 if (_InstancesInfos[i].Clusters.size() > 0)
+00703                 {
+00704                         _Instances[i]->clipUnlinkFromAll();
+00705                         for (j = 0; j < _InstancesInfos[i].Clusters.size(); ++j)
+00706                                 _ClusterInstances[_InstancesInfos[i].Clusters[j]]->clipAddChild( _Instances[i] );
+00707                         // For the first time we have to set all the instances to NOT move (and not be rebinded)
+00708                         _Instances[i]->freeze();
+00709                         _Instances[i]->setClusterSystem (this);
+00710                 }
+00711                 else
+00712                 {
+00713                         // These instances are not attached to a cluster at this level so we cannot freeze them
+00714                         // Moreover we must set their clustersystem they will be tested against
+00715                         _Instances[i]->setClusterSystem (_ClusterSystemForInstances);
+00716                 }
+00717         }
+00718         _Root->freeze();
+00719 
+00720         // HRC OBS like
+00721         for (i = 0; i < _ClusterInstances.size(); ++i)
+00722         {
+00723                 _ClusterInstances[i]->setWorldMatrix (_Root->getMatrix());
+00724 
+00725                 for (j = 0; j < _ClusterInstances[i]->getNbPortals(); ++j)
+00726                 {
+00727                         CPortal *pPortal = _ClusterInstances[i]->getPortal(j);
+00728                         pPortal->setWorldMatrix (_Root->getMatrix());
+00729                 }
+00730 
+00731                 // Re affect the cluster to the accelerator if not the root
+00732                 if (!_ClusterInstances[i]->isRoot())
+00733                 {
+00734                         _ClipTrav->Accel.erase (_ClusterInstances[i]->AccelIt);
+00735                         _ClipTrav->registerCluster (_ClusterInstances[i]);
+00736                 }
+00737         }
+00738 
+00739 
+00740         // Link the instance group to the parent
+00741         linkToParent (scene.getGlobalInstanceGroup());
+00742 
+00743         // Attach the clusters to the root of the instance group
+00744         for (i = 0; i < _ClusterInstances.size(); ++i)
+00745                 _Root->hrcLinkSon( _ClusterInstances[i] );
+00746 
+00747 
+00748         // Default: freezeHRC all instances.
+00749         freezeHRC();
+00750 
+00751 
+00752         // Register the instanceGroup for light animation
+00753         // -----------------
+00754         // If some PointLight to animate
+00755         if(_PointLightArray.getPointLights().size() > 0)
+00756                 scene.addInstanceGroupForLightAnimation(this);
+00757 
+00758         _AddToSceneState = StateAdded;
+00759 
+00760         if (_AddRemoveInstance)
+00761                 _AddRemoveInstance->instanceGroupAdded();
+00762         return true;
+00763 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CInstanceGroup::build const CVector vGlobalPos,
const TInstanceArray array,
const std::vector< CCluster > &  Clusters,
const std::vector< CPortal > &  Portals,
const std::vector< CPointLightNamed > &  pointLightList,
const CIGSurfaceLight::TRetrieverGridMap retrieverGridMap = NULL,
float  igSurfaceLightCellSize = 0
+
+ + + + + +
+   + + +

+Build the group Build also the list of light. NB: sort by LightGroupName the array. Give also a ptr on a retrieverGridMap to build surfaces (if not NULL). +

+Definition at line 266 of file scene_group.cpp. +

+References _ClusterInfos, _GlobalPos, _IGSurfaceLight, _InstancesInfos, NL3D::CIGSurfaceLight::build(), buildPointLightList(), NL3D::CIGSurfaceLight::clear(), TInstanceArray, NL3D::CIGSurfaceLight::TRetrieverGridMap, and uint32. +

+

00272 {
+00273         _GlobalPos = vGlobalPos;
+00274         // Copy the array
+00275         _InstancesInfos = array;
+00276 
+00277         _Portals = Portals;
+00278         _ClusterInfos = Clusters;
+00279 
+00280         // Link portals and clusters
+00281         uint32 i, j, k;
+00282         for (i = 0; i < _Portals.size(); ++i)
+00283         {
+00284                 for (j = 0; j < _ClusterInfos.size(); ++j)
+00285                 {
+00286                         bool bPortalInCluster = true;
+00287                         for (k = 0; k < _Portals[i]._Poly.size(); ++k)
+00288                                 if (!_ClusterInfos[j].isIn (_Portals[i]._Poly[k]) )
+00289                                 {
+00290                                         bPortalInCluster = false;
+00291                                         break;
+00292                                 }
+00293                         if (bPortalInCluster)
+00294                         {                               
+00295                                 _Portals[i].setCluster(&_ClusterInfos[j]);
+00296                                 _ClusterInfos[j].link (&_Portals[i]);
+00297                         }
+00298                 }
+00299         }
+00300 
+00301         // Create Meta Cluster if needed
+00302         /*
+00303         CCluster clusterTemp;
+00304         bool mustAdd = false;
+00305         for (i = 0; i < _Portals.size(); ++i)
+00306         if (_Portals[i].getNbCluster() == 1)
+00307         {
+00308                 mustAdd = true;
+00309                 break;
+00310         }
+00311         if (mustAdd)
+00312         {
+00313                 CCluster clusterTemp;
+00314                 _ClusterInfos.push_back(clusterTemp);
+00315                 CCluster *pMetaCluster = &_ClusterInfos[_ClusterInfos.size()-1];
+00316                 pMetaCluster->setMetaCluster();
+00317                 for (i = 0; i < _Portals.size(); ++i)
+00318                 if (_Portals[i].getNbCluster() == 1)
+00319                 {
+00320                         _Portals[i].setCluster(pMetaCluster);
+00321                         pMetaCluster->link(&_Portals[i]);
+00322                 }
+00323         }*/
+00324 
+00325 
+00326         // Build the list of light. NB: sort by LightGroupName the array.
+00327         std::vector<uint>       plRemap;
+00328         buildPointLightList(pointLightList, plRemap);
+00329 
+00330         // Build IgSurfaceLight
+00331         // clear
+00332         _IGSurfaceLight.clear();
+00333         if(retrieverGridMap)
+00334         {
+00335                 //build
+00336                 _IGSurfaceLight.build(*retrieverGridMap, igSurfaceLightCellSize, plRemap);
+00337         }
+00338 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CInstanceGroup::build const CVector vGlobalPos,
const TInstanceArray array,
const std::vector< CCluster > &  Clusters,
const std::vector< CPortal > &  Portals
+
+ + + + + +
+   + + +

+Build the group Build with an empty list of light +

+Definition at line 342 of file scene_group.cpp. +

+References TInstanceArray. +

+Referenced by NL3D::CInstanceLighter::light(). +

+

00345 {
+00346         // empty pointLightList
+00347         std::vector<CPointLightNamed> pointLightList;
+00348 
+00349         build(vGlobalPos, array, Clusters, Portals, pointLightList);
+00350 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CInstanceGroup::buildPointLightList const std::vector< CPointLightNamed > &  pointLightList,
std::vector< uint > &  plRemap
[private]
+
+ + + + + +
+   + + +

+Build the list of light. NB: sort by LightGroupName the array, and return index remap. +

+ +

+Definition at line 1165 of file scene_group.cpp. +

+References _InstancesInfos, _PointLightArray, NL3D::CPointLightNamedArray::build(), NL3D::CPointLightNamedArray::getPointLights(), NL3D::CInstanceGroup::CInstance::Light, NL3D::CInstanceGroup::CInstance::LocalAmbientId, nlassert, NL3D::CInstanceGroup::CInstance::StaticLightEnabled, and uint. +

+Referenced by build(). +

+

01167 {
+01168         // build.
+01169         _PointLightArray.build(pointLightList, plRemap);
+01170 
+01171         // remap Instance precalc lighted.
+01172         for(uint i=0; i<_InstancesInfos.size(); i++)
+01173         {
+01174                 CInstance       &inst= _InstancesInfos[i];
+01175                 // If the instance has no precomputed lighting, skip
+01176                 if(!inst.StaticLightEnabled)
+01177                         continue;
+01178 
+01179                 // remap pointlights
+01180                 for(uint l=0; l<CInstanceGroup::NumStaticLightPerInstance; l++)
+01181                 {
+01182                         // If NULL light, break and continue to next instance
+01183                         if(inst.Light[l]== 0xFF)
+01184                                 break;
+01185                         else
+01186                         {
+01187                                 // Check good index.
+01188                                 nlassert(inst.Light[l] < _PointLightArray.getPointLights().size());
+01189                                 // Remap index, because of light sorting.
+01190                                 inst.Light[l]= plRemap[inst.Light[l]];
+01191                         }
+01192                 }
+01193 
+01194                 // remap ambient light
+01195                 if(inst.LocalAmbientId!=0xFF)
+01196                 {
+01197                         nlassert(inst.LocalAmbientId < _PointLightArray.getPointLights().size());
+01198                         inst.LocalAmbientId= plRemap[inst.LocalAmbientId];
+01199                 }
+01200         }
+01201 
+01202 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CInstanceGroup::createRoot CScene scene  ) 
+
+ + + + + +
+   + + +

+Add all the instances to the scene. +

+ +

+Definition at line 476 of file scene_group.cpp. +

+References NL3D::CScene::createModel(), NL3D::CTransform::setDontUnfreezeChildren(), setPos(), and NL3D::TransformId. +

+Referenced by addToSceneWhenAllShapesLoaded(), and NL3D::CInstanceGroupUser::createRoot(). +

+

00477 {
+00478         _Root = (CTransform*)scene.createModel (TransformId);
+00479         _Root->setDontUnfreezeChildren (true);
+00480         setPos (CVector(0,0,0));
+00481 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CInstanceGroup::displayDebugClusters IDriver drv,
class CTextContext txtCtx
+
+ + + + + +
+   + + +

+For Debug Display of clusters. The view matrix and frustum should have been setuped NB: the ModelMatrix is modified by this method +

+Definition at line 1224 of file scene_group.cpp. +

+References NL3D::CCluster::_BBox, _ClusterInstances, NL3D::CCluster::_Portals, NL3D::CCluster::_Volume, NL3D::IDriver::activeVertexBuffer(), NL3D::CPrimitiveBlock::addLine(), NL3D::CPrimitiveBlock::addTri(), NLMISC::CPolygon::clip(), NLMISC::CAABBox::getCenter(), NLMISC::CPlane::getNormal(), NLMISC::CAABBox::getRadius(), NL3D::IDriver::getViewMatrix(), NL3D::CMaterial::initUnlit(), NLMISC::CMatrix::inverted(), NL3D::CCluster::Name, NLMISC::CMatrix::normalize(), NLMISC::CPlane::normalize(), NLMISC::CPlane::project(), NL3D::IDriver::render(), NL3D::CComputedString::render3D(), NL3D::CPrimitiveBlock::reserveLine(), NL3D::CPrimitiveBlock::reserveTri(), s, NLMISC::CMatrix::scale(), NL3D::CMaterial::setBlend(), NL3D::CMaterial::setBlendFunc(), NL3D::CMaterial::setColor(), NL3D::CMaterial::setDoubleSided(), NL3D::CPrimitiveBlock::setNumLine(), NL3D::CPrimitiveBlock::setNumTri(), NL3D::CVertexBuffer::setNumVertices(), NLMISC::CMatrix::setPos(), NLMISC::CMatrix::setRot(), NL3D::IDriver::setupModelMatrix(), NL3D::CVertexBuffer::setVertexCoord(), NL3D::CVertexBuffer::setVertexFormat(), NL3D::CMaterial::setZFunc(), NL3D::CMaterial::setZWrite(), uint, NLMISC::CPolygon::Vertices, and NLMISC::CVector::y. +

+Referenced by NL3D::CInstanceGroupUser::displayDebugClusters(). +

+

01225 {
+01226         uint    opacity= 50;
+01227         CRGBA   colorCluster(255, 128, 255, opacity);
+01228         // portals are drawn twice
+01229         CRGBA   colorPortal(128, 255, 128, opacity/2);
+01230 
+01231         CMaterial               clusterMat;
+01232         CMaterial               portalMat;
+01233         CMaterial               lineMat;
+01234         clusterMat.initUnlit();
+01235         clusterMat.setBlend(true);
+01236         clusterMat.setBlendFunc(CMaterial::srcalpha, CMaterial::invsrcalpha);
+01237         clusterMat.setZWrite(false);
+01238         clusterMat.setDoubleSided(true);
+01239         clusterMat.setColor(colorCluster);
+01240         portalMat.initUnlit();
+01241         portalMat.setBlend(true);
+01242         portalMat.setBlendFunc(CMaterial::srcalpha, CMaterial::invsrcalpha);
+01243         portalMat.setZWrite(false);
+01244         portalMat.setDoubleSided(true);
+01245         portalMat.setColor(colorPortal);
+01246         lineMat.initUnlit();
+01247         lineMat.setBlend(true);
+01248         lineMat.setBlendFunc(CMaterial::srcalpha, CMaterial::invsrcalpha);
+01249         lineMat.setZWrite(false);
+01250         lineMat.setDoubleSided(true);
+01251         lineMat.setColor(CRGBA(0,0,0,opacity));
+01252         
+01253 
+01254         // The geometry for each cluster
+01255         CVertexBuffer   vb;
+01256         // too big cluster won't be rendered
+01257         const uint      maxVertices= 10000;
+01258         vb.setVertexFormat(CVertexBuffer::PositionFlag);
+01259         vb.setNumVertices(maxVertices);
+01260         CPrimitiveBlock         clusterTriangles;
+01261         CPrimitiveBlock         clusterLines;
+01262         CPrimitiveBlock         portalTriangles;
+01263         CPrimitiveBlock         portalLines;
+01264         clusterTriangles.reserveTri(maxVertices);
+01265         clusterLines.reserveLine(maxVertices);
+01266         portalTriangles.reserveTri(maxVertices);
+01267         portalLines.reserveLine(maxVertices);
+01268         
+01269         // setup identity matrix
+01270         drv->setupModelMatrix(CMatrix::Identity);
+01271 
+01272         // For all clusters
+01273         uint    i;
+01274         for(i=0;i<_ClusterInstances.size();i++)
+01275         {
+01276                 CCluster        *cluster= _ClusterInstances[i];
+01277                 if(cluster)
+01278                 {
+01279                         uint    numTotalVertices= 0;
+01280 
+01281                         // **** Build a set of polys representing the volume (slow but debug!)
+01282                         static  std::vector<CPolygon>   polygons;
+01283                         polygons.clear();
+01284                         polygons.resize(cluster->_Volume.size());
+01285                         // for each plane, build the associated polygon
+01286                         uint    j;
+01287                         for(j=0;j<polygons.size();j++)
+01288                         {
+01289                                 // Start with a big quad centered on bbox center
+01290                                 CPlane  p= cluster->_Volume[j];
+01291                                 p.normalize();
+01292                                 CVector quadCenter= p.project(cluster->_BBox.getCenter());
+01293 
+01294                                 // choose a basis on this plane
+01295                                 CMatrix         mat;
+01296                                 if( fabs(p.getNormal().y)>0.9 )
+01297                                         mat.setRot(CVector::K, CVector::I, p.getNormal());
+01298                                 else
+01299                                         mat.setRot(CVector::I, CVector::J, p.getNormal());
+01300                                 mat.normalize(CMatrix::ZYX);
+01301                                 mat.setPos(quadCenter);
+01302 
+01303                                 // Build the initial Big quad
+01304                                 CPolygon        &poly= polygons[j];
+01305                                 poly.Vertices.resize(4);
+01306                                 float   s= 10 * cluster->_BBox.getRadius();
+01307                                 poly.Vertices[0]= mat * CVector(-s,-s,0);
+01308                                 poly.Vertices[1]= mat * CVector(s,-s,0);
+01309                                 poly.Vertices[2]= mat * CVector(s,s,0);
+01310                                 poly.Vertices[3]= mat * CVector(-s,s,0);
+01311 
+01312                                 // clip this poly against all the other (ie not me) planes
+01313                                 // This make this algo O(N2) but this is for debug....
+01314                                 for(uint k=0;k<cluster->_Volume.size();k++)
+01315                                 {
+01316                                         if(j!=k)
+01317                                         {
+01318                                                 poly.clip(&cluster->_Volume[k], 1);
+01319                                         }
+01320                                 }
+01321 
+01322                                 // count the number of vertices / triangles / lines to add
+01323                                 if(poly.Vertices.size()>=3)
+01324                                 {
+01325                                         numTotalVertices+= poly.Vertices.size();
+01326                                 }
+01327                         }
+01328 
+01329                         // **** count the number of portals vertices
+01330                         for(j=0;j<cluster->_Portals.size();j++)
+01331                         {
+01332                                 numTotalVertices+= cluster->_Portals[j]->_Poly.size();
+01333                         }
+01334 
+01335                         // **** Draw those cluster polygons, and portals
+01336                         // too big clusters won't be rendered
+01337                         if(numTotalVertices<=maxVertices)
+01338                         {
+01339                                 uint    iVert= 0;
+01340                                 uint    j;
+01341 
+01342                                 // build the cluster geometry
+01343                                 clusterTriangles.setNumTri(0);
+01344                                 clusterLines.setNumLine(0);
+01345                                 for(j=0;j<polygons.size();j++)
+01346                                 {
+01347                                         CPolygon        &poly= polygons[j];
+01348                                         if(poly.Vertices.size()>=3)
+01349                                         {
+01350                                                 uint    k;
+01351                                                 // add the vertices
+01352                                                 for(k=0;k<poly.Vertices.size();k++)
+01353                                                         vb.setVertexCoord(iVert+k, poly.Vertices[k]);
+01354 
+01355                                                 // add the triangles
+01356                                                 for(k=0;k<poly.Vertices.size()-2;k++)
+01357                                                         clusterTriangles.addTri(iVert+0, iVert+k+1, iVert+k+2);
+01358 
+01359                                                 // add the lines
+01360                                                 for(k=0;k<poly.Vertices.size();k++)
+01361                                                         clusterLines.addLine(iVert+k, iVert+ ((k+1)%poly.Vertices.size()) );
+01362 
+01363                                                 iVert+= poly.Vertices.size();
+01364                                         }
+01365                                 }
+01366 
+01367                                 // build the portal geometry
+01368                                 portalTriangles.setNumTri(0);
+01369                                 portalLines.setNumLine(0);
+01370                                         for(j=0;j<cluster->_Portals.size();j++)
+01371                                 {
+01372                                         std::vector<CVector>    &portalVerts= cluster->_Portals[j]->_Poly;
+01373                                         if(portalVerts.size()>=3)
+01374                                         {
+01375                                                 uint    k;
+01376                                                 // add the vertices
+01377                                                 for(k=0;k<portalVerts.size();k++)
+01378                                                         vb.setVertexCoord(iVert+k, portalVerts[k]);
+01379                                                 
+01380                                                 // add the triangles
+01381                                                 for(k=0;k<portalVerts.size()-2;k++)
+01382                                                         portalTriangles.addTri(iVert+0, iVert+k+1, iVert+k+2);
+01383                                                 
+01384                                                 // add the lines
+01385                                                 for(k=0;k<portalVerts.size();k++)
+01386                                                         portalLines.addLine(iVert+k, iVert+ ((k+1)%portalVerts.size()) );
+01387                                                 
+01388                                                 iVert+= portalVerts.size();
+01389                                         }
+01390                                 }
+01391                                 
+01392                                 // render 2 pass with or without ZBuffer (for clearness)
+01393                                 for(uint pass=0;pass<2;pass++)
+01394                                 {
+01395                                         if(pass==0)
+01396                                         {
+01397                                                 clusterMat.setZFunc(CMaterial::always);
+01398                                                 portalMat.setZFunc(CMaterial::always);
+01399                                                 lineMat.setZFunc(CMaterial::always);
+01400                                         }
+01401                                         else
+01402                                         {
+01403                                                 clusterMat.setZFunc(CMaterial::lessequal);
+01404                                                 portalMat.setZFunc(CMaterial::lessequal);
+01405                                                 lineMat.setZFunc(CMaterial::lessequal);
+01406                                         }
+01407 
+01408                                         drv->activeVertexBuffer(vb);
+01409                                         drv->render(clusterTriangles, clusterMat);
+01410                                         drv->render(clusterLines, lineMat);
+01411                                         drv->render(portalTriangles, portalMat);
+01412                                         drv->render(portalLines, lineMat);
+01413                                 }
+01414                         }
+01415 
+01416                 }
+01417         }
+01418 
+01419         // **** For all clusters, Draw the cluster name at center of the cluster
+01420         if(txtCtx)
+01421         {
+01422                 CComputedString computedStr;
+01423 
+01424                 // bkup fontSize
+01425                 uint            bkFontSize;
+01426                 CMatrix         fontMatrix;
+01427                 bkFontSize= txtCtx->getFontSize();
+01428                 // to be readable
+01429                 txtCtx->setFontSize(24);
+01430 
+01431                 // the font matrix
+01432                 fontMatrix.setRot(drv->getViewMatrix().inverted());
+01433                 fontMatrix.normalize(CMatrix::YZX);
+01434                 fontMatrix.scale(10);
+01435 
+01436                 // parse all clusters
+01437                 for(i=0;i<_ClusterInstances.size();i++)
+01438                 {
+01439                         CCluster        *cluster= _ClusterInstances[i];
+01440                         if(cluster)
+01441                         {
+01442                                 fontMatrix.setPos(cluster->_BBox.getCenter());
+01443                                 txtCtx->computeString(cluster->Name, computedStr);
+01444                                 computedStr.render3D(*drv, fontMatrix);
+01445                         }
+01446                 }
+01447 
+01448                 // restore fontsize
+01449                 txtCtx->setFontSize(bkFontSize);
+01450         }
+01451 
+01452 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CInstanceGroup::enableRealTimeSunContribution bool  enable  ) 
+
+ + + + + +
+   + + +

+Setuped at export, tells if the ig is touched by the sun. true by default. +

+ +

+Definition at line 1212 of file scene_group.cpp. +

+References _RealTimeSunContribution. +

+

01213 {
+01214         _RealTimeSunContribution= enable;
+01215 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CInstanceGroup::freezeHRC  ) 
+
+ + + + + +
+   + + +

+see CTransform::freezeHRC(). Do it for all instances (not clusters), and for the root of the IG. +

+ +

+Definition at line 1132 of file scene_group.cpp. +

+References NL3D::CTransform::freezeHRC(), and uint. +

+Referenced by addToSceneWhenAllShapesLoaded(), and NL3D::CInstanceGroupUser::freezeHRC(). +

+

01133 {
+01134         // For all instances.
+01135         for (uint i=0; i < _Instances.size(); i++)
+01136         {
+01137                 if(_Instances[i])
+01138                         _Instances[i]->freezeHRC();
+01139         }
+01140         // and for root.
+01141         _Root->freezeHRC();
+01142 }
+
+

+ + + + +
+ + + + + + + + + +
CInstanceGroup::TState NL3D::CInstanceGroup::getAddToSceneState  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 868 of file scene_group.cpp. +

+References _AddToSceneSignal, _AddToSceneTempSelectTexture, addToScene(), and StateAdding. +

+Referenced by NL3D::CInstanceGroupUser::getAddToSceneState(). +

+

00869 {
+00870         // If we are adding but we have finished loading shapes (all shapes are here)
+00871         if (_AddToSceneState == StateAdding)
+00872         {
+00873                 if (_AddToSceneSignal)
+00874                 {
+00875                         addToScene (*_AddToSceneTempScene, _AddToSceneTempDriver, _AddToSceneTempSelectTexture);
+00876                 }
+00877         }
+00878         return _AddToSceneState;
+00879 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CInstanceGroup::getBlendShapes std::set< std::string > &  BlendShapeNames  ) 
+
+ + + + + +
+   + + +

+Get all the blendshapes from an instance group. +

+BlendShape part +

+Definition at line 1015 of file scene_group.cpp. +

+References NL3D::CMeshBaseInstance::getBlendShapeName(), NL3D::CMeshBaseInstance::getNbBlendShape(), and uint32. +

+

01016 {
+01017         BlendShapeNames.clear();
+01018         for( uint32 i = 0; i < _Instances.size(); ++i )
+01019         {
+01020                 CMeshBaseInstance *pMBI = dynamic_cast<CMeshBaseInstance*>(_Instances[i]);
+01021                 if (pMBI != NULL)
+01022                 {
+01023                         uint32 nNbBS = pMBI->getNbBlendShape();
+01024                         for( uint32 j = 0; j < nNbBS; ++j )
+01025                         {
+01026                                 string sTmp;
+01027                                 pMBI->getBlendShapeName( j, sTmp );
+01028                                 set<string>::iterator itSet =  BlendShapeNames.find(sTmp);
+01029                                 if( itSet == BlendShapeNames.end() )
+01030                                         BlendShapeNames.insert( sTmp );
+01031                         }
+01032                 }
+01033         }
+01034 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CInstanceGroup::getDynamicPortal std::string &  name  ) 
+
+ + + + + +
+   + + +

+Get the state of a dynamic portal (true=opened, false=closed). +

+ +

+Definition at line 1081 of file scene_group.cpp. +

+References uint32. +

+Referenced by NL3D::CInstanceGroupUser::getDynamicPortal(). +

+

01082 {
+01083         for (uint32 i = 0; i < _Portals.size(); ++i)
+01084                 if (_Portals[i].getName() == name)
+01085                         return _Portals[i].isOpened ();
+01086         return false;
+01087 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CInstanceGroup::getDynamicPortals std::vector< std::string > &  names  ) 
+
+ + + + + +
+   + + +

+Get all dynamic portals of an instance group. +

+ +

+Definition at line 1065 of file scene_group.cpp. +

+References getName(), and uint32. +

+Referenced by NL3D::CInstanceGroupUser::getDynamicPortals(). +

+

01066 {
+01067         for (uint32 i = 0; i < _Portals.size(); ++i)
+01068                 if (_Portals[i].getName() != "")
+01069                         names.push_back (_Portals[i].getName());
+01070 }
+
+

+ + + + +
+ + + + + + + + + +
const NLMISC::CVector& NL3D::CInstanceGroup::getGlobalPos  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 175 of file scene_group.h. +

+References _GlobalPos. +

+

00175 { return _GlobalPos; }
+
+

+ + + + +
+ + + + + + + + + +
const CIGSurfaceLight& NL3D::CInstanceGroup::getIGSurfaceLight  )  const [inline]
+
+ + + + + +
+   + + +

+Get the SurfaceLight info, for debug purposes. +

+ +

+Definition at line 361 of file scene_group.h. +

+References _IGSurfaceLight. +

+Referenced by NL3D::CIGSurfaceLightBuild::buildPLDebugMesh(). +

+

00361 {return _IGSurfaceLight;}
+
+

+ + + + +
+ + + + + + + + + + +
CInstanceGroup::CInstance & NL3D::CInstanceGroup::getInstance uint  instanceNb  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 231 of file scene_group.cpp. +

+References _InstancesInfos, and uint. +

+

00232 {
+00233         return _InstancesInfos[instanceNb];
+00234 }
+
+

+ + + + +
+ + + + + + + + + + +
const CInstanceGroup::CInstance & NL3D::CInstanceGroup::getInstance uint  instanceNb  )  const
+
+ + + + + +
+   + + +

+ +

+Definition at line 225 of file scene_group.cpp. +

+References _InstancesInfos, and uint. +

+Referenced by NL3D::CInstanceLighter::lightIgSimple(). +

+

00226 {
+00227         return _InstancesInfos[instanceNb];
+00228 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CInstanceGroup::getInstanceMatrix uint  instanceNb,
NLMISC::CMatrix dest
const
+
+ + + + + +
+   + + +

+ +

+Definition at line 205 of file scene_group.cpp. +

+References getInstancePos(), getInstanceRot(), getInstanceScale(), NLMISC::CMatrix::identity(), NLMISC::CMatrix::rotate(), NLMISC::CMatrix::scale(), NLMISC::CMatrix::translate(), and uint. +

+Referenced by NL3D::CInstanceGroupUser::getInstanceMatrix(). +

+

00206 {
+00207         dest.identity();        
+00208         dest.translate(getInstancePos(instanceNb));
+00209         dest.rotate(getInstanceRot(instanceNb));
+00210         dest.scale(getInstanceScale(instanceNb));       
+00211 }
+
+

+ + + + +
+ + + + + + + + + + +
const string & NL3D::CInstanceGroup::getInstanceName uint  instanceNb  )  const
+
+ + + + + +
+   + + +

+Get the instance name. +

+ +

+Definition at line 173 of file scene_group.cpp. +

+References _InstancesInfos, and uint. +

+Referenced by NL3D::CInstanceGroupUser::addToScene(), NL3D::CInstanceGroupUser::getAddToSceneState(), and NL3D::CInstanceGroupUser::getInstanceName(). +

+

00174 {
+00175         // Return the name of the n-th instance
+00176         return _InstancesInfos[instanceNb].InstanceName;
+00177 }
+
+

+ + + + +
+ + + + + + + + + + +
const sint32 NL3D::CInstanceGroup::getInstanceParent uint  instanceNb  )  const
+
+ + + + + +
+   + + +

+ +

+Definition at line 217 of file scene_group.cpp. +

+References _InstancesInfos, sint32, and uint. +

+

00218 {
+00219         // Return the scale vector of the n-th instance
+00220         return _InstancesInfos[instanceNb].nParent;
+00221 }
+
+

+ + + + +
+ + + + + + + + + + +
const CVector & NL3D::CInstanceGroup::getInstancePos uint  instanceNb  )  const
+
+ + + + + +
+   + + +

+Get an instance position. +

+ +

+Definition at line 181 of file scene_group.cpp. +

+References _InstancesInfos, and uint. +

+Referenced by getInstanceMatrix(), NL3D::CInstanceGroupUser::getInstancePos(), and NL3D::CInstanceLighter::lightIgSimple(). +

+

00182 {
+00183         // Return the position vector of the n-th instance
+00184         return _InstancesInfos[instanceNb].Pos;
+00185 }
+
+

+ + + + +
+ + + + + + + + + + +
const CQuat & NL3D::CInstanceGroup::getInstanceRot uint  instanceNb  )  const
+
+ + + + + +
+   + + +

+Get an instance rotation. +

+ +

+Definition at line 189 of file scene_group.cpp. +

+References _InstancesInfos, and uint. +

+Referenced by getInstanceMatrix(), NL3D::CInstanceGroupUser::getInstanceRot(), and NL3D::CInstanceLighter::lightIgSimple(). +

+

00190 {
+00191         // Return the rotation vector of the n-th instance
+00192         return _InstancesInfos[instanceNb].Rot;
+00193 }
+
+

+ + + + +
+ + + + + + + + + + +
const CVector & NL3D::CInstanceGroup::getInstanceScale uint  instanceNb  )  const
+
+ + + + + +
+   + + +

+ +

+Definition at line 197 of file scene_group.cpp. +

+References _InstancesInfos, and uint. +

+Referenced by getInstanceMatrix(), NL3D::CInstanceGroupUser::getInstanceScale(), and NL3D::CInstanceLighter::lightIgSimple(). +

+

00198 {
+00199         // Return the scale vector of the n-th instance
+00200         return _InstancesInfos[instanceNb].Scale;
+00201 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CInstanceGroup::getLights std::set< std::string > &  LightNames  ) 
+
+ + + + + +
+   + + +

+Get all lights (lightmaps) from an instance group. +

+LightMap part +

+Definition at line 993 of file scene_group.cpp. +

+References NL3D::CMeshBaseInstance::getLightMapName(), NL3D::CMeshBaseInstance::getNbLightMap(), and uint32. +

+

00994 {
+00995         LightNames.clear();
+00996         for( uint32 i = 0; i < _Instances.size(); ++i )
+00997         {
+00998                 CMeshInstance *pMI = dynamic_cast<CMeshInstance*>(_Instances[i]);
+00999                 if( pMI != NULL )
+01000                 {
+01001                         uint32 nNbLM = pMI->getNbLightMap();
+01002                         for( uint32 j = 0; j < nNbLM; ++j )
+01003                         {
+01004                                 string sTmp;
+01005                                 pMI->getLightMapName( j, sTmp );
+01006                                 set<string>::iterator itSet =  LightNames.find(sTmp);
+01007                                 if( itSet == LightNames.end() )
+01008                                         LightNames.insert( sTmp );
+01009                         }
+01010                 }
+01011         }
+01012 }
+
+

+ + + + +
+ + + + + + + + + +
uint NL3D::CInstanceGroup::getNumInstance  )  const
+
+ + + + + +
+   + + +

+Get number of instance in this group. +

+

Todo:
remove all of these methods. For the moment DO NOT USE THEM !!!
+ +

+Definition at line 158 of file scene_group.cpp. +

+References _InstancesInfos, and uint. +

+Referenced by NL3D::CInstanceGroupUser::getCoarseMeshDist(), NL3D::CInstanceGroupUser::getDistMax(), NL3D::CInstanceGroupUser::getInstanceName(), NL3D::CInstanceGroupUser::getInstancePos(), NL3D::CInstanceGroupUser::getInstanceRot(), NL3D::CInstanceGroupUser::getInstanceScale(), NL3D::CInstanceGroupUser::getNumInstance(), NL3D::CInstanceGroupUser::getShapeName(), NL3D::CInstanceLighter::lightIgSimple(), NL3D::CInstanceGroupUser::setCoarseMeshDist(), and NL3D::CInstanceGroupUser::setDistMax(). +

+

00159 {
+00160         return _InstancesInfos.size();
+00161 }
+
+

+ + + + +
+ + + + + + + + + +
uint NL3D::CInstanceGroup::getNumPointLights  )  const [inline]
+
+ + + + + +
+   + + +

+Get the number of point lights. +

+ +

+Definition at line 341 of file scene_group.h. +

+References _PointLightArray, NL3D::CPointLightNamedArray::getPointLights(), and uint. +

+

00341 { return _PointLightArray.getPointLights().size(); }
+
+

+ + + + +
+ + + + + + + + + +
CInstanceGroup* NL3D::CInstanceGroup::getParentClusterSystem  )  const [inline]
+
+ + + + + +
+   + + +

+Get the parent ClusterSystem +

+Definition at line 376 of file scene_group.h. +

+References _ParentClusterSystem. +

+Referenced by NL3D::CScene::findCameraClusterSystemFromRay(), and NL3D::CInstanceGroupUser::getParentCluster(). +

+

00376 {return _ParentClusterSystem;}
+
+

+ + + + +
+ + + + + + + + + +
const std::vector<CPointLightNamed>& NL3D::CInstanceGroup::getPointLightList  )  const [inline]
+
+ + + + + +
+   + + +

+get the list of light. NB: the array is sorted by LightGroupName. +

+ +

+Definition at line 338 of file scene_group.h. +

+References _PointLightArray, and NL3D::CPointLightNamedArray::getPointLights(). +

+Referenced by NL3D::CIGSurfaceLightBuild::buildPLDebugMesh(), NL3D::CSurfaceLightGrid::getStaticLightSetup(), NL3D::CInstanceLighter::lightIgSimple(), and retrieve(). +

+

00338 {return _PointLightArray.getPointLights();}
+
+

+ + + + +
+ + + + + + + + + + +
CPointLightNamed& NL3D::CInstanceGroup::getPointLightNamed uint  index  )  [inline]
+
+ + + + + +
+   + + +

+Get a mutable ref on a point light named. +

+ +

+Definition at line 344 of file scene_group.h. +

+References _PointLightArray, NL3D::CPointLightNamedArray::getPointLights(), index, and uint. +

+

00345         { 
+00346                 return _PointLightArray.getPointLights()[index]; 
+00347         } 
+
+

+ + + + +
+ + + + + + + + + +
CVector NL3D::CInstanceGroup::getPos  ) 
+
+ + + + + +
+   + + +

+Get the position of the IG. +

+ +

+Definition at line 1105 of file scene_group.cpp. +

+References NL3D::ITransformable::getPos(). +

+Referenced by NL3D::CInstanceGroupUser::getPos(). +

+

01106 {
+01107         if (_Root != NULL)
+01108                 return _Root->getPos ();
+01109         else
+01110                 return CVector(0.0f, 0.0f, 0.0f);
+01111 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CInstanceGroup::getRealTimeSunContribution  )  const [inline]
+
+ + + + + +
+   + + +

+Setuped at export, tells if the ig is touched by the sun. true by default. +

+ +

+Definition at line 365 of file scene_group.h. +

+References _RealTimeSunContribution. +

+

00365 {return _RealTimeSunContribution;}
+
+

+ + + + +
+ + + + + + + + + +
CQuat NL3D::CInstanceGroup::getRotQuat  ) 
+
+ + + + + +
+   + + +

+Get the rotation of the IG. +

+ +

+Definition at line 1114 of file scene_group.cpp. +

+References NL3D::ITransformable::getRotQuat(). +

+Referenced by NL3D::CInstanceGroupUser::getRotQuat(). +

+

01115 {
+01116         if (_Root != NULL)
+01117                 return _Root->getRotQuat ();
+01118         else
+01119                 return CQuat();
+01120 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CInstanceGroup::getShapeName uint  instanceIndex,
std::string &  shapeName
const
+
+ + + + + +
+   + + +

+Get the instance name to create as written in the instance group. +

+Definition at line 552 of file scene_group.cpp. +

+References _InstancesInfos, _TransformName, NL3D::CInstanceGroup::CInstance::InstanceName, NL3D::CInstanceGroup::CInstance::Name, NLMISC::strlwr(), NL3D::ITransformName::transformName(), and uint. +

+

00553 {
+00554         const CInstance &rInstanceInfo = _InstancesInfos[instanceIndex];
+00555         shapeName = rInstanceInfo.Name;
+00556 
+00557         // If there is a callback added to this instance group then transform
+00558         // the name of the shape to load.
+00559         if (_TransformName != NULL && !rInstanceInfo.InstanceName.empty())
+00560         {                                                                                               
+00561                 shapeName = _TransformName->transformName (instanceIndex, rInstanceInfo.InstanceName, rInstanceInfo.Name);
+00562         }
+00563         
+00564         shapeName = strlwr (shapeName);
+00565         if (!shapeName.empty() && shapeName.find('.') == std::string::npos)
+00566                 shapeName += ".shape";
+00567 }
+
+

+ + + + +
+ + + + + + + + + + +
const string & NL3D::CInstanceGroup::getShapeName uint  instanceNb  )  const
+
+ + + + + +
+   + + +

+Get the name of the mesh referenced. +

+ +

+Definition at line 165 of file scene_group.cpp. +

+References _InstancesInfos, and uint. +

+Referenced by addToScene(), NL3D::CInstanceGroupUser::getShapeName(), and NL3D::CInstanceLighter::lightIgSimple(). +

+

00166 {
+00167         // Return the name of the n-th instance
+00168         return _InstancesInfos[instanceNb].Name;
+00169 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
bool NL3D::CInstanceGroup::getStaticLightSetup uint  retrieverIdentifier,
sint  surfaceId,
const CVector localPos,
std::vector< CPointLightInfluence > &  pointLightList,
uint8 sunContribution,
NLMISC::CRGBA localAmbient
[inline]
+
+ + + + + +
+   + + +

+See CIGSurfaceLight::getStaticLightSetup(). +

+ +

+Definition at line 353 of file scene_group.h. +

+References _IGSurfaceLight, NL3D::CIGSurfaceLight::getStaticLightSetup(), sint, uint, and uint8. +

+Referenced by NL3D::CInstanceGroupUser::getStaticLightSetup(). +

+

00355         {
+00356                 return _IGSurfaceLight.getStaticLightSetup(retrieverIdentifier, surfaceId, localPos,
+00357                         pointLightList, sunContribution, localAmbient);
+00358         }
+
+

+ + + + +
+ + + + + + + + + + +
CTransformShape * NL3D::CInstanceGroup::getTransformShape uint  instanceNb  )  const
+
+ + + + + +
+   + + +

+Get the instance added to the scene. NULL if instanceNb too big, if addToScene not called, or if instance is DontAddToScene +

+Definition at line 237 of file scene_group.cpp. +

+References uint. +

+

00238 {
+00239         if(instanceNb>_Instances.size())
+00240                 return NULL;
+00241         return _Instances[instanceNb];
+00242 }
+
+

+ + + + +
+ + + + + + + + + +
class UInstanceGroup* NL3D::CInstanceGroup::getUserInterface  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 251 of file scene_group.h. +

+References _UserIg. +

+Referenced by NL3D::CInstanceGroupUser::getParentCluster(). +

+

00251 {return _UserIg;}
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CInstanceGroup::linkRoot CScene scene,
CTransform father
+
+ + + + + +
+   + + +

+link the root of the ig to a node. No-op if not added to scene. Pass NULL to reset by default +

+Transformation part +

+Definition at line 1123 of file scene_group.cpp. +

+References NL3D::CTransform::hrcLinkSon(). +

+

01124 {
+01125         if(_Root)
+01126         {
+01127                 father->hrcLinkSon( _Root );
+01128         }
+01129 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CInstanceGroup::linkToParent CInstanceGroup pFather  ) 
+
+ + + + + +
+   + + +

+Look through all hierarchy our clusters that must be linked to our parent +

+Definition at line 884 of file scene_group.cpp. +

+References _ClusterInstances, _ParentClusterSystem, and uint32. +

+Referenced by addToSceneWhenAllShapesLoaded(), and NL3D::CInstanceGroupUser::linkToParentCluster(). +

+

00885 {               
+00886         uint32 i, j;
+00887         bool ret;
+00888 /*
+00889         for (i = 0; i < pFather->_ClusterInstances.size(); ++i)
+00890         {
+00891                 for(j = 0; j < pFather->_ClusterInstances[i]->Children.size(); ++j)
+00892                 {
+00893                         if (linkToParent(pFather->_ClusterInstances[i]->Children[j]->Group))
+00894                                 return true;
+00895                 }
+00896         }       
+00897 */
+00898         ret = false;
+00899         if (this != pFather)
+00900         {               
+00901                 for (j = 0; j < this->_ClusterInstances.size(); ++j)
+00902                 {
+00903                         if ((this->_ClusterInstances[j]->FatherVisible) ||
+00904                                 (this->_ClusterInstances[j]->VisibleFromFather))
+00905                         {
+00906                                 for (i = 0; i < pFather->_ClusterInstances .size(); ++i)
+00907                                 {
+00908                                         // If my cluster j is in the cluster i of the father
+00909                                         if (pFather->_ClusterInstances[i]->isIn(this->_ClusterInstances[j]->getBBox()))
+00910                                         {
+00911                                                 if (this->_ClusterInstances[j]->Father != pFather->_ClusterInstances[i]) // and not already son of the father cluster ?
+00912                                                 {                                               
+00913                                                         // unlink from parent
+00914                                                         this->_ClusterInstances[j]->unlinkFromParent();
+00915 
+00916                                                         // relink to the new father found
+00917                                                         pFather->_ClusterInstances[i]->Children.push_back(this->_ClusterInstances[j]);
+00918                                                         this->_ClusterInstances[j]->Father = pFather->_ClusterInstances[i];
+00919                                                 }
+00920                                                 ret = true;
+00921                                         }
+00922                                 }
+00923                         }
+00924                 }
+00925         }
+00926 
+00927         // store new parent
+00928         if(ret)
+00929                 _ParentClusterSystem= pFather;
+00930 
+00931         return ret;
+00932 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CInstanceGroup::removeFromScene CScene scene  ) 
+
+ + + + + +
+   + + +

+Remove all the instances from the scene. +

+ +

+Definition at line 935 of file scene_group.cpp. +

+References _AddRemoveInstance, _ClusterInfos, _ClusterInstances, _PointLightArray, NL3D::CScene::deleteInstance(), NL3D::CScene::deleteModel(), NL3D::CScene::getClipTrav(), NL3D::CPointLightNamedArray::getPointLights(), NL3D::IAddRemoveInstance::instanceGroupRemoved(), nlassert, NL3D::CScene::removeInstanceGroupForLightAnimation(), uint32, NL3D::CTransform::unfreezeStaticLightSetup(), and NL3D::CClipTrav::unregisterCluster(). +

+Referenced by NL3D::CInstanceGroupUser::removeFromScene(). +

+

00936 {
+00937         uint32 i, j, k;
+00938 
+00939         // Remove shapes
+00940         for (i = 0; i < _Instances.size(); ++i)
+00941         {
+00942                 CTransformShape *pTShape = _Instances[i];
+00943                 if(pTShape)
+00944                 {
+00945                         // For security, unfreeze any StaticLightSetup setuped.
+00946                         pTShape->unfreezeStaticLightSetup();
+00947                         // delete the instance
+00948                         scene.deleteInstance (pTShape);
+00949                         _Instances[i] = NULL;
+00950                 }
+00951         }
+00952 
+00953         // Relink portals with old clusters
+00954         for (i = 0; i < _Portals.size(); ++i)
+00955         for (k = 0; k < 2; ++k)
+00956         {
+00957                 if (_Portals[i]._Clusters[k])
+00958                 {
+00959                         for (j = 0; j < _ClusterInstances.size(); ++j)
+00960                                 if( _Portals[i]._Clusters[k] == _ClusterInstances[j] )
+00961                                         break;
+00962 
+00963                         nlassert (j!=_ClusterInstances.size());
+00964                         _Portals[i]._Clusters[k] = &_ClusterInfos[j];
+00965                 }       
+00966         }
+00967 
+00968         // Remove clusters
+00969         CClipTrav *pClipTrav = &scene.getClipTrav();
+00970         for (i = 0; i < _ClusterInstances.size(); ++i)
+00971         {
+00972                 pClipTrav->unregisterCluster (_ClusterInstances[i]);
+00973                 scene.deleteModel (_ClusterInstances[i]);
+00974         }
+00975 
+00976         scene.deleteModel (_Root);
+00977         _Root = NULL;
+00978 
+00979 
+00980         // UnRegister the instanceGroup for light animation
+00981         // -----------------
+00982         // If some PointLight to animate
+00983         if(_PointLightArray.getPointLights().size() > 0)
+00984                 scene.removeInstanceGroupForLightAnimation(this);
+00985 
+00986         if (_AddRemoveInstance)
+00987                 _AddRemoveInstance->instanceGroupRemoved();
+00988         return true;
+00989 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CInstanceGroup::retrieve CVector vGlobalPos,
TInstanceArray array,
std::vector< CCluster > &  Clusters,
std::vector< CPortal > &  Portals,
std::vector< CPointLightNamed > &  pointLightList
const
+
+ + + + + +
+   + + +

+Retreive group information. NB: data may have changed, eg: order of lights. +

+Definition at line 354 of file scene_group.cpp. +

+References _ClusterInfos, _GlobalPos, _InstancesInfos, getPointLightList(), TInstanceArray, and uint. +

+Referenced by NL3D::CInstanceLighter::light(). +

+

00358 {
+00359         // Just copy infos. NB: light information order have change but is still valid
+00360         vGlobalPos= _GlobalPos;
+00361         array= _InstancesInfos;
+00362 
+00363         Portals= _Portals;
+00364         Clusters= _ClusterInfos;
+00365         // Must reset links to all portals and clusters.
+00366         uint    i;
+00367         for(i=0; i<Portals.size(); i++)
+00368                 Portals[i].resetClusterLinks();
+00369         for(i=0; i<Clusters.size(); i++)
+00370                 Clusters[i].resetPortalLinks();
+00371 
+00372 
+00373         pointLightList= getPointLightList();
+00374 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CInstanceGroup::serial NLMISC::IStream f  ) 
+
+ + + + + +
+   + + +

+Serial the group. +

+ +

+Definition at line 379 of file scene_group.cpp. +

+References _ClusterInfos, _GlobalPos, _IGSurfaceLight, _InstancesInfos, _PointLightArray, _RealTimeSunContribution, NL3D::CPointLightNamedArray::clear(), NL3D::CIGSurfaceLight::clear(), NLMISC::IStream::isReading(), NLMISC::IStream::serial(), NLMISC::IStream::serialCheck(), NLMISC::IStream::serialCont(), NLMISC::IStream::serialVersion(), sint, sint32, and uint32. +

+Referenced by NL3D::CInstanceGroupUser::init(), and NL3D::CAsyncFileManager3D::CIGLoad::run(). +

+

00380 {
+00381         // Serial a header
+00382         f.serialCheck ((uint32)'TPRG');
+00383 
+00384         /*
+00385         Version 5:
+00386                 _ _RealTimeSunContribution
+00387         Version 4:
+00388                 _ IGSurfaceLight
+00389         Version 3:
+00390                 - PointLights
+00391         */
+00392         // Serial a version number
+00393         sint version=f.serialVersion (5);
+00394 
+00395 
+00396         // _RealTimeSunContribution
+00397         if (version >= 5)
+00398         {
+00399                 f.serial(_RealTimeSunContribution);
+00400         }
+00401         else if(f.isReading())
+00402         {
+00403                 _RealTimeSunContribution= true;
+00404         }
+00405 
+00406 
+00407         // Serial the IGSurfaceLight
+00408         if (version >= 4)
+00409         {
+00410                 f.serial(_IGSurfaceLight);
+00411         }
+00412         else if(f.isReading())
+00413         {
+00414                 _IGSurfaceLight.clear();
+00415         }
+00416 
+00417 
+00418         // Serial the PointLights info
+00419         if (version >= 3)
+00420         {
+00421                 f.serial(_PointLightArray);
+00422         }
+00423         else if(f.isReading())
+00424         {
+00425                 _PointLightArray.clear();
+00426         }
+00427 
+00428 
+00429         if (version >= 2)
+00430                 f.serial(_GlobalPos);
+00431 
+00432         if (version >= 1)
+00433         {
+00434                 f.serialCont (_ClusterInfos);
+00435                 f.serialCont (_Portals);
+00436                 // Links
+00437                 if (f.isReading())
+00438                 {
+00439                         uint32 i, j;
+00440                         for (i = 0; i < _ClusterInfos.size(); ++i)
+00441                         {
+00442                                 uint32 nNbPortals;
+00443                                 f.serial (nNbPortals);
+00444                                 _ClusterInfos[i]._Portals.resize (nNbPortals);
+00445                                 // Recreate clusters to portals links
+00446                                 for (j = 0; j < nNbPortals; ++j)
+00447                                 {
+00448                                         sint32 nPortalNb;
+00449                                         f.serial (nPortalNb);
+00450                                         _ClusterInfos[i]._Portals[j] = &_Portals[nPortalNb];
+00451                                         _Portals[nPortalNb].setCluster (&_ClusterInfos[i]);
+00452                                 }
+00453                         }
+00454                 }
+00455                 else // We are writing to the stream
+00456                 {
+00457                         uint32 i, j;
+00458                         for (i = 0; i < _ClusterInfos.size(); ++i)
+00459                         {
+00460                                 uint32 nNbPortals = _ClusterInfos[i]._Portals.size();
+00461                                 f.serial (nNbPortals);
+00462                                 for (j = 0; j < nNbPortals; ++j)
+00463                                 {
+00464                                         sint32 nPortalNb = (_ClusterInfos[i]._Portals[j] - &_Portals[0]);
+00465                                         f.serial (nPortalNb);
+00466                                 }
+00467                         }
+00468                 }
+00469         }
+00470 
+00471         // Serial the array
+00472         f.serialCont (_InstancesInfos);
+00473 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CInstanceGroup::setAddRemoveInstanceCallback IAddRemoveInstance callback  ) 
+
+ + + + + +
+   + + +

+Set a callback to know when an instance has been added / removed. +

+ +

+Definition at line 491 of file scene_group.cpp. +

+References _AddRemoveInstance. +

+Referenced by NL3D::CInstanceGroupUser::setAddRemoveInstanceCallback(). +

+

00492 {
+00493         _AddRemoveInstance = callback;
+00494 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CInstanceGroup::setBlendShapeFactor const std::string &  BlendShapeName,
float  rFactor
+
+ + + + + +
+   + + +

+Set the blendshape factor for the whole instance group (-100 -> 100). +

+ +

+Definition at line 1037 of file scene_group.cpp. +

+References NL3D::CMeshBaseInstance::setBlendShapeFactor(), and uint32. +

+Referenced by NL3D::CInstanceGroupUser::setBlendShapeFactor(). +

+

01038 {
+01039         for( uint32 i = 0; i < _Instances.size(); ++i )
+01040         {
+01041                 CMeshBaseInstance *pMI = dynamic_cast<CMeshBaseInstance*>(_Instances[i]);
+01042                 if( pMI != NULL )
+01043                 {
+01044                         pMI->setBlendShapeFactor( BlendShapeName, rFactor );
+01045                 }
+01046         }
+01047 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CInstanceGroup::setClusterSystemForInstances CInstanceGroup pIG  ) 
+
+ + + + + +
+   + + +

+Set the cluster system to test for instances that are not in a cluster of this IG. +

+ +

+Definition at line 1056 of file scene_group.cpp. +

+References _ClusterSystemForInstances, _InstancesInfos, and uint32. +

+Referenced by NL3D::CInstanceGroupUser::setClusterSystemForInstances(), and NL3D::CSceneUser::setToGlobalInstanceGroup(). +

+

01057 {
+01058         _ClusterSystemForInstances = pIG;
+01059         for (uint32 i = 0; i < _Instances.size(); ++i)
+01060                 if (_Instances[i] && _InstancesInfos[i].Clusters.size() == 0)
+01061                         _Instances[i]->setClusterSystem (_ClusterSystemForInstances);
+01062 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CInstanceGroup::setDynamicPortal std::string &  name,
bool  opened
+
+ + + + + +
+   + + +

+Set the state of a dynamic portal (true=opened, false=closed). +

+ +

+Definition at line 1073 of file scene_group.cpp. +

+References uint32. +

+Referenced by NL3D::CInstanceGroupUser::setDynamicPortal(). +

+

01074 {
+01075         for (uint32 i = 0; i < _Portals.size(); ++i)
+01076                 if (_Portals[i].getName() == name)
+01077                         _Portals[i].open (opened);
+01078 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CInstanceGroup::setIGAddBeginCallback IIGAddBegin callback  ) 
+
+ + + + + +
+   + + +

+Set a callback to know when an instance group is being created, and how many instances it contains. +

+ +

+Definition at line 497 of file scene_group.cpp. +

+References _IGAddBeginCallback. +

+Referenced by NL3D::CInstanceGroupUser::setIGAddBeginCallback(). +

+

00498 {
+00499         _IGAddBeginCallback = callback;
+00500 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CInstanceGroup::setPointLightFactor const CScene scene  ) 
+
+ + + + + +
+   + + +

+set the Light factor for all pointLights "lightGroupName". +

+ +

+Definition at line 1205 of file scene_group.cpp. +

+References _PointLightArray, and NL3D::CPointLightNamedArray::setPointLightFactor(). +

+Referenced by NL3D::CScene::animate(). +

+

01206 {
+01207         _PointLightArray.setPointLightFactor(scene);
+01208 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CInstanceGroup::setPos const CVector pos  ) 
+
+ + + + + +
+   + + +

+Set the position of the IG. +

+ +

+

Todo:
Make this work (precision): _Root->setPos (_GlobalPos+pos);
+ +

+Definition at line 1090 of file scene_group.cpp. +

+References NL3D::ITransformable::setPos(). +

+Referenced by createRoot(), and NL3D::CInstanceGroupUser::setPos(). +

+

01091 {
+01092         if (_Root != NULL)
+01094                 _Root->setPos (pos);
+01095 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CInstanceGroup::setRotQuat const CQuat quat  ) 
+
+ + + + + +
+   + + +

+Set the rotation of the IG. +

+ +

+Definition at line 1098 of file scene_group.cpp. +

+References NL3D::ITransformable::setRotQuat(). +

+Referenced by NL3D::CInstanceGroupUser::setRotQuat(). +

+

01099 {
+01100         if (_Root != NULL)
+01101                 _Root->setRotQuat (quat);
+01102 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CInstanceGroup::setTransformNameCallback ITransformName pTN  ) 
+
+ + + + + +
+   + + +

+Setup the callback in charge of changing name at the addToScene moment. +

+ +

+Definition at line 484 of file scene_group.cpp. +

+References _TransformName. +

+Referenced by NL3D::CInstanceGroupUser::setTransformNameCallback(). +

+

00485 {
+00486         _TransformName = pTN;
+00487 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CInstanceGroup::setUserInterface class UInstanceGroup uig  )  [inline]
+
+ + + + + +
+   + + +

+User Interface related: yes it is ugly.... +

+ +

+Definition at line 250 of file scene_group.h. +

+References _UserIg. +

+Referenced by NL3D::CInstanceGroupUser::CInstanceGroupUser(). +

+

00250 {_UserIg= uig;}
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CInstanceGroup::stopAddToSceneAsync  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 828 of file scene_group.cpp. +

+References _AddToSceneSignal, _InstancesInfos, _TransformName, NL3D::CShapeBank::cancelLoadAsync(), NL3D::CInstanceGroup::CInstance::DontAddToScene, NL3D::CScene::getShapeBank(), NL3D::CInstanceGroup::CInstance::InstanceName, NL3D::CInstanceGroup::CInstance::Name, StateAdding, StateNotAdded, NLMISC::strlwr(), NL3D::ITransformName::transformName(), and uint32. +

+Referenced by NL3D::CInstanceGroupUser::stopAddToSceneAsync(). +

+

00829 {
+00830         if (_AddToSceneState != StateAdding)
+00831                 return;
+00832         vector<CInstance>::iterator it = _InstancesInfos.begin();
+00833         CAsyncFileManager::getInstance().cancelSignal (&_AddToSceneSignal);
+00834         for (uint32 i = 0; i < _InstancesInfos.size(); ++i, ++it)
+00835         {
+00836                 CInstance &rInstanceInfo = *it;
+00837                 if (!rInstanceInfo.DontAddToScene)
+00838                 {
+00839                         string shapeName;
+00840 
+00841 
+00842                         bool getShapeName = true;
+00843 
+00844                         if (_TransformName != NULL && !rInstanceInfo.InstanceName.empty())
+00845                         {                                                                                               
+00846                                 shapeName = _TransformName->transformName (i, rInstanceInfo.InstanceName, rInstanceInfo.Name);
+00847                                 if (shapeName != rInstanceInfo.Name)
+00848                                         getShapeName = false;
+00849                         }
+00850 
+00851                         
+00852                         if (getShapeName)
+00853                         {                       
+00854                                 if (rInstanceInfo.Name.find('.') == std::string::npos)
+00855                                         shapeName = rInstanceInfo.Name + ".shape";
+00856                                 else    // extension has already been added
+00857                                         shapeName  = rInstanceInfo.Name;
+00858                         }
+00859 
+00860                         shapeName = strlwr (shapeName);
+00861                         _AddToSceneTempScene->getShapeBank()->cancelLoadAsync (shapeName);
+00862                 }
+00863         }
+00864         _AddToSceneState = StateNotAdded;
+00865 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CInstanceGroup::unfreezeHRC  ) 
+
+ + + + + +
+   + + +

+see CTransform::unfreezeHRC(). Do it for all instances (not clusters), and for the root of the IG. +

+ +

+Definition at line 1146 of file scene_group.cpp. +

+References uint, and NL3D::CTransform::unfreezeHRC(). +

+Referenced by NL3D::CInstanceGroupUser::unfreezeHRC(). +

+

01147 {
+01148         // For all instances.
+01149         for (uint i=0; i < _Instances.size(); i++)
+01150         {
+01151                 if(_Instances[i])
+01152                         _Instances[i]->unfreezeHRC();
+01153         }
+01154         // and for root.
+01155         _Root->unfreezeHRC();
+01156 }
+
+


Field Documentation

+

+ + + + +
+ + +
IAddRemoveInstance* NL3D::CInstanceGroup::_AddRemoveInstance [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 427 of file scene_group.h. +

+Referenced by addToSceneWhenAllShapesLoaded(), CInstanceGroup(), removeFromScene(), and setAddRemoveInstanceCallback().

+

+ + + + +
+ + +
bool NL3D::CInstanceGroup::_AddToSceneSignal [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 419 of file scene_group.h. +

+Referenced by addToSceneAsync(), getAddToSceneState(), and stopAddToSceneAsync().

+

+ + + + +
+ + +
TState NL3D::CInstanceGroup::_AddToSceneState [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 420 of file scene_group.h.

+

+ + + + +
+ + +
IDriver* NL3D::CInstanceGroup::_AddToSceneTempDriver [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 422 of file scene_group.h.

+

+ + + + +
+ + +
CScene* NL3D::CInstanceGroup::_AddToSceneTempScene [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 421 of file scene_group.h.

+

+ + + + +
+ + +
uint NL3D::CInstanceGroup::_AddToSceneTempSelectTexture [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 423 of file scene_group.h. +

+Referenced by addToSceneAsync(), and getAddToSceneState().

+

+ + + + +
+ + +
CClipTrav* NL3D::CInstanceGroup::_ClipTrav +
+
+ + + + + +
+   + + +

+ +

+Definition at line 389 of file scene_group.h. +

+Referenced by addToSceneWhenAllShapesLoaded(), and NL3D::CCluster::traverseHrc().

+

+ + + + +
+ + +
std::vector<CCluster> NL3D::CInstanceGroup::_ClusterInfos +
+
+ + + + + +
+   + + +

+ +

+Definition at line 384 of file scene_group.h. +

+Referenced by addToSceneWhenAllShapesLoaded(), build(), removeFromScene(), retrieve(), and serial().

+

+ + + + +
+ + +
std::vector<CCluster*> NL3D::CInstanceGroup::_ClusterInstances +
+
+ + + + + +
+   + + +

+ +

+Definition at line 385 of file scene_group.h. +

+Referenced by addCluster(), addToSceneWhenAllShapesLoaded(), displayDebugClusters(), NL3D::CClipTrav::fullSearch(), linkToParent(), and removeFromScene().

+

+ + + + +
+ + +
CInstanceGroup* NL3D::CInstanceGroup::_ClusterSystemForInstances +
+
+ + + + + +
+   + + +

+ +

+Definition at line 391 of file scene_group.h. +

+Referenced by addToSceneWhenAllShapesLoaded(), CInstanceGroup(), and setClusterSystemForInstances().

+

+ + + + +
+ + +
NLMISC::CVector NL3D::CInstanceGroup::_GlobalPos +
+
+ + + + + +
+   + + +

+ +

+Definition at line 395 of file scene_group.h. +

+Referenced by build(), CInstanceGroup(), getGlobalPos(), retrieve(), and serial().

+

+ + + + +
+ + +
IIGAddBegin* NL3D::CInstanceGroup::_IGAddBeginCallback [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 428 of file scene_group.h. +

+Referenced by addToScene(), addToSceneAsync(), CInstanceGroup(), and setIGAddBeginCallback().

+

+ + + + +
+ + +
CIGSurfaceLight NL3D::CInstanceGroup::_IGSurfaceLight [private] +
+
+ + + + + +
+   + + +

+The object used to light dynamic models in town and buildings. +

+ +

+Definition at line 413 of file scene_group.h. +

+Referenced by build(), CInstanceGroup(), getIGSurfaceLight(), getStaticLightSetup(), and serial().

+

+ + + + +
+ + +
std::vector<CTransformShape*> NL3D::CInstanceGroup::_Instances +
+
+ + + + + +
+   + + +

+ +

+Definition at line 381 of file scene_group.h. +

+Referenced by NL3D::CInstanceGroupUser::addToScene(), NL3D::CInstanceGroupUser::getAddToSceneState(), NL3D::CInstanceGroupUser::getCoarseMeshDist(), NL3D::CInstanceGroupUser::getDistMax(), NL3D::CInstanceGroupUser::setCoarseMeshDist(), and NL3D::CInstanceGroupUser::setDistMax().

+

+ + + + +
+ + +
TInstanceArray NL3D::CInstanceGroup::_InstancesInfos +
+
+ + + + + +
+   + + +

+ +

+Definition at line 380 of file scene_group.h. +

+Referenced by addToScene(), addToSceneAsync(), addToSceneWhenAllShapesLoaded(), build(), buildPointLightList(), getInstance(), getInstanceName(), getInstanceParent(), getInstancePos(), getInstanceRot(), getInstanceScale(), getNumInstance(), getShapeName(), retrieve(), serial(), setClusterSystemForInstances(), and stopAddToSceneAsync().

+

+ + + + +
+ + +
CInstanceGroup* NL3D::CInstanceGroup::_ParentClusterSystem +
+
+ + + + + +
+   + + +

+ +

+Definition at line 393 of file scene_group.h. +

+Referenced by CInstanceGroup(), getParentClusterSystem(), and linkToParent().

+

+ + + + +
+ + +
CPointLightNamedArray NL3D::CInstanceGroup::_PointLightArray [private] +
+
+ + + + + +
+   + + +

+Array of pointLights. +

+ +

+Definition at line 406 of file scene_group.h. +

+Referenced by addToScene(), addToSceneAsync(), addToSceneWhenAllShapesLoaded(), buildPointLightList(), getNumPointLights(), getPointLightList(), getPointLightNamed(), removeFromScene(), serial(), and setPointLightFactor().

+

+ + + + +
+ + +
std::vector<CPortal> NL3D::CInstanceGroup::_Portals +
+
+ + + + + +
+   + + +

+ +

+Definition at line 383 of file scene_group.h.

+

+ + + + +
+ + +
bool NL3D::CInstanceGroup::_RealTimeSunContribution [private] +
+
+ + + + + +
+   + + +

+RealTimeSunContribution. Used for ig_lighter and zone_ig_lighter. +

+ +

+Definition at line 403 of file scene_group.h. +

+Referenced by CInstanceGroup(), enableRealTimeSunContribution(), getRealTimeSunContribution(), and serial().

+

+ + + + +
+ + +
CTransform* NL3D::CInstanceGroup::_Root +
+
+ + + + + +
+   + + +

+ +

+Definition at line 387 of file scene_group.h.

+

+ + + + +
+ + +
ITransformName* NL3D::CInstanceGroup::_TransformName [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 426 of file scene_group.h. +

+Referenced by addToSceneAsync(), CInstanceGroup(), getShapeName(), setTransformNameCallback(), and stopAddToSceneAsync().

+

+ + + + +
+ + +
UInstanceGroup* NL3D::CInstanceGroup::_UserIg [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 431 of file scene_group.h. +

+Referenced by CInstanceGroup(), getUserInterface(), and setUserInterface().

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 06:47:22 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1