FCDocument/FCDGeometrySource.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 
00014 #ifndef _FCD_GEOMETRY_SOURCE_H_
00015 #define _FCD_GEOMETRY_SOURCE_H_
00016 
00017 #ifndef __FCD_OBJECT_WITH_ID_H_
00018 #include "FCDocument/FCDObjectWithId.h"
00019 #endif // __FCD_OBJECT_WITH_ID_H_
00020 #ifndef _FU_DAE_ENUM_H_
00021 #include "FUtils/FUDaeEnum.h"
00022 #endif // _FU_DAE_ENUM_H_
00023 #ifndef _FCD_PARAMETER_ANIMATABLE_H_
00024 #include "FCDocument/FCDParameterAnimatable.h"
00025 #endif // _FCD_PARAMETER_ANIMATABLE_H_
00026 
00027 class FCDExtra;
00028 
00043 class FCOLLADA_EXPORT FCDGeometrySource : public FCDObjectWithId
00044 {
00045 private:
00046     DeclareObjectType(FCDObjectWithId);
00047     DeclareParameter(fstring, FUParameterQualifiers::SIMPLE, name, FC("Name"));
00048     DeclareParameterListAnimatable(float, FUParameterQualifiers::SIMPLE, sourceData, FC("Data"))
00049     DeclareParameter(uint32, FUParameterQualifiers::SIMPLE, stride, FC("Stride"));
00050     DeclareParameter(uint32, FUParameterQualifiers::SIMPLE, sourceType, FC("Value Type")); // FUDaeGeometryInput::Semantic sourceType;
00051     DeclareParameterRef(FCDExtra, extra, FC("Extra Tree"));
00052 
00053 public:
00057     FCDGeometrySource(FCDocument* document);
00058 
00060     virtual ~FCDGeometrySource();
00061 
00067     FCDGeometrySource* Clone(FCDGeometrySource* clone = NULL) const;
00068 
00072     inline const fstring& GetName() const { return name; }
00073 
00077     inline float* GetData() { return !sourceData.empty() ? &sourceData.front() : NULL; }
00078     inline const float* GetData() const { return !sourceData.empty() ? &sourceData.front() : NULL; } 
00083     inline FCDParameterListAnimatableFloat& GetSourceData(){ return sourceData; }
00084     inline const FCDParameterListAnimatableFloat& GetSourceData() const { return sourceData; }
00085 
00089     inline float** GetDataPtr() { return (float**) sourceData.GetDataPtr(); }
00090     inline const float** GetDataPtr() const { return (const float**) sourceData.GetDataPtr(); } 
00094     inline size_t GetDataCount() const { return sourceData.size(); }
00095 
00100     void SetDataCount(size_t count);
00101 
00108     inline uint32 GetStride() const { return stride; }
00109 
00112     inline size_t GetValueCount() const { return sourceData.size() / stride; }
00113 
00116     inline size_t GetValueReserved() const { return sourceData.capacity() / stride; }
00117 
00121     inline void SetValueCount(size_t count) { FUAssert(stride > 0, return); SetDataCount(count * stride); }
00122 
00126     inline const float* GetValue(size_t index) const { FUAssert(index < GetValueCount(), return NULL); return &sourceData.at(index * stride); } 
00131     inline void SetValue(size_t index, const float* value) { FUAssert(index < GetValueCount(), return); for (size_t i = 0; i < stride; ++i) sourceData.set(stride * index + i, value[i]); }
00132 
00138     inline FUDaeGeometryInput::Semantic GetType() const { return (FUDaeGeometryInput::Semantic) *sourceType; }
00139 
00146     inline void SetType(FUDaeGeometryInput::Semantic type) { sourceType = type; }
00147 
00150     inline FUObjectContainer<FCDAnimated>& GetAnimatedValues() { return sourceData.GetAnimatedValues(); }
00151     inline const FUObjectContainer<FCDAnimated>& GetAnimatedValues() const { return sourceData.GetAnimatedValues(); } 
00156     inline void SetName(const fstring& _name) { name = _name; SetDirtyFlag(); }
00157 
00165     void SetData(const FloatList& _sourceData, uint32 _sourceStride, size_t count=0, size_t offset=0);
00166 
00169     inline void SetStride(uint32 _stride) { stride = _stride; SetDirtyFlag(); }
00170 
00173     void SetSourceType(FUDaeGeometryInput::Semantic type) { sourceType = type; }
00174 
00180     FCDExtra* GetExtra();
00181     inline const FCDExtra* GetExtra() const { return extra; } 
00185     FCDGeometrySource* Clone() const;
00186 };
00187 
00188 #endif // _FCD_GEOMETRY_SOURCE_H_

Generated on Thu Feb 14 16:58:34 2008 for FCollada by  doxygen 1.4.6-NO