Merge branch 'master' into patch-13
commit
65d6daa414
|
@ -186,7 +186,7 @@ IF( UNIX )
|
||||||
IF( ${OPERATING_SYSTEM} MATCHES "Android")
|
IF( ${OPERATING_SYSTEM} MATCHES "Android")
|
||||||
ELSE()
|
ELSE()
|
||||||
IF ( CMAKE_SIZEOF_VOID_P EQUAL 4) # only necessary for 32-bit linux
|
IF ( CMAKE_SIZEOF_VOID_P EQUAL 4) # only necessary for 32-bit linux
|
||||||
ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64 )
|
#ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64 )
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,12 @@ struct Error : DeadlyImportError {
|
||||||
* descendents. It serves as base class for all data structure fields. */
|
* descendents. It serves as base class for all data structure fields. */
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
struct ElemBase {
|
struct ElemBase {
|
||||||
|
ElemBase()
|
||||||
|
: dna_type(nullptr)
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~ElemBase() {
|
virtual ~ElemBase() {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,9 @@ template <> void Structure :: Convert<Object> (
|
||||||
{
|
{
|
||||||
|
|
||||||
ReadField<ErrorPolicy_Fail>(dest.id,"id",db);
|
ReadField<ErrorPolicy_Fail>(dest.id,"id",db);
|
||||||
ReadField<ErrorPolicy_Fail>((int&)dest.type,"type",db);
|
int temp = 0;
|
||||||
|
ReadField<ErrorPolicy_Fail>(temp,"type",db);
|
||||||
|
dest.type = static_cast<Assimp::Blender::Object::Type>(temp);
|
||||||
ReadFieldArray2<ErrorPolicy_Warn>(dest.obmat,"obmat",db);
|
ReadFieldArray2<ErrorPolicy_Warn>(dest.obmat,"obmat",db);
|
||||||
ReadFieldArray2<ErrorPolicy_Warn>(dest.parentinv,"parentinv",db);
|
ReadFieldArray2<ErrorPolicy_Warn>(dest.parentinv,"parentinv",db);
|
||||||
ReadFieldArray<ErrorPolicy_Warn>(dest.parsubstr,"parsubstr",db);
|
ReadFieldArray<ErrorPolicy_Warn>(dest.parsubstr,"parsubstr",db);
|
||||||
|
@ -100,14 +102,21 @@ template <> void Structure :: Convert<MTex> (
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
|
||||||
ReadField<ErrorPolicy_Igno>((short&)dest.mapto,"mapto",db);
|
int temp_short = 0;
|
||||||
ReadField<ErrorPolicy_Igno>((int&)dest.blendtype,"blendtype",db);
|
ReadField<ErrorPolicy_Igno>(temp_short,"mapto",db);
|
||||||
|
dest.mapto = static_cast<Assimp::Blender::MTex::MapType>(temp_short);
|
||||||
|
int temp = 0;
|
||||||
|
ReadField<ErrorPolicy_Igno>(temp,"blendtype",db);
|
||||||
|
dest.blendtype = static_cast<Assimp::Blender::MTex::BlendType>(temp);
|
||||||
ReadFieldPtr<ErrorPolicy_Igno>(dest.object,"*object",db);
|
ReadFieldPtr<ErrorPolicy_Igno>(dest.object,"*object",db);
|
||||||
ReadFieldPtr<ErrorPolicy_Igno>(dest.tex,"*tex",db);
|
ReadFieldPtr<ErrorPolicy_Igno>(dest.tex,"*tex",db);
|
||||||
ReadFieldArray<ErrorPolicy_Igno>(dest.uvname,"uvname",db);
|
ReadFieldArray<ErrorPolicy_Igno>(dest.uvname,"uvname",db);
|
||||||
ReadField<ErrorPolicy_Igno>((int&)dest.projx,"projx",db);
|
ReadField<ErrorPolicy_Igno>(temp,"projx",db);
|
||||||
ReadField<ErrorPolicy_Igno>((int&)dest.projy,"projy",db);
|
dest.projx = static_cast<Assimp::Blender::MTex::Projection>(temp);
|
||||||
ReadField<ErrorPolicy_Igno>((int&)dest.projz,"projz",db);
|
ReadField<ErrorPolicy_Igno>(temp,"projy",db);
|
||||||
|
dest.projy = static_cast<Assimp::Blender::MTex::Projection>(temp);
|
||||||
|
ReadField<ErrorPolicy_Igno>(temp,"projz",db);
|
||||||
|
dest.projx = static_cast<Assimp::Blender::MTex::Projection>(temp);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.mapping,"mapping",db);
|
ReadField<ErrorPolicy_Igno>(dest.mapping,"mapping",db);
|
||||||
ReadFieldArray<ErrorPolicy_Igno>(dest.ofs,"ofs",db);
|
ReadFieldArray<ErrorPolicy_Igno>(dest.ofs,"ofs",db);
|
||||||
ReadFieldArray<ErrorPolicy_Igno>(dest.size,"size",db);
|
ReadFieldArray<ErrorPolicy_Igno>(dest.size,"size",db);
|
||||||
|
@ -190,7 +199,9 @@ template <> void Structure :: Convert<Lamp> (
|
||||||
{
|
{
|
||||||
|
|
||||||
ReadField<ErrorPolicy_Fail>(dest.id,"id",db);
|
ReadField<ErrorPolicy_Fail>(dest.id,"id",db);
|
||||||
ReadField<ErrorPolicy_Fail>((int&)dest.type,"type",db);
|
int temp = 0;
|
||||||
|
ReadField<ErrorPolicy_Fail>(temp,"type",db);
|
||||||
|
dest.type = static_cast<Assimp::Blender::Lamp::Type>(temp);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.flags,"flags",db);
|
ReadField<ErrorPolicy_Igno>(dest.flags,"flags",db);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.colormodel,"colormodel",db);
|
ReadField<ErrorPolicy_Igno>(dest.colormodel,"colormodel",db);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.totex,"totex",db);
|
ReadField<ErrorPolicy_Igno>(dest.totex,"totex",db);
|
||||||
|
@ -204,7 +215,8 @@ template <> void Structure :: Convert<Lamp> (
|
||||||
ReadField<ErrorPolicy_Igno>(dest.spotblend,"spotblend",db);
|
ReadField<ErrorPolicy_Igno>(dest.spotblend,"spotblend",db);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.att1,"att1",db);
|
ReadField<ErrorPolicy_Igno>(dest.att1,"att1",db);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.att2,"att2",db);
|
ReadField<ErrorPolicy_Igno>(dest.att2,"att2",db);
|
||||||
ReadField<ErrorPolicy_Igno>((int&)dest.falloff_type,"falloff_type",db);
|
ReadField<ErrorPolicy_Igno>(temp,"falloff_type",db);
|
||||||
|
dest.falloff_type = static_cast<Assimp::Blender::Lamp::FalloffType>(temp);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.sun_brightness,"sun_brightness",db);
|
ReadField<ErrorPolicy_Igno>(dest.sun_brightness,"sun_brightness",db);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.area_size,"area_size",db);
|
ReadField<ErrorPolicy_Igno>(dest.area_size,"area_size",db);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.area_sizey,"area_sizey",db);
|
ReadField<ErrorPolicy_Igno>(dest.area_sizey,"area_sizey",db);
|
||||||
|
@ -693,8 +705,12 @@ template <> void Structure :: Convert<Tex> (
|
||||||
const FileDatabase& db
|
const FileDatabase& db
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
ReadField<ErrorPolicy_Igno>((short&)dest.imaflag,"imaflag",db);
|
short temp_short = 0;
|
||||||
ReadField<ErrorPolicy_Fail>((int&)dest.type,"type",db);
|
ReadField<ErrorPolicy_Igno>(temp_short,"imaflag",db);
|
||||||
|
dest.imaflag = static_cast<Assimp::Blender::Tex::ImageFlags>(temp_short);
|
||||||
|
int temp = 0;
|
||||||
|
ReadField<ErrorPolicy_Fail>(temp,"type",db);
|
||||||
|
dest.type = static_cast<Assimp::Blender::Tex::Type>(temp);
|
||||||
ReadFieldPtr<ErrorPolicy_Warn>(dest.ima,"*ima",db);
|
ReadFieldPtr<ErrorPolicy_Warn>(dest.ima,"*ima",db);
|
||||||
|
|
||||||
db.reader->IncPtr(size);
|
db.reader->IncPtr(size);
|
||||||
|
@ -708,8 +724,11 @@ template <> void Structure :: Convert<Camera> (
|
||||||
{
|
{
|
||||||
|
|
||||||
ReadField<ErrorPolicy_Fail>(dest.id,"id",db);
|
ReadField<ErrorPolicy_Fail>(dest.id,"id",db);
|
||||||
ReadField<ErrorPolicy_Warn>((int&)dest.type,"type",db);
|
int temp = 0;
|
||||||
ReadField<ErrorPolicy_Warn>((int&)dest.flag,"flag",db);
|
ReadField<ErrorPolicy_Warn>(temp,"type",db);
|
||||||
|
dest.type = static_cast<Assimp::Blender::Camera::Type>(temp);
|
||||||
|
ReadField<ErrorPolicy_Warn>(temp,"flag",db);
|
||||||
|
dest.flag = static_cast<Assimp::Blender::Camera::Type>(temp);
|
||||||
ReadField<ErrorPolicy_Warn>(dest.lens,"lens",db);
|
ReadField<ErrorPolicy_Warn>(dest.lens,"lens",db);
|
||||||
ReadField<ErrorPolicy_Warn>(dest.sensor_x,"sensor_x",db);
|
ReadField<ErrorPolicy_Warn>(dest.sensor_x,"sensor_x",db);
|
||||||
ReadField<ErrorPolicy_Igno>(dest.clipsta,"clipsta",db);
|
ReadField<ErrorPolicy_Igno>(dest.clipsta,"clipsta",db);
|
||||||
|
|
|
@ -225,6 +225,14 @@ struct TFace : ElemBase {
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------
|
||||||
struct MTFace : ElemBase {
|
struct MTFace : ElemBase {
|
||||||
|
MTFace()
|
||||||
|
: flag(0)
|
||||||
|
, mode(0)
|
||||||
|
, tile(0)
|
||||||
|
, unwrap(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
float uv[4][2] FAIL;
|
float uv[4][2] FAIL;
|
||||||
char flag;
|
char flag;
|
||||||
short mode;
|
short mode;
|
||||||
|
|
|
@ -45,13 +45,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||||
|
|
||||||
|
#include "FIReader.hpp"
|
||||||
|
#include "StringUtils.h"
|
||||||
|
|
||||||
// Workaround for issue #1361
|
// Workaround for issue #1361
|
||||||
// https://github.com/assimp/assimp/issues/1361
|
// https://github.com/assimp/assimp/issues/1361
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
#define _GLIBCXX_USE_C99 1
|
# define _GLIBCXX_USE_C99 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "FIReader.hpp"
|
|
||||||
#include "Exceptional.h"
|
#include "Exceptional.h"
|
||||||
#include <assimp/IOStream.hpp>
|
#include <assimp/IOStream.hpp>
|
||||||
#include <assimp/types.h>
|
#include <assimp/types.h>
|
||||||
|
@ -485,7 +487,9 @@ struct FIFloatDecoder: public FIDecoder {
|
||||||
value.reserve(numFloats);
|
value.reserve(numFloats);
|
||||||
for (size_t i = 0; i < numFloats; ++i) {
|
for (size_t i = 0; i < numFloats; ++i) {
|
||||||
int v = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
|
int v = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
|
||||||
value.push_back(*(float*)&v);
|
float f;
|
||||||
|
memcpy(&f, &v, 4);
|
||||||
|
value.push_back(f);
|
||||||
data += 4;
|
data += 4;
|
||||||
}
|
}
|
||||||
return FIFloatValue::create(std::move(value));
|
return FIFloatValue::create(std::move(value));
|
||||||
|
@ -503,7 +507,9 @@ struct FIDoubleDecoder: public FIDecoder {
|
||||||
for (size_t i = 0; i < numDoubles; ++i) {
|
for (size_t i = 0; i < numDoubles; ++i) {
|
||||||
long long b0 = data[0], b1 = data[1], b2 = data[2], b3 = data[3], b4 = data[4], b5 = data[5], b6 = data[6], b7 = data[7];
|
long long b0 = data[0], b1 = data[1], b2 = data[2], b3 = data[3], b4 = data[4], b5 = data[5], b6 = data[6], b7 = data[7];
|
||||||
long long v = (b0 << 56) | (b1 << 48) | (b2 << 40) | (b3 << 32) | (b4 << 24) | (b5 << 16) | (b6 << 8) | b7;
|
long long v = (b0 << 56) | (b1 << 48) | (b2 << 40) | (b3 << 32) | (b4 << 24) | (b5 << 16) | (b6 << 8) | b7;
|
||||||
value.push_back(*(double*)&v);
|
double f;
|
||||||
|
memcpy(&f, &v, 8);
|
||||||
|
value.push_back(f);
|
||||||
data += 8;
|
data += 8;
|
||||||
}
|
}
|
||||||
return FIDoubleValue::create(std::move(value));
|
return FIDoubleValue::create(std::move(value));
|
||||||
|
@ -685,7 +691,7 @@ public:
|
||||||
if (intValue) {
|
if (intValue) {
|
||||||
return intValue->value.size() == 1 ? intValue->value.front() : 0;
|
return intValue->value.size() == 1 ? intValue->value.front() : 0;
|
||||||
}
|
}
|
||||||
return stoi(attr->value->toString());
|
return atoi(attr->value->toString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int getAttributeValueAsInt(int idx) const /*override*/ {
|
virtual int getAttributeValueAsInt(int idx) const /*override*/ {
|
||||||
|
@ -696,7 +702,7 @@ public:
|
||||||
if (intValue) {
|
if (intValue) {
|
||||||
return intValue->value.size() == 1 ? intValue->value.front() : 0;
|
return intValue->value.size() == 1 ? intValue->value.front() : 0;
|
||||||
}
|
}
|
||||||
return stoi(attributes[idx].value->toString());
|
return atoi(attributes[idx].value->toString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual float getAttributeValueAsFloat(const char* name) const /*override*/ {
|
virtual float getAttributeValueAsFloat(const char* name) const /*override*/ {
|
||||||
|
@ -708,7 +714,7 @@ public:
|
||||||
if (floatValue) {
|
if (floatValue) {
|
||||||
return floatValue->value.size() == 1 ? floatValue->value.front() : 0;
|
return floatValue->value.size() == 1 ? floatValue->value.front() : 0;
|
||||||
}
|
}
|
||||||
return stof(attr->value->toString());
|
return atof(attr->value->toString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual float getAttributeValueAsFloat(int idx) const /*override*/ {
|
virtual float getAttributeValueAsFloat(int idx) const /*override*/ {
|
||||||
|
@ -719,7 +725,7 @@ public:
|
||||||
if (floatValue) {
|
if (floatValue) {
|
||||||
return floatValue->value.size() == 1 ? floatValue->value.front() : 0;
|
return floatValue->value.size() == 1 ? floatValue->value.front() : 0;
|
||||||
}
|
}
|
||||||
return stof(attributes[idx].value->toString());
|
return atof(attributes[idx].value->toString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const char* getNodeName() const /*override*/ {
|
virtual const char* getNodeName() const /*override*/ {
|
||||||
|
@ -984,13 +990,13 @@ private:
|
||||||
if (index < 32) {
|
if (index < 32) {
|
||||||
FIDecoder *decoder = defaultDecoder[index];
|
FIDecoder *decoder = defaultDecoder[index];
|
||||||
if (!decoder) {
|
if (!decoder) {
|
||||||
throw DeadlyImportError("Invalid encoding algorithm index " + std::to_string(index));
|
throw DeadlyImportError("Invalid encoding algorithm index " + to_string(index));
|
||||||
}
|
}
|
||||||
return decoder->decode(dataP, len);
|
return decoder->decode(dataP, len);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (index - 32 >= vocabulary.encodingAlgorithmTable.size()) {
|
if (index - 32 >= vocabulary.encodingAlgorithmTable.size()) {
|
||||||
throw DeadlyImportError("Invalid encoding algorithm index " + std::to_string(index));
|
throw DeadlyImportError("Invalid encoding algorithm index " + to_string(index));
|
||||||
}
|
}
|
||||||
std::string uri = vocabulary.encodingAlgorithmTable[index - 32];
|
std::string uri = vocabulary.encodingAlgorithmTable[index - 32];
|
||||||
auto it = decoderMap.find(uri);
|
auto it = decoderMap.find(uri);
|
||||||
|
@ -1014,12 +1020,12 @@ private:
|
||||||
alphabet = "0123456789-:TZ ";
|
alphabet = "0123456789-:TZ ";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw DeadlyImportError("Invalid restricted alphabet index " + std::to_string(index));
|
throw DeadlyImportError("Invalid restricted alphabet index " + to_string(index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (index - 16 >= vocabulary.restrictedAlphabetTable.size()) {
|
if (index - 16 >= vocabulary.restrictedAlphabetTable.size()) {
|
||||||
throw DeadlyImportError("Invalid restricted alphabet index " + std::to_string(index));
|
throw DeadlyImportError("Invalid restricted alphabet index " + to_string(index));
|
||||||
}
|
}
|
||||||
alphabet = vocabulary.restrictedAlphabetTable[index - 16];
|
alphabet = vocabulary.restrictedAlphabetTable[index - 16];
|
||||||
}
|
}
|
||||||
|
@ -1027,7 +1033,7 @@ private:
|
||||||
utf8::utf8to32(alphabet.begin(), alphabet.end(), back_inserter(alphabetUTF32));
|
utf8::utf8to32(alphabet.begin(), alphabet.end(), back_inserter(alphabetUTF32));
|
||||||
std::string::size_type alphabetLength = alphabetUTF32.size();
|
std::string::size_type alphabetLength = alphabetUTF32.size();
|
||||||
if (alphabetLength < 2) {
|
if (alphabetLength < 2) {
|
||||||
throw DeadlyImportError("Invalid restricted alphabet length " + std::to_string(alphabetLength));
|
throw DeadlyImportError("Invalid restricted alphabet length " + to_string(alphabetLength));
|
||||||
}
|
}
|
||||||
std::string::size_type bitsPerCharacter = 1;
|
std::string::size_type bitsPerCharacter = 1;
|
||||||
while ((1ull << bitsPerCharacter) <= alphabetLength) {
|
while ((1ull << bitsPerCharacter) <= alphabetLength) {
|
||||||
|
|
|
@ -46,12 +46,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef INCLUDED_AI_FI_READER_H
|
#ifndef INCLUDED_AI_FI_READER_H
|
||||||
#define INCLUDED_AI_FI_READER_H
|
#define INCLUDED_AI_FI_READER_H
|
||||||
|
|
||||||
|
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||||
|
|
||||||
|
//#include <wchar.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdint>
|
//#include <stdio.h>
|
||||||
|
//#include <cstdint>
|
||||||
#include <irrXML.h>
|
#include <irrXML.h>
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
@ -176,4 +180,6 @@ FIReader::~FIReader() {
|
||||||
|
|
||||||
}// namespace Assimp
|
}// namespace Assimp
|
||||||
|
|
||||||
|
#endif // #ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||||
|
|
||||||
#endif // INCLUDED_AI_FI_READER_H
|
#endif // INCLUDED_AI_FI_READER_H
|
||||||
|
|
|
@ -665,7 +665,9 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
|
||||||
if (0.0f != pcMatIn->Power)
|
if (0.0f != pcMatIn->Power)
|
||||||
{
|
{
|
||||||
iShadingMode = (int)aiShadingMode_Phong;
|
iShadingMode = (int)aiShadingMode_Phong;
|
||||||
pcMatOut->AddProperty<float>(&pcMatIn->Power,1,AI_MATKEY_SHININESS);
|
// pcMatIn is packed, we can't form pointers to its members
|
||||||
|
float power = pcMatIn->Power;
|
||||||
|
pcMatOut->AddProperty<float>(&power,1,AI_MATKEY_SHININESS);
|
||||||
}
|
}
|
||||||
pcMatOut->AddProperty<int>(&iShadingMode,1,AI_MATKEY_SHADING_MODEL);
|
pcMatOut->AddProperty<int>(&iShadingMode,1,AI_MATKEY_SHADING_MODEL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,28 +334,28 @@ void ValidateDSProcess::Validate( const aiMesh* pMesh)
|
||||||
case 1:
|
case 1:
|
||||||
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_POINT))
|
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_POINT))
|
||||||
{
|
{
|
||||||
ReportError("aiMesh::mFaces[%i] is a POINT but aiMesh::mPrimtiveTypes "
|
ReportError("aiMesh::mFaces[%i] is a POINT but aiMesh::mPrimitiveTypes "
|
||||||
"does not report the POINT flag",i);
|
"does not report the POINT flag",i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_LINE))
|
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_LINE))
|
||||||
{
|
{
|
||||||
ReportError("aiMesh::mFaces[%i] is a LINE but aiMesh::mPrimtiveTypes "
|
ReportError("aiMesh::mFaces[%i] is a LINE but aiMesh::mPrimitiveTypes "
|
||||||
"does not report the LINE flag",i);
|
"does not report the LINE flag",i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_TRIANGLE))
|
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_TRIANGLE))
|
||||||
{
|
{
|
||||||
ReportError("aiMesh::mFaces[%i] is a TRIANGLE but aiMesh::mPrimtiveTypes "
|
ReportError("aiMesh::mFaces[%i] is a TRIANGLE but aiMesh::mPrimitiveTypes "
|
||||||
"does not report the TRIANGLE flag",i);
|
"does not report the TRIANGLE flag",i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_POLYGON))
|
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_POLYGON))
|
||||||
{
|
{
|
||||||
this->ReportError("aiMesh::mFaces[%i] is a POLYGON but aiMesh::mPrimtiveTypes "
|
this->ReportError("aiMesh::mFaces[%i] is a POLYGON but aiMesh::mPrimitiveTypes "
|
||||||
"does not report the POLYGON flag",i);
|
"does not report the POLYGON flag",i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -231,7 +231,8 @@ namespace o3dgc
|
||||||
float ReadFloat32Bin(unsigned long & position) const
|
float ReadFloat32Bin(unsigned long & position) const
|
||||||
{
|
{
|
||||||
unsigned long value = ReadUInt32Bin(position);
|
unsigned long value = ReadUInt32Bin(position);
|
||||||
float fvalue = *((float *)(&value));
|
float fvalue;
|
||||||
|
memcpy(&fvalue, &value, 4);
|
||||||
return fvalue;
|
return fvalue;
|
||||||
}
|
}
|
||||||
unsigned long ReadUInt32Bin(unsigned long & position) const
|
unsigned long ReadUInt32Bin(unsigned long & position) const
|
||||||
|
@ -261,7 +262,8 @@ namespace o3dgc
|
||||||
|
|
||||||
void WriteFloat32ASCII(float value)
|
void WriteFloat32ASCII(float value)
|
||||||
{
|
{
|
||||||
unsigned long uiValue = *((unsigned long *)(&value));
|
unsigned long uiValue;
|
||||||
|
memcpy(&uiValue, &value, 4);
|
||||||
WriteUInt32ASCII(uiValue);
|
WriteUInt32ASCII(uiValue);
|
||||||
}
|
}
|
||||||
void WriteUInt32ASCII(unsigned long position, unsigned long value)
|
void WriteUInt32ASCII(unsigned long position, unsigned long value)
|
||||||
|
@ -314,7 +316,8 @@ namespace o3dgc
|
||||||
float ReadFloat32ASCII(unsigned long & position) const
|
float ReadFloat32ASCII(unsigned long & position) const
|
||||||
{
|
{
|
||||||
unsigned long value = ReadUInt32ASCII(position);
|
unsigned long value = ReadUInt32ASCII(position);
|
||||||
float fvalue = *((float *)(&value));
|
float fvalue;
|
||||||
|
memcpy(&fvalue, &value, 4);
|
||||||
return fvalue;
|
return fvalue;
|
||||||
}
|
}
|
||||||
unsigned long ReadUInt32ASCII(unsigned long & position) const
|
unsigned long ReadUInt32ASCII(unsigned long & position) const
|
||||||
|
|
|
@ -294,12 +294,12 @@ TEST_F(utObjImportExport, relative_indices_Test) {
|
||||||
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure);
|
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
|
|
||||||
EXPECT_EQ(scene->mNumMeshes, 1);
|
EXPECT_EQ(scene->mNumMeshes, 1U);
|
||||||
const aiMesh *mesh = scene->mMeshes[0];
|
const aiMesh *mesh = scene->mMeshes[0];
|
||||||
EXPECT_EQ(mesh->mNumVertices, 4);
|
EXPECT_EQ(mesh->mNumVertices, 4U);
|
||||||
EXPECT_EQ(mesh->mNumFaces, 1);
|
EXPECT_EQ(mesh->mNumFaces, 1U);
|
||||||
const aiFace face = mesh->mFaces[0];
|
const aiFace face = mesh->mFaces[0];
|
||||||
EXPECT_EQ(face.mNumIndices, 4);
|
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);
|
EXPECT_EQ(face.mIndices[i], i);
|
||||||
|
@ -318,12 +318,12 @@ TEST_F(utObjImportExport, homogeneous_coordinates_Test) {
|
||||||
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure);
|
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure);
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
|
|
||||||
EXPECT_EQ(scene->mNumMeshes, 1);
|
EXPECT_EQ(scene->mNumMeshes, 1U);
|
||||||
const aiMesh *mesh = scene->mMeshes[0];
|
const aiMesh *mesh = scene->mMeshes[0];
|
||||||
EXPECT_EQ(mesh->mNumVertices, 3);
|
EXPECT_EQ(mesh->mNumVertices, 3U);
|
||||||
EXPECT_EQ(mesh->mNumFaces, 1);
|
EXPECT_EQ(mesh->mNumFaces, 1U);
|
||||||
const aiFace face = mesh->mFaces[0];
|
const aiFace face = mesh->mFaces[0];
|
||||||
EXPECT_EQ(face.mNumIndices, 3);
|
EXPECT_EQ(face.mNumIndices, 3U);
|
||||||
const aiVector3D vertice = mesh->mVertices[0];
|
const aiVector3D vertice = mesh->mVertices[0];
|
||||||
EXPECT_EQ(vertice.x, -1.0f);
|
EXPECT_EQ(vertice.x, -1.0f);
|
||||||
EXPECT_EQ(vertice.y, 0.0f);
|
EXPECT_EQ(vertice.y, 0.0f);
|
||||||
|
|
|
@ -177,6 +177,17 @@ inline uint32_t Write<aiVector3D>(const aiVector3D& v)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------
|
||||||
|
// Serialize a color value
|
||||||
|
template <>
|
||||||
|
inline uint32_t Write<aiColor3D>(const aiColor3D& v)
|
||||||
|
{
|
||||||
|
uint32_t t = Write<float>(v.r);
|
||||||
|
t += Write<float>(v.g);
|
||||||
|
t += Write<float>(v.b);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
// Serialize a color value
|
// Serialize a color value
|
||||||
template <>
|
template <>
|
||||||
|
@ -566,9 +577,9 @@ uint32_t WriteBinaryLight(const aiLight* l)
|
||||||
len += Write<float>(l->mAttenuationQuadratic);
|
len += Write<float>(l->mAttenuationQuadratic);
|
||||||
}
|
}
|
||||||
|
|
||||||
len += Write<aiVector3D>((const aiVector3D&)l->mColorDiffuse);
|
len += Write<aiColor3D>(l->mColorDiffuse);
|
||||||
len += Write<aiVector3D>((const aiVector3D&)l->mColorSpecular);
|
len += Write<aiColor3D>(l->mColorSpecular);
|
||||||
len += Write<aiVector3D>((const aiVector3D&)l->mColorAmbient);
|
len += Write<aiColor3D>(l->mColorAmbient);
|
||||||
|
|
||||||
if (l->mType == aiLightSource_SPOT) {
|
if (l->mType == aiLightSource_SPOT) {
|
||||||
len += Write<float>(l->mAngleInnerCone);
|
len += Write<float>(l->mAngleInnerCone);
|
||||||
|
|
Loading…
Reference in New Issue