00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00017 #ifndef _FC_DOCUMENT_H_
00018 #define _FC_DOCUMENT_H_
00019
00020 #include "FUtils/FUObject.h"
00021
00022 template <class T> class FCDLibrary;
00023 template <class T> class FUUniqueStringMapT;
00024
00025 class FCDAnimation;
00026 class FCDAnimationChannel;
00027 class FCDAnimationClip;
00028 class FCDAnimated;
00029 class FCDAsset;
00030 class FCDCamera;
00031 class FCDController;
00032 class FCDEffect;
00033 class FCDGeometry;
00034 class FCDImage;
00035 class FCDLight;
00036 class FCDMaterial;
00037 class FCDMaterialLibrary;
00038 class FCDObject;
00039 class FCDPhysicsMaterial;
00040 class FCDPhysicsModel;
00041 class FCDPhysicsSceneNode;
00042 class FCDTexture;
00043 class FCDSceneNode;
00044 class FUFileManager;
00045
00050 class FCOLLADA_EXPORT FCDLayer
00051 {
00052 public:
00053 string name;
00054 StringList objects;
00055 };
00056
00057 typedef vector<FCDMaterial*> FCDMaterialList;
00058 typedef vector<FCDAnimated*> FCDAnimatedList;
00059 typedef vector<FCDAnimationChannel*> FCDAnimationChannelList;
00060 typedef map<const float*, FCDAnimated*> FCDAnimatedValueMap;
00061 typedef vector<FCDLayer*> FCDLayerList;
00062 typedef vector<FCDObject*> FCDObjectList;
00064 typedef FCDLibrary<FCDAnimation> FCDAnimationLibrary;
00065 typedef FCDLibrary<FCDAnimationClip> FCDAnimationClipLibrary;
00066 typedef FCDLibrary<FCDCamera> FCDCameraLibrary;
00067 typedef FCDLibrary<FCDController> FCDControllerLibrary;
00068 typedef FCDLibrary<FCDGeometry> FCDGeometryLibrary;
00069 typedef FCDLibrary<FCDImage> FCDImageLibrary;
00070 typedef FCDLibrary<FCDLight> FCDLightLibrary;
00071 typedef FCDLibrary<FCDSceneNode> FCDVisualSceneNodeLibrary;
00072 typedef FCDLibrary<FCDPhysicsModel> FCDPhysicsModelLibrary;
00073 typedef FCDLibrary<FCDPhysicsMaterial> FCDPhysicsMaterialLibrary;
00074 typedef FCDLibrary<FCDPhysicsSceneNode> FCDPhysicsSceneLibrary;
00075 typedef FUUniqueStringMapT<FUSStringBuilder> FUSUniqueStringMap;
00090 class FCOLLADA_EXPORT FCDocument : public FUObjectContainer
00091 {
00092 private:
00093 FUFileManager* fileManager;
00094 FCDSceneNode* visualSceneRoot;
00095 FCDPhysicsSceneNode* physicsSceneRoot;
00096 FUSUniqueStringMap* uniqueNameMap;
00097
00098
00099 FCDAsset* asset;
00100 float lengthUnitWanted, lengthUnitConversion;
00101 bool hasStartTime, hasEndTime;
00102 float startTime, endTime;
00103 FCDLayerList layers;
00104
00105
00106 FCDAnimationLibrary* animationLibrary;
00107 FCDAnimationClipLibrary* animationClipLibrary;
00108 FCDCameraLibrary* cameraLibrary;
00109 FCDControllerLibrary* controllerLibrary;
00110 FCDGeometryLibrary* geometryLibrary;
00111 FCDImageLibrary* imageLibrary;
00112 FCDLightLibrary* lightLibrary;
00113 FCDMaterialLibrary* materialLibrary;
00114 FCDPhysicsModelLibrary* physicsModelLibrary;
00115 FCDPhysicsMaterialLibrary* physicsMaterialLibrary;
00116 FCDPhysicsSceneLibrary* physicsSceneLibrary;
00117 FCDVisualSceneNodeLibrary* visualSceneLibrary;
00118
00119
00120 FCDAnimatedList animatedValues;
00121 FCDAnimatedValueMap animatedValueMap;
00122
00123 StringList postCmds;
00124
00125 public:
00127 FCDocument();
00128
00130 virtual ~FCDocument();
00131
00134 FCDAsset* GetAsset() { return asset; }
00135 const FCDAsset* GetAsset() const { return asset; }
00140 FUFileManager* GetFileManager() { return fileManager; }
00141 const FUFileManager* GetFileManager() const { return fileManager; }
00145 FCDSceneNode* GetVisualSceneRoot() { return visualSceneRoot; }
00146 const FCDSceneNode* GetVisualSceneRoot() const { return visualSceneRoot; }
00150 FCDPhysicsSceneNode* GetPhysicsSceneRoot() { return physicsSceneRoot; }
00151 const FCDPhysicsSceneNode* GetPhysicsSceneRoot() const { return physicsSceneRoot; }
00155 const FCDMaterialList& GetMaterialList();
00156
00159 FUSUniqueStringMap* GetUniqueNameMap() { return uniqueNameMap; }
00160 const FUSUniqueStringMap* GetUniqueNameMap() const { return uniqueNameMap; }
00165 const FMVector3& GetUpAxis() const;
00166
00171 float GetLengthUnit() const;
00172
00176 float GetLengthUnitConversion() const { return lengthUnitConversion; }
00177
00181 inline void SetLengthUnitWanted(float wantedLengthUnit) { lengthUnitWanted = wantedLengthUnit; }
00182
00185 bool HasStartTime() const { return hasStartTime; }
00188 float GetStartTime() const { return startTime; }
00191 void SetStartTime(float time) { startTime = time; hasStartTime = true; }
00192
00195 bool HasEndTime() const { return hasEndTime; }
00198 float GetEndTime() const { return endTime; }
00201 void SetEndTime(float time) { endTime = time; hasEndTime = true; }
00202
00205 FCDLayerList& GetLayers() { return layers; }
00206 const FCDLayerList& GetLayers() const { return layers; }
00210 size_t GetLayerCount() const { return layers.size(); }
00211
00216 FCDLayer* GetLayer(size_t index) { FUAssert(index < GetLayerCount(), return NULL); return layers.at(index); }
00217 const FCDLayer* GetLayer(size_t index) const { FUAssert(index < GetLayerCount(), return NULL); return layers.at(index); }
00218
00221 FCDLayer* AddLayer();
00222
00225 void ReleaseLayer(FCDLayer* layer);
00226
00232 FCDAnimationLibrary* GetAnimationLibrary() { return animationLibrary; }
00233 const FCDAnimationLibrary* GetAnimationLibrary() const { return animationLibrary; }
00239 FCDAnimationClipLibrary* GetAnimationClipLibrary() { return animationClipLibrary; }
00240 const FCDAnimationClipLibrary* GetAnimationClipLibrary() const { return animationClipLibrary; }
00245 FCDCameraLibrary* GetCameraLibrary() { return cameraLibrary; }
00246 const FCDCameraLibrary* GetCameraLibrary() const { return cameraLibrary; }
00251 FCDControllerLibrary* GetControllerLibrary() { return controllerLibrary; }
00252 const FCDControllerLibrary* GetControllerLibrary() const { return controllerLibrary; }
00258 FCDGeometryLibrary* GetGeometryLibrary() { return geometryLibrary; }
00259 const FCDGeometryLibrary* GetGeometryLibrary() const { return geometryLibrary; }
00264 FCDImageLibrary* GetImageLibrary() { return imageLibrary; }
00265 const FCDImageLibrary* GetImageLibrary() const { return imageLibrary; }
00271 FCDLightLibrary* GetLightLibrary() { return lightLibrary; }
00272 const FCDLightLibrary* GetLightLibrary() const { return lightLibrary; }
00278 FCDMaterialLibrary* GetMaterialLibrary() { return materialLibrary; }
00279 const FCDMaterialLibrary* GetMaterialLibrary() const { return materialLibrary; }
00285 FCDMaterialLibrary* GetEffectLibrary() { return materialLibrary; }
00286 const FCDMaterialLibrary* GetEffectLibrary() const { return materialLibrary; }
00295 FCDVisualSceneNodeLibrary* GetVisualSceneLibrary() { return visualSceneLibrary; }
00296 const FCDVisualSceneNodeLibrary* GetVisualSceneLibrary() const { return visualSceneLibrary; }
00300 FCDPhysicsModelLibrary* GetPhysicsModelLibrary() { return physicsModelLibrary; }
00301 const FCDPhysicsModelLibrary* GetPhysicsModelLibrary() const { return physicsModelLibrary; }
00305 FCDPhysicsMaterialLibrary* GetPhysicsMaterialLibrary() { return physicsMaterialLibrary; }
00306 const FCDPhysicsMaterialLibrary* GetPhysicsMaterialLibrary() const { return physicsMaterialLibrary; }
00311 FCDPhysicsSceneLibrary* GetPhysicsSceneLibrary() { return physicsSceneLibrary;}
00312 const FCDPhysicsSceneLibrary* GetPhysicsSceneLibrary() const { return physicsSceneLibrary;}
00317 FCDSceneNode* AddVisualScene();
00318
00322 FCDPhysicsSceneNode* AddPhysicsScene();
00323
00328 void FindAnimationChannels(const string& pointer, FCDAnimationChannelList& channels);
00329
00334 void FindAnimationChannelsArrayIndices(xmlNode* targetArray, Int32List& animatedIndices);
00335
00340 FCDAnimation* FindAnimation(const string& daeId);
00341
00346 FCDAnimationClip* FindAnimationClip(const string& daeId);
00347
00351 FCDCamera* FindCamera(const string& daeId);
00352
00356 FCDController* FindController(const string& daeId);
00357
00361 FCDEffect* FindEffect(const string& daeId);
00362
00366 FCDGeometry* FindGeometry(const string& daeId);
00367
00371 FCDImage* FindImage(const string& daeId);
00372
00376 FCDLight* FindLight(const string& daeId);
00377
00381 FCDMaterial* FindMaterial(const string& daeId);
00382
00386 FCDTexture* FindTexture(const string& daeId);
00387
00391 FCDSceneNode* FindVisualScene(const string& daeId);
00392
00396 FCDPhysicsSceneNode* FindPhysicsScene(const string& daeId);
00397
00401 FCDPhysicsMaterial* FindPhysicsMaterial(const string& daeId);
00402
00406 FCDPhysicsModel* FindPhysicsModel(const string& daeId);
00407
00413 FCDSceneNode* FindSceneNode(const string& daeId);
00414
00418 void RegisterAnimatedValue(FCDAnimated* animated);
00419
00423 void UnregisterAnimatedValue(FCDAnimated* animated);
00424
00430 bool LinkDriver(FCDAnimated* animated);
00431
00435 FCDAnimated* FindAnimatedValue(float* ptr);
00436 const FCDAnimated* FindAnimatedValue(const float* ptr) const;
00442 const float* FindAnimatedTarget(const string& fullyQualifiedTarget);
00443
00450 const FCDAnimated* FindNamedAnimated(const string& shader, const string& attribute) const;
00451
00455 bool IsValueAnimated(const float* ptr) const;
00456
00462 FUStatus LoadFromFile(const fstring& filename);
00463
00471 FUStatus LoadFromText(const fstring& basePath, const fchar* text);
00472
00478 FUStatus LoadDocumentFromXML(xmlNode* colladaNode);
00479
00486 FUStatus WriteToFile(const fstring& filename) const;
00487
00494 FUStatus WriteDocumentToXML(xmlNode* colladaNode) const;
00495
00505 void WriteAnimatedValueToXML(const float* value, xmlNode* valueNode, const char* wantedSid, int32 arrayElement = -1) const;
00506
00509 const StringList& GetPostProcessCmds() const { return postCmds; }
00510
00514 const FCDAnimatedList& getAnimatedValues() { return animatedValues; }
00515 };
00516
00517 #endif //_FC_DOCUMENT_H_