int OgreNodeHandler::startNormal(const X3DAttributes &attr) { if(!_currentGeometry) throw std::runtime_error("Normal currently only supported for IndexedFaceSets"); int index = attr.getAttributeIndex(ID::vector); if (index != -1) _currentGeometry->setNormals(attr.getMFVec3f(index)); else throw std::runtime_error("No points given within Coordinate node"); return 1; }
int X3DXIOTNodeHandler::startCoordinate(const X3DAttributes &attr) { int index = attr.getAttributeIndex(ID::point); if (index == -1) { //TODO: warn user instead //throw std::runtime_error("No points given within Coordinate node"); return SKIP_CHILDREN; } MFVec3f points; attr.getMFVec3f(index,points); unsigned count = points.size(); if (count == 0) return SKIP_CHILDREN; ccPointCloud* cloud = new ccPointCloud(attr.isDEF() ? attr.getDEF().c_str() : 0); if (!cloud->reserve(count)) { //not enough memory! delete cloud; return SKIP_CHILDREN; } for (MFVec3f::const_iterator it=points.begin(); it!=points.end(); ++it) cloud->addPoint(CCVector3(it->x,it->y,it->z)); assert(m_currentLeaf); m_currentLeaf->addChild(cloud); //cloud = parent vertices? if (m_currentLeaf->isKindOf(CC_MESH)) { ccGenericMesh* mesh = ccHObjectCaster::ToGenericMesh(m_currentLeaf); if (mesh->getAssociatedCloud()==0) { mesh->setAssociatedCloud(cloud); cloud->setVisible(false); } } m_currentLeaf = cloud; return CONTINUE; }