2
Copyright (c) 2008-2009 NetAllied Systems GmbH
4
This file is part of COLLADAFramework.
6
Licensed under the MIT Open Source License,
7
for details please see LICENSE file or the website
8
http://www.opensource.org/licenses/mit-license.php
11
#ifndef __COLLADAFW_MESHINPUTS_H__
12
#define __COLLADAFW_MESHINPUTS_H__
14
#include "COLLADAFWPrerequisites.h"
15
#include "COLLADAFWArrayPrimitiveType.h"
16
#include "COLLADAFWFloatOrDoubleArray.h"
24
/** Base class for mesh input elements, like positions, normals, colors, texcoord, ... */
25
class MeshVertexData : public FloatOrDoubleArray
30
* Additional informations about multiple inputs.
38
typedef ArrayPrimitiveType<InputInfos*> InputInfosArray;
42
/** Array with additional informations about multiple input elements. */
43
InputInfosArray mInputInfosArray;
49
: FloatOrDoubleArray()
50
, mInputInfosArray (0)
54
MeshVertexData ( DataType type )
55
: FloatOrDoubleArray(type)
56
, mInputInfosArray (0)
60
virtual ~MeshVertexData()
62
for ( size_t i=0; i<mInputInfosArray.getCount(); ++i )
64
delete mInputInfosArray [i];
66
mInputInfosArray.releaseMemory ();
70
* Returns the number of uv sets.
72
size_t getNumInputInfos () const { return mInputInfosArray.getCount (); }
74
/** Returns the InputInfosArray.*/
75
const InputInfosArray& getInputInfosArray() const { return mInputInfosArray; }
78
* Appends the values in the array on the list of values and stores the information
79
* of the current input.
80
* @param const FloatArray& valuesArray The list of values.
81
* @param const String& name The name of the current element.
82
* @param const size_t stride The data stride.
84
void appendValues ( const FloatArray& valuesArray, const String& name, const size_t stride )
86
setType ( DATA_TYPE_FLOAT );
87
FloatOrDoubleArray::appendValues ( valuesArray );
89
InputInfos* info = new InputInfos();
90
info->mLength = valuesArray.getCount ();
92
info->mStride = stride;
94
mInputInfosArray.append ( info );
98
* Appends the values in the array on the list of values and stores the information
99
* of the current input.
100
* @param const FloatArray& valuesArray The list of values.
101
* @param const String& name The name of the current element.
102
* @param const size_t stride The data stride.
104
void appendValues ( const DoubleArray& valuesArray, const String& name, const size_t stride )
106
setType ( DATA_TYPE_DOUBLE );
107
FloatOrDoubleArray::appendValues ( valuesArray );
109
InputInfos* info = new InputInfos();
110
info->mLength = valuesArray.getCount ();
112
info->mStride = stride;
114
mInputInfosArray.append ( info );
117
/** The stride at the specified index. */
118
String getName ( size_t index ) const
120
COLLADABU_ASSERT ( index <= mInputInfosArray.getCount() );
121
if ( index >= mInputInfosArray.getCount () ) return 0;
122
return mInputInfosArray[index]->mName;
125
/** The stride at the specified index. */
126
size_t getStride ( size_t index ) const
128
COLLADABU_ASSERT ( index <= mInputInfosArray.getCount() );
129
if ( index >= mInputInfosArray.getCount () ) return 0;
130
return mInputInfosArray[index]->mStride;
133
/** The stride can differ, so we have to set. */
134
size_t getLength ( size_t index ) const
136
COLLADABU_ASSERT ( index <= mInputInfosArray.getCount() );
137
if ( index >= mInputInfosArray.getCount () ) return 0;
138
return mInputInfosArray[index]->mLength;
142
/** Appends the values of the input array to the end of values array.
143
The programmer must ensure, that the memory allocated,
144
was large enough to hold another element. No new memory is allocated.*/
145
bool appendValues ( const FloatArray& valuesArray )
147
return FloatOrDoubleArray::appendValues ( valuesArray );
150
/** Appends the values of the input array to the end of values array.
151
The programmer must ensure, that the memory allocated,
152
was large enough to hold another element. No new memory is allocated.*/
153
bool appendValues ( const DoubleArray& valuesArray )
155
return FloatOrDoubleArray::appendValues ( valuesArray );
161
/** Disable default copy ctor. */
162
MeshVertexData( const MeshVertexData& pre );
164
/** Disable default assignment operator. */
165
const MeshVertexData& operator= ( const MeshVertexData& pre );
169
} // namespace COLLADAFW
171
#endif // __COLLADAFW_MESHINPUTS_H__