/usr/include/opencollada/COLLADASaxFrameworkLoader/COLLADASaxFWLSource.h is in opencollada-dev 0.1.0~20140703.ddf8f47+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | /*
Copyright (c) 2008-2009 NetAllied Systems GmbH
This file is part of COLLADASaxFrameworkLoader.
Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
*/
#ifndef __COLLADASAXFWL_SOURCE_H__
#define __COLLADASAXFWL_SOURCE_H__
#include "COLLADASaxFWLPrerequisites.h"
#include "COLLADASaxFWLTechniqueCommon.h"
#include "COLLADASaxFWLArrayElement.h"
#include "COLLADASaxFWLInputUnshared.h"
#include "COLLADAFWObject.h"
#include "COLLADAFWArray.h"
#include "COLLADAFWMeshPrimitive.h"
namespace COLLADASaxFWL
{
/**
* Base source class for hold source element pointers in an array.
*/
class SourceBase
{
public:
enum DataType
{
DATA_TYPE_INT,
DATA_TYPE_LONG64,
DATA_TYPE_FLOAT,
DATA_TYPE_DOUBLE,
#ifdef COLLADASAXFWL_REAL_IS_FLOAT
DATA_TYPE_REAL = DATA_TYPE_FLOAT,
#else
DATA_TYPE_REAL = DATA_TYPE_DOUBLE,
#endif
DATA_TYPE_BOOL,
DATA_TYPE_NAME,
DATA_TYPE_IDREF,
DATA_TYPE_INTERPOLATIONTYPE,
DATA_TYPE_UNKNOWN
};
/** Describes one parameter in a COLLADA accessor.*/
struct AccessorParameter
{
String name;
String type;
bool operator==( const SourceBase::AccessorParameter& rhs) const
{
return ( name == rhs.name) && ( type == rhs.type );
}
bool operator!=( const SourceBase::AccessorParameter& rhs) const
{
return ( name != rhs.name) || ( type != rhs.type );
}
};
/** List of all parameters of an accessor, defining the meaning of the values in an array.*/
typedef std::vector< AccessorParameter > Accessor;
private:
/**
* A text string containing the unique identifier of the element. This value must be unique
* within the instance document. Required.
*/
String mId;
/**
* The number of values that are to be considered a unit during each access to the array.
* The default is 1, indicating that a single value is accessed. Optional.
*/
unsigned long long mStride;
/**
* This member will be used, if multiple source elements with the same input semantic are
* referenced in the current mesh.
*/
size_t mInitialIndex;
/**
* Flags, if the source element is already loaded into the framework. A source element
* can be referenced from the same input element in multiple primitive elements or from
* different input elements (NORMALS, COLOR, TEXCOORD, ...). It should be loaded only once
* from every input element.
*/
COLLADAFW::ArrayPrimitiveType<InputSemantic::Semantic> mLoadedInputElements;
/** The accessor of the source.*/
Accessor mAccessor;
public:
/** Constructor. */
SourceBase ( )
: mId()
, mStride(0)
, mInitialIndex (0)
, mLoadedInputElements ( COLLADAFW::MeshPrimitiveArray::OWNER )
{}
/** Destructor. */
virtual ~SourceBase ()
{
mLoadedInputElements.clear();
}
/**
* The value type of the current values.
*/
virtual DataType getDataType ()const =0;
/**
* Adds the current input element in the list of already loaded input elements.
* Returns true, if the input element was not already in the list and was successfully added.
* A source element can be referenced from the same input element in multiple primitive
* elements or from different input elements (NORMALS, COLOR, TEXCOORD, ...). It should be
* loaded only once from every input element.
*/
bool addLoadedInputElement ( const InputSemantic::Semantic& semantic )
{
if ( !isLoadedInputElement ( semantic ) )
{
mLoadedInputElements.append ( semantic );
return true;
}
return false;
}
/**
* Checks if the current input element is already in the list of loaded input elements.
* Returns true, if the input element was not already in the list and was successfully added.
* A source element can be referenced from the same input element in multiple primitive
* elements or from different input elements (NORMALS, COLOR, TEXCOORD, ...). It should be
* loaded only once from every input element.
*/
bool isLoadedInputElement ( const InputSemantic::Semantic& semantic )
{
const size_t numLoadedInputElements = mLoadedInputElements.getCount ();
for ( size_t i=0; i<numLoadedInputElements; ++i )
{
InputSemantic::Semantic& currentSemantic = mLoadedInputElements [i];
if ( currentSemantic == semantic ) return true;
}
return false;
}
/**
* A text string containing the unique identifier of the element.
* This value must be unique within the instance document. Required.
* @return const String& The unique identifier of the element.
*/
const String& getId () const { return mId; }
/**
* A text string containing the unique identifier of the element.
* This value must be unique within the instance document. Required.
* @param val The unique identifier of the element.
*/
void setId ( const String& val ) { mId = val; }
/**
* The number of values that are to be considered a unit during each access to the array.
* The default is 1, indicating that a single value is accessed. Optional.
*/
unsigned long long getStride () const { return mStride; }
/**
* The number of values that are to be considered a unit during each access to the array.
* The default is 1, indicating that a single value is accessed. Optional.
*/
void setStride ( unsigned long long Stride ) { mStride = Stride; }
/**
* This member will be used, if multiple source elements with the same input semantic are
* referenced in the current mesh.
* The sources of semantic "POSITION" and "NORMAL" will be concated to one source and
* and one indices array.
*/
size_t getInitialIndex () const { return mInitialIndex; }
/**
* This member will be used, if multiple source elements with the same input semantic are
* referenced in the current mesh.
* The sources of semantic "POSITION" and "NORMAL" will be concated to one source and
* and one indices array.
*/
void setInitialIndex ( size_t InitialIndex ) { mInitialIndex = InitialIndex; }
/** Appends an accessor parameter to the source's accessor.*/
void appendAccessorParameter( const AccessorParameter& parameter ) { mAccessor.push_back( parameter ); }
/** Returns the accessor.*/
const Accessor& getAccessor() const { return mAccessor; }
};
/**
* Declares a data repository that provides values according to the
* semantics of an <input> element that refers to it.
* A data source is a well-known source of information that can be accessed
* through an established communication channel.
* The data source provides access methods to the information. These access
* methods implement various techniques according to the representation of
* the information. The information may be stored locally as an array of
* data or a program that generates the data.
*/
template < class ArrayType, SourceBase::DataType dataType >
class Source : public SourceBase
{
private:
/**
* Stores a homogeneous array of values.
*/
ArrayType mArrayElement;
public:
/** Constructor. */
Source () : SourceBase () {}
/** Destructor. */
virtual ~Source ()
{
}
/**
* The value type of the current values. All other arrays are empty!
*/
DataType getDataType () const { return dataType; }
/**
* Stores a homogeneous array of values.
* The class contains members for all valid array element types,
* but there is always just one, which is initialized.
* @return const IntArrayElement The array element with the values array.
*/
ArrayType& getArrayElement ()
{
return mArrayElement;
}
/**
* Stores a homogeneous array of values.
* The class contains members for all valid array element types,
* but there is always just one, which is initialized.
* @return const IntArrayElement The array element with the values array.
*/
const ArrayType& getArrayElement() const
{
return mArrayElement;
}
};
typedef Source < DoubleArrayElement, SourceBase::DATA_TYPE_DOUBLE > DoubleSource;
typedef Source < FloatArrayElement, SourceBase::DATA_TYPE_FLOAT > FloatSource;
typedef Source < IntArrayElement, SourceBase::DATA_TYPE_INT > IntSource;
typedef Source < Long64ArrayElement, SourceBase::DATA_TYPE_LONG64 > Long64Source;
typedef Source < BoolArrayElement, SourceBase::DATA_TYPE_BOOL > BoolSource;
#ifdef COLLADASAXFWL_REAL_IS_FLOAT
typedef FloatSource RealSource;
#else
typedef DoubleSource RealSource;
#endif
typedef COLLADAFW::ArrayPrimitiveType<SourceBase*> SourceArray;
} // namespace COLLADASaxFWL
#endif // __COLLADASAXFWL_SOURCE_H__
|