1 #ifndef GEOMETRY_LOADER_BASE_H
2 #define GEOMETRY_LOADER_BASE_H
9 #include <osg/Geometry>
11 using namespace vrecko;
13 namespace APSpacePartitioning {
15 #ifdef AP_SPACEPARTITIONING_EXPORTS
16 #define SPACEPARTITIONING_IMP_EXP __declspec(dllexport)
18 #define SPACEPARTITIONING_IMP_EXP __declspec(dllimport)
40 virtual bool loadXMLParameters(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *
node);
45 virtual bool loadGeometry(osg::Node *pNode);
64 unsigned long vIndex[3];
75 inline void*
getFace(
unsigned long index) {
return (
void*)(((
unsigned char*)faces) + index * face_size); }
76 inline void*
getVertex(
unsigned long index) {
return (
void*)(((
unsigned char*)vertices) + index * vertex_size); }
81 void debugWriteNormals();
94 bool getOSGInitCounts(osg::Node *pNode,
unsigned long &pVertexCount,
unsigned long &pPrimitiveCount);
96 bool loadGeometryHelper(osg::Node *pNode, osg::Matrix &transform,
unsigned long &vertex_pos,
unsigned long &face_pos);
98 void sortVerticesClockwise();
99 virtual void destroyGeometry();
100 void recalculateNormals();
105 inline osg::Vec3 *
getNormalByIndex(osg::Geometry::AttributeBinding normalBinding, osg::Vec3Array * pNormArray, osg::IndexArray * pNormIndices,
unsigned long index) {
106 if (osg::Geometry::BIND_OFF == normalBinding)
107 return ((osg::Vec3*)NULL);
110 switch (pNormIndices->getDataType()) {
111 case osg::Array::ByteArrayType:
112 index = *(((
char*)pNormIndices->getDataPointer()) + index);
114 case osg::Array::ShortArrayType:
115 index = *(((
short*)pNormIndices->getDataPointer()) + index);
117 case osg::Array::IntArrayType:
118 index = *(((
int*)pNormIndices->getDataPointer()) + index);
120 case osg::Array::UByteArrayType:
121 index = *(((
unsigned char*)pNormIndices->getDataPointer()) + index);
123 case osg::Array::UShortArrayType:
124 index = *(((
unsigned short*)pNormIndices->getDataPointer()) + index);
126 case osg::Array::UIntArrayType:
127 index = *(((
unsigned int*)pNormIndices->getDataPointer()) + index);
130 logger.
debugLog(
"GeometryLoaderBase error: Unsupported data type for normals array");
131 return (osg::Vec3*)NULL;
134 return ((osg::Vec3*)pNormArray->getDataPointer()) + index;