- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# FCDocument/FCDocument.h

Go to the documentation of this file.

    00001 /*
    00002     Copyright (C) 2005-2007 Feeling Software Inc.
    00003     Portions of the code are:
    00004     Copyright (C) 2005-2007 Sony Computer Entertainment America
    00005
    00006     MIT License: http://www.opensource.org/licenses/mit-license.php
    00007 */
    00008 /*
    00009     Based on the FS Import classes:
    00010     Copyright (C) 2005-2006 Feeling Software Inc
    00011     Copyright (C) 2005-2006 Autodesk Media Entertainment
    00012     MIT License: http://www.opensource.org/licenses/mit-license.php
    00013 */
    00014
    00020 #ifndef _FC_DOCUMENT_H_
    00021 #define _FC_DOCUMENT_H_
    00022
    00023 #ifndef __FCD_OBJECT_H_
    00024 #include "FCDocument/FCDObject.h"
    00025 #endif // __FCD_OBJECT_H_
    00026 #ifndef _FU_PARAMETER_H_
    00027 #include "FUtils/FUParameter.h"
    00028 #endif // _FU_PARAMETER_H_
    00029
    00030 #ifndef LINUX
    00031 template <class T> class FCOLLADA_EXPORT FCDLibrary;
    00032 template <class T> class FCOLLADA_EXPORT FUUniqueStringMapT;
    00033 #else
    00034 template <class T> class FCDLibrary;
    00035 template <class T> class FUUniqueStringMapT;
    00036 #endif // LINUX
    00037
    00038 class FCDAnimated;
    00039 class FCDAnimation;
    00040 class FCDAnimationChannel;
    00041 class FCDAnimationClip;
    00042 class FCDAsset;
    00043 class FCDCamera;
    00044 class FCDController;
    00045 class FCDEffect;
    00046 class FCDEntity;
    00047 class FCDEntityReference;
    00048 class FCDEmitter;
    00049 class FCDExternalReferenceManager;
    00050 class FCDExtra;
    00051 class FCDForceField;
    00052 class FCDGeometry;
    00053 class FCDImage;
    00054 class FCDLight;
    00055 class FCDMaterial;
    00056 class FCDObject;
    00057 class FCDPhysicsMaterial;
    00058 class FCDPhysicsModel;
    00059 class FCDPhysicsScene;
    00060 class FCDTexture;
    00061 class FCDSceneNode;
    00062 class FCDVersion;
    00063 class FUFileManager;
    00064
    00069 class FCOLLADA_EXPORT FCDLayer
    00070 {
    00071 public:
    00072     fm::string name;
    00073     StringList objects;
    00074 };
    00075
    00076 typedef fm::pvector<FCDLayer> FCDLayerList;
    00078 typedef FCDLibrary<FCDAnimation> FCDAnimationLibrary;
    00079 typedef FCDLibrary<FCDAnimationClip> FCDAnimationClipLibrary;
    00080 typedef FCDLibrary<FCDCamera> FCDCameraLibrary;
    00081 typedef FCDLibrary<FCDController> FCDControllerLibrary;
    00082 typedef FCDLibrary<FCDEffect> FCDEffectLibrary;
    00083 typedef FCDLibrary<FCDEmitter> FCDEmitterLibrary;
    00084 typedef FCDLibrary<FCDForceField> FCDForceFieldLibrary;
    00085 typedef FCDLibrary<FCDGeometry> FCDGeometryLibrary;
    00086 typedef FCDLibrary<FCDImage> FCDImageLibrary;
    00087 typedef FCDLibrary<FCDLight> FCDLightLibrary;
    00088 typedef FCDLibrary<FCDMaterial> FCDMaterialLibrary;
    00089 typedef FCDLibrary<FCDSceneNode> FCDVisualSceneNodeLibrary;
    00090 typedef FCDLibrary<FCDPhysicsModel> FCDPhysicsModelLibrary;
    00091 typedef FCDLibrary<FCDPhysicsMaterial> FCDPhysicsMaterialLibrary;
    00092 typedef FCDLibrary<FCDPhysicsScene> FCDPhysicsSceneLibrary;
    00093 typedef FUUniqueStringMapT<char> FUSUniqueStringMap;
    00094 typedef fm::map<FCDExtra*, FCDExtra*> FCDExtraSet;
    00109 class FCOLLADA_EXPORT FCDocument : public FCDObject
    00110 {
    00111 private:
    00112     DeclareObjectType(FCDObject);
    00113
    00114     FUFileManager* fileManager;
    00115     FUObjectRef<FCDExternalReferenceManager> externalReferenceManager;
    00116     fstring fileUrl;
    00117     FCDVersion* version;
    00118     FCDExtraSet extraTrees;
    00119
    00120     FUSUniqueStringMap* uniqueNameMap;
    00121     DeclareParameterRef(FCDEntityReference, visualSceneRoot, FC("Root Visual Scene"));
    00122     DeclareParameterContainer(FCDEntityReference, physicsSceneRoots, FC("Root Physics Scenes"));
    00123
    00124     // Document parameters
    00125     DeclareParameterRef(FCDAsset, asset, FC("Asset Tag"));
    00126     DeclareParameterRef(FCDExtra, extra, FC("Extra Tree"));
    00127     bool hasStartTime, hasEndTime;
    00128     DeclareParameter(float, FUParameterQualifiers::SIMPLE, startTime, FC("Start Time"));
    00129     DeclareParameter(float, FUParameterQualifiers::SIMPLE, endTime, FC("End Time"));
    00130     FCDLayerList layers; // Maya-only
    00131
    00132     // Parsed and merged libraries
    00133     DeclareParameterRef(FCDAnimationLibrary, animationLibrary, FC("Animation Library"));
    00134     DeclareParameterRef(FCDAnimationClipLibrary, animationClipLibrary, FC("Animation Clip Library"));
    00135     DeclareParameterRef(FCDCameraLibrary, cameraLibrary, FC("Camera Library"));
    00136     DeclareParameterRef(FCDControllerLibrary, controllerLibrary, FC("Controller Library"));
    00137     DeclareParameterRef(FCDEffectLibrary, effectLibrary, FC("Effect Library"));
    00138     DeclareParameterRef(FCDForceFieldLibrary, forceFieldLibrary, FC("Force-field Library"));
    00139     DeclareParameterRef(FCDGeometryLibrary, geometryLibrary, FC("Geometry Library"));
    00140     DeclareParameterRef(FCDImageLibrary, imageLibrary, FC("Image Library"));
    00141     DeclareParameterRef(FCDLightLibrary, lightLibrary, FC("Light Library"));
    00142     DeclareParameterRef(FCDMaterialLibrary, materialLibrary, FC("Material Library"));
    00143     DeclareParameterRef(FCDPhysicsModelLibrary, physicsModelLibrary, FC("Physics Model Library"));
    00144     DeclareParameterRef(FCDPhysicsMaterialLibrary, physicsMaterialLibrary, FC("Physics Material Library"));
    00145     DeclareParameterRef(FCDPhysicsSceneLibrary, physicsSceneLibrary, FC("Physics Scene Library"));
    00146     DeclareParameterRef(FCDVisualSceneNodeLibrary, visualSceneLibrary, FC("Visual Scene Library"));
    00147     DeclareParameterRef(FCDEmitterLibrary, emitterLibrary, FC("Emitter Library"));
    00148
    00149     // Animated values
    00150     typedef fm::map<FCDAnimated*, FCDAnimated*> FCDAnimatedSet;
    00151     FCDAnimatedSet animatedValues;
    00152
    00153 public:
    00155     FCDocument();
    00156
    00158     virtual ~FCDocument();
    00159
    00162     inline FCDAsset* GetAsset() { return asset; }
    00163     inline const FCDAsset* GetAsset() const { return asset; }
    00168     inline FCDExtra* GetExtra() { return extra; }
    00169     inline const FCDExtra* GetExtra() const { return extra; }
    00173     inline FCDVersion& GetVersion() { return *version; }
    00174     inline const FCDVersion& GetVersion() const { return *version; }
    00179     inline FUFileManager* GetFileManager() { return fileManager; }
    00180     inline const FUFileManager* GetFileManager() const { return fileManager; }
    00185     inline FCDSceneNode* GetVisualSceneInstance() { return const_cast<FCDSceneNode*>(const_cast<const FCDocument*>(this)->GetVisualSceneInstance()); }
    00186     const FCDSceneNode* GetVisualSceneInstance() const;
    00187     DEPRECATED(3.04A, FCDocument::GetVisualSceneInstance) inline FCDSceneNode* GetVisualSceneRoot() { return GetVisualSceneInstance(); }
    00188     DEPRECATED(3.04A, FCDocument::GetVisualSceneInstance) inline const FCDSceneNode* GetVisualSceneRoot() const { return GetVisualSceneInstance(); }
    00192     inline FCDEntityReference* GetVisualSceneInstanceReference() { return visualSceneRoot; }
    00193     inline const FCDEntityReference* GetVisualSceneInstanceReference() const { return visualSceneRoot; }
    00197     inline size_t GetPhysicsSceneInstanceCount() const { return physicsSceneRoots.size(); }
    00198
    00203     inline FCDPhysicsScene* GetPhysicsSceneInstance(size_t index = 0) { return const_cast<FCDPhysicsScene*>(const_cast<const FCDocument*>(this)->GetPhysicsSceneInstance(index)); }
    00204     const FCDPhysicsScene* GetPhysicsSceneInstance(size_t index = 0) const;
    00205     DEPRECATED(3.04A, FCDocument::GetPhysicsSceneInstance) inline FCDPhysicsScene* GetPhysicsSceneRoot(size_t index = 0) { return GetPhysicsSceneInstance(index); }
    00206     DEPRECATED(3.04A, FCDocument::GetPhysicsSceneInstance) inline const FCDPhysicsScene* GetPhysicsSceneRoot(size_t index = 0) const { return GetPhysicsSceneInstance(index); }
    00210     void AddPhysicsSceneInstance(FCDPhysicsScene* scene);
    00211
    00216     inline FCDEntityReference* GetPhysicsSceneInstanceReference(size_t index = 0) { if (index == 0 && physicsSceneRoots.empty()) return NULL; FUAssert(index < physicsSceneRoots.size(), return NULL); return physicsSceneRoots[index]; }
    00217     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]; }
    00218
    00221     FCDEntityReference* AddPhysicsSceneInstanceReference();
    00222
    00225     inline FUSUniqueStringMap* GetUniqueNameMap() { return uniqueNameMap; }
    00226     inline const FUSUniqueStringMap* GetUniqueNameMap() const { return uniqueNameMap; }
    00230     inline FCDExternalReferenceManager* GetExternalReferenceManager() { return externalReferenceManager; }
    00231     inline const FCDExternalReferenceManager* GetExternalReferenceManager() const { return externalReferenceManager; }
    00235     const fstring& GetFileUrl() const { return fileUrl; }
    00236
    00240     void SetFileUrl(const fstring& filename);
    00241
    00244     inline bool HasStartTime() const { return hasStartTime; }
    00247     inline float GetStartTime() const { return startTime; }
    00250     inline void SetStartTime(float time) { startTime = time; hasStartTime = true; }
    00251
    00254     inline bool HasEndTime() const { return hasEndTime; }
    00257     inline float GetEndTime() const { return endTime; }
    00260     inline void SetEndTime(float time) { endTime = time; hasEndTime = true; }
    00261
    00264     inline void SetCurrentTime(float time);
    00265
    00268     inline FCDLayerList& GetLayers() { return layers; }
    00269     inline const FCDLayerList& GetLayers() const { return layers; }
    00273     inline size_t GetLayerCount() const { return layers.size(); }
    00274
    00279     inline FCDLayer* GetLayer(size_t index) { FUAssert(index < GetLayerCount(), return NULL); return layers.at(index); }
    00280     inline const FCDLayer* GetLayer(size_t index) const { FUAssert(index < GetLayerCount(), return NULL); return layers.at(index); }
    00284     FCDLayer* AddLayer();
    00285
    00288     void ReleaseLayer(FCDLayer* layer);
    00289
    00295     inline FCDAnimationLibrary* GetAnimationLibrary() { return animationLibrary; }
    00296     inline const FCDAnimationLibrary* GetAnimationLibrary() const { return animationLibrary; }
    00302     inline FCDAnimationClipLibrary* GetAnimationClipLibrary() { return animationClipLibrary; }
    00303     inline const FCDAnimationClipLibrary* GetAnimationClipLibrary() const { return animationClipLibrary; }
    00308     inline FCDCameraLibrary* GetCameraLibrary() { return cameraLibrary; }
    00309     inline const FCDCameraLibrary* GetCameraLibrary() const { return cameraLibrary; }
    00314     inline FCDControllerLibrary* GetControllerLibrary() { return controllerLibrary; }
    00315     inline const FCDControllerLibrary* GetControllerLibrary() const { return controllerLibrary; }
    00321     inline FCDGeometryLibrary* GetGeometryLibrary() { return geometryLibrary; }
    00322     inline const FCDGeometryLibrary* GetGeometryLibrary() const { return geometryLibrary; }
    00327     inline FCDForceFieldLibrary* GetForceFieldLibrary() { return forceFieldLibrary; }
    00328     inline const FCDForceFieldLibrary* GetForceFieldLibrary() const { return forceFieldLibrary; }
    00333     inline FCDImageLibrary* GetImageLibrary() { return imageLibrary; }
    00334     inline const FCDImageLibrary* GetImageLibrary() const { return imageLibrary; }
    00340     inline FCDLightLibrary* GetLightLibrary() { return lightLibrary; }
    00341     inline const FCDLightLibrary* GetLightLibrary() const { return lightLibrary; }
    00347     inline FCDMaterialLibrary* GetMaterialLibrary() { return materialLibrary; }
    00348     inline const FCDMaterialLibrary* GetMaterialLibrary() const { return materialLibrary; }
    00354     inline FCDEffectLibrary* GetEffectLibrary() { return effectLibrary; }
    00355     inline const FCDEffectLibrary* GetEffectLibrary() const { return effectLibrary; }
    00364     inline FCDVisualSceneNodeLibrary* GetVisualSceneLibrary() { return visualSceneLibrary; }
    00365     inline const FCDVisualSceneNodeLibrary* GetVisualSceneLibrary() const { return visualSceneLibrary; }
    00370     inline FCDPhysicsModelLibrary* GetPhysicsModelLibrary() { return physicsModelLibrary; }
    00371     inline const FCDPhysicsModelLibrary* GetPhysicsModelLibrary() const { return physicsModelLibrary; }
    00376     inline FCDPhysicsMaterialLibrary* GetPhysicsMaterialLibrary() { return physicsMaterialLibrary; }
    00377     inline const FCDPhysicsMaterialLibrary* GetPhysicsMaterialLibrary() const { return physicsMaterialLibrary; }
    00382     inline FCDPhysicsSceneLibrary* GetPhysicsSceneLibrary() { return physicsSceneLibrary; }
    00383     inline const FCDPhysicsSceneLibrary* GetPhysicsSceneLibrary() const { return physicsSceneLibrary; }
    00388     inline FCDEmitterLibrary* GetEmitterLibrary() { return emitterLibrary; }
    00389     inline const FCDEmitterLibrary* GetEmitterLibrary() const { return emitterLibrary; }
    00394     FCDSceneNode* AddVisualScene();
    00395
    00399     FCDPhysicsScene* AddPhysicsScene();
    00400
    00405     FCDAnimation* FindAnimation(const fm::string& daeId);
    00406
    00411     FCDAnimationClip* FindAnimationClip(const fm::string& daeId);
    00412
    00416     FCDCamera* FindCamera(const fm::string& daeId);
    00417
    00421     FCDController* FindController(const fm::string& daeId);
    00422
    00426     FCDEffect* FindEffect(const fm::string& daeId);
    00427
    00433     FCDEntity* FindEntity(const fm::string& daeId);
    00434
    00438     FCDEmitter* FindEmitter(const fm::string& daeId);
    00439
    00443     FCDForceField* FindForceField(const fm::string& daeId);
    00444
    00448     FCDGeometry* FindGeometry(const fm::string& daeId);
    00449
    00453     FCDImage* FindImage(const fm::string& daeId);
    00454
    00459     FCDLayer* FindLayer(const fm::string& name);
    00460
    00464     FCDLight* FindLight(const fm::string& daeId);
    00465
    00469     FCDMaterial* FindMaterial(const fm::string& daeId);
    00470
    00474     FCDSceneNode* FindVisualScene(const fm::string& daeId);
    00475
    00479     FCDPhysicsScene* FindPhysicsScene(const fm::string& daeId);
    00480
    00484     FCDPhysicsMaterial* FindPhysicsMaterial(const fm::string& daeId);
    00485
    00489     FCDPhysicsModel* FindPhysicsModel(const fm::string& daeId);
    00490
    00496     const FCDSceneNode* FindSceneNode(const char* daeId) const;
    00497     inline FCDSceneNode* FindSceneNode(const char* daeId) { return const_cast<FCDSceneNode*>(const_cast<const FCDocument*>(this)->FindSceneNode(daeId)); }
    00498
    00502     void RegisterAnimatedValue(FCDAnimated* animated);
    00503
    00507     void UnregisterAnimatedValue(FCDAnimated* animated);
    00508
    00512     inline void RegisterExtraTree(FCDExtra* tree) { extraTrees.insert(tree, tree); }
    00513
    00517     inline void UnregisterExtraTree(FCDExtra* tree) { FUAssert(extraTrees.find(tree) != extraTrees.end(), return); extraTrees.erase(tree); }
    00518
    00522     inline FCDExtraSet& GetExtraTrees() { return extraTrees; }
    00523 };
    00524
    00525 #endif //_FC_DOCUMENT_H_