Merge branch 'master' into master
commit
147c5f7cd2
|
@ -484,6 +484,12 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
|
|||
needMat[idx].second += ((unsigned int)(*it).entries.size() - 1) << 1u;
|
||||
break;
|
||||
|
||||
// triangle strip
|
||||
case 0x4:
|
||||
needMat[idx].first += (unsigned int)(*it).entries.size() - 2;
|
||||
needMat[idx].second += ((unsigned int)(*it).entries.size() - 2) * 3;
|
||||
break;
|
||||
|
||||
// 0 == polygon, else unknown
|
||||
default:
|
||||
if ((*it).flags & 0xf) {
|
||||
|
@ -570,6 +576,64 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (type == 0x4) {
|
||||
for (unsigned int i = 0; i < (unsigned int)src.entries.size() - 2; ++i) {
|
||||
const Surface::SurfaceEntry &entry1 = src.entries[i];
|
||||
const Surface::SurfaceEntry &entry2 = src.entries[i + 1];
|
||||
const Surface::SurfaceEntry &entry3 = src.entries[i + 2];
|
||||
|
||||
// skip degenerate triangles
|
||||
if (object.vertices[entry1.first] == object.vertices[entry2.first] ||
|
||||
object.vertices[entry1.first] == object.vertices[entry3.first] ||
|
||||
object.vertices[entry2.first] == object.vertices[entry3.first]) {
|
||||
mesh->mNumFaces--;
|
||||
mesh->mNumVertices -= 3;
|
||||
continue;
|
||||
}
|
||||
|
||||
aiFace &face = *faces++;
|
||||
face.mNumIndices = 3;
|
||||
face.mIndices = new unsigned int[face.mNumIndices];
|
||||
face.mIndices[0] = cur++;
|
||||
face.mIndices[1] = cur++;
|
||||
face.mIndices[2] = cur++;
|
||||
if (!(i & 1)) {
|
||||
*vertices++ = object.vertices[entry1.first] + object.translation;
|
||||
if (uv) {
|
||||
uv->x = entry1.second.x;
|
||||
uv->y = entry1.second.y;
|
||||
++uv;
|
||||
}
|
||||
*vertices++ = object.vertices[entry2.first] + object.translation;
|
||||
if (uv) {
|
||||
uv->x = entry2.second.x;
|
||||
uv->y = entry2.second.y;
|
||||
++uv;
|
||||
}
|
||||
} else {
|
||||
*vertices++ = object.vertices[entry2.first] + object.translation;
|
||||
if (uv) {
|
||||
uv->x = entry2.second.x;
|
||||
uv->y = entry2.second.y;
|
||||
++uv;
|
||||
}
|
||||
*vertices++ = object.vertices[entry1.first] + object.translation;
|
||||
if (uv) {
|
||||
uv->x = entry1.second.x;
|
||||
uv->y = entry1.second.y;
|
||||
++uv;
|
||||
}
|
||||
}
|
||||
if (static_cast<unsigned>(vertices - mesh->mVertices) >= mesh->mNumVertices) {
|
||||
throw DeadlyImportError("AC3D: Invalid number of vertices");
|
||||
}
|
||||
*vertices++ = object.vertices[entry3.first] + object.translation;
|
||||
if (uv) {
|
||||
uv->x = entry3.second.x;
|
||||
uv->y = entry3.second.y;
|
||||
++uv;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
it2 = (*it).entries.begin();
|
||||
|
|
|
@ -1988,6 +1988,7 @@ void FBXConverter::SetTextureProperties(aiMaterial *out_mat, const TextureMap &_
|
|||
TrySetTextureProperties(out_mat, _textures, "ShininessExponent", aiTextureType_SHININESS, mesh);
|
||||
TrySetTextureProperties(out_mat, _textures, "TransparencyFactor", aiTextureType_OPACITY, mesh);
|
||||
TrySetTextureProperties(out_mat, _textures, "EmissiveFactor", aiTextureType_EMISSIVE, mesh);
|
||||
TrySetTextureProperties(out_mat, _textures, "ReflectionFactor", aiTextureType_METALNESS, mesh);
|
||||
//Maya counterparts
|
||||
TrySetTextureProperties(out_mat, _textures, "Maya|DiffuseTexture", aiTextureType_DIFFUSE, mesh);
|
||||
TrySetTextureProperties(out_mat, _textures, "Maya|NormalTexture", aiTextureType_NORMALS, mesh);
|
||||
|
|
|
@ -400,6 +400,65 @@ void FBXExporter::WriteHeaderExtension ()
|
|||
);
|
||||
}
|
||||
|
||||
// WriteGlobalSettings helpers
|
||||
|
||||
void WritePropInt(const aiScene* scene, FBX::Node& p, const std::string& key, int defaultValue)
|
||||
{
|
||||
int value;
|
||||
if (scene->mMetaData->Get(key, value)) {
|
||||
p.AddP70int(key, value);
|
||||
} else {
|
||||
p.AddP70int(key, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
void WritePropDouble(const aiScene* scene, FBX::Node& p, const std::string& key, double defaultValue)
|
||||
{
|
||||
double value;
|
||||
if (scene->mMetaData->Get(key, value)) {
|
||||
p.AddP70double(key, value);
|
||||
} else {
|
||||
// fallback lookup float instead
|
||||
float floatValue;
|
||||
if (scene->mMetaData->Get(key, floatValue)) {
|
||||
p.AddP70double(key, (double)floatValue);
|
||||
} else {
|
||||
p.AddP70double(key, defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WritePropEnum(const aiScene* scene, FBX::Node& p, const std::string& key, int defaultValue)
|
||||
{
|
||||
int value;
|
||||
if (scene->mMetaData->Get(key, value)) {
|
||||
p.AddP70enum(key, value);
|
||||
} else {
|
||||
p.AddP70enum(key, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
void WritePropColor(const aiScene* scene, FBX::Node& p, const std::string& key, const aiVector3D& defaultValue)
|
||||
{
|
||||
aiVector3D value;
|
||||
if (scene->mMetaData->Get(key, value)) {
|
||||
// ai_real can be float or double, cast to avoid warnings
|
||||
p.AddP70color(key, (double)value.x, (double)value.y, (double)value.z);
|
||||
} else {
|
||||
p.AddP70color(key, (double)defaultValue.x, (double)defaultValue.y, (double)defaultValue.z);
|
||||
}
|
||||
}
|
||||
|
||||
void WritePropString(const aiScene* scene, FBX::Node& p, const std::string& key, const std::string& defaultValue)
|
||||
{
|
||||
aiString value; // MetaData doesn't hold std::string
|
||||
if (scene->mMetaData->Get(key, value)) {
|
||||
p.AddP70string(key, value.C_Str());
|
||||
} else {
|
||||
p.AddP70string(key, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
void FBXExporter::WriteGlobalSettings ()
|
||||
{
|
||||
if (!binary) {
|
||||
|
@ -409,26 +468,26 @@ void FBXExporter::WriteGlobalSettings ()
|
|||
gs.AddChild("Version", int32_t(1000));
|
||||
|
||||
FBX::Node p("Properties70");
|
||||
p.AddP70int("UpAxis", 1);
|
||||
p.AddP70int("UpAxisSign", 1);
|
||||
p.AddP70int("FrontAxis", 2);
|
||||
p.AddP70int("FrontAxisSign", 1);
|
||||
p.AddP70int("CoordAxis", 0);
|
||||
p.AddP70int("CoordAxisSign", 1);
|
||||
p.AddP70int("OriginalUpAxis", 1);
|
||||
p.AddP70int("OriginalUpAxisSign", 1);
|
||||
p.AddP70double("UnitScaleFactor", 1.0);
|
||||
p.AddP70double("OriginalUnitScaleFactor", 1.0);
|
||||
p.AddP70color("AmbientColor", 0.0, 0.0, 0.0);
|
||||
p.AddP70string("DefaultCamera", "Producer Perspective");
|
||||
p.AddP70enum("TimeMode", 11);
|
||||
p.AddP70enum("TimeProtocol", 2);
|
||||
p.AddP70enum("SnapOnFrameMode", 0);
|
||||
WritePropInt(mScene, p, "UpAxis", 1);
|
||||
WritePropInt(mScene, p, "UpAxisSign", 1);
|
||||
WritePropInt(mScene, p, "FrontAxis", 2);
|
||||
WritePropInt(mScene, p, "FrontAxisSign", 1);
|
||||
WritePropInt(mScene, p, "CoordAxis", 0);
|
||||
WritePropInt(mScene, p, "CoordAxisSign", 1);
|
||||
WritePropInt(mScene, p, "OriginalUpAxis", 1);
|
||||
WritePropInt(mScene, p, "OriginalUpAxisSign", 1);
|
||||
WritePropDouble(mScene, p, "UnitScaleFactor", 1.0);
|
||||
WritePropDouble(mScene, p, "OriginalUnitScaleFactor", 1.0);
|
||||
WritePropColor(mScene, p, "AmbientColor", aiVector3D((ai_real)0.0, (ai_real)0.0, (ai_real)0.0));
|
||||
WritePropString(mScene, p,"DefaultCamera", "Producer Perspective");
|
||||
WritePropEnum(mScene, p, "TimeMode", 11);
|
||||
WritePropEnum(mScene, p, "TimeProtocol", 2);
|
||||
WritePropEnum(mScene, p, "SnapOnFrameMode", 0);
|
||||
p.AddP70time("TimeSpanStart", 0); // TODO: animation support
|
||||
p.AddP70time("TimeSpanStop", FBX::SECOND); // TODO: animation support
|
||||
p.AddP70double("CustomFrameRate", -1.0);
|
||||
WritePropDouble(mScene, p, "CustomFrameRate", -1.0);
|
||||
p.AddP70("TimeMarker", "Compound", "", ""); // not sure what this is
|
||||
p.AddP70int("CurrentTimeMarker", -1);
|
||||
WritePropInt(mScene, p, "CurrentTimeMarker", -1);
|
||||
gs.AddChild(p);
|
||||
|
||||
gs.Dump(outfile, binary, 0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
@ -49,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef GLTFASSET_H_INC
|
||||
#define GLTFASSET_H_INC
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF1_IMPORTER)
|
||||
|
||||
#include <assimp/Exceptional.h>
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef GLTFASSETWRITER_H_INC
|
||||
#define GLTFASSETWRITER_H_INC
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF1_IMPORTER)
|
||||
|
||||
#include "glTFAsset.h"
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef AI_GLTFEXPORTER_H_INC
|
||||
#define AI_GLTFEXPORTER_H_INC
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_EXPORTER
|
||||
#if !defined(ASSIMP_BUILD_NO_GLTF_EXPORTER) && !defined(ASSIMP_BUILD_NO_GLTF1_EXPORTER)
|
||||
|
||||
#include <assimp/types.h>
|
||||
#include <assimp/material.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
@ -39,7 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF1_IMPORTER)
|
||||
|
||||
#include "AssetLib/glTF/glTFImporter.h"
|
||||
#include "AssetLib/glTF/glTFAsset.h"
|
||||
|
|
|
@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef GLTF2ASSET_H_INC
|
||||
#define GLTF2ASSET_H_INC
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_IMPORTER)
|
||||
|
||||
#include <assimp/Exceptional.h>
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef GLTF2ASSETWRITER_H_INC
|
||||
#define GLTF2ASSETWRITER_H_INC
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_IMPORTER)
|
||||
|
||||
#include "glTF2Asset.h"
|
||||
|
||||
|
|
|
@ -739,10 +739,13 @@ namespace glTF2 {
|
|||
// Binary chunk
|
||||
//
|
||||
|
||||
int GLB_Chunk_count = 1;
|
||||
uint32_t binaryChunkLength = 0;
|
||||
if (bodyBuffer->byteLength > 0) {
|
||||
binaryChunkLength = (bodyBuffer->byteLength + 3) & ~3; // Round up to next multiple of 4
|
||||
//auto curPaddingLength = binaryChunkLength - bodyBuffer->byteLength;
|
||||
|
||||
auto curPaddingLength = binaryChunkLength - bodyBuffer->byteLength;
|
||||
++GLB_Chunk_count;
|
||||
|
||||
GLB_Chunk binaryChunk;
|
||||
binaryChunk.chunkLength = binaryChunkLength;
|
||||
|
@ -757,7 +760,7 @@ namespace glTF2 {
|
|||
if (outfile->Write(bodyBuffer->GetPointer(), 1, bodyBuffer->byteLength) != bodyBuffer->byteLength) {
|
||||
throw DeadlyExportError("Failed to write body data!");
|
||||
}
|
||||
if (paddingLength && outfile->Write(&padding, 1, paddingLength) != paddingLength) {
|
||||
if (curPaddingLength && outfile->Write(&padding, 1, paddingLength) != paddingLength) {
|
||||
throw DeadlyExportError("Failed to write body data padding!");
|
||||
}
|
||||
}
|
||||
|
@ -772,7 +775,7 @@ namespace glTF2 {
|
|||
header.version = 2;
|
||||
AI_SWAP4(header.version);
|
||||
|
||||
header.length = uint32_t(sizeof(GLB_Header) + 2 * sizeof(GLB_Chunk) + jsonChunkLength + binaryChunkLength);
|
||||
header.length = uint32_t(sizeof(GLB_Header) + GLB_Chunk_count * sizeof(GLB_Chunk) + jsonChunkLength + binaryChunkLength);
|
||||
AI_SWAP4(header.length);
|
||||
|
||||
outfile->Seek(0, aiOrigin_SET);
|
||||
|
|
|
@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef AI_GLTF2EXPORTER_H_INC
|
||||
#define AI_GLTF2EXPORTER_H_INC
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_IMPORTER)
|
||||
|
||||
#include <assimp/types.h>
|
||||
#include <assimp/material.h>
|
||||
|
|
|
@ -39,7 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_IMPORTER)
|
||||
|
||||
#include "AssetLib/glTF2/glTF2Importer.h"
|
||||
#include "PostProcessing/MakeVerboseFormat.h"
|
||||
|
|
|
@ -179,11 +179,14 @@ static void setupExporterArray(std::vector<Exporter::ExportFormatEntry> &exporte
|
|||
aiProcess_Triangulate | aiProcess_SortByPType | aiProcess_JoinIdenticalVertices));
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_EXPORTER
|
||||
#if !defined(ASSIMP_BUILD_NO_GLTF_EXPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_EXPORTER)
|
||||
exporters.push_back(Exporter::ExportFormatEntry("gltf2", "GL Transmission Format v. 2", "gltf", &ExportSceneGLTF2,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType));
|
||||
exporters.push_back(Exporter::ExportFormatEntry("glb2", "GL Transmission Format v. 2 (binary)", "glb", &ExportSceneGLB2,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType));
|
||||
#endif
|
||||
|
||||
#if !defined(ASSIMP_BUILD_NO_GLTF_EXPORTER) && !defined(ASSIMP_BUILD_NO_GLTF1_EXPORTER)
|
||||
exporters.push_back(Exporter::ExportFormatEntry("gltf", "GL Transmission Format", "gltf", &ExportSceneGLTF,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType));
|
||||
exporters.push_back(Exporter::ExportFormatEntry("glb", "GL Transmission Format (binary)", "glb", &ExportSceneGLB,
|
||||
|
|
|
@ -1174,7 +1174,7 @@ void Importer::GetMemoryRequirements(aiMemoryInfo& in) const {
|
|||
|
||||
// add all bone anims
|
||||
for (unsigned int a = 0; a < pc->mNumChannels; ++a) {
|
||||
const aiNodeAnim* pc2 = pc->mChannels[i];
|
||||
const aiNodeAnim* pc2 = pc->mChannels[a];
|
||||
in.animations += sizeof(aiNodeAnim);
|
||||
in.animations += pc2->mNumPositionKeys * sizeof(aiVectorKey);
|
||||
in.animations += pc2->mNumScalingKeys * sizeof(aiVectorKey);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
@ -179,8 +179,10 @@ corresponding preprocessor flag to selectively disable formats.
|
|||
#ifndef ASSIMP_BUILD_NO_ASSBIN_IMPORTER
|
||||
#include "AssetLib/Assbin/AssbinLoader.h"
|
||||
#endif
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF1_IMPORTER)
|
||||
#include "AssetLib/glTF/glTFImporter.h"
|
||||
#endif
|
||||
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_IMPORTER)
|
||||
#include "AssetLib/glTF2/glTF2Importer.h"
|
||||
#endif
|
||||
#ifndef ASSIMP_BUILD_NO_C4D_IMPORTER
|
||||
|
@ -339,8 +341,10 @@ void GetImporterInstanceList(std::vector<BaseImporter *> &out) {
|
|||
#if (!defined ASSIMP_BUILD_NO_ASSBIN_IMPORTER)
|
||||
out.push_back(new AssbinImporter());
|
||||
#endif
|
||||
#if (!defined ASSIMP_BUILD_NO_GLTF_IMPORTER)
|
||||
#if (!defined ASSIMP_BUILD_NO_GLTF_IMPORTER && !defined ASSIMP_BUILD_NO_GLTF1_IMPORTER)
|
||||
out.push_back(new glTFImporter());
|
||||
#endif
|
||||
#if (!defined ASSIMP_BUILD_NO_GLTF_IMPORTER && !defined ASSIMP_BUILD_NO_GLTF2_IMPORTER)
|
||||
out.push_back(new glTF2Importer());
|
||||
#endif
|
||||
#if (!defined ASSIMP_BUILD_NO_C4D_IMPORTER)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -101,6 +101,12 @@ TEST(utACImportExport, importWuson) {
|
|||
ASSERT_NE(nullptr, scene);
|
||||
}
|
||||
|
||||
TEST(utACImportExport, importWusonACC) {
|
||||
Assimp::Importer importer;
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/Wuson.acc", aiProcess_ValidateDataStructure);
|
||||
ASSERT_NE(nullptr, scene);
|
||||
}
|
||||
|
||||
TEST(utACImportExport, testFormatDetection) {
|
||||
Assimp::Importer importer;
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/TestFormatDetection", aiProcess_ValidateDataStructure);
|
||||
|
|
Loading…
Reference in New Issue