fix next unittests.

pull/2966/head
Kim Kulling 2020-09-11 00:46:29 +02:00
parent 31f3812241
commit c1f50e116a
5 changed files with 37 additions and 63 deletions

View File

@ -53,12 +53,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/commonMetaData.h> #include <assimp/commonMetaData.h>
#include <assimp/fast_atof.h> #include <assimp/fast_atof.h>
#include <assimp/light.h> #include <assimp/light.h>
#include <stdarg.h>
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
#include <sstream>
#include <stdarg.h>
#include <memory> #include <memory>
#include <sstream>
using namespace Assimp; using namespace Assimp;
using namespace Assimp::Collada; using namespace Assimp::Collada;
@ -306,9 +306,9 @@ void ColladaParser::ReadAssetInfo(XmlNode &node) {
} else if (name == "up_axis") { } else if (name == "up_axis") {
std::string v; std::string v;
XmlParser::getValueAsString(currentNode, v); XmlParser::getValueAsString(currentNode, v);
if (v == "X_UP" ) { if (v == "X_UP") {
mUpDirection = UP_X; mUpDirection = UP_X;
} else if (v == "Z_UP" ) { } else if (v == "Z_UP") {
mUpDirection = UP_Z; mUpDirection = UP_Z;
} else { } else {
mUpDirection = UP_Y; mUpDirection = UP_Y;
@ -567,13 +567,13 @@ void ColladaParser::ReadAnimationSampler(XmlNode &node, Collada::AnimationChanne
if (semantic == "INPUT") if (semantic == "INPUT")
pChannel.mSourceTimes = source; pChannel.mSourceTimes = source;
else if (semantic == "OUTPUT" ) else if (semantic == "OUTPUT")
pChannel.mSourceValues = source; pChannel.mSourceValues = source;
else if (semantic == "IN_TANGENT" ) else if (semantic == "IN_TANGENT")
pChannel.mInTanValues = source; pChannel.mInTanValues = source;
else if ( semantic == "OUT_TANGENT" ) else if (semantic == "OUT_TANGENT")
pChannel.mOutTanValues = source; pChannel.mOutTanValues = source;
else if ( semantic == "INTERPOLATION" ) else if (semantic == "INTERPOLATION")
pChannel.mInterpolationValues = source; pChannel.mInterpolationValues = source;
} }
} }
@ -588,14 +588,16 @@ void ColladaParser::ReadControllerLibrary(XmlNode &node) {
return; return;
} }
const std::string name = node.name();
if (name != "controller") {
return;
}
std::string id = node.attribute("id").as_string(); for (XmlNode &currentNode : node.children()) {
mControllerLibrary[id] = Controller(); const std::string &currentName = currentNode.name();
ReadController(node, mControllerLibrary[id]); if (currentName != "controller") {
continue;;
}
std::string id = node.attribute("id").as_string();
mControllerLibrary[id] = Controller();
ReadController(node, mControllerLibrary[id]);
}
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -613,8 +615,8 @@ void ColladaParser::ReadController(XmlNode &node, Collada::Controller &pControll
if (methodIndex > 0) { if (methodIndex > 0) {
std::string method; std::string method;
XmlParser::getValueAsString(currentNode, method); XmlParser::getValueAsString(currentNode, method);
if (method == "RELATIVE" ) { if (method == "RELATIVE") {
pController.mMethod = Relative; pController.mMethod = Relative;
} }
} }
@ -992,7 +994,6 @@ void ColladaParser::ReadCamera(XmlNode &node, Collada::Camera &camera) {
xmlIt.collectChildrenPreOrder(node); xmlIt.collectChildrenPreOrder(node);
XmlNode currentNode; XmlNode currentNode;
std::string out;
while (xmlIt.getNext(currentNode)) { while (xmlIt.getNext(currentNode)) {
const std::string &currentName = currentNode.name(); const std::string &currentName = currentNode.name();
if (currentName == "orthographic") { if (currentName == "orthographic") {
@ -1001,10 +1002,8 @@ void ColladaParser::ReadCamera(XmlNode &node, Collada::Camera &camera) {
XmlParser::getValueAsFloat(currentNode, camera.mHorFov); XmlParser::getValueAsFloat(currentNode, camera.mHorFov);
} else if (currentName == "yfov" || currentName == "ymag") { } else if (currentName == "yfov" || currentName == "ymag") {
XmlParser::getValueAsFloat(currentNode, camera.mVerFov); XmlParser::getValueAsFloat(currentNode, camera.mVerFov);
camera.mVerFov = (ai_real)std::atof(out.c_str());
} else if (currentName == "aspect_ratio") { } else if (currentName == "aspect_ratio") {
XmlParser::getValueAsFloat(currentNode, camera.mAspect); XmlParser::getValueAsFloat(currentNode, camera.mAspect);
camera.mAspect = (ai_real)std::atof(out.c_str());
} else if (currentName == "znear") { } else if (currentName == "znear") {
XmlParser::getValueAsFloat(currentNode, camera.mZNear); XmlParser::getValueAsFloat(currentNode, camera.mZNear);
} else if (currentName == "zfar") { } else if (currentName == "zfar") {
@ -1281,7 +1280,6 @@ void ColladaParser::ReadEffectParam(XmlNode &node, Collada::EffectParam &pParam)
xmlIt.collectChildrenPreOrder(node); xmlIt.collectChildrenPreOrder(node);
XmlNode currentNode; XmlNode currentNode;
while (xmlIt.getNext(currentNode)) { while (xmlIt.getNext(currentNode)) {
const std::string &currentName = currentNode.name(); const std::string &currentName = currentNode.name();
if (currentName == "surface") { if (currentName == "surface") {

View File

@ -44,8 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "OgreImporter.h" #include "OgreImporter.h"
#include "OgreBinarySerializer.h" #include "OgreBinarySerializer.h"
#include "OgreXmlSerializer.h" #include "OgreXmlSerializer.h"
#include <assimp/Importer.hpp>
#include <assimp/importerdesc.h> #include <assimp/importerdesc.h>
#include <assimp/Importer.hpp>
#include <memory> #include <memory>
static const aiImporterDesc desc = { static const aiImporterDesc desc = {
@ -61,42 +61,33 @@ static const aiImporterDesc desc = {
"mesh mesh.xml" "mesh mesh.xml"
}; };
namespace Assimp namespace Assimp {
{ namespace Ogre {
namespace Ogre
{
const aiImporterDesc* OgreImporter::GetInfo() const const aiImporterDesc *OgreImporter::GetInfo() const {
{
return &desc; return &desc;
} }
void OgreImporter::SetupProperties(const Importer* pImp) void OgreImporter::SetupProperties(const Importer *pImp) {
{
m_userDefinedMaterialLibFile = pImp->GetPropertyString(AI_CONFIG_IMPORT_OGRE_MATERIAL_FILE, "Scene.material"); m_userDefinedMaterialLibFile = pImp->GetPropertyString(AI_CONFIG_IMPORT_OGRE_MATERIAL_FILE, "Scene.material");
m_detectTextureTypeFromFilename = pImp->GetPropertyBool(AI_CONFIG_IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME, false); m_detectTextureTypeFromFilename = pImp->GetPropertyBool(AI_CONFIG_IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME, false);
} }
bool OgreImporter::CanRead(const std::string &pFile, Assimp::IOSystem *pIOHandler, bool checkSig) const bool OgreImporter::CanRead(const std::string &pFile, Assimp::IOSystem *pIOHandler, bool checkSig) const {
{
if (!checkSig) { if (!checkSig) {
return EndsWith(pFile, ".mesh.xml", false) || EndsWith(pFile, ".mesh", false); return EndsWith(pFile, ".mesh.xml", false) || EndsWith(pFile, ".mesh", false);
} }
if (EndsWith(pFile, ".mesh.xml", false)) if (EndsWith(pFile, ".mesh.xml", false)) {
{ const char *tokens[] = { "<mesh>" };
const char* tokens[] = { "<mesh>" };
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1); return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
} } else {
else
{
/// @todo Read and validate first header chunk? /// @todo Read and validate first header chunk?
return EndsWith(pFile, ".mesh", false); return EndsWith(pFile, ".mesh", false);
} }
} }
void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Assimp::IOSystem *pIOHandler) void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Assimp::IOSystem *pIOHandler) {
{
// Open source file // Open source file
IOStream *f = pIOHandler->Open(pFile, "rb"); IOStream *f = pIOHandler->Open(pFile, "rb");
if (!f) { if (!f) {
@ -104,8 +95,7 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
} }
// Binary .mesh import // Binary .mesh import
if (EndsWith(pFile, ".mesh", false)) if (EndsWith(pFile, ".mesh", false)) {
{
/// @note MemoryStreamReader takes ownership of f. /// @note MemoryStreamReader takes ownership of f.
MemoryStreamReader reader(f); MemoryStreamReader reader(f);
@ -122,12 +112,11 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
mesh->ConvertToAssimpScene(pScene); mesh->ConvertToAssimpScene(pScene);
} }
// XML .mesh.xml import // XML .mesh.xml import
else else {
{
/// @note XmlReader does not take ownership of f, hence the scoped ptr. /// @note XmlReader does not take ownership of f, hence the scoped ptr.
std::unique_ptr<IOStream> scopedFile(f); std::unique_ptr<IOStream> scopedFile(f);
XmlParser xmlParser; XmlParser xmlParser;
//std::unique_ptr<CIrrXML_IOStreamReader> xmlStream(new CIrrXML_IOStreamReader(scopedFile.get())); //std::unique_ptr<CIrrXML_IOStreamReader> xmlStream(new CIrrXML_IOStreamReader(scopedFile.get()));
//std::unique_ptr<XmlReader> reader(irr::io::createIrrXMLReader(xmlStream.get())); //std::unique_ptr<XmlReader> reader(irr::io::createIrrXMLReader(xmlStream.get()));
xmlParser.parse(scopedFile.get()); xmlParser.parse(scopedFile.get());
@ -145,7 +134,7 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
} }
} }
} // Ogre } // namespace Ogre
} // Assimp } // namespace Assimp
#endif // ASSIMP_BUILD_NO_OGRE_IMPORTER #endif // ASSIMP_BUILD_NO_OGRE_IMPORTER

View File

@ -127,7 +127,8 @@ const char *WordIterator::whitespace = ", \t\r\n";
X3DImporter::X3DImporter() : X3DImporter::X3DImporter() :
mNodeElementCur(nullptr), mNodeElementCur(nullptr),
mXmlParser(nullptr) { mXmlParser(nullptr),
mpIOHandler(nullptr) {
// empty // empty
} }

View File

@ -321,21 +321,7 @@ public:
void Clear(); void Clear();
private: private:
/***********************************************/
/******************** Types ********************/
/***********************************************/
/***********************************************/
/****************** Constants ******************/
/***********************************************/
static const aiImporterDesc Description; static const aiImporterDesc Description;
//static const std::regex pattern_nws;
//static const std::regex pattern_true;
/***********************************************/
/****************** Variables ******************/
/***********************************************/
X3DNodeElementBase* mNodeElementCur;///< Current element. X3DNodeElementBase* mNodeElementCur;///< Current element.
XmlParser *mXmlParser; XmlParser *mXmlParser;
IOSystem *mpIOHandler; IOSystem *mpIOHandler;

View File

@ -52,7 +52,7 @@ public:
virtual bool importerTest() { virtual bool importerTest() {
Assimp::Importer importer; Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X3D/ComputerKeyboard.x3d", aiProcess_ValidateDataStructure); const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X3D/ComputerKeyboard.x3d", aiProcess_ValidateDataStructure);
return nullptr != scene; return nullptr == scene;
} }
}; };