1 | /*
|
---|
2 | Copyright (C) 2005-2006 Feeling Software Inc.
|
---|
3 | MIT License: http://www.opensource.org/licenses/mit-license.php
|
---|
4 | */
|
---|
5 |
|
---|
6 | /**
|
---|
7 | @file FCDGeometrySource.h
|
---|
8 | This file contains the FCDGeometrySource class.
|
---|
9 | */
|
---|
10 |
|
---|
11 | #ifndef _FCD_GEOMETRY_SOURCE_H_
|
---|
12 | #define _FCD_GEOMETRY_SOURCE_H_
|
---|
13 |
|
---|
14 |
|
---|
15 | #include "FCDocument/FCDObject.h"
|
---|
16 | #include "FUtils/FUDaeEnum.h"
|
---|
17 |
|
---|
18 | class FCDAnimated;
|
---|
19 |
|
---|
20 | /** A dynamically-sized array of FCDAnimated objects. */
|
---|
21 | typedef vector<FCDAnimated*> FCDAnimatedList;
|
---|
22 |
|
---|
23 | /**
|
---|
24 | A COLLADA data source for geometric meshes.
|
---|
25 |
|
---|
26 | A COLLADA data source for geometric meshes contains a list of floating-point values and the information
|
---|
27 | to parse these floating-point values into meaningful content: the stride of the list and the type of data
|
---|
28 | that the floating-point values represent. When the floating-point values are split according to the stride,
|
---|
29 | you get multiple elemental values of the given type. A data source may also have a user-generated name to
|
---|
30 | identify the data within. The name is optional and is used to keep around the user-friendly name for texture coordinate
|
---|
31 | sets or color sets.
|
---|
32 |
|
---|
33 | The values of the COLLADA data source may be animated individually, or together: as an element.
|
---|
34 |
|
---|
35 | @ingroup FCDGeometry
|
---|
36 | */
|
---|
37 | class FCOLLADA_EXPORT FCDGeometrySource : public FCDObjectWithId
|
---|
38 | {
|
---|
39 | private:
|
---|
40 | DeclareObjectType
|
---|
41 | fstring name;
|
---|
42 | FloatList sourceData;
|
---|
43 | uint32 sourceStride;
|
---|
44 | xmlNode* sourceNode;
|
---|
45 | FUDaeGeometryInput::Semantic sourceType;
|
---|
46 |
|
---|
47 | // The animated values held here are contained within the document.
|
---|
48 | FCDAnimatedList animatedValues;
|
---|
49 |
|
---|
50 | public:
|
---|
51 | /** Constructor: do not use directly.
|
---|
52 | Use FCDGeometryMesh::AddSource or FCDGeometryMesh::AddValueSource instead.
|
---|
53 | @param document The COLLADA document which owns the data source. */
|
---|
54 | FCDGeometrySource(FCDocument* document);
|
---|
55 |
|
---|
56 | /** Destructor: do not use directly.
|
---|
57 | The geometric mesh which contains the data source will release it. */
|
---|
58 | virtual ~FCDGeometrySource();
|
---|
59 |
|
---|
60 | /** Retrieves the name of the data source. The name is optional and is used to
|
---|
61 | keep around a user-friendly name for texture coordinate sets or color sets.
|
---|
62 | @return The name of the data source. */
|
---|
63 | const fstring& GetName() const { return name; }
|
---|
64 |
|
---|
65 | /** Retrieves the pure data of the data source. This is a dynamically-sized array of
|
---|
66 | floating-point values that contains all the data of the source.
|
---|
67 | @return The pure data of the data source. */
|
---|
68 | FloatList& GetSourceData() { return sourceData; }
|
---|
69 | const FloatList& GetSourceData() const { return sourceData; } /**< See above. */
|
---|
70 |
|
---|
71 | /** Retrieves the stride of the data within the source.
|
---|
72 | There is no guarantee that the number of data values within the source is a multiple of the stride,
|
---|
73 | yet you should always verify that the stride is at least the wanted dimension. For example, there is
|
---|
74 | no guarantee that your vertex position data source has a stride of 3. 3dsMax is known to always
|
---|
75 | export 3D texture coordinate positions.
|
---|
76 | @return The stride of the data. */
|
---|
77 | uint32 GetSourceStride() const { return sourceStride; }
|
---|
78 |
|
---|
79 | /** @deprecated Retrieves the COLLADA id for the source.
|
---|
80 | Use the class parent's GetDaeId function instead.
|
---|
81 | @return The COLLADA id. */
|
---|
82 | const string& GetSourceId() const { return GetDaeId(); }
|
---|
83 |
|
---|
84 | /** Retrieves the list of animated values for the data of the source.
|
---|
85 | @return The list of animated values. */
|
---|
86 | FCDAnimatedList& GetAnimatedValues() { return animatedValues; }
|
---|
87 | const FCDAnimatedList& GetAnimatedValues() const { return animatedValues; } /**< See above. */
|
---|
88 |
|
---|
89 | /** @deprecated [INTERNAL] Retrieves the XML tree node that represent this source.
|
---|
90 | This is used when computing the list of animated values.
|
---|
91 | @todo Take the XML tree node out of this class.
|
---|
92 | @return The XML tree node. This pointer is invalid if accessed after the document is
|
---|
93 | fully parsed. */
|
---|
94 | xmlNode* GetSourceNode() { return sourceNode; } // Should be taken out of this class
|
---|
95 |
|
---|
96 | /** Retrieves the type of data contained within the source.
|
---|
97 | Common values for the type of data are POSITION, NORMAL, COLOR and TEXCOORD.
|
---|
98 | Please see FUDaeGeometryInput for more information.
|
---|
99 | @see FUDaeGeometryInput.
|
---|
100 | @return The type of data contained within the source. */
|
---|
101 | FUDaeGeometryInput::Semantic GetSourceType() const { return sourceType; }
|
---|
102 |
|
---|
103 | /** Sets the user-friendly name of the data source. The name is optional and is used to
|
---|
104 | keep around a user-friendly name for texture coordinate sets or color sets.
|
---|
105 | @param _name The user-friendly name of the data source. */
|
---|
106 | void SetName(const fstring& _name) { name = _name; }
|
---|
107 |
|
---|
108 | /** Overwrites the data contained within the data source.
|
---|
109 | @param _sourceData The new data for this source.
|
---|
110 | @param _sourceStride The stride for the new data.
|
---|
111 | @param offset The offset at which to start retrieving the new data.
|
---|
112 | This argument defaults at 0 to indicate that the data copy should start from the beginning.
|
---|
113 | @param count The number of data entries to copy into the data source.
|
---|
114 | This argument defaults at 0 to indicate that the data copy should include everything. */
|
---|
115 | void SetSourceData(const FloatList& _sourceData, uint32 _sourceStride, size_t offset=0, size_t count=0);
|
---|
116 |
|
---|
117 | /** [INTERNAL] Sets the XML tree node associated with the data source.
|
---|
118 | @todo Take the XML tree node out of this class.
|
---|
119 | @param _sourceNode A XML tree node. */
|
---|
120 | void SetSourceNode(xmlNode* _sourceNode) { sourceNode = _sourceNode; }
|
---|
121 |
|
---|
122 | /** Sets the type of data contained within this data source.
|
---|
123 | @param type The new type of data for this data source. */
|
---|
124 | void SetSourceType(FUDaeGeometryInput::Semantic type);
|
---|
125 |
|
---|
126 | /** [INTERNAL] Clones this data source. You will need to release this pointer manually.
|
---|
127 | @return An identical copy of the data source. */
|
---|
128 | FCDGeometrySource* Clone() const;
|
---|
129 |
|
---|
130 | /** [INTERNAL] Reads in the \<source\> element from a given COLLADA XML tree node.
|
---|
131 | @param sourceNode The COLLADA XML tree node.
|
---|
132 | @return The status of the import. If the status is not successful,
|
---|
133 | it may be dangerous to extract information from the data source.*/
|
---|
134 | FUStatus LoadFromXML(xmlNode* sourceNode);
|
---|
135 |
|
---|
136 | /** [INTERNAL] Writes out the \<source\> element to the given COLLADA XML tree node.
|
---|
137 | @param parentNode The COLLADA XML parent node in which to insert the data source.
|
---|
138 | @return The created \<source\> element XML tree node. */
|
---|
139 | xmlNode* WriteToXML(xmlNode* parentNode) const;
|
---|
140 | };
|
---|
141 |
|
---|
142 | #endif // _FCD_GEOMETRY_SOURCE_H_
|
---|