fix compiler warnings in tools and test-
parent
02e5698a38
commit
7e7555a91b
|
@ -155,12 +155,14 @@ void LWOImporter::InternReadFile(const std::string &pFile,
|
|||
// Allocate storage and copy the contents of the file to a memory buffer
|
||||
std::vector<uint8_t> mBuffer(fileSize);
|
||||
file->Read(&mBuffer[0], 1, fileSize);
|
||||
this->mScene = pScene;
|
||||
mScene = pScene;
|
||||
|
||||
// Determine the type of the file
|
||||
uint32_t fileType;
|
||||
const char *sz = IFF::ReadHeader(&mBuffer[0], fileType);
|
||||
if (sz) throw DeadlyImportError(sz);
|
||||
if (sz) {
|
||||
throw DeadlyImportError(sz);
|
||||
}
|
||||
|
||||
mFileBuffer = &mBuffer[0] + 12;
|
||||
fileSize -= 12;
|
||||
|
@ -194,18 +196,15 @@ void LWOImporter::InternReadFile(const std::string &pFile,
|
|||
mIsLWO2 = false;
|
||||
mIsLXOB = false;
|
||||
LoadLWOBFile();
|
||||
}
|
||||
} else if (AI_LWO_FOURCC_LWO2 == fileType) {
|
||||
// New lightwave format
|
||||
else if (AI_LWO_FOURCC_LWO2 == fileType) {
|
||||
mIsLXOB = false;
|
||||
ASSIMP_LOG_INFO("LWO file format: LWO2 (>= LightWave 6)");
|
||||
}
|
||||
} else if (AI_LWO_FOURCC_LXOB == fileType) {
|
||||
// MODO file format
|
||||
else if (AI_LWO_FOURCC_LXOB == fileType) {
|
||||
mIsLXOB = true;
|
||||
ASSIMP_LOG_INFO("LWO file format: LXOB (Modo)");
|
||||
}
|
||||
// we don't know this format
|
||||
else {
|
||||
char szBuff[5];
|
||||
szBuff[0] = (char)(fileType >> 24u);
|
||||
|
@ -421,7 +420,7 @@ void LWOImporter::InternReadFile(const std::string &pFile,
|
|||
// Compute normal vectors for the mesh - we can't use our GenSmoothNormal-
|
||||
// Step here since it wouldn't handle smoothing groups correctly for LWO.
|
||||
// So we use a separate implementation.
|
||||
ComputeNormals(mesh, smoothingGroups, _mSurfaces[i]);
|
||||
ComputeNormals(mesh, smoothingGroups, _mSurfaces[j]);
|
||||
} else {
|
||||
ASSIMP_LOG_DEBUG("LWO2: No need to compute normals, they're already there");
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -96,7 +95,7 @@ glTF2Importer::glTF2Importer() :
|
|||
BaseImporter(),
|
||||
meshOffsets(),
|
||||
embeddedTexIdxs(),
|
||||
mScene(NULL) {
|
||||
mScene(nullptr) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
|
|
@ -54,8 +54,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <assimp/types.h>
|
||||
#include <assimp/quaternion.h>
|
||||
#include <assimp/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -63,8 +63,7 @@ extern "C" {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** A time-value pair specifying a certain 3D vector for the given time. */
|
||||
struct aiVectorKey
|
||||
{
|
||||
struct aiVectorKey {
|
||||
/** The time of this key */
|
||||
double mTime;
|
||||
|
||||
|
@ -75,16 +74,15 @@ struct aiVectorKey
|
|||
|
||||
/// @brief The default constructor.
|
||||
aiVectorKey() AI_NO_EXCEPT
|
||||
: mTime( 0.0 )
|
||||
, mValue() {
|
||||
: mTime(0.0),
|
||||
mValue() {
|
||||
// empty
|
||||
}
|
||||
|
||||
/// @brief Construction from a given time and key value.
|
||||
|
||||
aiVectorKey(double time, const aiVector3D& value)
|
||||
: mTime( time )
|
||||
, mValue( value ) {
|
||||
aiVectorKey(double time, const aiVector3D &value) :
|
||||
mTime(time), mValue(value) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
@ -111,8 +109,7 @@ struct aiVectorKey
|
|||
// ---------------------------------------------------------------------------
|
||||
/** A time-value pair specifying a rotation for the given time.
|
||||
* Rotations are expressed with quaternions. */
|
||||
struct aiQuatKey
|
||||
{
|
||||
struct aiQuatKey {
|
||||
/** The time of this key */
|
||||
double mTime;
|
||||
|
||||
|
@ -121,16 +118,14 @@ struct aiQuatKey
|
|||
|
||||
#ifdef __cplusplus
|
||||
aiQuatKey() AI_NO_EXCEPT
|
||||
: mTime( 0.0 )
|
||||
, mValue() {
|
||||
: mTime(0.0),
|
||||
mValue() {
|
||||
// empty
|
||||
}
|
||||
|
||||
/** Construction from a given time and key value */
|
||||
aiQuatKey(double time, const aiQuaternion& value)
|
||||
: mTime (time)
|
||||
, mValue (value)
|
||||
{}
|
||||
aiQuatKey(double time, const aiQuaternion &value) :
|
||||
mTime(time), mValue(value) {}
|
||||
|
||||
typedef aiQuaternion elem_type;
|
||||
|
||||
|
@ -154,8 +149,7 @@ struct aiQuatKey
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Binds a anim-mesh to a specific point in time. */
|
||||
struct aiMeshKey
|
||||
{
|
||||
struct aiMeshKey {
|
||||
/** The time of this key */
|
||||
double mTime;
|
||||
|
||||
|
@ -168,16 +162,13 @@ struct aiMeshKey
|
|||
#ifdef __cplusplus
|
||||
|
||||
aiMeshKey() AI_NO_EXCEPT
|
||||
: mTime(0.0)
|
||||
, mValue(0)
|
||||
{
|
||||
: mTime(0.0),
|
||||
mValue(0) {
|
||||
}
|
||||
|
||||
/** Construction from a given time and key value */
|
||||
aiMeshKey(double time, const unsigned int value)
|
||||
: mTime (time)
|
||||
, mValue (value)
|
||||
{}
|
||||
aiMeshKey(double time, const unsigned int value) :
|
||||
mTime(time), mValue(value) {}
|
||||
|
||||
typedef unsigned int elem_type;
|
||||
|
||||
|
@ -202,8 +193,7 @@ struct aiMeshKey
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Binds a morph anim mesh to a specific point in time. */
|
||||
struct aiMeshMorphKey
|
||||
{
|
||||
struct aiMeshMorphKey {
|
||||
/** The time of this key */
|
||||
double mTime;
|
||||
|
||||
|
@ -215,16 +205,13 @@ struct aiMeshMorphKey
|
|||
unsigned int mNumValuesAndWeights;
|
||||
#ifdef __cplusplus
|
||||
aiMeshMorphKey() AI_NO_EXCEPT
|
||||
: mTime(0.0)
|
||||
, mValues(nullptr)
|
||||
, mWeights(nullptr)
|
||||
, mNumValuesAndWeights(0)
|
||||
{
|
||||
|
||||
: mTime(0.0),
|
||||
mValues(nullptr),
|
||||
mWeights(nullptr),
|
||||
mNumValuesAndWeights(0) {
|
||||
}
|
||||
|
||||
~aiMeshMorphKey()
|
||||
{
|
||||
~aiMeshMorphKey() {
|
||||
if (mNumValuesAndWeights && mValues && mWeights) {
|
||||
delete[] mValues;
|
||||
delete[] mWeights;
|
||||
|
@ -237,8 +224,7 @@ struct aiMeshMorphKey
|
|||
/** Defines how an animation channel behaves outside the defined time
|
||||
* range. This corresponds to aiNodeAnim::mPreState and
|
||||
* aiNodeAnim::mPostState.*/
|
||||
enum aiAnimBehaviour
|
||||
{
|
||||
enum aiAnimBehaviour {
|
||||
/** The value from the default node transformation is taken*/
|
||||
aiAnimBehaviour_DEFAULT = 0x0,
|
||||
|
||||
|
@ -329,14 +315,14 @@ struct aiNodeAnim {
|
|||
|
||||
#ifdef __cplusplus
|
||||
aiNodeAnim() AI_NO_EXCEPT
|
||||
: mNumPositionKeys( 0 )
|
||||
, mPositionKeys( nullptr )
|
||||
, mNumRotationKeys( 0 )
|
||||
, mRotationKeys( nullptr )
|
||||
, mNumScalingKeys( 0 )
|
||||
, mScalingKeys( nullptr )
|
||||
, mPreState( aiAnimBehaviour_DEFAULT )
|
||||
, mPostState( aiAnimBehaviour_DEFAULT ) {
|
||||
: mNumPositionKeys(0),
|
||||
mPositionKeys(nullptr),
|
||||
mNumRotationKeys(0),
|
||||
mRotationKeys(nullptr),
|
||||
mNumScalingKeys(0),
|
||||
mScalingKeys(nullptr),
|
||||
mPreState(aiAnimBehaviour_DEFAULT),
|
||||
mPostState(aiAnimBehaviour_DEFAULT) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
@ -354,8 +340,7 @@ struct aiNodeAnim {
|
|||
* aiMesh::mAnimMeshes array. The purpose of aiMeshAnim is to
|
||||
* define keyframes linking each mesh attachment to a particular
|
||||
* point in time. */
|
||||
struct aiMeshAnim
|
||||
{
|
||||
struct aiMeshAnim {
|
||||
/** Name of the mesh to be animated. An empty string is not allowed,
|
||||
* animated meshes need to be named (not necessarily uniquely,
|
||||
* the name can basically serve as wild-card to select a group
|
||||
|
@ -371,12 +356,10 @@ struct aiMeshAnim
|
|||
#ifdef __cplusplus
|
||||
|
||||
aiMeshAnim() AI_NO_EXCEPT
|
||||
: mNumKeys()
|
||||
, mKeys()
|
||||
{}
|
||||
: mNumKeys(),
|
||||
mKeys() {}
|
||||
|
||||
~aiMeshAnim()
|
||||
{
|
||||
~aiMeshAnim() {
|
||||
delete[] mKeys;
|
||||
}
|
||||
|
||||
|
@ -385,8 +368,7 @@ struct aiMeshAnim
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Describes a morphing animation of a given mesh. */
|
||||
struct aiMeshMorphAnim
|
||||
{
|
||||
struct aiMeshMorphAnim {
|
||||
/** Name of the mesh to be animated. An empty string is not allowed,
|
||||
* animated meshes need to be named (not necessarily uniquely,
|
||||
* the name can basically serve as wildcard to select a group
|
||||
|
@ -402,12 +384,10 @@ struct aiMeshMorphAnim
|
|||
#ifdef __cplusplus
|
||||
|
||||
aiMeshMorphAnim() AI_NO_EXCEPT
|
||||
: mNumKeys()
|
||||
, mKeys()
|
||||
{}
|
||||
: mNumKeys(),
|
||||
mKeys() {}
|
||||
|
||||
~aiMeshMorphAnim()
|
||||
{
|
||||
~aiMeshMorphAnim() {
|
||||
delete[] mKeys;
|
||||
}
|
||||
|
||||
|
@ -437,7 +417,6 @@ struct aiAnimation {
|
|||
* The array is mNumChannels in size. */
|
||||
C_STRUCT aiNodeAnim **mChannels;
|
||||
|
||||
|
||||
/** The number of mesh animation channels. Each channel affects
|
||||
* a single mesh and defines vertex-based animation. */
|
||||
unsigned int mNumMeshChannels;
|
||||
|
@ -456,14 +435,14 @@ struct aiAnimation {
|
|||
|
||||
#ifdef __cplusplus
|
||||
aiAnimation() AI_NO_EXCEPT
|
||||
: mDuration(-1.)
|
||||
, mTicksPerSecond(0.)
|
||||
, mNumChannels(0)
|
||||
, mChannels(nullptr)
|
||||
, mNumMeshChannels(0)
|
||||
, mMeshChannels(nullptr)
|
||||
, mNumMorphMeshChannels(0)
|
||||
, mMorphMeshChannels(nullptr) {
|
||||
: mDuration(-1.),
|
||||
mTicksPerSecond(0.),
|
||||
mNumChannels(0),
|
||||
mChannels(nullptr),
|
||||
mNumMeshChannels(0),
|
||||
mMeshChannels(nullptr),
|
||||
mNumMorphMeshChannels(0),
|
||||
mMorphMeshChannels(nullptr) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
@ -495,7 +474,6 @@ struct aiAnimation {
|
|||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
}
|
||||
|
||||
/// @brief Some C++ utilities for inter- and extrapolation
|
||||
|
@ -509,16 +487,15 @@ namespace Assimp {
|
|||
* types of the arguments.
|
||||
*/
|
||||
template <typename T>
|
||||
struct Interpolator
|
||||
{
|
||||
struct Interpolator {
|
||||
// ------------------------------------------------------------------
|
||||
/** @brief Get the result of the interpolation between a,b.
|
||||
*
|
||||
* The interpolation algorithm depends on the type of the operands.
|
||||
* aiQuaternion's and aiQuatKey's SLERP, the rest does a simple
|
||||
* linear interpolation. */
|
||||
void operator () (T& out,const T& a, const T& b, ai_real d) const {
|
||||
out = a + (b-a)*d;
|
||||
void operator()(T &anim_out, const T &a, const T &b, ai_real d) const {
|
||||
anim_out = a + (b - a) * d;
|
||||
}
|
||||
}; // ! Interpolator <T>
|
||||
|
||||
|
@ -527,8 +504,7 @@ struct Interpolator
|
|||
template <>
|
||||
struct Interpolator<aiQuaternion> {
|
||||
void operator()(aiQuaternion &out, const aiQuaternion &a,
|
||||
const aiQuaternion& b, ai_real d) const
|
||||
{
|
||||
const aiQuaternion &b, ai_real d) const {
|
||||
aiQuaternion::Interpolate(out, a, b, d);
|
||||
}
|
||||
}; // ! Interpolator <aiQuaternion>
|
||||
|
@ -536,8 +512,7 @@ struct Interpolator <aiQuaternion> {
|
|||
template <>
|
||||
struct Interpolator<unsigned int> {
|
||||
void operator()(unsigned int &out, unsigned int a,
|
||||
unsigned int b, ai_real d) const
|
||||
{
|
||||
unsigned int b, ai_real d) const {
|
||||
out = d > 0.5f ? b : a;
|
||||
}
|
||||
}; // ! Interpolator <aiQuaternion>
|
||||
|
@ -545,8 +520,7 @@ struct Interpolator <unsigned int> {
|
|||
template <>
|
||||
struct Interpolator<aiVectorKey> {
|
||||
void operator()(aiVector3D &out, const aiVectorKey &a,
|
||||
const aiVectorKey& b, ai_real d) const
|
||||
{
|
||||
const aiVectorKey &b, ai_real d) const {
|
||||
Interpolator<aiVector3D> ipl;
|
||||
ipl(out, a.mValue, b.mValue, d);
|
||||
}
|
||||
|
@ -555,8 +529,7 @@ struct Interpolator<aiVectorKey> {
|
|||
template <>
|
||||
struct Interpolator<aiQuatKey> {
|
||||
void operator()(aiQuaternion &out, const aiQuatKey &a,
|
||||
const aiQuatKey& b, ai_real d) const
|
||||
{
|
||||
const aiQuatKey &b, ai_real d) const {
|
||||
Interpolator<aiQuaternion> ipl;
|
||||
ipl(out, a.mValue, b.mValue, d);
|
||||
}
|
||||
|
@ -565,8 +538,7 @@ struct Interpolator<aiQuatKey> {
|
|||
template <>
|
||||
struct Interpolator<aiMeshKey> {
|
||||
void operator()(unsigned int &out, const aiMeshKey &a,
|
||||
const aiMeshKey& b, ai_real d) const
|
||||
{
|
||||
const aiMeshKey &b, ai_real d) const {
|
||||
Interpolator<unsigned int> ipl;
|
||||
ipl(out, a.mValue, b.mValue, d);
|
||||
}
|
||||
|
@ -574,7 +546,7 @@ struct Interpolator<aiMeshKey> {
|
|||
|
||||
//! @endcond
|
||||
|
||||
} // ! end namespace Assimp
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
|
|
|
@ -49,7 +49,9 @@ using namespace Assimp;
|
|||
|
||||
class TestProgressHandler : public ProgressHandler {
|
||||
public:
|
||||
TestProgressHandler() : ProgressHandler() {
|
||||
TestProgressHandler() :
|
||||
ProgressHandler(),
|
||||
mPercentage(0.f) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
@ -58,8 +60,10 @@ public:
|
|||
}
|
||||
|
||||
bool Update(float percentage = -1.f) override {
|
||||
mPercentage = percentage;
|
||||
return true;
|
||||
}
|
||||
float mPercentage;
|
||||
};
|
||||
|
||||
class ExporterTest : public ::testing::Test {
|
||||
|
@ -79,8 +83,7 @@ TEST_F(ExporterTest, ExporterIdTest) {
|
|||
EXPECT_NE(0u, exportFormatCount) << "No registered exporters";
|
||||
typedef std::map<std::string, const aiExportFormatDesc *> ExportIdMap;
|
||||
ExportIdMap exporterMap;
|
||||
for (size_t i = 0; i < exportFormatCount; ++i)
|
||||
{
|
||||
for (size_t i = 0; i < exportFormatCount; ++i) {
|
||||
// Check that the exporter description exists and makes sense
|
||||
const aiExportFormatDesc *desc = exporter.GetExportFormatDescription(i);
|
||||
ASSERT_NE(nullptr, desc) << "Missing aiExportFormatDesc at index " << i;
|
||||
|
|
|
@ -53,7 +53,6 @@ public:
|
|||
virtual bool importerTest() {
|
||||
Assimp::Importer importer;
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/NFF/NFF/ManyEarthsNotJustOne.nff", 0);
|
||||
return true;
|
||||
return nullptr != scene;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -88,8 +88,6 @@ bool SceneDiffer::isEqual( const aiScene *expected, const aiScene *toCompare ) {
|
|||
}
|
||||
}
|
||||
|
||||
// ToDo!
|
||||
return true;
|
||||
// materials
|
||||
if ( expected->mNumMaterials != toCompare->mNumMaterials ) {
|
||||
std::stringstream stream;
|
||||
|
@ -112,6 +110,7 @@ bool SceneDiffer::isEqual( const aiScene *expected, const aiScene *toCompare ) {
|
|||
std::stringstream stream;
|
||||
stream << "Materials are not equal, index : " << i << "\n";
|
||||
addDiff( stream.str() );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ public:
|
|||
virtual bool importerTest() {
|
||||
Assimp::Importer importer;
|
||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/MDC/spider.mdc", 0);
|
||||
return true;
|
||||
return nullptr != scene;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -41,13 +41,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "UnitTestPCH.h"
|
||||
#include "SceneDiffer.h"
|
||||
#include "AbstractImportExportBase.h"
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/Exporter.hpp>
|
||||
#include "SceneDiffer.h"
|
||||
#include "UnitTestPCH.h"
|
||||
#include <assimp/postprocess.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/Exporter.hpp>
|
||||
#include <assimp/Importer.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
@ -240,8 +240,7 @@ TEST_F( utObjImportExport, obj_import_test ) {
|
|||
differ.showReport();
|
||||
|
||||
m_im->FreeScene();
|
||||
for(unsigned int i = 0; i < expected->mNumMeshes; ++i)
|
||||
{
|
||||
for (unsigned int i = 0; i < expected->mNumMeshes; ++i) {
|
||||
delete expected->mMeshes[i];
|
||||
}
|
||||
delete[] expected->mMeshes;
|
||||
|
@ -290,7 +289,7 @@ TEST_F( utObjImportExport, issue1923_vertex_color_Test ) {
|
|||
}
|
||||
|
||||
TEST_F(utObjImportExport, issue1453_segfault) {
|
||||
static const char *ObjModel =
|
||||
static const char *curObjModel =
|
||||
"v 0.0 0.0 0.0\n"
|
||||
"v 0.0 0.0 1.0\n"
|
||||
"v 0.0 1.0 0.0\n"
|
||||
|
@ -301,12 +300,12 @@ TEST_F( utObjImportExport, issue1453_segfault ) {
|
|||
"v 1.0 1.0 1.0\nB";
|
||||
|
||||
Assimp::Importer myimporter;
|
||||
const aiScene *scene = myimporter.ReadFileFromMemory( ObjModel, strlen(ObjModel), aiProcess_ValidateDataStructure );
|
||||
const aiScene *scene = myimporter.ReadFileFromMemory(curObjModel, strlen(curObjModel), aiProcess_ValidateDataStructure);
|
||||
EXPECT_EQ(nullptr, scene);
|
||||
}
|
||||
|
||||
TEST_F(utObjImportExport, relative_indices_Test) {
|
||||
static const char *ObjModel =
|
||||
static const char *curObjModel =
|
||||
"v -0.500000 0.000000 0.400000\n"
|
||||
"v -0.500000 0.000000 -0.800000\n"
|
||||
"v -0.500000 1.000000 -0.800000\n"
|
||||
|
@ -314,7 +313,7 @@ TEST_F(utObjImportExport, relative_indices_Test) {
|
|||
"f -4 -3 -2 -1\nB";
|
||||
|
||||
Assimp::Importer myimporter;
|
||||
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), aiProcess_ValidateDataStructure);
|
||||
const aiScene *scene = myimporter.ReadFileFromMemory(curObjModel, strlen(curObjModel), aiProcess_ValidateDataStructure);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
|
||||
EXPECT_EQ(scene->mNumMeshes, 1U);
|
||||
|
@ -323,22 +322,20 @@ TEST_F(utObjImportExport, relative_indices_Test) {
|
|||
EXPECT_EQ(mesh->mNumFaces, 1U);
|
||||
const aiFace face = mesh->mFaces[0];
|
||||
EXPECT_EQ(face.mNumIndices, 4U);
|
||||
for (unsigned int i = 0; i < face.mNumIndices; ++i)
|
||||
{
|
||||
for (unsigned int i = 0; i < face.mNumIndices; ++i) {
|
||||
EXPECT_EQ(face.mIndices[i], i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TEST_F(utObjImportExport, homogeneous_coordinates_Test) {
|
||||
static const char *ObjModel =
|
||||
static const char *curObjModel =
|
||||
"v -0.500000 0.000000 0.400000 0.50000\n"
|
||||
"v -0.500000 0.000000 -0.800000 1.00000\n"
|
||||
"v 0.500000 1.000000 -0.800000 0.5000\n"
|
||||
"f 1 2 3\nB";
|
||||
|
||||
Assimp::Importer myimporter;
|
||||
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), aiProcess_ValidateDataStructure);
|
||||
const aiScene *scene = myimporter.ReadFileFromMemory(curObjModel, strlen(curObjModel), aiProcess_ValidateDataStructure);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
|
||||
EXPECT_EQ(scene->mNumMeshes, 1U);
|
||||
|
@ -354,31 +351,31 @@ TEST_F(utObjImportExport, homogeneous_coordinates_Test) {
|
|||
}
|
||||
|
||||
TEST_F(utObjImportExport, homogeneous_coordinates_divide_by_zero_Test) {
|
||||
static const char *ObjModel =
|
||||
static const char *curObjModel =
|
||||
"v -0.500000 0.000000 0.400000 0.\n"
|
||||
"v -0.500000 0.000000 -0.800000 1.00000\n"
|
||||
"v 0.500000 1.000000 -0.800000 0.5000\n"
|
||||
"f 1 2 3\nB";
|
||||
|
||||
Assimp::Importer myimporter;
|
||||
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), aiProcess_ValidateDataStructure);
|
||||
const aiScene *scene = myimporter.ReadFileFromMemory(curObjModel, strlen(curObjModel), aiProcess_ValidateDataStructure);
|
||||
EXPECT_EQ(nullptr, scene);
|
||||
}
|
||||
|
||||
TEST_F(utObjImportExport, 0based_array_Test) {
|
||||
static const char *ObjModel =
|
||||
static const char *curObjModel =
|
||||
"v -0.500000 0.000000 0.400000\n"
|
||||
"v -0.500000 0.000000 -0.800000\n"
|
||||
"v -0.500000 1.000000 -0.800000\n"
|
||||
"f 0 1 2\nB";
|
||||
|
||||
Assimp::Importer myImporter;
|
||||
const aiScene *scene = myImporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), 0);
|
||||
const aiScene *scene = myImporter.ReadFileFromMemory(curObjModel, strlen(curObjModel), 0);
|
||||
EXPECT_EQ(nullptr, scene);
|
||||
}
|
||||
|
||||
TEST_F(utObjImportExport, invalid_normals_uvs) {
|
||||
static const char *ObjModel =
|
||||
static const char *curObjModel =
|
||||
"v -0.500000 0.000000 0.400000\n"
|
||||
"v -0.500000 0.000000 -0.800000\n"
|
||||
"v -0.500000 1.000000 -0.800000\n"
|
||||
|
@ -387,12 +384,12 @@ TEST_F(utObjImportExport, invalid_normals_uvs) {
|
|||
"f 1/1/1 1/1/1 2/2/2\nB";
|
||||
|
||||
Assimp::Importer myImporter;
|
||||
const aiScene *scene = myImporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), 0);
|
||||
const aiScene *scene = myImporter.ReadFileFromMemory(curObjModel, strlen(curObjModel), 0);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
}
|
||||
|
||||
TEST_F(utObjImportExport, no_vt_just_vns) {
|
||||
static const char *ObjModel =
|
||||
static const char *curObjModel =
|
||||
"v 0 0 0\n"
|
||||
"v 0 0 0\n"
|
||||
"v 0 0 0\n"
|
||||
|
@ -420,7 +417,7 @@ TEST_F(utObjImportExport, no_vt_just_vns) {
|
|||
"f 10/10 11/11 12/12\n";
|
||||
|
||||
Assimp::Importer myImporter;
|
||||
const aiScene *scene = myImporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), 0);
|
||||
const aiScene *scene = myImporter.ReadFileFromMemory(curObjModel, strlen(curObjModel), 0);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
}
|
||||
|
||||
|
@ -450,7 +447,7 @@ TEST_F(utObjImportExport, import_without_linend) {
|
|||
}
|
||||
|
||||
TEST_F(utObjImportExport, import_with_line_continuations) {
|
||||
static const char *ObjModel =
|
||||
static const char *curObjModel =
|
||||
"v -0.5 -0.5 0.5\n"
|
||||
"v -0.5 \\\n"
|
||||
" -0.5 -0.5\n"
|
||||
|
@ -460,7 +457,7 @@ TEST_F(utObjImportExport, import_with_line_continuations) {
|
|||
"f 1 2 3\n";
|
||||
|
||||
Assimp::Importer myImporter;
|
||||
const aiScene *scene = myImporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), 0);
|
||||
const aiScene *scene = myImporter.ReadFileFromMemory(curObjModel, strlen(curObjModel), 0);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
|
||||
EXPECT_EQ(scene->mNumMeshes, 1U);
|
||||
|
|
|
@ -183,7 +183,7 @@ TEST_F(SortByPTypeProcessTest, SortByPTypeStep) {
|
|||
unsigned int idx = 0;
|
||||
for (unsigned int m = 0,real = 0; m< 10;++m) {
|
||||
for (unsigned int n = 0; n < 4;++n) {
|
||||
idx = num[m][n])
|
||||
idx = num[m][n];
|
||||
if (idx) {
|
||||
EXPECT_TRUE(real < mScene->mNumMeshes);
|
||||
|
||||
|
|
|
@ -112,11 +112,11 @@ TEST_F(TriangulateProcessTest, testTriangulation) {
|
|||
std::vector<bool> ait(q,false);
|
||||
|
||||
for (unsigned int i = 0, tt = q-2; i < tt; ++i,++m) {
|
||||
aiFace& face = pcMesh->mFaces[m];
|
||||
EXPECT_EQ(3U, face.mNumIndices);
|
||||
aiFace& curFace = pcMesh->mFaces[m];
|
||||
EXPECT_EQ(3U, curFace.mNumIndices);
|
||||
|
||||
for (unsigned int qqq = 0; qqq < face.mNumIndices; ++qqq) {
|
||||
ait[face.mIndices[qqq]-idx] = true;
|
||||
for (unsigned int qqq = 0; qqq < curFace.mNumIndices; ++qqq) {
|
||||
ait[curFace.mIndices[qqq] - idx] = true;
|
||||
}
|
||||
}
|
||||
for (std::vector<bool>::const_iterator it = ait.begin(); it != ait.end(); ++it) {
|
||||
|
|
|
@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
#include "Main.h"
|
||||
#include <assimp/ParsingUtils.h>
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
|
||||
|
@ -53,13 +54,10 @@ const char* AICMD_MSG_EXPORT_HELP_E =
|
|||
"assimp export <model> [<out>] [-f<h>] [common parameters]\n"
|
||||
"\t -f<h> Specify the file format. If omitted, the output format is \n"
|
||||
"\t\tderived from the file extension of the given output file \n"
|
||||
"\t[See the assimp_cmd docs for a full list of all common parameters] \n"
|
||||
;
|
||||
|
||||
"\t[See the assimp_cmd docs for a full list of all common parameters] \n";
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
size_t GetMatchingFormat(const std::string& outf,bool byext=false)
|
||||
{
|
||||
size_t GetMatchingFormat(const std::string &outf, bool byext = false) {
|
||||
for (size_t i = 0, end = globalExporter->GetExportFormatCount(); i < end; ++i) {
|
||||
const aiExportFormatDesc *const e = globalExporter->GetExportFormatDescription(i);
|
||||
if (outf == (byext ? e->fileExtension : e->id)) {
|
||||
|
@ -69,10 +67,8 @@ size_t GetMatchingFormat(const std::string& outf,bool byext=false)
|
|||
return SIZE_MAX;
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
int Assimp_Export(const char* const* params, unsigned int num)
|
||||
{
|
||||
int Assimp_Export(const char *const *params, unsigned int num) {
|
||||
const char *const invalid = "assimp export: Invalid number of arguments. See \'assimp export --help\'\n";
|
||||
if (num < 1) {
|
||||
printf(invalid);
|
||||
|
@ -108,13 +104,12 @@ int Assimp_Export(const char* const* params, unsigned int num)
|
|||
if (!strncmp(params[i], "-f", 2)) {
|
||||
if (strncmp(params[i], "-fi", 3))
|
||||
outf = std::string(params[i] + 2);
|
||||
}
|
||||
else if ( !strncmp( params[i], "--format=",9)) {
|
||||
} else if (!strncmp(params[i], "--format=", 9)) {
|
||||
outf = std::string(params[i] + 9);
|
||||
}
|
||||
}
|
||||
|
||||
std::transform(outf.begin(),outf.end(),outf.begin(),::tolower);
|
||||
std::transform(outf.begin(), outf.end(), outf.begin(), Assimp::ToLower<char>);
|
||||
|
||||
// convert the output format to a format id
|
||||
size_t outfi = GetMatchingFormat(outf);
|
||||
|
@ -134,20 +129,19 @@ int Assimp_Export(const char* const* params, unsigned int num)
|
|||
printf("assimp export: no output format specified and I failed to guess it\n");
|
||||
return -23;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
outext = outf;
|
||||
}
|
||||
}
|
||||
|
||||
// if no output file is specified, take the file name from input file
|
||||
if (out[0] == '-') {
|
||||
std::string::size_type s = in.find_last_of('.');
|
||||
if (s == std::string::npos) {
|
||||
s = in.length();
|
||||
std::string::size_type pos = in.find_last_of('.');
|
||||
if (pos == std::string::npos) {
|
||||
pos = in.length();
|
||||
}
|
||||
|
||||
out = in.substr(0,s);
|
||||
out = in.substr(0, pos);
|
||||
}
|
||||
|
||||
const aiExportFormatDesc *const e = globalExporter->GetExportFormatDescription(outfi);
|
||||
|
@ -171,4 +165,3 @@ int Assimp_Export(const char* const* params, unsigned int num)
|
|||
}
|
||||
|
||||
#endif // no export
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -46,10 +44,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
#include "Main.h"
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/StringComparison.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
|
||||
const char* AICMD_MSG_DUMP_HELP_E =
|
||||
static const char *AICMD_MSG_DUMP_HELP_E =
|
||||
"assimp extract <model> [<out>] [-t<n>] [-f<fmt>] [-ba] [-s] [common parameters]\n"
|
||||
"\t -ba Writes BMP's with alpha channel\n"
|
||||
"\t -t<n> Zero-based index of the texture to be extracted \n"
|
||||
|
@ -57,16 +56,14 @@ const char* AICMD_MSG_DUMP_HELP_E =
|
|||
"\t[See the assimp_cmd docs for a full list of all common parameters] \n"
|
||||
"\t -cfast Fast post processing preset, runs just a few important steps \n"
|
||||
"\t -cdefault Default post processing: runs all recommended steps\n"
|
||||
"\t -cfull Fires almost all post processing steps \n"
|
||||
;
|
||||
"\t -cfull Fires almost all post processing steps \n";
|
||||
|
||||
#define AI_EXTRACT_WRITE_BMP_ALPHA 0x1
|
||||
#include <assimp/Compiler/pushpack1.h>
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Data structure for the first header of a BMP
|
||||
struct BITMAPFILEHEADER
|
||||
{
|
||||
struct BITMAPFILEHEADER {
|
||||
uint16_t bfType;
|
||||
uint32_t bfSize;
|
||||
uint16_t bfReserved1;
|
||||
|
@ -76,8 +73,7 @@ struct BITMAPFILEHEADER
|
|||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Data structure for the second header of a BMP
|
||||
struct BITMAPINFOHEADER
|
||||
{
|
||||
struct BITMAPINFOHEADER {
|
||||
int32_t biSize;
|
||||
int32_t biWidth;
|
||||
int32_t biHeight;
|
||||
|
@ -95,14 +91,13 @@ struct BITMAPINFOHEADER
|
|||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Data structure for the header of a TGA
|
||||
struct TGA_HEADER
|
||||
{
|
||||
struct TGA_HEADER {
|
||||
uint8_t identsize; // size of ID field that follows 18 byte header (0 usually)
|
||||
uint8_t colourmaptype; // type of colour map 0=none, 1=has palette
|
||||
uint8_t imagetype; // type of image 0=none,1=indexed,2=rgb,3=grey,+8=rle packed
|
||||
uint8_t imagetype; // type of image 0=none,1=indexed,2=rgb,3=gray,+8=rle packed
|
||||
|
||||
uint16_t colourmapstart; // first colour map entry in palette
|
||||
uint16_t colourmaplength; // number of colours in palette
|
||||
uint16_t colourmaplength; // number of colors in palette
|
||||
uint8_t colourmapbits; // number of bits per palette entry 15,16,24,32
|
||||
|
||||
uint16_t xstart; // image x origin
|
||||
|
@ -115,13 +110,11 @@ struct TGA_HEADER
|
|||
// pixel data follows header
|
||||
} PACK_STRUCT;
|
||||
|
||||
|
||||
#include <assimp/Compiler/poppack1.h>
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Save a texture as bitmap
|
||||
int SaveAsBMP (FILE* file, const aiTexel* data, unsigned int width, unsigned int height, bool SaveAlpha = false)
|
||||
{
|
||||
int SaveAsBMP(FILE *file, const aiTexel *data, unsigned int width, unsigned int height, bool SaveAlpha = false) {
|
||||
if (!file || !data) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -155,7 +148,7 @@ int SaveAsBMP (FILE* file, const aiTexel* data, unsigned int width, unsigned int
|
|||
info.biWidth = width;
|
||||
info.biHeight = height;
|
||||
info.biPlanes = 1;
|
||||
info.biBitCount = numc<<3;
|
||||
info.biBitCount = (int16_t)numc << 3;
|
||||
info.biCompression = 0;
|
||||
info.biSizeImage = width * height * numc;
|
||||
info.biXPelsPerMeter = 1; // dummy
|
||||
|
@ -179,8 +172,7 @@ int SaveAsBMP (FILE* file, const aiTexel* data, unsigned int width, unsigned int
|
|||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Save a texture as tga
|
||||
int SaveAsTGA (FILE* file, const aiTexel* data, unsigned int width, unsigned int height)
|
||||
{
|
||||
int SaveAsTGA(FILE *file, const aiTexel *data, unsigned int width, unsigned int height) {
|
||||
if (!file || !data) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -207,17 +199,14 @@ int SaveAsTGA (FILE* file, const aiTexel* data, unsigned int width, unsigned int
|
|||
// -----------------------------------------------------------------------------------
|
||||
// Do the texture import for a given aiTexture
|
||||
int DoExport(const aiTexture *tx, FILE *p, const std::string &extension,
|
||||
unsigned int flags)
|
||||
{
|
||||
unsigned int flags) {
|
||||
// export the image to the appropriate decoder
|
||||
if (extension == "bmp") {
|
||||
SaveAsBMP(p, tx->pcData, tx->mWidth, tx->mHeight,
|
||||
(0 != (flags & AI_EXTRACT_WRITE_BMP_ALPHA)));
|
||||
}
|
||||
else if (extension == "tga") {
|
||||
} else if (extension == "tga") {
|
||||
SaveAsTGA(p, tx->pcData, tx->mWidth, tx->mHeight);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
printf("assimp extract: No available texture encoder found for %s\n", extension.c_str());
|
||||
return AssimpCmdExtractError::NoAvailableTextureEncoderFound;
|
||||
}
|
||||
|
@ -226,8 +215,7 @@ int DoExport(const aiTexture* tx, FILE* p, const std::string& extension,
|
|||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Implementation of the assimp extract utility
|
||||
int Assimp_Extract (const char* const* params, unsigned int num)
|
||||
{
|
||||
int Assimp_Extract(const char *const *params, unsigned int num) {
|
||||
const char *const invalid = "assimp extract: Invalid number of arguments. See \'assimp extract --help\'\n";
|
||||
// assimp extract in out [options]
|
||||
if (num < 1) {
|
||||
|
@ -241,8 +229,6 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
|||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string in = std::string(params[0]);
|
||||
std::string out = (num > 1 ? std::string(params[1]) : "-");
|
||||
|
||||
|
@ -262,20 +248,15 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
|||
|
||||
if (!strncmp(params[i], "-f", 2)) {
|
||||
extension = std::string(params[i] + 2);
|
||||
}
|
||||
else if ( !strncmp( params[i], "--format=",9)) {
|
||||
} else if (!strncmp(params[i], "--format=", 9)) {
|
||||
extension = std::string(params[i] + 9);
|
||||
}
|
||||
else if ( !strcmp( params[i], "--nosuffix") || !strcmp(params[i],"-s")) {
|
||||
} else if (!strcmp(params[i], "--nosuffix") || !strcmp(params[i], "-s")) {
|
||||
nosuffix = true;
|
||||
}
|
||||
else if ( !strncmp( params[i], "--texture=",10)) {
|
||||
} else if (!strncmp(params[i], "--texture=", 10)) {
|
||||
texIdx = Assimp::strtoul10(params[i] + 10);
|
||||
}
|
||||
else if ( !strncmp( params[i], "-t",2)) {
|
||||
} else if (!strncmp(params[i], "-t", 2)) {
|
||||
texIdx = Assimp::strtoul10(params[i] + 2);
|
||||
}
|
||||
else if ( !strcmp( params[i], "-ba") || !strcmp( params[i], "--bmp-with-alpha")) {
|
||||
} else if (!strcmp(params[i], "-ba") || !strcmp(params[i], "--bmp-with-alpha")) {
|
||||
flags |= AI_EXTRACT_WRITE_BMP_ALPHA;
|
||||
}
|
||||
#if 0
|
||||
|
@ -286,7 +267,7 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
|||
#endif
|
||||
}
|
||||
|
||||
std::transform(extension.begin(),extension.end(),extension.begin(),::tolower);
|
||||
std::transform(extension.begin(), extension.end(), extension.begin(), Assimp::ToLower<char>);
|
||||
|
||||
if (out[0] == '-') {
|
||||
// take file name from input file
|
||||
|
@ -320,8 +301,7 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
|||
texIdx, scene->mNumTextures);
|
||||
return AssimpCmdExtractError::TextureIndexIsOutOfRange;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
::printf("assimp extract: Exporting %i textures\n", scene->mNumTextures);
|
||||
}
|
||||
|
||||
|
@ -363,16 +343,19 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
|||
int m;
|
||||
|
||||
if (!tex->mHeight) {
|
||||
m = (1 != fwrite(tex->pcData,tex->mWidth,1,p))
|
||||
? static_cast<int>(AssimpCmdError::Success)
|
||||
: static_cast<int>(AssimpCmdExtractError::FailedToExportCompressedTexture);
|
||||
m = (1 != fwrite(tex->pcData, tex->mWidth, 1, p)) ?
|
||||
static_cast<int>(AssimpCmdError::Success) :
|
||||
static_cast<int>(AssimpCmdExtractError::FailedToExportCompressedTexture);
|
||||
} else {
|
||||
m = DoExport(tex, p, extension, flags);
|
||||
}
|
||||
else m = DoExport(tex,p,extension,flags);
|
||||
::fclose(p);
|
||||
|
||||
printf("assimp extract: Wrote texture %i to %s\n", i, out_cpy.c_str());
|
||||
if (texIdx != 0xffffffff)
|
||||
if (texIdx != 0xffffffff) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
|
|
@ -56,8 +56,7 @@ const char* AICMD_MSG_DUMP_HELP =
|
|||
"\t[See the assimp_cmd docs for a full list of all common parameters] \n"
|
||||
"\t -cfast Fast post processing preset, runs just a few important steps \n"
|
||||
"\t -cdefault Default post processing: runs all recommended steps\n"
|
||||
"\t -cfull Fires almost all post processing steps \n"
|
||||
;
|
||||
"\t -cfull Fires almost all post processing steps \n";
|
||||
|
||||
#include "Common/assbin_chunks.h"
|
||||
#include <assimp/DefaultIOSystem.h>
|
||||
|
@ -70,8 +69,7 @@ FILE* out = NULL;
|
|||
bool shortened = false;
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
int Assimp_Dump (const char* const* params, unsigned int num)
|
||||
{
|
||||
int Assimp_Dump(const char *const *params, unsigned int num) {
|
||||
const char *fail = "assimp dump: Invalid number of arguments. "
|
||||
"See \'assimp dump --help\'\r\n";
|
||||
|
||||
|
@ -88,11 +86,11 @@ int Assimp_Dump (const char* const* params, unsigned int num)
|
|||
}
|
||||
|
||||
std::string in = std::string(params[0]);
|
||||
std::string out = (num > 1 ? std::string(params[1]) : std::string("-"));
|
||||
std::string cur_out = (num > 1 ? std::string(params[1]) : std::string("-"));
|
||||
|
||||
// store full command line
|
||||
std::string cmd;
|
||||
for (unsigned int i = (out[0] == '-' ? 1 : 2); i < num;++i) {
|
||||
for (unsigned int i = (cur_out[0] == '-' ? 1 : 2); i < num; ++i) {
|
||||
if (!params[i]) continue;
|
||||
cmd.append(params[i]);
|
||||
cmd.append(" ");
|
||||
|
@ -102,18 +100,18 @@ int Assimp_Dump (const char* const* params, unsigned int num)
|
|||
ImportData import;
|
||||
ProcessStandardArguments(import, params + 1, num - 1);
|
||||
|
||||
bool binary = false, shortened = false,compressed=false;
|
||||
bool binary = false, cur_shortened = false, compressed = false;
|
||||
|
||||
// process other flags
|
||||
for (unsigned int i = 1; i < num; ++i) {
|
||||
if (!params[i])continue;
|
||||
if (!params[i]) {
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(params[i], "-b") || !strcmp(params[i], "--binary")) {
|
||||
binary = true;
|
||||
}
|
||||
else if (!strcmp( params[i], "-s") || !strcmp( params[i], "--short")) {
|
||||
} else if (!strcmp(params[i], "-s") || !strcmp(params[i], "--short")) {
|
||||
shortened = true;
|
||||
}
|
||||
else if (!strcmp( params[i], "-z") || !strcmp( params[i], "--compressed")) {
|
||||
} else if (!strcmp(params[i], "-z") || !strcmp(params[i], "--compressed")) {
|
||||
compressed = true;
|
||||
}
|
||||
#if 0
|
||||
|
@ -124,17 +122,17 @@ int Assimp_Dump (const char* const* params, unsigned int num)
|
|||
#endif
|
||||
}
|
||||
|
||||
if (out[0] == '-') {
|
||||
if (cur_out[0] == '-') {
|
||||
// take file name from input file
|
||||
std::string::size_type s = in.find_last_of('.');
|
||||
if (s == std::string::npos) {
|
||||
s = in.length();
|
||||
std::string::size_type pos = in.find_last_of('.');
|
||||
if (pos == std::string::npos) {
|
||||
pos = in.length();
|
||||
}
|
||||
|
||||
out = in.substr(0,s);
|
||||
out.append((binary ? ".assbin" : ".assxml"));
|
||||
if (shortened && binary) {
|
||||
out.append(".regress");
|
||||
cur_out = in.substr(0, pos);
|
||||
cur_out.append((binary ? ".assbin" : ".assxml"));
|
||||
if (cur_shortened && binary) {
|
||||
cur_out.append(".regress");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,24 +147,20 @@ int Assimp_Dump (const char* const* params, unsigned int num)
|
|||
// Dump the main model, using the appropriate method.
|
||||
std::unique_ptr<IOSystem> pIOSystem(new DefaultIOSystem());
|
||||
if (binary) {
|
||||
DumpSceneToAssbin(out.c_str(), cmd.c_str(), pIOSystem.get(),
|
||||
DumpSceneToAssbin(cur_out.c_str(), cmd.c_str(), pIOSystem.get(),
|
||||
scene, shortened, compressed);
|
||||
}
|
||||
else {
|
||||
DumpSceneToAssxml(out.c_str(), cmd.c_str(), pIOSystem.get(),
|
||||
} else {
|
||||
DumpSceneToAssxml(cur_out.c_str(), cmd.c_str(), pIOSystem.get(),
|
||||
scene, shortened);
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
} catch (const std::exception &e) {
|
||||
printf("%s", ("assimp dump: " + std::string(e.what())).c_str());
|
||||
return AssimpCmdError::ExceptionWasRaised;
|
||||
}
|
||||
catch (...) {
|
||||
printf("assimp dump: An unknown exception occured.\n");
|
||||
} catch (...) {
|
||||
printf("assimp dump: An unknown exception occurred.\n");
|
||||
return AssimpCmdError::ExceptionWasRaised;
|
||||
}
|
||||
|
||||
printf("assimp dump: Wrote output dump %s\n",out.c_str());
|
||||
printf("assimp dump: Wrote output dump %s\n", cur_out.c_str());
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue