1 /*
2 	Copyright (C) 2005-2007 Feeling Software Inc.
3 	Portions of the code are:
4 	Copyright (C) 2005-2007 Sony Computer Entertainment America
5 
6 	MIT License: http://www.opensource.org/licenses/mit-license.php
7 */
8 /*
9 	Based on the FS Import classes:
10 	Copyright (C) 2005-2006 Feeling Software Inc
11 	Copyright (C) 2005-2006 Autodesk Media Entertainment
12 	MIT License: http://www.opensource.org/licenses/mit-license.php
13 */
14 
15 /**
16 	@file FCDocument.h
17 	This file declares the COLLADA document object model top class: FCDocument.
18 */
19 
20 #ifndef _FC_DOCUMENT_H_
21 #define _FC_DOCUMENT_H_
22 
23 #ifndef __FCD_OBJECT_H_
24 #include "FCDocument/FCDObject.h"
25 #endif // __FCD_OBJECT_H_
26 #ifndef _FU_PARAMETER_H_
27 #include "FUtils/FUParameter.h"
28 #endif // _FU_PARAMETER_H_
29 
30 #if defined(WIN32)
31 template <class T> class FCOLLADA_EXPORT FCDLibrary; /**< Trick Doxygen. */
32 template <class T> class FCOLLADA_EXPORT FUUniqueStringMapT; /**< Trick Doxygen. */
33 #elif defined(LINUX) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
34 template <class T> class FCDLibrary; /**< Trick Doxygen. */
35 template <class T> class FUUniqueStringMapT; /**< Trick Doxygen. */
36 #endif // LINUX
37 
38 class FCDAnimated;
39 class FCDAnimation;
40 class FCDAnimationChannel;
41 class FCDAnimationClip;
42 class FCDAsset;
43 class FCDCamera;
44 class FCDController;
45 class FCDEffect;
46 class FCDEntity;
47 class FCDEntityReference;
48 class FCDEmitter;
49 class FCDExternalReferenceManager;
50 class FCDExtra;
51 class FCDForceField;
52 class FCDGeometry;
53 class FCDImage;
54 class FCDLight;
55 class FCDMaterial;
56 class FCDObject;
57 class FCDPhysicsMaterial;
58 class FCDPhysicsModel;
59 class FCDPhysicsScene;
60 class FCDTexture;
61 class FCDSceneNode;
62 class FCDVersion;
63 class FUFileManager;
64 
65 /**
66 	A layer declaration.
67 	Contains a name for the layer and the ids of all the entities within the layer.
68 */
69 class FCOLLADA_EXPORT FCDLayer
70 {
71 public:
72 	fm::string name; /**< The layer name. There is no guarantee of uniqueness. */
73 	StringList objects; /**< The list of COLLADA entity ids which are contained by this layer. */
74 };
75 
76 typedef fm::pvector<FCDLayer> FCDLayerList; /**< A dynamically-sized array of layer declarations. */
77 
78 typedef FCDLibrary<FCDAnimation> FCDAnimationLibrary; /**< A COLLADA library of animation entities. */
79 typedef FCDLibrary<FCDAnimationClip> FCDAnimationClipLibrary; /**< A COLLADA library of animation clip entities. */
80 typedef FCDLibrary<FCDCamera> FCDCameraLibrary; /**< A COLLADA library of camera entities. */
81 typedef FCDLibrary<FCDController> FCDControllerLibrary; /**< A COLLADA library of controller entities. */
82 typedef FCDLibrary<FCDEffect> FCDEffectLibrary; /**< A COLLADA library of effect entities. */
83 typedef FCDLibrary<FCDEmitter> FCDEmitterLibrary; /**< A non-standard library of generic emitters. */
84 typedef	FCDLibrary<FCDForceField> FCDForceFieldLibrary; /**< A COLLADA library of force fields. */
85 typedef FCDLibrary<FCDGeometry> FCDGeometryLibrary; /**< A COLLADA library of geometric entities. */
86 typedef FCDLibrary<FCDImage> FCDImageLibrary; /**< A COLLADA library of images. */
87 typedef FCDLibrary<FCDLight> FCDLightLibrary; /**< A COLLADA library of light entities. */
88 typedef FCDLibrary<FCDMaterial> FCDMaterialLibrary; /**< A COLLADA library of visual material entities. */
89 typedef FCDLibrary<FCDSceneNode> FCDVisualSceneNodeLibrary; /**< A COLLADA library of visual scene nodes. */
90 typedef FCDLibrary<FCDPhysicsModel> FCDPhysicsModelLibrary; /**< A COLLADA library of physics model entities. */
91 typedef FCDLibrary<FCDPhysicsMaterial> FCDPhysicsMaterialLibrary; /**< A COLLADA library of physics material entities. */
92 typedef	FCDLibrary<FCDPhysicsScene> FCDPhysicsSceneLibrary; /**< A COLLADA library of physics scene nodes. */
93 typedef FUUniqueStringMapT<char> FUSUniqueStringMap; /**< A set of unique strings. */
94 typedef fm::map<FCDExtra*, FCDExtra*> FCDExtraSet; /**< A set of extra trees. */
95 
96 /** @defgroup FCDocument COLLADA Document Object Model. */
97 
98 /** The top class for the COLLADA object model.
99 
100 	This class holds all the COLLADA libraries, the scene graphs and the
101 	document's asset tag.
102 
103 	It also holds some global information, such as the animation start and end
104 	time and the layers. This global information is only exported by ColladaMaya
105 	right now.
106 
107 	@ingroup FCDocument COLLADA Document Object Model
108 */
109 class FCOLLADA_EXPORT FCDocument : public FCDObject
110 {
111 private:
112 	DeclareObjectType(FCDObject);
113 
114 	FUFileManager* fileManager;
115 	FUObjectRef<FCDExternalReferenceManager> externalReferenceManager;
116 	fstring fileUrl;
117 	FCDVersion* version;
118 	FCDExtraSet extraTrees;
119 
120 	FUSUniqueStringMap* uniqueNameMap;
121 	DeclareParameterRef(FCDEntityReference, visualSceneRoot, FC("Root Visual Scene"));
122 	DeclareParameterContainer(FCDEntityReference, physicsSceneRoots, FC("Root Physics Scenes"));
123 
124 	// Document parameters
125 	DeclareParameterRef(FCDAsset, asset, FC("Asset Tag"));
126 	DeclareParameterRef(FCDExtra, extra, FC("Extra Tree"));
127 	bool hasStartTime, hasEndTime;
128 	DeclareParameter(float, FUParameterQualifiers::SIMPLE, startTime, FC("Start Time"));
129 	DeclareParameter(float, FUParameterQualifiers::SIMPLE, endTime, FC("End Time"));
130 	FCDLayerList layers; // Maya-only
131 
132 	// Parsed and merged libraries
133 	DeclareParameterRef(FCDAnimationLibrary, animationLibrary, FC("Animation Library"));
134 	DeclareParameterRef(FCDAnimationClipLibrary, animationClipLibrary, FC("Animation Clip Library"));
135 	DeclareParameterRef(FCDCameraLibrary, cameraLibrary, FC("Camera Library"));
136 	DeclareParameterRef(FCDControllerLibrary, controllerLibrary, FC("Controller Library"));
137 	DeclareParameterRef(FCDEffectLibrary, effectLibrary, FC("Effect Library"));
138 	DeclareParameterRef(FCDForceFieldLibrary, forceFieldLibrary, FC("Force-field Library"));
139 	DeclareParameterRef(FCDGeometryLibrary, geometryLibrary, FC("Geometry Library"));
140 	DeclareParameterRef(FCDImageLibrary, imageLibrary, FC("Image Library"));
141 	DeclareParameterRef(FCDLightLibrary, lightLibrary, FC("Light Library"));
142 	DeclareParameterRef(FCDMaterialLibrary, materialLibrary, FC("Material Library"));
143 	DeclareParameterRef(FCDPhysicsModelLibrary, physicsModelLibrary, FC("Physics Model Library"));
144 	DeclareParameterRef(FCDPhysicsMaterialLibrary, physicsMaterialLibrary, FC("Physics Material Library"));
145 	DeclareParameterRef(FCDPhysicsSceneLibrary, physicsSceneLibrary, FC("Physics Scene Library"));
146 	DeclareParameterRef(FCDVisualSceneNodeLibrary, visualSceneLibrary, FC("Visual Scene Library"));
147 	DeclareParameterRef(FCDEmitterLibrary, emitterLibrary, FC("Emitter Library"));
148 
149 	// Animated values
150 	typedef fm::map<FCDAnimated*, FCDAnimated*> FCDAnimatedSet;
151 	FCDAnimatedSet animatedValues;
152 
153 public:
154 	/** Construct a new COLLADA document. */
155 	FCDocument();
156 
157 	/** COLLADA document destructor. This clears out all the memory related to the document. */
158 	virtual ~FCDocument();
159 
160 	/** Retrieves the asset information for this COLLADA document. The asset information should always be present.
161 		@return A pointer to the asset information structure. This pointer should never be NULL. */
GetAsset()162 	inline FCDAsset* GetAsset() { return asset; }
GetAsset()163 	inline const FCDAsset* GetAsset() const { return asset; } /**< See above. */
164 
165 	/** Retrieves the base extra tree for this COLLADA document. An extra tree should always be present,
166 		but is likely to be empty.
167 		@return A pointer to the base extra tree. This pointer should never be NULL. */
GetExtra()168 	inline FCDExtra* GetExtra() { return extra; }
GetExtra()169 	inline const FCDExtra* GetExtra() const { return extra; } /**< See above. */
170 
171 	/** Retrieves the version numbers for this COLLADA document. The version numbers should always be present.
172 		@return The version number structure.*/
GetVersion()173 	inline FCDVersion& GetVersion() { return *version; }
GetVersion()174 	inline const FCDVersion& GetVersion() const { return *version; } /**< See above. */
175 
176 	/** [INTERNAL] Retrieves the local file manager for the COLLADA document. Used to resolve URIs and transform file
177 		paths into their relative or absolute equivalent. May be deprecated in future versions.
178 		@return The file manager for this COLLADA document. This pointer should never be NULL. */
GetFileManager()179 	inline FUFileManager* GetFileManager() { return fileManager; }
GetFileManager()180 	inline const FUFileManager* GetFileManager() const { return fileManager; } /**< See above. */
181 
182 	/** Retrieves the currently instanced visual scene.
183 		NOTE: GetVisualSceneRoot is deprecated. Please start using GetVisualSceneInstance.
184 		@return The currently instanced visual scene. */
GetVisualSceneInstance()185 	inline FCDSceneNode* GetVisualSceneInstance() { return const_cast<FCDSceneNode*>(const_cast<const FCDocument*>(this)->GetVisualSceneInstance()); }
186 	const FCDSceneNode* GetVisualSceneInstance() const; /**< See above. */
GetVisualSceneRoot()187 	DEPRECATED(3.04A, FCDocument::GetVisualSceneInstance) inline FCDSceneNode* GetVisualSceneRoot() { return GetVisualSceneInstance(); } /**< See above. */
GetVisualSceneRoot()188 	DEPRECATED(3.04A, FCDocument::GetVisualSceneInstance) inline const FCDSceneNode* GetVisualSceneRoot() const { return GetVisualSceneInstance(); } /**< See above. */
189 
190 	/** Retrieves the reference to the currently instanced visual scene.
191 		@return The instanced visual scene reference. */
GetVisualSceneInstanceReference()192 	inline FCDEntityReference* GetVisualSceneInstanceReference() { return visualSceneRoot; }
GetVisualSceneInstanceReference()193 	inline const FCDEntityReference* GetVisualSceneInstanceReference() const { return visualSceneRoot; } /**< See above. */
194 
195 	/** Retrieves the number of instanced physics scenes.
196 		@return The number of instanced physics scenes. */
GetPhysicsSceneInstanceCount()197 	inline size_t GetPhysicsSceneInstanceCount() const { return physicsSceneRoots.size(); }
198 
199 	/** Retrieves one instanced physics scene.
200 		@param index The index of the physics scene to retrieve.
201 			If the index is out-of-bounds, NULL is returned.
202 		@return A currently instanced physics scene. */
203 	inline FCDPhysicsScene* GetPhysicsSceneInstance(size_t index = 0) { return const_cast<FCDPhysicsScene*>(const_cast<const FCDocument*>(this)->GetPhysicsSceneInstance(index)); }
204 	const FCDPhysicsScene* GetPhysicsSceneInstance(size_t index = 0) const; /**< See above. */
205 	DEPRECATED(3.04A, FCDocument::GetPhysicsSceneInstance) inline FCDPhysicsScene* GetPhysicsSceneRoot(size_t index = 0) { return GetPhysicsSceneInstance(index); } /**< See above. */
206 	DEPRECATED(3.04A, FCDocument::GetPhysicsSceneInstance) inline const FCDPhysicsScene* GetPhysicsSceneRoot(size_t index = 0) const { return GetPhysicsSceneInstance(index); } /**< See above. */
207 
208 	/** Adds one instanced physics scene to the document.
209 		@param scene The newly instanced physics scene. */
210 	void AddPhysicsSceneInstance(FCDPhysicsScene* scene);
211 
212 	/** Retrieves a reference to the instanced physics scene.
213 		@param index The index of the physics scene instance reference to
214 			retrieve. If the index is out-of-bounds, NULL is returned.
215 		@return The reference to the index physics scene reference. */
216 	inline FCDEntityReference* GetPhysicsSceneInstanceReference(size_t index = 0) { if (index == 0 && physicsSceneRoots.empty()) return NULL; FUAssert(index < physicsSceneRoots.size(), return NULL); return physicsSceneRoots[index]; }
217 	inline const FCDEntityReference* GetPhysicsSceneInstanceReference(size_t index = 0) const { if (index == 0 && physicsSceneRoots.empty()) return NULL; FUAssert(index < physicsSceneRoots.size(), return NULL); return physicsSceneRoots[index]; }
218 
219 	/** Adds an empty reference in the list of instanced physics scenes.
220 		@return The new, empty, reference. */
221 	FCDEntityReference* AddPhysicsSceneInstanceReference();
222 
223 	/** [INTERNAL] Retrieves the map of unique ids for this document.
224 		@return The map of unique ids for this document. */
GetUniqueNameMap()225 	inline FUSUniqueStringMap* GetUniqueNameMap() { return uniqueNameMap; }
GetUniqueNameMap()226 	inline const FUSUniqueStringMap* GetUniqueNameMap() const { return uniqueNameMap; } /**< See above. */
227 
228 	/** Retrieves the external reference manager.
229 		@return The external reference manager. */
GetExternalReferenceManager()230 	inline FCDExternalReferenceManager* GetExternalReferenceManager() { return externalReferenceManager; }
GetExternalReferenceManager()231 	inline const FCDExternalReferenceManager* GetExternalReferenceManager() const { return externalReferenceManager; } /**< See above. */
232 
233 	/** Retrieves the file URL for this document.
234 		@return The file URL for the document. */
GetFileUrl()235 	const fstring& GetFileUrl() const { return fileUrl; }
236 
237 	/** Sets the file URL for this document.
238 		Useful when working with external references.
239 		@param filename The filename for the document. */
240 	void SetFileUrl(const fstring& filename);
241 
242 	/** Returns whether a start time is being enforced for the document.
243 		@return Whether the document has a start time. */
HasStartTime()244 	inline bool HasStartTime() const { return hasStartTime; }
245 	/** Retrieves the start time set for the document.
246 		@return The document start time. */
GetStartTime()247 	inline float GetStartTime() const { return startTime; }
248 	/** Enforces a certain time as the start time for the document.
249 		@param time The document start time. */
SetStartTime(float time)250 	inline void SetStartTime(float time) { startTime = time; hasStartTime = true; }
251 
252 	/** Returns whether a end time is being enforced for the document.
253 		@return Whether the document has a end time. */
HasEndTime()254 	inline bool HasEndTime() const { return hasEndTime; }
255 	/** Retrieves the end time set for the document.
256 		@return The document end time. */
GetEndTime()257 	inline float GetEndTime() const { return endTime; }
258 	/** Enforces a certain time as the end time for the document.
259 		@param time The document end time. */
SetEndTime(float time)260 	inline void SetEndTime(float time) { endTime = time; hasEndTime = true; }
261 
262 	/** Evaluate the animation objects at the given time
263 		@param time The time to evaluate the objects at */
264 	inline void SetCurrentTime(float time);
265 
266 	/** Retrieves the list of entity layers.
267 		@return The list of entity layers. */
GetLayers()268 	inline FCDLayerList& GetLayers() { return layers; }
GetLayers()269 	inline const FCDLayerList& GetLayers() const { return layers; } /**< See above. */
270 
271 	/** Retrieves the number of entity layers contained within the document.
272 		@return The number of layers. */
GetLayerCount()273 	inline size_t GetLayerCount() const { return layers.size(); }
274 
275 	/** Retrieves a specific entity layer contained within the document.
276 		@param index The index of the layer.
277 		@return The entity layer. This pointer will be NULL if the index
278 			is out-of-bounds. */
GetLayer(size_t index)279 	inline FCDLayer* GetLayer(size_t index) { FUAssert(index < GetLayerCount(), return NULL); return layers.at(index); }
GetLayer(size_t index)280 	inline const FCDLayer* GetLayer(size_t index) const { FUAssert(index < GetLayerCount(), return NULL); return layers.at(index); } /**< See above. */
281 
282 	/** Adds an entity layer to the document.
283 		@return The new layer. */
284 	FCDLayer* AddLayer();
285 
286 	/** Releases an entity layer from the document
287 		@param layer The layer to release. */
288 	void ReleaseLayer(FCDLayer* layer);
289 
290 	/** Retrieves the animation library. The animation library contains the animation curves
291 		within a tree structure. To create and find animation curves, do not use the animation
292 		library directly: use the FCDAnimated class, the FindAnimatedValue() function and the
293 		RegisterAnimatedValue() function.
294 		@return The animation library. */
GetAnimationLibrary()295 	inline FCDAnimationLibrary* GetAnimationLibrary() { return animationLibrary; }
GetAnimationLibrary()296 	inline const FCDAnimationLibrary* GetAnimationLibrary() const { return animationLibrary; } /**< See above. */
297 
298 	/** Retrieves the animation clip library. The animation clip library contains a list of animation clips.
299 		Each animation clip instantiates nodes from the animation library. Sections of the animation curves
300 		belonging to the instantiated animation nodes are thereby packaged together as animation clips.
301 		@return The animation clip library. */
GetAnimationClipLibrary()302 	inline FCDAnimationClipLibrary* GetAnimationClipLibrary() { return animationClipLibrary; }
GetAnimationClipLibrary()303 	inline const FCDAnimationClipLibrary* GetAnimationClipLibrary() const { return animationClipLibrary; } /**< See above. */
304 
305 	/** Retrieves the camera library. The camera library contains a list of cameras, which may be
306 		instantiated within the scene graph. COLLADA supports two camera types: perspective and orthographic.
307 		@return The camera library. */
GetCameraLibrary()308 	inline FCDCameraLibrary* GetCameraLibrary() { return cameraLibrary; }
GetCameraLibrary()309 	inline const FCDCameraLibrary* GetCameraLibrary() const { return cameraLibrary; } /**< See above. */
310 
311 	/** Retrieves the controller library. The controller library contains a list of controllers, which may
312 		be instantiated within the scene graph. COLLADA supports two controller types: skin and morph.
313 		@return The controller library. */
GetControllerLibrary()314 	inline FCDControllerLibrary* GetControllerLibrary() { return controllerLibrary; }
GetControllerLibrary()315 	inline const FCDControllerLibrary* GetControllerLibrary() const { return controllerLibrary; } /**< See above. */
316 
317 	/** Retrieves the geometry library. The geometry library contains a list of basic geometries, which may
318 		be instantiated within the scene graph and may be used by controllers.
319 		COLLADA supports two geometry types: mesh and spline.
320 		@return The geometry library. */
GetGeometryLibrary()321 	inline FCDGeometryLibrary* GetGeometryLibrary() { return geometryLibrary; }
GetGeometryLibrary()322 	inline const FCDGeometryLibrary* GetGeometryLibrary() const { return geometryLibrary; } /**< See above. */
323 
324 	/** Retrieves the physics force field library.
325 		Force fields are emitters of physical force and have no COMMON profile in COLLADA.
326 		@return The force field library. */
GetForceFieldLibrary()327 	inline FCDForceFieldLibrary* GetForceFieldLibrary() { return forceFieldLibrary; }
GetForceFieldLibrary()328 	inline const FCDForceFieldLibrary* GetForceFieldLibrary() const { return forceFieldLibrary; } /**< See above. */
329 
330 	/** Retrieves the image library. The image library contains a list of images. Images are used
331 		by effects for textures.
332 		@return The image library. */
GetImageLibrary()333 	inline FCDImageLibrary* GetImageLibrary() { return imageLibrary; }
GetImageLibrary()334 	inline const FCDImageLibrary* GetImageLibrary() const { return imageLibrary; } /**< See above. */
335 
336 	/** Retrieves the light library. The light library contains a list of light, which may be
337 		instantiated within the scene graph. COLLADA supports four light types: ambient, directional,
338 		point and spot lights.
339 		@return The light library. */
GetLightLibrary()340 	inline FCDLightLibrary* GetLightLibrary() { return lightLibrary; }
GetLightLibrary()341 	inline const FCDLightLibrary* GetLightLibrary() const { return lightLibrary; } /**< See above. */
342 
343 	/** Retrieves the visual material library. The visual material library contains a list of visual materials,
344 		which are bound to mesh polygons within the scene graph. A visual material instantiates an effect and
345 		presets the effect parameters for a given visual result.
346 		@return The visual material library. */
GetMaterialLibrary()347 	inline FCDMaterialLibrary* GetMaterialLibrary() { return materialLibrary; }
GetMaterialLibrary()348 	inline const FCDMaterialLibrary* GetMaterialLibrary() const { return materialLibrary; } /**< See above. */
349 
350 	/** Retrieves the effect library. The effect library contains a list of effects, which may be instantiated
351 		by materials. An effect defines an interface for a rendering shader. A ColladaFX effect may contain multiple
352 		passes and techniques for different platforms or level of details.
353 		@return The effect library. */
GetEffectLibrary()354 	inline FCDEffectLibrary* GetEffectLibrary() { return effectLibrary; }
GetEffectLibrary()355 	inline const FCDEffectLibrary* GetEffectLibrary() const { return effectLibrary; } /**< See above. */
356 
357 	/** Retrieves the visual scene library. The visual scene library contains an acyclic directed graph of
358 		visual scene nodes: a visual scene node contains one or more parent nodes and zero or more child nodes.
359 		A visual scene node also contains 3D transformations: translation, rotation, scale, skew, as well as
360 		the compound transformations: lookAt and matrix. A visual scene node also contains instances of
361 		geometries, controllers, cameras and/or lights. Only one visual scene should be used at one time
362 		by the global scene.
363 		@return The visual scene library. */
GetVisualSceneLibrary()364 	inline FCDVisualSceneNodeLibrary* GetVisualSceneLibrary() { return visualSceneLibrary; }
GetVisualSceneLibrary()365 	inline const FCDVisualSceneNodeLibrary* GetVisualSceneLibrary() const { return visualSceneLibrary; } /**< See above. */
366 
367 	/** Retrieves the physics model library.
368 		The physics model library contains a list of physics models.
369 		@return The physics model library. */
GetPhysicsModelLibrary()370 	inline FCDPhysicsModelLibrary* GetPhysicsModelLibrary() { return physicsModelLibrary; }
GetPhysicsModelLibrary()371 	inline const FCDPhysicsModelLibrary* GetPhysicsModelLibrary() const { return physicsModelLibrary; } /**< See above. */
372 
373 	/** Retrieves the physics material library.
374 		The physics material library contains a list of physics material.
375 		@return The physics material library. */
GetPhysicsMaterialLibrary()376 	inline FCDPhysicsMaterialLibrary* GetPhysicsMaterialLibrary() { return physicsMaterialLibrary; }
GetPhysicsMaterialLibrary()377 	inline const FCDPhysicsMaterialLibrary* GetPhysicsMaterialLibrary() const { return physicsMaterialLibrary; } /**< See above. */
378 
379 	/** Retrieves the physics scene library.
380 		The physics scene library contains a list of physics scene nodes.
381 		@return The physics scene library. */
GetPhysicsSceneLibrary()382 	inline FCDPhysicsSceneLibrary* GetPhysicsSceneLibrary() { return physicsSceneLibrary; }
GetPhysicsSceneLibrary()383 	inline const FCDPhysicsSceneLibrary* GetPhysicsSceneLibrary() const { return physicsSceneLibrary; } /**< See above. */
384 
385 	/** Retrieves the emitter library.
386 		The emitter library contains a list of emitter definitions.
387 		@return The emitter library. */
GetEmitterLibrary()388 	inline FCDEmitterLibrary* GetEmitterLibrary() { return emitterLibrary; }
GetEmitterLibrary()389 	inline const FCDEmitterLibrary* GetEmitterLibrary() const { return emitterLibrary; } /**< See above. */
390 
391 	/** Insert a new visual scene within the visual scene library.
392 		The new visual scene will be used as the root visual scene.
393 		@return The newly created visual scene. */
394 	FCDSceneNode* AddVisualScene();
395 
396 	/** Insert a new physics scene within the physics material library.
397 		The new physics scene will be used as the root physics scene.
398 		@return The newly created physics scene. */
399 	FCDPhysicsScene* AddPhysicsScene();
400 
401 	/** Retrieves the animation tree node that matches the given COLLADA id.
402 		@param daeId A valid COLLADA id.
403 		@return The animation tree node. This pointer will be NULL if
404 			no matching animation tree node was found. */
405 	FCDAnimation* FindAnimation(const fm::string& daeId);
406 
407 	/** Retrieves the animation clip that matches the given COLLADA id.
408 		@param daeId A valid COLLADA id.
409 		@return The animation clip. This pointer will be NULL if
410 			no matching animation clip was found. */
411 	FCDAnimationClip* FindAnimationClip(const fm::string& daeId);
412 
413 	/** Retrieves the camera that matches the given COLLADA id.
414 		@param daeId A valid COLLADA id.
415 		@return The camera. This pointer will be NULL if no matching camera was found. */
416 	FCDCamera* FindCamera(const fm::string& daeId);
417 
418 	/** Retrieves the controller that matches the given COLLADA id.
419 		@param daeId A valid COLLADA id.
420 		@return The controller. This pointer will be NULL if no matching controller was found. */
421 	FCDController* FindController(const fm::string& daeId);
422 
423 	/** Retrieves the effect that matches the given COLLADA id.
424 		@param daeId A valid COLLADA id.
425 		@return The effect. This pointer will be NULL if no matching effect was found. */
426 	FCDEffect* FindEffect(const fm::string& daeId);
427 
428 	/** Retrieves the entity that matches the given COLLADA id.
429 		This function will look through all the libraries for any entity
430 		with the given COLLADA id.
431 		@param daeId A valid COLLADA id.
432 		@return The entity. This pointer will be NULL if no matching entity was found. */
433 	FCDEntity* FindEntity(const fm::string& daeId);
434 
435 	/** Retrieves the emitter that matches the given COLLADA id.
436 		@param daeId A valid COLLADA id.
437 		@return The emitter. This pointer will be NULL if no matching emitter was found. */
438 	FCDEmitter* FindEmitter(const fm::string& daeId);
439 
440 	/** Retrieves the force field that matches the given COLLADA id.
441 		@param daeId A valid COLLADA id.
442 		@return The force field. This pointer will be NULL if no matching force field was found. */
443 	FCDForceField* FindForceField(const fm::string& daeId);
444 
445 	/** Retrieves the geometry that matches the given COLLADA id.
446 		@param daeId A valid COLLADA id.
447 		@return The geometry. This pointer will be NULL if no matching geometry was found. */
448 	FCDGeometry* FindGeometry(const fm::string& daeId);
449 
450 	/** Retrieves the image that matches the given COLLADA id.
451 		@param daeId A valid COLLADA id.
452 		@return The image. This pointer will be NULL if no matching image was found. */
453 	FCDImage* FindImage(const fm::string& daeId);
454 
455 	/** Retrieves the layer that matches the given name.
456 		Note that there are no checks for uniqueness in layer names.
457 		@param name A layer name.
458 		@return The layer. This pointer will be NULL if no matching layer was found. */
459 	FCDLayer* FindLayer(const fm::string& name);
460 
461 	/** Retrieves the light that matches the given COLLADA id.
462 		@param daeId A valid COLLADA id.
463 		@return The light. This pointer will be NULL if no matching light was found. */
464 	FCDLight* FindLight(const fm::string& daeId);
465 
466 	/** Retrieves the visual material that matches the given COLLADA id.
467 		@param daeId A valid COLLADA id.
468 		@return The visual material. This pointer will be NULL if no matching visual material was found. */
469 	FCDMaterial* FindMaterial(const fm::string& daeId);
470 
471 	/** Retrieves the visual scene that matches the given COLLADA id.
472 		@param daeId A valid COLLADA id.
473 		@return The visual scene. This pointer will be NULL if no matching visual scene was found. */
474 	FCDSceneNode* FindVisualScene(const fm::string& daeId);
475 
476 	/** Retrieves the physics scene that matches the given COLLADA id.
477 		@param daeId A valid COLLADA id.
478 		@return The physics scene. This pointer will be NULL if no matching physics scene was found. */
479 	FCDPhysicsScene* FindPhysicsScene(const fm::string& daeId);
480 
481 	/** Retrieves the physics material that matches the given COLLADA id.
482 		@param daeId A valid COLLADA id.
483 		@return The physics material. This pointer will be NULL if no matching physics material was found. */
484 	FCDPhysicsMaterial* FindPhysicsMaterial(const fm::string& daeId);
485 
486 	/** Retrieves the physics model that matches the given COLLADA id.
487 		@param daeId A valid COLLADA id.
488 		@return The physics model. This pointer will be NULL if no matching physics model was found. */
489 	FCDPhysicsModel* FindPhysicsModel(const fm::string& daeId);
490 
491 	/** Retrieves the visual scene node that matches the given COLLADA id.
492 		This method searches through all the visual scenes within the visual scene library and
493 		their child visual scene nodes to find the correct visual scene node.
494 		@param daeId A valid COLLADA id.
495 		@return The visual scene node. This pointer will be NULL if no matching visual scene node was found. */
496 	const FCDSceneNode* FindSceneNode(const char* daeId) const;
FindSceneNode(const char * daeId)497 	inline FCDSceneNode* FindSceneNode(const char* daeId) { return const_cast<FCDSceneNode*>(const_cast<const FCDocument*>(this)->FindSceneNode(daeId)); }
498 
499 	/** [INTERNAL] Registers an animated value with the document. All animated values are
500 		listed within the document.
501 		@param animated The new animated value to list within the document. */
502 	void RegisterAnimatedValue(FCDAnimated* animated);
503 
504 	/** [INTERNAL] Unregisters an animated value of the document. All animated values are
505 		listed within the document. This function must be called before deleting an animated value.
506 		@param animated The animated value to un-list from the document. */
507 	void UnregisterAnimatedValue(FCDAnimated* animated);
508 
509 	/** [INTERNAL] Registers an extra tree with the document.
510 		All extra trees are listed within the document to support extra-technique plug-ins.
511 		@param tree The new extra tree to list within the document. */
RegisterExtraTree(FCDExtra * tree)512 	inline void RegisterExtraTree(FCDExtra* tree) { extraTrees.insert(tree, tree); }
513 
514 	/** [INTERNAL] Unregisters an extra tree of the document.
515 		All extra trees are listed within the document to support extra-technique plug-ins.
516 		@param tree The extra tree to un-list from the document. */
UnregisterExtraTree(FCDExtra * tree)517 	inline void UnregisterExtraTree(FCDExtra* tree) { FUAssert(extraTrees.find(tree) != extraTrees.end(), return); extraTrees.erase(tree); }
518 
519 	/** [INTERNAL] Retrieves the set of extra trees.
520 		This function is meant only to be used for supporting the extra-technique plug-ins.
521 		@return The set of extra trees for this document. */
GetExtraTrees()522 	inline FCDExtraSet& GetExtraTrees() { return extraTrees; }
523 };
524 
525 #endif //_FC_DOCUMENT_H_
526