// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
XGLImporter::XGLImporter()
-{}
+: m_reader( nullptr )
+, m_scene( nullptr ) {
+ // empty
+}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
-XGLImporter::~XGLImporter()
-{}
+XGLImporter::~XGLImporter() {
+ // empty
+}
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
free_it free_it_really(dest);
#endif
- scene = pScene;
+ m_scene = pScene;
std::shared_ptr<IOStream> stream( pIOHandler->Open( pFile, "rb"));
// check whether we can read from the file
// construct the irrXML parser
CIrrXML_IOStreamReader st(stream.get());
- std::unique_ptr<IrrXMLReader> read( createIrrXMLReader((IFileReadCallBack*) &st) );
- reader = read.get();
+ m_reader.reset( createIrrXMLReader( ( IFileReadCallBack* ) &st ) );
// parse the XML file
TempScope scope;
while (ReadElement()) {
- if (!ASSIMP_stricmp(reader->getNodeName(),"world")) {
+ if (!ASSIMP_stricmp(m_reader->getNodeName(),"world")) {
ReadWorld(scope);
}
}
}
// copy meshes
- scene->mNumMeshes = static_cast<unsigned int>(meshes.size());
- scene->mMeshes = new aiMesh*[scene->mNumMeshes]();
- std::copy(meshes.begin(),meshes.end(),scene->mMeshes);
+ m_scene->mNumMeshes = static_cast<unsigned int>(meshes.size());
+ m_scene->mMeshes = new aiMesh*[m_scene->mNumMeshes]();
+ std::copy(meshes.begin(),meshes.end(),m_scene->mMeshes);
// copy materials
- scene->mNumMaterials = static_cast<unsigned int>(materials.size());
- scene->mMaterials = new aiMaterial*[scene->mNumMaterials]();
- std::copy(materials.begin(),materials.end(),scene->mMaterials);
+ m_scene->mNumMaterials = static_cast<unsigned int>(materials.size());
+ m_scene->mMaterials = new aiMaterial*[m_scene->mNumMaterials]();
+ std::copy(materials.begin(),materials.end(),m_scene->mMaterials);
if (scope.light) {
- scene->mNumLights = 1;
- scene->mLights = new aiLight*[1];
- scene->mLights[0] = scope.light;
+ m_scene->mNumLights = 1;
+ m_scene->mLights = new aiLight*[1];
+ m_scene->mLights[0] = scope.light;
- scope.light->mName = scene->mRootNode->mName;
+ scope.light->mName = m_scene->mRootNode->mName;
}
scope.dismiss();
// ------------------------------------------------------------------------------------------------
bool XGLImporter::ReadElement()
{
- while(reader->read()) {
- if (reader->getNodeType() == EXN_ELEMENT) {
+ while(m_reader->read()) {
+ if (m_reader->getNodeType() == EXN_ELEMENT) {
return true;
}
}
// ------------------------------------------------------------------------------------------------
bool XGLImporter::ReadElementUpToClosing(const char* closetag)
{
- while(reader->read()) {
- if (reader->getNodeType() == EXN_ELEMENT) {
+ while(m_reader->read()) {
+ if (m_reader->getNodeType() == EXN_ELEMENT) {
return true;
}
- else if (reader->getNodeType() == EXN_ELEMENT_END && !ASSIMP_stricmp(reader->getNodeName(),closetag)) {
+ else if (m_reader->getNodeType() == EXN_ELEMENT_END && !ASSIMP_stricmp(m_reader->getNodeName(),closetag)) {
return false;
}
}
// ------------------------------------------------------------------------------------------------
bool XGLImporter::SkipToText()
{
- while(reader->read()) {
- if (reader->getNodeType() == EXN_TEXT) {
+ while(m_reader->read()) {
+ if (m_reader->getNodeType() == EXN_TEXT) {
return true;
}
- else if (reader->getNodeType() == EXN_ELEMENT || reader->getNodeType() == EXN_ELEMENT_END) {
+ else if (m_reader->getNodeType() == EXN_ELEMENT || m_reader->getNodeType() == EXN_ELEMENT_END) {
ThrowException("expected text contents but found another element (or element end)");
}
}
// ------------------------------------------------------------------------------------------------
std::string XGLImporter::GetElementName()
{
- const char* s = reader->getNodeName();
+ const char* s = m_reader->getNodeName();
size_t len = strlen(s);
std::string ret;
nd->mName.Set("WORLD");
}
- scene->mRootNode = nd;
+ m_scene->mRootNode = nd;
}
// ------------------------------------------------------------------------------------------------
ReadMaterial(scope);
}
else if (s == "p") {
- if (!reader->getAttributeValue("ID")) {
+ if (!m_reader->getAttributeValue("ID")) {
LogWarn("no ID attribute on <p>, ignoring");
}
else {
- int id = reader->getAttributeValueAsInt("ID");
+ int id = m_reader->getAttributeValueAsInt("ID");
t.points[id] = ReadVec3();
}
}
else if (s == "n") {
- if (!reader->getAttributeValue("ID")) {
+ if (!m_reader->getAttributeValue("ID")) {
LogWarn("no ID attribute on <n>, ignoring");
}
else {
- int id = reader->getAttributeValueAsInt("ID");
+ int id = m_reader->getAttributeValueAsInt("ID");
t.normals[id] = ReadVec3();
}
}
else if (s == "tc") {
- if (!reader->getAttributeValue("ID")) {
+ if (!m_reader->getAttributeValue("ID")) {
LogWarn("no ID attribute on <tc>, ignoring");
}
else {
- int id = reader->getAttributeValueAsInt("ID");
+ int id = m_reader->getAttributeValueAsInt("ID");
t.uvs[id] = ReadVec2();
}
}
// ------------------------------------------------------------------------------------------------
unsigned int XGLImporter::ReadIDAttr()
{
- for(int i = 0, e = reader->getAttributeCount(); i < e; ++i) {
+ for(int i = 0, e = m_reader->getAttributeCount(); i < e; ++i) {
- if(!ASSIMP_stricmp(reader->getAttributeName(i),"id")) {
- return reader->getAttributeValueAsInt(i);
+ if(!ASSIMP_stricmp(m_reader->getAttributeName(i),"id")) {
+ return m_reader->getAttributeValueAsInt(i);
}
}
return ~0u;
LogError("unexpected EOF reading float element contents");
return 0.f;
}
- const char* s = reader->getNodeData(), *se;
+ const char* s = m_reader->getNodeData(), *se;
if(!SkipSpaces(&s)) {
LogError("unexpected EOL, failed to parse float");
LogError("unexpected EOF reading index element contents");
return ~0u;
}
- const char* s = reader->getNodeData(), *se;
+ const char* s = m_reader->getNodeData(), *se;
if(!SkipSpaces(&s)) {
LogError("unexpected EOL, failed to parse index element");
return ~0u;
LogError("unexpected EOF reading vec2 contents");
return vec;
}
- const char* s = reader->getNodeData();
+ const char* s = m_reader->getNodeData();
for(int i = 0; i < 2; ++i) {
if(!SkipSpaces(&s)) {
LogError("unexpected EOF reading vec3 contents");
return vec;
}
- const char* s = reader->getNodeData();
+ const char* s = m_reader->getNodeData();
for(int i = 0; i < 3; ++i) {
if(!SkipSpaces(&s)) {