1 #ifndef GEOMETRY_LOADER_BASE_H
2 #define GEOMETRY_LOADER_BASE_H
13 #include <osg/Geometry>
15 using namespace vrecko;
17 namespace APFFDEditor {
36 virtual bool loadXMLParameters(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *
node);
49 unsigned long vIndex[3];
58 inline void*
getFace(
unsigned long index) {
return (
void*)(((
unsigned char*)faces) + index * face_size); }
59 inline void*
getVertex(
unsigned long index) {
return (
void*)(((
unsigned char*)vertices) + index * vertex_size); }
64 void debugWriteNormals();
81 bool getOSGInitCounts(osg::Node *pNode,
unsigned long &pVertexCount,
unsigned long &pPrimitiveCount);
84 virtual bool loadGeometry(osg::Node *pNode);
85 bool loadGeometryHelper(osg::Node *pNode, osg::Matrix &transform,
unsigned long &vertex_pos,
unsigned long &face_pos);
86 inline osg::Vec3 * getNormalByIndex(osg::Geometry::AttributeBinding normalBinding, osg::Vec3Array * pNormArray, osg::IndexArray * pNormIndices,
unsigned long index);
89 void sortVerticesClockwise();
92 virtual void destroyGeometry();
95 void recalculateNormals();
100 inline osg::Vec3 * GeometryLoaderBase::getNormalByIndex(osg::Geometry::AttributeBinding normalBinding, osg::Vec3Array * pNormArray, osg::IndexArray * pNormIndices,
unsigned long index) {
101 if (osg::Geometry::BIND_OFF == normalBinding)
102 return ((osg::Vec3*)NULL);
105 switch (pNormIndices->getDataType()) {
106 case osg::Array::ByteArrayType:
107 index = *(((
char*)pNormIndices->getDataPointer()) + index);
109 case osg::Array::ShortArrayType:
110 index = *(((
short*)pNormIndices->getDataPointer()) + index);
112 case osg::Array::IntArrayType:
113 index = *(((
int*)pNormIndices->getDataPointer()) + index);
115 case osg::Array::UByteArrayType:
116 index = *(((
unsigned char*)pNormIndices->getDataPointer()) + index);
118 case osg::Array::UShortArrayType:
119 index = *(((
unsigned short*)pNormIndices->getDataPointer()) + index);
121 case osg::Array::UIntArrayType:
122 index = *(((
unsigned int*)pNormIndices->getDataPointer()) + index);
126 return (osg::Vec3*)NULL;
130 return ((osg::Vec3*)pNormArray->getDataPointer()) + index;