Merge branch 'master' into iamAdrianIusca-master
commit
0be78e0ca3
|
@ -44,16 +44,46 @@ jobs:
|
|||
with:
|
||||
CXX: ${{ matrix.cxx }}
|
||||
CC: ${{ matrix.cc }}
|
||||
|
||||
- name: Cache DX SDK
|
||||
id: dxcache
|
||||
if: matrix.name == 'windows-msvc'
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: '${{ github.workspace }}/DX_SDK'
|
||||
key: ${{ runner.os }}-DX_SDK
|
||||
restore-keys: |
|
||||
${{ runner.os }}-DX_SDK
|
||||
|
||||
- name: Download DXSetup
|
||||
if: matrix.name == 'windows-msvc' && steps.dxcache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
curl -s -o DXSDK_Jun10.exe --location https://download.microsoft.com/download/A/E/7/AE743F1F-632B-4809-87A9-AA1BB3458E31/DXSDK_Jun10.exe
|
||||
cmd.exe /c start /wait .\DXSDK_Jun10.exe /U /O /F /S /P "${{ github.workspace }}\DX_SDK"
|
||||
|
||||
- name: Set Windows specific CMake arguments
|
||||
if: matrix.name == 'windows-msvc'
|
||||
id: windows_extra_cmake_args
|
||||
run: echo "::set-output name=args::'-DASSIMP_BUILD_ASSIMP_TOOLS=1 -DASSIMP_BUILD_ASSIMP_VIEW=1'"
|
||||
|
||||
- name: configure and build
|
||||
uses: lukka/run-cmake@v2
|
||||
env:
|
||||
DXSDK_DIR: '${{ github.workspace }}/DX_SDK'
|
||||
|
||||
with:
|
||||
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
|
||||
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
|
||||
cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release'
|
||||
cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release ${{ steps.windows_extra_cmake_args.outputs.args }}'
|
||||
buildWithCMakeArgs: '-- -v'
|
||||
buildDirectory: '${{ github.workspace }}/build/'
|
||||
|
||||
- name: test
|
||||
run: cd build/bin && ./unit
|
||||
shell: bash
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: matrix.name == 'windows-msvc'
|
||||
with:
|
||||
name: 'assimp-bins-${{ matrix.name }}-${{ github.sha }}'
|
||||
path: build/bin
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#----------------------------------------------------------------------
|
||||
SET(CMAKE_POLICY_DEFAULT_CMP0074 NEW)
|
||||
SET(CMAKE_POLICY_DEFAULT_CMP0092 NEW)
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED( VERSION 3.0 )
|
||||
|
||||
|
@ -44,8 +45,8 @@ option(ASSIMP_HUNTER_ENABLED "Enable Hunter package manager support" OFF)
|
|||
IF(ASSIMP_HUNTER_ENABLED)
|
||||
include("cmake/HunterGate.cmake")
|
||||
HunterGate(
|
||||
URL "https://github.com/ruslo/hunter/archive/v0.23.176.tar.gz"
|
||||
SHA1 "2e9ae973d028660b735ac4c6142725ca36a0048a"
|
||||
URL "https://github.com/cpp-pm/hunter/archive/v0.23.261.tar.gz"
|
||||
SHA1 "1540dad7b97c849784a09e8c452ba811c9f71ba2"
|
||||
)
|
||||
|
||||
add_definitions(-DASSIMP_USE_HUNTER)
|
||||
|
@ -257,7 +258,11 @@ IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW)
|
|||
SET(LIBSTDC++_LIBRARIES -lstdc++)
|
||||
ELSEIF(MSVC)
|
||||
# enable multi-core compilation with MSVC
|
||||
ADD_COMPILE_OPTIONS(/MP /bigobj /W4 /WX )
|
||||
IF( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) # clang-cl
|
||||
ADD_COMPILE_OPTIONS(/bigobj /W4 /WX )
|
||||
ELSE() # msvc
|
||||
ADD_COMPILE_OPTIONS(/MP /bigobj /W4 /WX)
|
||||
ENDIF()
|
||||
# disable "elements of array '' will be default initialized" warning on MSVC2013
|
||||
IF(MSVC12)
|
||||
ADD_COMPILE_OPTIONS(/wd4351)
|
||||
|
@ -357,6 +362,34 @@ IF (NOT TARGET uninstall)
|
|||
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
||||
ENDIF()
|
||||
|
||||
# cmake configuration files
|
||||
if(${BUILD_SHARED_LIBS})
|
||||
set(BUILD_LIB_TYPE SHARED)
|
||||
else()
|
||||
set(BUILD_LIB_TYPE STATIC)
|
||||
endif()
|
||||
|
||||
IF( UNIX )
|
||||
# Use GNUInstallDirs for Unix predefined directories
|
||||
INCLUDE(GNUInstallDirs)
|
||||
|
||||
SET( ASSIMP_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
|
||||
SET( ASSIMP_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
SET( ASSIMP_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR})
|
||||
ELSE()
|
||||
# Cache these to allow the user to override them on non-Unix platforms
|
||||
SET( ASSIMP_LIB_INSTALL_DIR "lib" CACHE STRING
|
||||
"Path the built library files are installed to." )
|
||||
SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE STRING
|
||||
"Path the header files are installed to." )
|
||||
SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE STRING
|
||||
"Path the tool executables are installed to." )
|
||||
|
||||
SET(CMAKE_INSTALL_FULL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_INCLUDE_INSTALL_DIR})
|
||||
SET(CMAKE_INSTALL_FULL_LIBDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_LIB_INSTALL_DIR})
|
||||
SET(CMAKE_INSTALL_FULL_BINDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_BIN_INSTALL_DIR})
|
||||
ENDIF()
|
||||
|
||||
IF(ASSIMP_HUNTER_ENABLED)
|
||||
set(CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}")
|
||||
set(INCLUDE_INSTALL_DIR "include")
|
||||
|
@ -395,34 +428,6 @@ IF(ASSIMP_HUNTER_ENABLED)
|
|||
DESTINATION "${CONFIG_INSTALL_DIR}"
|
||||
)
|
||||
ELSE()
|
||||
# cmake configuration files
|
||||
if(${BUILD_SHARED_LIBS})
|
||||
set(BUILD_LIB_TYPE SHARED)
|
||||
else()
|
||||
set(BUILD_LIB_TYPE STATIC)
|
||||
endif()
|
||||
|
||||
IF( UNIX )
|
||||
# Use GNUInstallDirs for Unix predefined directories
|
||||
INCLUDE(GNUInstallDirs)
|
||||
|
||||
SET( ASSIMP_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
|
||||
SET( ASSIMP_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
SET( ASSIMP_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR})
|
||||
ELSE()
|
||||
# Cache these to allow the user to override them on non-Unix platforms
|
||||
SET( ASSIMP_LIB_INSTALL_DIR "lib" CACHE STRING
|
||||
"Path the built library files are installed to." )
|
||||
SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE STRING
|
||||
"Path the header files are installed to." )
|
||||
SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE STRING
|
||||
"Path the tool executables are installed to." )
|
||||
|
||||
SET(CMAKE_INSTALL_FULL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_INCLUDE_INSTALL_DIR})
|
||||
SET(CMAKE_INSTALL_FULL_LIBDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_LIB_INSTALL_DIR})
|
||||
SET(CMAKE_INSTALL_FULL_BINDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_BIN_INSTALL_DIR})
|
||||
ENDIF()
|
||||
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" @ONLY IMMEDIATE)
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets.cmake" @ONLY IMMEDIATE)
|
||||
IF (is_multi_config)
|
||||
|
|
|
@ -4,8 +4,6 @@ A library to import and export various 3d-model-formats including scene-post-pro
|
|||
### Current project status ###
|
||||
[![Financial Contributors on Open Collective](https://opencollective.com/assimp/all/badge.svg?label=financial+contributors)](https://opencollective.com/assimp)
|
||||
![C/C++ CI](https://github.com/assimp/assimp/workflows/C/C++%20CI/badge.svg)
|
||||
[![Linux Build Status](https://travis-ci.org/assimp/assimp.svg)](https://travis-ci.org/assimp/assimp)
|
||||
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/tmo433wax6u6cjp4?svg=true)](https://ci.appveyor.com/project/kimkulling/assimp)
|
||||
<a href="https://scan.coverity.com/projects/5607">
|
||||
<img alt="Coverity Scan Build Status"
|
||||
src="https://scan.coverity.com/projects/5607/badge.svg"/>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
find_package(RapidJSON CONFIG REQUIRED)
|
||||
find_package(ZLIB CONFIG REQUIRED)
|
||||
find_package(utf8 CONFIG REQUIRED)
|
||||
find_package(utf8cpp CONFIG REQUIRED)
|
||||
find_package(irrXML CONFIG REQUIRED)
|
||||
find_package(minizip CONFIG REQUIRED)
|
||||
find_package(openddlparser CONFIG REQUIRED)
|
||||
|
|
|
@ -321,9 +321,10 @@ public:
|
|||
struct Face : public FaceWithSmoothingGroup {
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4315)
|
||||
#endif
|
||||
#endif // _MSC_VER
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Helper structure representing a texture */
|
||||
|
@ -412,6 +413,10 @@ struct Texture {
|
|||
|
||||
#include <assimp/Compiler/poppack1.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif // _MSC_VER
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Helper structure representing a 3ds material */
|
||||
struct Material {
|
||||
|
|
|
@ -471,26 +471,33 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
|
|||
++node->mNumMeshes;
|
||||
}
|
||||
|
||||
switch ((*it).flags & 0xf) {
|
||||
switch ((*it).GetType()) {
|
||||
// closed line
|
||||
case 0x1:
|
||||
case Surface::ClosedLine:
|
||||
needMat[idx].first += (unsigned int)(*it).entries.size();
|
||||
needMat[idx].second += (unsigned int)(*it).entries.size() << 1u;
|
||||
break;
|
||||
|
||||
// unclosed line
|
||||
case 0x2:
|
||||
case Surface::OpenLine:
|
||||
needMat[idx].first += (unsigned int)(*it).entries.size() - 1;
|
||||
needMat[idx].second += ((unsigned int)(*it).entries.size() - 1) << 1u;
|
||||
break;
|
||||
|
||||
// 0 == polygon, else unknown
|
||||
default:
|
||||
if ((*it).flags & 0xf) {
|
||||
ASSIMP_LOG_WARN("AC3D: The type flag of a surface is unknown");
|
||||
(*it).flags &= ~(0xf);
|
||||
}
|
||||
// triangle strip
|
||||
case Surface::TriangleStrip:
|
||||
needMat[idx].first += (unsigned int)(*it).entries.size() - 2;
|
||||
needMat[idx].second += ((unsigned int)(*it).entries.size() - 2) * 3;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Coerce unknowns to a polygon and warn
|
||||
ASSIMP_LOG_WARN_F("AC3D: The type flag of a surface is unknown: ", (*it).flags);
|
||||
(*it).flags &= ~(Surface::Mask);
|
||||
// fallthrough
|
||||
|
||||
// polygon
|
||||
case Surface::Polygon:
|
||||
// the number of faces increments by one, the number
|
||||
// of vertices by surface.numref.
|
||||
needMat[idx].first++;
|
||||
|
@ -546,8 +553,8 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
|
|||
const Surface &src = *it;
|
||||
|
||||
// closed polygon
|
||||
unsigned int type = (*it).flags & 0xf;
|
||||
if (!type) {
|
||||
uint8_t type = (*it).GetType();
|
||||
if (type == Surface::Polygon) {
|
||||
aiFace &face = *faces++;
|
||||
face.mNumIndices = (unsigned int)src.entries.size();
|
||||
if (0 != face.mNumIndices) {
|
||||
|
@ -570,13 +577,71 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (type == Surface::TriangleStrip) {
|
||||
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();
|
||||
|
||||
// either a closed or an unclosed line
|
||||
unsigned int tmp = (unsigned int)(*it).entries.size();
|
||||
if (0x2 == type) --tmp;
|
||||
if (Surface::OpenLine == type) --tmp;
|
||||
for (unsigned int m = 0; m < tmp; ++m) {
|
||||
aiFace &face = *faces++;
|
||||
|
||||
|
@ -599,7 +664,7 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
|
|||
++uv;
|
||||
}
|
||||
|
||||
if (0x1 == type && tmp - 1 == m) {
|
||||
if (Surface::ClosedLine == type && tmp - 1 == m) {
|
||||
// if this is a closed line repeat its beginning now
|
||||
it2 = (*it).entries.begin();
|
||||
} else
|
||||
|
|
|
@ -69,7 +69,10 @@ public:
|
|||
// Represents an AC3D material
|
||||
struct Material {
|
||||
Material() :
|
||||
rgb(0.6f, 0.6f, 0.6f), spec(1.f, 1.f, 1.f), shin(0.f), trans(0.f) {}
|
||||
rgb(0.6f, 0.6f, 0.6f),
|
||||
spec(1.f, 1.f, 1.f),
|
||||
shin(0.f),
|
||||
trans(0.f) {}
|
||||
|
||||
// base color of the material
|
||||
aiColor3D rgb;
|
||||
|
@ -96,18 +99,43 @@ public:
|
|||
// Represents an AC3D surface
|
||||
struct Surface {
|
||||
Surface() :
|
||||
mat(0), flags(0) {}
|
||||
mat(0),
|
||||
flags(0) {}
|
||||
|
||||
unsigned int mat, flags;
|
||||
|
||||
typedef std::pair<unsigned int, aiVector2D> SurfaceEntry;
|
||||
std::vector<SurfaceEntry> entries;
|
||||
|
||||
// Type is low nibble of flags
|
||||
enum Type : uint8_t {
|
||||
Polygon = 0x0,
|
||||
ClosedLine = 0x1,
|
||||
OpenLine = 0x2,
|
||||
TriangleStrip = 0x4, // ACC extension (TORCS and Speed Dreams)
|
||||
|
||||
Mask = 0xf,
|
||||
};
|
||||
|
||||
inline constexpr uint8_t GetType() const { return (flags & Mask); }
|
||||
};
|
||||
|
||||
// Represents an AC3D object
|
||||
struct Object {
|
||||
Object() :
|
||||
type(World), name(""), children(), texture(""), texRepeat(1.f, 1.f), texOffset(0.0f, 0.0f), rotation(), translation(), vertices(), surfaces(), numRefs(0), subDiv(0), crease() {}
|
||||
type(World),
|
||||
name(""),
|
||||
children(),
|
||||
texture(""),
|
||||
texRepeat(1.f, 1.f),
|
||||
texOffset(0.0f, 0.0f),
|
||||
rotation(),
|
||||
translation(),
|
||||
vertices(),
|
||||
surfaces(),
|
||||
numRefs(0),
|
||||
subDiv(0),
|
||||
crease() {}
|
||||
|
||||
// Type description
|
||||
enum Type {
|
||||
|
|
|
@ -60,10 +60,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <time.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4706)
|
||||
#endif // _WIN32
|
||||
#endif // _MSC_VER
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
|
@ -825,8 +825,8 @@ void DumpSceneToAssbin(
|
|||
AssbinFileWriter fileWriter(shortened, compressed);
|
||||
fileWriter.WriteBinaryDump(pFile, cmd, pIOSystem, pScene);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
#if _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif // _WIN32
|
||||
#endif // _MSC_VER
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
|
|
@ -8,9 +8,9 @@ For details, see http://sourceforge.net/projects/libb64
|
|||
#ifndef BASE64_CENCODE_H
|
||||
#define BASE64_CENCODE_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4127 )
|
||||
#endif // _WIN32
|
||||
#endif // _MSC_VER
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
|
|
@ -386,7 +386,14 @@ void BlenderTessellatorP2T::ReferencePoints( std::vector< Blender::PointP2T >& p
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
inline PointP2T& BlenderTessellatorP2T::GetActualPointStructure( p2t::Point& point ) const
|
||||
{
|
||||
#if defined __clang__
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Winvalid-offsetof"
|
||||
#endif // __clang__
|
||||
unsigned int pointOffset = offsetof( PointP2T, point2D );
|
||||
#if defined __clang__
|
||||
# pragma clang diagnostic pop
|
||||
#endif
|
||||
PointP2T& pointStruct = *reinterpret_cast< PointP2T* >( reinterpret_cast< char* >( &point ) - pointOffset );
|
||||
if ( pointStruct.magic != static_cast<int>( BLEND_TESS_MAGIC ) )
|
||||
{
|
||||
|
@ -394,7 +401,6 @@ inline PointP2T& BlenderTessellatorP2T::GetActualPointStructure( p2t::Point& poi
|
|||
}
|
||||
return pointStruct;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void BlenderTessellatorP2T::MakeFacesFromTriangles( std::vector< p2t::Triangle* >& triangles ) const
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -45,9 +45,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "AssetLib/Step/STEPFile.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning( disable : 4512 )
|
||||
#endif // _WIN32
|
||||
#endif // _MSC_VER
|
||||
|
||||
namespace Assimp {
|
||||
namespace IFC {
|
||||
|
@ -4372,4 +4373,8 @@ namespace STEP {
|
|||
} //! STEP
|
||||
} //! Assimp
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif // _MSC_VER
|
||||
|
||||
#endif // INCLUDED_IFC_READER_GEN_H
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -68,9 +68,9 @@ namespace Assimp {
|
|||
namespace MDL {
|
||||
namespace HalfLife {
|
||||
|
||||
#ifdef _WIN32
|
||||
# pragma warning(disable : 4706)
|
||||
#endif // _WIN32
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(disable : 4706)
|
||||
#endif // _MSC_VER
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
HL1MDLLoader::HL1MDLLoader(
|
||||
|
|
|
@ -43,7 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "MMDPmxParser.h"
|
||||
#include <assimp/StringUtils.h>
|
||||
#ifdef ASSIMP_USE_HUNTER
|
||||
# include <utf8/utf8.h>
|
||||
# include <utf8.h>
|
||||
#else
|
||||
# include "../contrib/utf8cpp/source/utf8.h"
|
||||
#endif
|
||||
|
|
|
@ -59,7 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/StreamReader.h>
|
||||
#include <assimp/TinyFormatter.h>
|
||||
#ifdef ASSIMP_USE_HUNTER
|
||||
#include <utf8/utf8.h>
|
||||
#include <utf8.h>
|
||||
#else
|
||||
//# include "../contrib/ConvertUTF/ConvertUTF.h"
|
||||
#include "../contrib/utf8cpp/source/utf8.h"
|
||||
|
|
|
@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "STEPFileEncoding.h"
|
||||
#include <assimp/fast_atof.h>
|
||||
#ifdef ASSIMP_USE_HUNTER
|
||||
# include <utf8/utf8.h>
|
||||
# include <utf8.h>
|
||||
#else
|
||||
# include <contrib/utf8cpp/source/utf8.h>
|
||||
#endif
|
||||
|
|
|
@ -54,10 +54,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4127 4456 4245 4512 )
|
||||
#endif // _WIN32
|
||||
#endif // _MSC_VER
|
||||
|
||||
//
|
||||
#if _MSC_VER > 1500 || (defined __GNUC___)
|
||||
|
@ -130,8 +130,8 @@ namespace STEP {
|
|||
* coupled with a line number. */
|
||||
// -------------------------------------------------------------------------------
|
||||
struct SyntaxError : DeadlyImportError {
|
||||
enum {
|
||||
LINE_NOT_SPECIFIED = 0xffffffffffffffffLL
|
||||
enum : uint64_t {
|
||||
LINE_NOT_SPECIFIED = 0xfffffffffffffffLL
|
||||
};
|
||||
|
||||
SyntaxError(const std::string &s, uint64_t line = LINE_NOT_SPECIFIED);
|
||||
|
@ -143,8 +143,8 @@ struct SyntaxError : DeadlyImportError {
|
|||
* It is typically coupled with both an entity id and a line number.*/
|
||||
// -------------------------------------------------------------------------------
|
||||
struct TypeError : DeadlyImportError {
|
||||
enum {
|
||||
ENTITY_NOT_SPECIFIED = 0xffffffffffffffffLL,
|
||||
enum : uint64_t {
|
||||
ENTITY_NOT_SPECIFIED = 0xffffffffffffffffUL,
|
||||
ENTITY_NOT_SPECIFIED_32 = 0x00000000ffffffff
|
||||
};
|
||||
|
||||
|
@ -727,7 +727,7 @@ struct InternGenericConvert<Maybe<T>> {
|
|||
}
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _MSC_VER > 1920
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4127)
|
||||
#endif // _WIN32
|
||||
|
@ -960,9 +960,9 @@ private:
|
|||
const EXPRESS::ConversionSchema *schema;
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif // _WIN32
|
||||
#endif // _MSC_VER
|
||||
|
||||
} // namespace STEP
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/MemoryIOWrapper.h>
|
||||
#include <assimp/irrXMLWrapper.h>
|
||||
#ifdef ASSIMP_USE_HUNTER
|
||||
# include <utf8/utf8.h>
|
||||
# include <utf8.h>
|
||||
#else
|
||||
# include "../contrib/utf8cpp/source/utf8.h"
|
||||
#endif
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -57,10 +57,10 @@ namespace glTF {
|
|||
|
||||
namespace {
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4706)
|
||||
#endif // _WIN32
|
||||
#endif // _MSC_VER
|
||||
|
||||
//
|
||||
// JSON Value reading helpers
|
||||
|
@ -372,7 +372,7 @@ inline void Buffer::EncodedRegion_Mark(const size_t pOffset, const size_t pEncod
|
|||
|
||||
char val[val_size];
|
||||
|
||||
ai_snprintf(val, val_size, "%llu", (long long)pOffset);
|
||||
ai_snprintf(val, val_size, AI_SIZEFMT, pOffset);
|
||||
throw DeadlyImportError(std::string("GLTF: incorrect offset value (") + val + ") for marking encoded region.");
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ inline void Buffer::EncodedRegion_Mark(const size_t pOffset, const size_t pEncod
|
|||
|
||||
char val[val_size];
|
||||
|
||||
ai_snprintf(val, val_size, "%llu, %llu", (long long)pOffset, (long long)pEncodedData_Length);
|
||||
ai_snprintf(val, val_size, AI_SIZEFMT "/" AI_SIZEFMT, pOffset, pEncodedData_Length);
|
||||
throw DeadlyImportError(std::string("GLTF: encoded region with offset/length (") + val + ") is out of range.");
|
||||
}
|
||||
|
||||
|
@ -836,8 +836,8 @@ inline void Mesh::Read(Value &pJSON_Object, Asset &pAsset_Root) {
|
|||
|
||||
if (json_extensions == nullptr) goto mr_skip_extensions;
|
||||
|
||||
for (Value::MemberIterator it_memb = json_extensions->MemberBegin(); it_memb != json_extensions->MemberEnd(); it_memb++) {
|
||||
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
|
||||
for (Value::MemberIterator it_memb = json_extensions->MemberBegin(); it_memb != json_extensions->MemberEnd(); it_memb++) {
|
||||
if (it_memb->name.GetString() == std::string("Open3DGC-compression")) {
|
||||
// Search for compressed data.
|
||||
// Compressed data contain description of part of "buffer" which is encoded. This part must be decoded and
|
||||
|
@ -887,11 +887,11 @@ inline void Mesh::Read(Value &pJSON_Object, Asset &pAsset_Root) {
|
|||
Extension.push_back(ext_o3dgc); // store info in mesh extensions list.
|
||||
} // if(it_memb->name.GetString() == "Open3DGC-compression")
|
||||
else
|
||||
#endif
|
||||
{
|
||||
throw DeadlyImportError(std::string("GLTF: Unknown mesh extension: \"") + it_memb->name.GetString() + "\".");
|
||||
}
|
||||
} // for(Value::MemberIterator it_memb = json_extensions->MemberBegin(); it_memb != json_extensions->MemberEnd(); json_extensions++)
|
||||
#endif
|
||||
|
||||
mr_skip_extensions:
|
||||
|
||||
|
@ -1412,8 +1412,8 @@ inline std::string Asset::FindUniqueID(const std::string &str, const char *suffi
|
|||
return id;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif // WIN32
|
||||
#endif // _MSC_VER
|
||||
|
||||
} // namespace glTF
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -43,10 +43,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <rapidjson/writer.h>
|
||||
#include <rapidjson/prettywriter.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning( disable : 4706)
|
||||
#endif // _WIN32
|
||||
#endif // _MSC_VER
|
||||
|
||||
namespace glTF {
|
||||
|
||||
|
@ -305,11 +305,11 @@ namespace glTF {
|
|||
Value json_extensions;
|
||||
|
||||
json_extensions.SetObject();
|
||||
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
|
||||
for(Mesh::SExtension* ptr_ext : m.Extension)
|
||||
{
|
||||
switch(ptr_ext->Type)
|
||||
{
|
||||
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
|
||||
case Mesh::SExtension::EType::Compression_Open3DGC:
|
||||
{
|
||||
Value json_comp_data;
|
||||
|
@ -339,11 +339,11 @@ namespace glTF {
|
|||
}
|
||||
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
throw DeadlyImportError("GLTF: Can not write mesh: unknown mesh extension, only Open3DGC is supported.");
|
||||
}// switch(ptr_ext->Type)
|
||||
}// for(Mesh::SExtension* ptr_ext : m.Extension)
|
||||
#endif
|
||||
|
||||
// Add extensions to mesh
|
||||
obj.AddMember("extensions", json_extensions, w.mAl);
|
||||
|
@ -707,7 +707,7 @@ namespace glTF {
|
|||
w.WriteObjects(d);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif // _WIN32
|
||||
|
||||
|
|
|
@ -190,10 +190,10 @@ inline void CopyValue(const glTFCommon::mat4 &v, aiMatrix4x4 &o) {
|
|||
o.d4 = v[15];
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4310)
|
||||
#endif // _WIN32
|
||||
#endif // _MSC_VER
|
||||
|
||||
inline std::string getCurrentAssetDir(const std::string &pFile) {
|
||||
std::string path = pFile;
|
||||
|
@ -204,9 +204,9 @@ inline std::string getCurrentAssetDir(const std::string &pFile) {
|
|||
|
||||
return path;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
#if _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif // _WIN32
|
||||
#endif // _MSC_VER
|
||||
|
||||
namespace Util {
|
||||
|
||||
|
|
|
@ -525,6 +525,12 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref<Mesh>& meshRef, Ref<Buf
|
|||
delete[] vertexJointData;
|
||||
}
|
||||
|
||||
#if defined(__has_warning)
|
||||
#if __has_warning("-Wunused-but-set-variable")
|
||||
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void glTFExporter::ExportMeshes()
|
||||
{
|
||||
// Not for
|
||||
|
@ -677,7 +683,7 @@ void glTFExporter::ExportMeshes()
|
|||
{
|
||||
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
|
||||
// Only one type of compression supported at now - Open3DGC.
|
||||
//
|
||||
//
|
||||
o3dgc::BinaryStream bs;
|
||||
o3dgc::SC3DMCEncoder<IndicesType> encoder;
|
||||
o3dgc::IndexedFaceSet<IndicesType> comp_o3dgc_ifs;
|
||||
|
@ -793,6 +799,12 @@ void glTFExporter::ExportMeshes()
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(__has_warning)
|
||||
#if __has_warning("-Wunused-but-set-variable")
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Export the root node of the node hierarchy.
|
||||
* Calls ExportNode for all children.
|
||||
|
|
|
@ -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"
|
||||
|
@ -215,8 +215,8 @@ void glTFImporter::ImportMeshes(glTF::Asset &r) {
|
|||
|
||||
// Check if mesh extensions is used
|
||||
if (mesh.Extension.size() > 0) {
|
||||
for (Mesh::SExtension *cur_ext : mesh.Extension) {
|
||||
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
|
||||
for (Mesh::SExtension *cur_ext : mesh.Extension) {
|
||||
if (cur_ext->Type == Mesh::SExtension::EType::Compression_Open3DGC) {
|
||||
// Limitations for meshes when using Open3DGC-compression.
|
||||
// It's a current limitation of sp... Specification have not this part still - about mesh compression. Why only one primitive?
|
||||
|
@ -233,12 +233,12 @@ void glTFImporter::ImportMeshes(glTF::Asset &r) {
|
|||
|
||||
buf->EncodedRegion_SetCurrent(mesh.id);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
throw DeadlyImportError("GLTF: Can not import mesh: unknown mesh extension (code: \"" + to_string(cur_ext->Type) +
|
||||
"\"), only Open3DGC is supported.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} // if(mesh.Extension.size() > 0)
|
||||
|
||||
meshOffsets.push_back(k);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -406,6 +406,8 @@ struct Accessor : public Object {
|
|||
void ExtractData(T *&outData);
|
||||
|
||||
void WriteData(size_t count, const void *src_buffer, size_t src_stride);
|
||||
void WriteSparseValues(size_t count, const void *src_data, size_t src_dataStride);
|
||||
void WriteSparseIndices(size_t count, const void *src_idx, size_t src_idxStride);
|
||||
|
||||
//! Helper class to iterate the data
|
||||
class Indexer {
|
||||
|
@ -1066,6 +1068,7 @@ public:
|
|||
} extensionsRequired;
|
||||
|
||||
AssetMetadata asset;
|
||||
Value* extras = nullptr;
|
||||
|
||||
// Dictionaries for each type of object
|
||||
|
||||
|
|
|
@ -436,7 +436,7 @@ inline void Buffer::EncodedRegion_Mark(const size_t pOffset, const size_t pEncod
|
|||
|
||||
char val[val_size];
|
||||
|
||||
ai_snprintf(val, val_size, "%llu", (long long)pOffset);
|
||||
ai_snprintf(val, val_size, AI_SIZEFMT, pOffset);
|
||||
throw DeadlyImportError(std::string("GLTF: incorrect offset value (") + val + ") for marking encoded region.");
|
||||
}
|
||||
|
||||
|
@ -446,7 +446,7 @@ inline void Buffer::EncodedRegion_Mark(const size_t pOffset, const size_t pEncod
|
|||
|
||||
char val[val_size];
|
||||
|
||||
ai_snprintf(val, val_size, "%llu, %llu", (long long)pOffset, (long long)pEncodedData_Length);
|
||||
ai_snprintf(val, val_size, AI_SIZEFMT "/" AI_SIZEFMT, pOffset, pEncodedData_Length);
|
||||
throw DeadlyImportError(std::string("GLTF: encoded region with offset/length (") + val + ") is out of range.");
|
||||
}
|
||||
|
||||
|
@ -757,6 +757,33 @@ inline void Accessor::WriteData(size_t _count, const void *src_buffer, size_t sr
|
|||
CopyData(_count, src, src_stride, dst, dst_stride);
|
||||
}
|
||||
|
||||
inline void Accessor::WriteSparseValues(size_t _count, const void *src_data, size_t src_dataStride) {
|
||||
if (!sparse)
|
||||
return;
|
||||
|
||||
// values
|
||||
uint8_t *value_buffer_ptr = sparse->values->buffer->GetPointer();
|
||||
size_t value_offset = sparse->valuesByteOffset + sparse->values->byteOffset;
|
||||
size_t value_dst_stride = GetNumComponents() * GetBytesPerComponent();
|
||||
const uint8_t *value_src = reinterpret_cast<const uint8_t *>(src_data);
|
||||
uint8_t *value_dst = reinterpret_cast<uint8_t *>(value_buffer_ptr + value_offset);
|
||||
ai_assert(value_dst + _count * value_dst_stride <= value_buffer_ptr + sparse->values->buffer->byteLength);
|
||||
CopyData(_count, value_src, src_dataStride, value_dst, value_dst_stride);
|
||||
}
|
||||
|
||||
inline void Accessor::WriteSparseIndices(size_t _count, const void *src_idx, size_t src_idxStride) {
|
||||
if (!sparse)
|
||||
return;
|
||||
|
||||
// indices
|
||||
uint8_t *indices_buffer_ptr = sparse->indices->buffer->GetPointer();
|
||||
size_t indices_offset = sparse->indicesByteOffset + sparse->indices->byteOffset;
|
||||
size_t indices_dst_stride = 1 * sizeof(unsigned short);
|
||||
const uint8_t *indices_src = reinterpret_cast<const uint8_t *>(src_idx);
|
||||
uint8_t *indices_dst = reinterpret_cast<uint8_t *>(indices_buffer_ptr + indices_offset);
|
||||
ai_assert(indices_dst + _count * indices_dst_stride <= indices_buffer_ptr + sparse->indices->buffer->byteLength);
|
||||
CopyData(_count, indices_src, src_idxStride, indices_dst, indices_dst_stride);
|
||||
}
|
||||
inline Accessor::Indexer::Indexer(Accessor &acc) :
|
||||
accessor(acc),
|
||||
data(acc.GetPointer()),
|
||||
|
@ -1015,10 +1042,10 @@ inline int Compare(const char *attr, const char (&str)[N]) {
|
|||
return (strncmp(attr, str, N - 1) == 0) ? N - 1 : 0;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4706)
|
||||
#endif // _WIN32
|
||||
#endif // _MSC_VER
|
||||
|
||||
inline bool GetAttribVector(Mesh::Primitive &p, const char *attr, Mesh::AccessorList *&v, int &pos) {
|
||||
if ((pos = Compare(attr, "POSITION"))) {
|
||||
|
@ -1287,6 +1314,8 @@ inline void Node::Read(Value &obj, Asset &r) {
|
|||
}
|
||||
}
|
||||
|
||||
// Do not retrieve a skin here, just take a reference, to avoid infinite recursion
|
||||
// Skins will be properly loaded later
|
||||
Value *curSkin = FindUInt(obj, "skin");
|
||||
if (nullptr != curSkin) {
|
||||
this->skin = r.skins.Get(curSkin->GetUint());
|
||||
|
@ -1584,7 +1613,6 @@ inline void Asset::Load(const std::string &pFile, bool isBinary) {
|
|||
}
|
||||
}
|
||||
|
||||
// Read skins after nodes have been loaded to avoid infinite recursion
|
||||
if (Value *skinsArray = FindArray(doc, "skins")) {
|
||||
for (unsigned int i = 0; i < skinsArray->Size(); ++i) {
|
||||
skins.Retrieve(i);
|
||||
|
@ -1695,8 +1723,8 @@ inline std::string Asset::FindUniqueID(const std::string &str, const char *suffi
|
|||
return id;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
#endif // _WIN32
|
||||
#if _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif // _MSC_VER
|
||||
|
||||
} // namespace glTF2
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
@ -107,21 +107,47 @@ namespace glTF2 {
|
|||
|
||||
inline void Write(Value& obj, Accessor& a, AssetWriter& w)
|
||||
{
|
||||
obj.AddMember("bufferView", a.bufferView->index, w.mAl);
|
||||
obj.AddMember("byteOffset", (unsigned int)a.byteOffset, w.mAl);
|
||||
if (a.bufferView) {
|
||||
obj.AddMember("bufferView", a.bufferView->index, w.mAl);
|
||||
obj.AddMember("byteOffset", (unsigned int)a.byteOffset, w.mAl);
|
||||
Value vTmpMax, vTmpMin;
|
||||
if (a.componentType == ComponentType_FLOAT) {
|
||||
obj.AddMember("max", MakeValue(vTmpMax, a.max, w.mAl), w.mAl);
|
||||
obj.AddMember("min", MakeValue(vTmpMin, a.min, w.mAl), w.mAl);
|
||||
} else {
|
||||
obj.AddMember("max", MakeValueCast<int64_t>(vTmpMax, a.max, w.mAl), w.mAl);
|
||||
obj.AddMember("min", MakeValueCast<int64_t>(vTmpMin, a.min, w.mAl), w.mAl);
|
||||
}
|
||||
}
|
||||
|
||||
obj.AddMember("componentType", int(a.componentType), w.mAl);
|
||||
obj.AddMember("count", (unsigned int)a.count, w.mAl);
|
||||
obj.AddMember("type", StringRef(AttribType::ToString(a.type)), w.mAl);
|
||||
|
||||
Value vTmpMax, vTmpMin;
|
||||
if (a.componentType == ComponentType_FLOAT) {
|
||||
obj.AddMember("max", MakeValue(vTmpMax, a.max, w.mAl), w.mAl);
|
||||
obj.AddMember("min", MakeValue(vTmpMin, a.min, w.mAl), w.mAl);
|
||||
} else {
|
||||
obj.AddMember("max", MakeValueCast<int64_t>(vTmpMax, a.max, w.mAl), w.mAl);
|
||||
obj.AddMember("min", MakeValueCast<int64_t>(vTmpMin, a.min, w.mAl), w.mAl);
|
||||
}
|
||||
if (a.sparse) {
|
||||
Value sparseValue;
|
||||
sparseValue.SetObject();
|
||||
|
||||
//count
|
||||
sparseValue.AddMember("count", (unsigned int)a.sparse->count, w.mAl);
|
||||
|
||||
//indices
|
||||
Value indices;
|
||||
indices.SetObject();
|
||||
indices.AddMember("bufferView", a.sparse->indices->index, w.mAl);
|
||||
indices.AddMember("byteOffset", (unsigned int)a.sparse->indicesByteOffset, w.mAl);
|
||||
indices.AddMember("componentType", int(a.sparse->indicesType), w.mAl);
|
||||
sparseValue.AddMember("indices", indices, w.mAl);
|
||||
|
||||
//values
|
||||
Value values;
|
||||
values.SetObject();
|
||||
values.AddMember("bufferView", a.sparse->values->index, w.mAl);
|
||||
values.AddMember("byteOffset", (unsigned int)a.sparse->valuesByteOffset, w.mAl);
|
||||
sparseValue.AddMember("values", values, w.mAl);
|
||||
|
||||
obj.AddMember("sparse", sparseValue, w.mAl);
|
||||
}
|
||||
}
|
||||
|
||||
inline void Write(Value& obj, Animation& a, AssetWriter& w)
|
||||
|
@ -616,6 +642,10 @@ namespace glTF2 {
|
|||
if (mAsset.scene) {
|
||||
mDoc.AddMember("scene", mAsset.scene->index, mAl);
|
||||
}
|
||||
|
||||
if(mAsset.extras) {
|
||||
mDoc.AddMember("extras", *mAsset.extras, mAl);
|
||||
}
|
||||
}
|
||||
|
||||
inline void AssetWriter::WriteFile(const char* path)
|
||||
|
@ -709,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;
|
||||
|
@ -727,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!");
|
||||
}
|
||||
}
|
||||
|
@ -742,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);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
@ -115,7 +115,14 @@ glTF2Exporter::glTF2Exporter(const char* filename, IOSystem* pIOSystem, const ai
|
|||
ExportScene();
|
||||
|
||||
ExportAnimations();
|
||||
|
||||
|
||||
// export extras
|
||||
if(mProperties->HasPropertyCallback("extras"))
|
||||
{
|
||||
std::function<void*(void*)> ExportExtras = mProperties->GetPropertyCallback("extras");
|
||||
mAsset->extras = (rapidjson::Value*)ExportExtras(0);
|
||||
}
|
||||
|
||||
AssetWriter writer(*mAsset);
|
||||
|
||||
if (isBinary) {
|
||||
|
@ -214,6 +221,158 @@ inline void SetAccessorRange(ComponentType compType, Ref<Accessor> acc, void* da
|
|||
}
|
||||
}
|
||||
|
||||
// compute the (data-dataBase), store the non-zero data items
|
||||
template <typename T>
|
||||
size_t NZDiff(void *data, void *dataBase, size_t count, unsigned int numCompsIn, unsigned int numCompsOut, void *&outputNZDiff, void *&outputNZIdx) {
|
||||
std::vector<T> vNZDiff;
|
||||
std::vector<unsigned short> vNZIdx;
|
||||
size_t totalComps = count * numCompsIn;
|
||||
T *bufferData_ptr = static_cast<T *>(data);
|
||||
T *bufferData_end = bufferData_ptr + totalComps;
|
||||
T *bufferBase_ptr = static_cast<T *>(dataBase);
|
||||
|
||||
// Search and set extreme values.
|
||||
for (short idx = 0; bufferData_ptr < bufferData_end; idx += 1, bufferData_ptr += numCompsIn) {
|
||||
bool bNonZero = false;
|
||||
|
||||
//for the data, check any component Non Zero
|
||||
for (unsigned int j = 0; j < numCompsOut; j++) {
|
||||
double valueData = bufferData_ptr[j];
|
||||
double valueBase = bufferBase_ptr ? bufferBase_ptr[j] : 0;
|
||||
if ((valueData - valueBase) != 0) {
|
||||
bNonZero = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//all zeros, continue
|
||||
if (!bNonZero)
|
||||
continue;
|
||||
|
||||
//non zero, store the data
|
||||
for (unsigned int j = 0; j < numCompsOut; j++) {
|
||||
T valueData = bufferData_ptr[j];
|
||||
T valueBase = bufferBase_ptr ? bufferBase_ptr[j] : 0;
|
||||
vNZDiff.push_back(valueData - valueBase);
|
||||
}
|
||||
vNZIdx.push_back(idx);
|
||||
}
|
||||
|
||||
//avoid all-0, put 1 item
|
||||
if (vNZDiff.size() == 0) {
|
||||
for (unsigned int j = 0; j < numCompsOut; j++)
|
||||
vNZDiff.push_back(0);
|
||||
vNZIdx.push_back(0);
|
||||
}
|
||||
|
||||
//process data
|
||||
outputNZDiff = new T[vNZDiff.size()];
|
||||
memcpy(outputNZDiff, vNZDiff.data(), vNZDiff.size() * sizeof(T));
|
||||
|
||||
outputNZIdx = new unsigned short[vNZIdx.size()];
|
||||
memcpy(outputNZIdx, vNZIdx.data(), vNZIdx.size() * sizeof(unsigned short));
|
||||
return vNZIdx.size();
|
||||
}
|
||||
|
||||
inline size_t NZDiff(ComponentType compType, void *data, void *dataBase, size_t count, unsigned int numCompsIn, unsigned int numCompsOut, void *&nzDiff, void *&nzIdx) {
|
||||
switch (compType) {
|
||||
case ComponentType_SHORT:
|
||||
return NZDiff<short>(data, dataBase, count, numCompsIn, numCompsOut, nzDiff, nzIdx);
|
||||
case ComponentType_UNSIGNED_SHORT:
|
||||
return NZDiff<unsigned short>(data, dataBase, count, numCompsIn, numCompsOut, nzDiff, nzIdx);
|
||||
case ComponentType_UNSIGNED_INT:
|
||||
return NZDiff<unsigned int>(data, dataBase, count, numCompsIn, numCompsOut, nzDiff, nzIdx);
|
||||
case ComponentType_FLOAT:
|
||||
return NZDiff<float>(data, dataBase, count, numCompsIn, numCompsOut, nzDiff, nzIdx);
|
||||
case ComponentType_BYTE:
|
||||
return NZDiff<int8_t>(data, dataBase, count, numCompsIn, numCompsOut, nzDiff, nzIdx);
|
||||
case ComponentType_UNSIGNED_BYTE:
|
||||
return NZDiff<uint8_t>(data, dataBase, count, numCompsIn, numCompsOut, nzDiff, nzIdx);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline Ref<Accessor> ExportDataSparse(Asset &a, std::string &meshName, Ref<Buffer> &buffer,
|
||||
size_t count, void *data, AttribType::Value typeIn, AttribType::Value typeOut, ComponentType compType, BufferViewTarget target = BufferViewTarget_NONE, void *dataBase = 0) {
|
||||
if (!count || !data) {
|
||||
return Ref<Accessor>();
|
||||
}
|
||||
|
||||
unsigned int numCompsIn = AttribType::GetNumComponents(typeIn);
|
||||
unsigned int numCompsOut = AttribType::GetNumComponents(typeOut);
|
||||
unsigned int bytesPerComp = ComponentTypeSize(compType);
|
||||
|
||||
// accessor
|
||||
Ref<Accessor> acc = a.accessors.Create(a.FindUniqueID(meshName, "accessor"));
|
||||
|
||||
// if there is a basic data vector
|
||||
if (dataBase) {
|
||||
size_t base_offset = buffer->byteLength;
|
||||
size_t base_padding = base_offset % bytesPerComp;
|
||||
base_offset += base_padding;
|
||||
size_t base_length = count * numCompsOut * bytesPerComp;
|
||||
buffer->Grow(base_length + base_padding);
|
||||
|
||||
Ref<BufferView> bv = a.bufferViews.Create(a.FindUniqueID(meshName, "view"));
|
||||
bv->buffer = buffer;
|
||||
bv->byteOffset = base_offset;
|
||||
bv->byteLength = base_length; //! The target that the WebGL buffer should be bound to.
|
||||
bv->byteStride = 0;
|
||||
bv->target = target;
|
||||
acc->bufferView = bv;
|
||||
acc->WriteData(count, dataBase, numCompsIn * bytesPerComp);
|
||||
}
|
||||
acc->byteOffset = 0;
|
||||
acc->componentType = compType;
|
||||
acc->count = count;
|
||||
acc->type = typeOut;
|
||||
|
||||
if (data) {
|
||||
void *nzDiff = 0, *nzIdx = 0;
|
||||
size_t nzCount = NZDiff(compType, data, dataBase, count, numCompsIn, numCompsOut, nzDiff, nzIdx);
|
||||
acc->sparse.reset(new Accessor::Sparse);
|
||||
acc->sparse->count = nzCount;
|
||||
|
||||
//indices
|
||||
unsigned int bytesPerIdx = sizeof(unsigned short);
|
||||
size_t indices_offset = buffer->byteLength;
|
||||
size_t indices_padding = indices_offset % bytesPerIdx;
|
||||
indices_offset += indices_padding;
|
||||
size_t indices_length = nzCount * 1 * bytesPerIdx;
|
||||
buffer->Grow(indices_length + indices_padding);
|
||||
|
||||
Ref<BufferView> indicesBV = a.bufferViews.Create(a.FindUniqueID(meshName, "view"));
|
||||
indicesBV->buffer = buffer;
|
||||
indicesBV->byteOffset = indices_offset;
|
||||
indicesBV->byteLength = indices_length;
|
||||
indicesBV->byteStride = 0;
|
||||
acc->sparse->indices = indicesBV;
|
||||
acc->sparse->indicesType = ComponentType_UNSIGNED_SHORT;
|
||||
acc->sparse->indicesByteOffset = 0;
|
||||
acc->WriteSparseIndices(nzCount, nzIdx, 1 * bytesPerIdx);
|
||||
|
||||
//values
|
||||
size_t values_offset = buffer->byteLength;
|
||||
size_t values_padding = values_offset % bytesPerComp;
|
||||
values_offset += values_padding;
|
||||
size_t values_length = nzCount * numCompsOut * bytesPerComp;
|
||||
buffer->Grow(values_length + values_padding);
|
||||
|
||||
Ref<BufferView> valuesBV = a.bufferViews.Create(a.FindUniqueID(meshName, "view"));
|
||||
valuesBV->buffer = buffer;
|
||||
valuesBV->byteOffset = values_offset;
|
||||
valuesBV->byteLength = values_length;
|
||||
valuesBV->byteStride = 0;
|
||||
acc->sparse->values = valuesBV;
|
||||
acc->sparse->valuesByteOffset = 0;
|
||||
acc->WriteSparseValues(nzCount, nzDiff, numCompsIn * bytesPerComp);
|
||||
|
||||
//clear
|
||||
delete[] (char*)nzDiff;
|
||||
delete[] (char*)nzIdx;
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
inline Ref<Accessor> ExportData(Asset& a, std::string& meshName, Ref<Buffer>& buffer,
|
||||
size_t count, void* data, AttribType::Value typeIn, AttribType::Value typeOut, ComponentType compType, BufferViewTarget target = BufferViewTarget_NONE)
|
||||
{
|
||||
|
@ -824,6 +983,10 @@ void glTF2Exporter::ExportMeshes()
|
|||
|
||||
/*************** Targets for blendshapes ****************/
|
||||
if (aim->mNumAnimMeshes > 0) {
|
||||
bool bUseSparse = this->mProperties->HasPropertyBool("GLTF2_SPARSE_ACCESSOR_EXP") &&
|
||||
this->mProperties->GetPropertyBool("GLTF2_SPARSE_ACCESSOR_EXP");
|
||||
bool bIncludeNormal = this->mProperties->HasPropertyBool("GLTF2_TARGET_NORMAL_EXP") &&
|
||||
this->mProperties->GetPropertyBool("GLTF2_TARGET_NORMAL_EXP");
|
||||
bool bExportTargetNames = this->mProperties->HasPropertyBool("GLTF2_TARGETNAMES_EXP") &&
|
||||
this->mProperties->GetPropertyBool("GLTF2_TARGETNAMES_EXP");
|
||||
|
||||
|
@ -832,7 +995,6 @@ void glTF2Exporter::ExportMeshes()
|
|||
aiAnimMesh *pAnimMesh = aim->mAnimMeshes[am];
|
||||
if (bExportTargetNames)
|
||||
m->targetNames.push_back(pAnimMesh->mName.data);
|
||||
|
||||
// position
|
||||
if (pAnimMesh->HasPositions()) {
|
||||
// NOTE: in gltf it is the diff stored
|
||||
|
@ -840,9 +1002,16 @@ void glTF2Exporter::ExportMeshes()
|
|||
for (unsigned int vt = 0; vt < pAnimMesh->mNumVertices; ++vt) {
|
||||
pPositionDiff[vt] = pAnimMesh->mVertices[vt] - aim->mVertices[vt];
|
||||
}
|
||||
Ref<Accessor> vec = ExportData(*mAsset, meshId, b,
|
||||
pAnimMesh->mNumVertices, pPositionDiff,
|
||||
AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
|
||||
Ref<Accessor> vec;
|
||||
if (bUseSparse) {
|
||||
vec = ExportDataSparse(*mAsset, meshId, b,
|
||||
pAnimMesh->mNumVertices, pPositionDiff,
|
||||
AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
|
||||
} else {
|
||||
vec = ExportData(*mAsset, meshId, b,
|
||||
pAnimMesh->mNumVertices, pPositionDiff,
|
||||
AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
|
||||
}
|
||||
if (vec) {
|
||||
p.targets[am].position.push_back(vec);
|
||||
}
|
||||
|
@ -850,14 +1019,21 @@ void glTF2Exporter::ExportMeshes()
|
|||
}
|
||||
|
||||
// normal
|
||||
if (pAnimMesh->HasNormals()) {
|
||||
if (pAnimMesh->HasNormals() && bIncludeNormal) {
|
||||
aiVector3D *pNormalDiff = new aiVector3D[pAnimMesh->mNumVertices];
|
||||
for (unsigned int vt = 0; vt < pAnimMesh->mNumVertices; ++vt) {
|
||||
pNormalDiff[vt] = pAnimMesh->mNormals[vt] - aim->mNormals[vt];
|
||||
}
|
||||
Ref<Accessor> vec = ExportData(*mAsset, meshId, b,
|
||||
pAnimMesh->mNumVertices, pNormalDiff,
|
||||
AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
|
||||
Ref<Accessor> vec;
|
||||
if (bUseSparse) {
|
||||
vec = ExportDataSparse(*mAsset, meshId, b,
|
||||
pAnimMesh->mNumVertices, pNormalDiff,
|
||||
AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
|
||||
} else {
|
||||
vec = ExportData(*mAsset, meshId, b,
|
||||
pAnimMesh->mNumVertices, pNormalDiff,
|
||||
AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
|
||||
}
|
||||
if (vec) {
|
||||
p.targets[am].normal.push_back(vec);
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
@ -298,25 +298,37 @@ void glTF2Importer::ImportMaterials(glTF2::Asset &r) {
|
|||
}
|
||||
}
|
||||
|
||||
static inline void SetFace(aiFace &face, int a) {
|
||||
face.mNumIndices = 1;
|
||||
face.mIndices = new unsigned int[1];
|
||||
face.mIndices[0] = a;
|
||||
static inline void SetFaceAndAdvance1(aiFace*& face, unsigned int numVertices, unsigned int a) {
|
||||
if (a >= numVertices) {
|
||||
return;
|
||||
}
|
||||
face->mNumIndices = 1;
|
||||
face->mIndices = new unsigned int[1];
|
||||
face->mIndices[0] = a;
|
||||
++face;
|
||||
}
|
||||
|
||||
static inline void SetFace(aiFace &face, int a, int b) {
|
||||
face.mNumIndices = 2;
|
||||
face.mIndices = new unsigned int[2];
|
||||
face.mIndices[0] = a;
|
||||
face.mIndices[1] = b;
|
||||
static inline void SetFaceAndAdvance2(aiFace*& face, unsigned int numVertices, unsigned int a, unsigned int b) {
|
||||
if ((a >= numVertices) || (b >= numVertices)) {
|
||||
return;
|
||||
}
|
||||
face->mNumIndices = 2;
|
||||
face->mIndices = new unsigned int[2];
|
||||
face->mIndices[0] = a;
|
||||
face->mIndices[1] = b;
|
||||
++face;
|
||||
}
|
||||
|
||||
static inline void SetFace(aiFace &face, int a, int b, int c) {
|
||||
face.mNumIndices = 3;
|
||||
face.mIndices = new unsigned int[3];
|
||||
face.mIndices[0] = a;
|
||||
face.mIndices[1] = b;
|
||||
face.mIndices[2] = c;
|
||||
static inline void SetFaceAndAdvance3(aiFace*& face, unsigned int numVertices, unsigned int a, unsigned int b, unsigned int c) {
|
||||
if ((a >= numVertices) || (b >= numVertices) || (c >= numVertices)) {
|
||||
return;
|
||||
}
|
||||
face->mNumIndices = 3;
|
||||
face->mIndices = new unsigned int[3];
|
||||
face->mIndices[0] = a;
|
||||
face->mIndices[1] = b;
|
||||
face->mIndices[2] = c;
|
||||
++face;
|
||||
}
|
||||
|
||||
#ifdef ASSIMP_BUILD_DEBUG
|
||||
|
@ -335,7 +347,7 @@ static inline bool CheckValidFacesIndices(aiFace *faces, unsigned nFaces, unsign
|
|||
|
||||
void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
||||
ASSIMP_LOG_DEBUG_F("Importing ", r.meshes.Size(), " meshes");
|
||||
std::vector<aiMesh *> meshes;
|
||||
std::vector<std::unique_ptr<aiMesh>> meshes;
|
||||
|
||||
unsigned int k = 0;
|
||||
meshOffsets.clear();
|
||||
|
@ -350,7 +362,7 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
|||
Mesh::Primitive &prim = mesh.primitives[p];
|
||||
|
||||
aiMesh *aim = new aiMesh();
|
||||
meshes.push_back(aim);
|
||||
meshes.push_back(std::unique_ptr<aiMesh>(aim));
|
||||
|
||||
aim->mName = mesh.name.empty() ? mesh.id : mesh.name;
|
||||
|
||||
|
@ -486,6 +498,7 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
|||
}
|
||||
|
||||
aiFace *faces = nullptr;
|
||||
aiFace *facePtr = nullptr;
|
||||
size_t nFaces = 0;
|
||||
|
||||
if (prim.indices) {
|
||||
|
@ -497,9 +510,9 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
|||
switch (prim.mode) {
|
||||
case PrimitiveMode_POINTS: {
|
||||
nFaces = count;
|
||||
faces = new aiFace[nFaces];
|
||||
facePtr = faces = new aiFace[nFaces];
|
||||
for (unsigned int i = 0; i < count; ++i) {
|
||||
SetFace(faces[i], data.GetUInt(i));
|
||||
SetFaceAndAdvance1(facePtr, aim->mNumVertices, data.GetUInt(i));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -510,9 +523,9 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
|||
ASSIMP_LOG_WARN("The number of vertices was not compatible with the LINES mode. Some vertices were dropped.");
|
||||
count = nFaces * 2;
|
||||
}
|
||||
faces = new aiFace[nFaces];
|
||||
facePtr = faces = new aiFace[nFaces];
|
||||
for (unsigned int i = 0; i < count; i += 2) {
|
||||
SetFace(faces[i / 2], data.GetUInt(i), data.GetUInt(i + 1));
|
||||
SetFaceAndAdvance2(facePtr, aim->mNumVertices, data.GetUInt(i), data.GetUInt(i + 1));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -520,13 +533,13 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
|||
case PrimitiveMode_LINE_LOOP:
|
||||
case PrimitiveMode_LINE_STRIP: {
|
||||
nFaces = count - ((prim.mode == PrimitiveMode_LINE_STRIP) ? 1 : 0);
|
||||
faces = new aiFace[nFaces];
|
||||
SetFace(faces[0], data.GetUInt(0), data.GetUInt(1));
|
||||
facePtr = faces = new aiFace[nFaces];
|
||||
SetFaceAndAdvance2(facePtr, aim->mNumVertices, data.GetUInt(0), data.GetUInt(1));
|
||||
for (unsigned int i = 2; i < count; ++i) {
|
||||
SetFace(faces[i - 1], faces[i - 2].mIndices[1], data.GetUInt(i));
|
||||
SetFaceAndAdvance2(facePtr, aim->mNumVertices, data.GetUInt(i - 1), data.GetUInt(i));
|
||||
}
|
||||
if (prim.mode == PrimitiveMode_LINE_LOOP) { // close the loop
|
||||
SetFace(faces[count - 1], faces[count - 2].mIndices[1], faces[0].mIndices[0]);
|
||||
SetFaceAndAdvance2(facePtr, aim->mNumVertices, data.GetUInt(static_cast<int>(count) - 1), faces[0].mIndices[0]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -537,33 +550,33 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
|||
ASSIMP_LOG_WARN("The number of vertices was not compatible with the TRIANGLES mode. Some vertices were dropped.");
|
||||
count = nFaces * 3;
|
||||
}
|
||||
faces = new aiFace[nFaces];
|
||||
facePtr = faces = new aiFace[nFaces];
|
||||
for (unsigned int i = 0; i < count; i += 3) {
|
||||
SetFace(faces[i / 3], data.GetUInt(i), data.GetUInt(i + 1), data.GetUInt(i + 2));
|
||||
SetFaceAndAdvance3(facePtr, aim->mNumVertices, data.GetUInt(i), data.GetUInt(i + 1), data.GetUInt(i + 2));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PrimitiveMode_TRIANGLE_STRIP: {
|
||||
nFaces = count - 2;
|
||||
faces = new aiFace[nFaces];
|
||||
facePtr = faces = new aiFace[nFaces];
|
||||
for (unsigned int i = 0; i < nFaces; ++i) {
|
||||
//The ordering is to ensure that the triangles are all drawn with the same orientation
|
||||
if ((i + 1) % 2 == 0) {
|
||||
//For even n, vertices n + 1, n, and n + 2 define triangle n
|
||||
SetFace(faces[i], data.GetUInt(i + 1), data.GetUInt(i), data.GetUInt(i + 2));
|
||||
SetFaceAndAdvance3(facePtr, aim->mNumVertices, data.GetUInt(i + 1), data.GetUInt(i), data.GetUInt(i + 2));
|
||||
} else {
|
||||
//For odd n, vertices n, n+1, and n+2 define triangle n
|
||||
SetFace(faces[i], data.GetUInt(i), data.GetUInt(i + 1), data.GetUInt(i + 2));
|
||||
SetFaceAndAdvance3(facePtr, aim->mNumVertices, data.GetUInt(i), data.GetUInt(i + 1), data.GetUInt(i + 2));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PrimitiveMode_TRIANGLE_FAN:
|
||||
nFaces = count - 2;
|
||||
faces = new aiFace[nFaces];
|
||||
SetFace(faces[0], data.GetUInt(0), data.GetUInt(1), data.GetUInt(2));
|
||||
facePtr = faces = new aiFace[nFaces];
|
||||
SetFaceAndAdvance3(facePtr, aim->mNumVertices, data.GetUInt(0), data.GetUInt(1), data.GetUInt(2));
|
||||
for (unsigned int i = 1; i < nFaces; ++i) {
|
||||
SetFace(faces[i], faces[0].mIndices[0], faces[i - 1].mIndices[2], data.GetUInt(i + 2));
|
||||
SetFaceAndAdvance3(facePtr, aim->mNumVertices, data.GetUInt(0), data.GetUInt(i + 1), data.GetUInt(i + 2));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -575,9 +588,9 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
|||
switch (prim.mode) {
|
||||
case PrimitiveMode_POINTS: {
|
||||
nFaces = count;
|
||||
faces = new aiFace[nFaces];
|
||||
facePtr = faces = new aiFace[nFaces];
|
||||
for (unsigned int i = 0; i < count; ++i) {
|
||||
SetFace(faces[i], i);
|
||||
SetFaceAndAdvance1(facePtr, aim->mNumVertices, i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -588,9 +601,9 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
|||
ASSIMP_LOG_WARN("The number of vertices was not compatible with the LINES mode. Some vertices were dropped.");
|
||||
count = (unsigned int)nFaces * 2;
|
||||
}
|
||||
faces = new aiFace[nFaces];
|
||||
facePtr = faces = new aiFace[nFaces];
|
||||
for (unsigned int i = 0; i < count; i += 2) {
|
||||
SetFace(faces[i / 2], i, i + 1);
|
||||
SetFaceAndAdvance2(facePtr, aim->mNumVertices, i, i + 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -598,13 +611,13 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
|||
case PrimitiveMode_LINE_LOOP:
|
||||
case PrimitiveMode_LINE_STRIP: {
|
||||
nFaces = count - ((prim.mode == PrimitiveMode_LINE_STRIP) ? 1 : 0);
|
||||
faces = new aiFace[nFaces];
|
||||
SetFace(faces[0], 0, 1);
|
||||
facePtr = faces = new aiFace[nFaces];
|
||||
SetFaceAndAdvance2(facePtr, aim->mNumVertices, 0, 1);
|
||||
for (unsigned int i = 2; i < count; ++i) {
|
||||
SetFace(faces[i - 1], faces[i - 2].mIndices[1], i);
|
||||
SetFaceAndAdvance2(facePtr, aim->mNumVertices, i - 1, i);
|
||||
}
|
||||
if (prim.mode == PrimitiveMode_LINE_LOOP) { // close the loop
|
||||
SetFace(faces[count - 1], faces[count - 2].mIndices[1], faces[0].mIndices[0]);
|
||||
SetFaceAndAdvance2(facePtr, aim->mNumVertices, count - 1, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -615,42 +628,50 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
|||
ASSIMP_LOG_WARN("The number of vertices was not compatible with the TRIANGLES mode. Some vertices were dropped.");
|
||||
count = (unsigned int)nFaces * 3;
|
||||
}
|
||||
faces = new aiFace[nFaces];
|
||||
facePtr = faces = new aiFace[nFaces];
|
||||
for (unsigned int i = 0; i < count; i += 3) {
|
||||
SetFace(faces[i / 3], i, i + 1, i + 2);
|
||||
SetFaceAndAdvance3(facePtr, aim->mNumVertices, i, i + 1, i + 2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PrimitiveMode_TRIANGLE_STRIP: {
|
||||
nFaces = count - 2;
|
||||
faces = new aiFace[nFaces];
|
||||
facePtr = faces = new aiFace[nFaces];
|
||||
for (unsigned int i = 0; i < nFaces; ++i) {
|
||||
//The ordering is to ensure that the triangles are all drawn with the same orientation
|
||||
if ((i + 1) % 2 == 0) {
|
||||
//For even n, vertices n + 1, n, and n + 2 define triangle n
|
||||
SetFace(faces[i], i + 1, i, i + 2);
|
||||
SetFaceAndAdvance3(facePtr, aim->mNumVertices, i + 1, i, i + 2);
|
||||
} else {
|
||||
//For odd n, vertices n, n+1, and n+2 define triangle n
|
||||
SetFace(faces[i], i, i + 1, i + 2);
|
||||
SetFaceAndAdvance3(facePtr, aim->mNumVertices, i, i + 1, i + 2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PrimitiveMode_TRIANGLE_FAN:
|
||||
nFaces = count - 2;
|
||||
faces = new aiFace[nFaces];
|
||||
SetFace(faces[0], 0, 1, 2);
|
||||
facePtr = faces = new aiFace[nFaces];
|
||||
SetFaceAndAdvance3(facePtr, aim->mNumVertices, 0, 1, 2);
|
||||
for (unsigned int i = 1; i < nFaces; ++i) {
|
||||
SetFace(faces[i], faces[0].mIndices[0], faces[i - 1].mIndices[2], i + 2);
|
||||
SetFaceAndAdvance3(facePtr, aim->mNumVertices, 0, i + 1, i + 2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nullptr != faces) {
|
||||
if (faces) {
|
||||
aim->mFaces = faces;
|
||||
aim->mNumFaces = static_cast<unsigned int>(nFaces);
|
||||
ai_assert(CheckValidFacesIndices(faces, static_cast<unsigned>(nFaces), aim->mNumVertices));
|
||||
const unsigned int actualNumFaces = static_cast<unsigned int>(facePtr - faces);
|
||||
if (actualNumFaces < nFaces) {
|
||||
ASSIMP_LOG_WARN("Some faces had out-of-range indices. Those faces were dropped.");
|
||||
}
|
||||
if (actualNumFaces == 0)
|
||||
{
|
||||
throw DeadlyImportError(std::string("Mesh \"") + aim->mName.C_Str() + "\" has no faces");
|
||||
}
|
||||
aim->mNumFaces = actualNumFaces;
|
||||
ai_assert(CheckValidFacesIndices(faces, actualNumFaces, aim->mNumVertices));
|
||||
}
|
||||
|
||||
if (prim.material) {
|
||||
|
|
|
@ -899,7 +899,7 @@ ENDIF()
|
|||
# utf8
|
||||
IF(ASSIMP_HUNTER_ENABLED)
|
||||
hunter_add_package(utf8)
|
||||
find_package(utf8 CONFIG REQUIRED)
|
||||
find_package(utf8cpp CONFIG REQUIRED)
|
||||
ELSE()
|
||||
# utf8 is header-only, so Assimp doesn't need to do anything.
|
||||
ENDIF()
|
||||
|
@ -1066,7 +1066,7 @@ endif()
|
|||
|
||||
ADD_DEFINITIONS( -DASSIMP_BUILD_DLL_EXPORT )
|
||||
|
||||
if ( MSVC )
|
||||
IF( MSVC OR "${CMAKE_CXX_SIMULATE_ID}" MATCHES "MSVC") # clang with MSVC ABI
|
||||
ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS )
|
||||
ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
|
||||
endif ()
|
||||
|
@ -1159,7 +1159,7 @@ IF(ASSIMP_HUNTER_ENABLED)
|
|||
minizip::minizip
|
||||
ZLIB::zlib
|
||||
RapidJSON::rapidjson
|
||||
utf8::utf8
|
||||
utf8cpp
|
||||
zip::zip
|
||||
)
|
||||
ELSE()
|
||||
|
|
|
@ -345,7 +345,7 @@ std::string BaseImporter::GetExtension(const std::string &file) {
|
|||
}
|
||||
|
||||
#ifdef ASSIMP_USE_HUNTER
|
||||
#include <utf8/utf8.h>
|
||||
#include <utf8.h>
|
||||
#else
|
||||
#include "../contrib/utf8cpp/source/utf8.h"
|
||||
#endif
|
||||
|
|
|
@ -100,7 +100,6 @@ size_t DefaultIOStream::Write(const void *pvBuffer,
|
|||
size_t pCount) {
|
||||
ai_assert(nullptr != pvBuffer);
|
||||
ai_assert(0 != pSize);
|
||||
ai_assert(0 != pCount);
|
||||
|
||||
return (mFile ? ::fwrite(pvBuffer, pSize, pCount, mFile) : 0);
|
||||
}
|
||||
|
|
|
@ -74,9 +74,9 @@ Here we implement only the C++ interface (Assimp::Exporter).
|
|||
|
||||
namespace Assimp {
|
||||
|
||||
#ifdef _WIN32
|
||||
# pragma warning( disable : 4800 )
|
||||
#endif // _WIN32
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning( disable : 4800 )
|
||||
#endif // _MSC_VER
|
||||
|
||||
|
||||
// PostStepRegistry.cpp
|
||||
|
@ -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,
|
||||
|
@ -580,10 +583,23 @@ ExportProperties::ExportProperties(const ExportProperties &other)
|
|||
: mIntProperties(other.mIntProperties)
|
||||
, mFloatProperties(other.mFloatProperties)
|
||||
, mStringProperties(other.mStringProperties)
|
||||
, mMatrixProperties(other.mMatrixProperties) {
|
||||
, mMatrixProperties(other.mMatrixProperties)
|
||||
, mCallbackProperties(other.mCallbackProperties){
|
||||
// empty
|
||||
}
|
||||
|
||||
bool ExportProperties::SetPropertyCallback(const char *szName, const std::function<void *(void *)> &f) {
|
||||
return SetGenericProperty<std::function<void *(void *)>>(mCallbackProperties, szName, f);
|
||||
}
|
||||
|
||||
std::function<void *(void *)> ExportProperties::GetPropertyCallback(const char *szName) const {
|
||||
return GetGenericProperty<std::function<void *(void *)>>(mCallbackProperties, szName, 0);
|
||||
}
|
||||
|
||||
bool ExportProperties::HasPropertyCallback(const char *szName) const {
|
||||
return HasGenericProperty<std::function<void *(void *)>>(mCallbackProperties, szName);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Set a configuration property
|
||||
bool ExportProperties::SetPropertyInteger(const char* szName, int iValue) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -53,9 +53,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
using namespace Assimp;
|
||||
void mydummy() {}
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4709)
|
||||
#endif // _WIN32
|
||||
#endif // _MSC_VER
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
/** Subdivider stub class to implement the Catmull-Clarke subdivision algorithm. The
|
||||
* implementation is basing on recursive refinement. Directly evaluating the result is also
|
||||
|
|
|
@ -312,10 +312,22 @@
|
|||
__pragma(warning(disable: warnings))
|
||||
# define GTEST_DISABLE_MSC_WARNINGS_POP_() \
|
||||
__pragma(warning(pop))
|
||||
# if defined(__clang__)
|
||||
# define GTEST_DISABLE_CLANG_DEPRECATED_WARNINGS_PUSH_() \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
|
||||
# define GTEST_DISABLE_CLANG_WARNINGS_POP_() \
|
||||
_Pragma("clang diagnostic pop")
|
||||
# else
|
||||
# define GTEST_DISABLE_CLANG_DEPRECATED_WARNINGS_PUSH_()
|
||||
# define GTEST_DISABLE_CLANG_WARNINGS_POP_()
|
||||
# endif
|
||||
#else
|
||||
// Older versions of MSVC don't have __pragma.
|
||||
# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)
|
||||
# define GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||
# define GTEST_DISABLE_CLANG_DEPRECATED_WARNINGS_PUSH_()
|
||||
# define GTEST_DISABLE_CLANG_WARNINGS_POP_()
|
||||
#endif
|
||||
|
||||
#ifndef GTEST_LANG_CXX11
|
||||
|
@ -2352,6 +2364,7 @@ inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
|
|||
// Functions deprecated by MSVC 8.0.
|
||||
|
||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996 /* deprecated function */)
|
||||
GTEST_DISABLE_CLANG_DEPRECATED_WARNINGS_PUSH_()
|
||||
|
||||
inline const char* StrNCpy(char* dest, const char* src, size_t n) {
|
||||
return strncpy(dest, src, n);
|
||||
|
@ -2399,6 +2412,7 @@ inline const char* GetEnv(const char* name) {
|
|||
#endif
|
||||
}
|
||||
|
||||
GTEST_DISABLE_CLANG_WARNINGS_POP_()
|
||||
GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||
|
||||
#if GTEST_OS_WINDOWS_MOBILE
|
||||
|
|
|
@ -926,7 +926,7 @@ GTestLog::~GTestLog() {
|
|||
// Disable Microsoft deprecation warnings for POSIX functions called from
|
||||
// this class (creat, dup, dup2, and close)
|
||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
|
||||
|
||||
GTEST_DISABLE_CLANG_DEPRECATED_WARNINGS_PUSH_()
|
||||
#if GTEST_HAS_STREAM_REDIRECTION
|
||||
|
||||
// Object that captures an output stream (stdout/stderr).
|
||||
|
@ -1010,6 +1010,7 @@ class CapturedStream {
|
|||
};
|
||||
|
||||
GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||
GTEST_DISABLE_CLANG_WARNINGS_POP_()
|
||||
|
||||
static CapturedStream* g_captured_stderr = NULL;
|
||||
static CapturedStream* g_captured_stdout = NULL;
|
||||
|
|
|
@ -36,10 +36,10 @@
|
|||
|
||||
namespace p2t {
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning( disable : 4702 )
|
||||
#endif // _WIN32
|
||||
#endif // _MSC_VER
|
||||
|
||||
// Triangulate simple polygon with holes
|
||||
void Sweep::Triangulate(SweepContext& tcx)
|
||||
|
@ -800,8 +800,8 @@ Sweep::~Sweep() {
|
|||
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning( pop )
|
||||
#endif // _WIN32
|
||||
#endif // _MSC_VER
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <limits>
|
||||
|
||||
RAPIDJSON_DIAG_PUSH
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && !(__clang__)
|
||||
RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant
|
||||
RAPIDJSON_DIAG_OFF(4244) // conversion from kXxxFlags to 'uint16_t', possible loss of data
|
||||
#endif
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "rapidjson.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
RAPIDJSON_DIAG_PUSH
|
||||
RAPIDJSON_DIAG_OFF(4244) // conversion from 'type1' to 'type2', possible loss of data
|
||||
RAPIDJSON_DIAG_OFF(4702) // unreachable code
|
||||
|
@ -709,7 +709,7 @@ struct Transcoder<Encoding, Encoding> {
|
|||
|
||||
RAPIDJSON_NAMESPACE_END
|
||||
|
||||
#if defined(__GNUC__) || defined(_MSC_VER)
|
||||
#if defined(__GNUC__) || (defined(_MSC_VER) && !defined(__clang__))
|
||||
RAPIDJSON_DIAG_POP
|
||||
#endif
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
RAPIDJSON_DIAG_PUSH
|
||||
RAPIDJSON_DIAG_OFF(effc++)
|
||||
#endif
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
RAPIDJSON_DIAG_PUSH
|
||||
RAPIDJSON_DIAG_OFF(6334)
|
||||
#endif
|
||||
|
@ -174,7 +174,7 @@ template <typename T> struct RemoveSfinaeTag<SfinaeTag&(*)(T)> { typedef T Type;
|
|||
RAPIDJSON_NAMESPACE_END
|
||||
//@endcond
|
||||
|
||||
#if defined(__GNUC__) || defined(_MSC_VER)
|
||||
#if defined(__GNUC__) || (defined(_MSC_VER) && !defined(__clang__))
|
||||
RAPIDJSON_DIAG_POP
|
||||
#endif
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
RAPIDJSON_DIAG_PUSH
|
||||
RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant
|
||||
RAPIDJSON_DIAG_OFF(4702) // unreachable code
|
||||
|
@ -2214,7 +2214,7 @@ RAPIDJSON_DIAG_POP
|
|||
RAPIDJSON_DIAG_POP
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
RAPIDJSON_DIAG_POP
|
||||
#endif
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined (_MSC_VER) && !defined(__clang__)
|
||||
RAPIDJSON_DIAG_PUSH
|
||||
RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant
|
||||
#endif
|
||||
|
@ -700,11 +700,11 @@ inline bool Writer<StringBuffer>::ScanWriteUnescapedString(StringStream& is, siz
|
|||
|
||||
RAPIDJSON_NAMESPACE_END
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
RAPIDJSON_DIAG_POP
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#if defined(__clang__)
|
||||
RAPIDJSON_DIAG_POP
|
||||
#endif
|
||||
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
#ifdef _WIN32
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4131 4100)
|
||||
# ifdef __clang__
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
# endif
|
||||
#endif // _WIN32
|
||||
|
||||
/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
|
||||
|
@ -181,4 +185,7 @@ void fill_fopen_filefunc (pzlib_filefunc_def)
|
|||
|
||||
#ifdef _WIN32
|
||||
# pragma warning(pop)
|
||||
# ifdef __clang__
|
||||
# pragma clang diagnostic pop
|
||||
# endif
|
||||
#endif // _WIN32
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#ifndef ZCALLBACK
|
||||
|
||||
#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
|
||||
#if (defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
|
||||
#define ZCALLBACK CALLBACK
|
||||
#else
|
||||
#define ZCALLBACK
|
||||
|
|
|
@ -1554,7 +1554,6 @@ extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
|
|||
char *szComment;
|
||||
uLong uSizeBuf;
|
||||
{
|
||||
int err=UNZ_OK;
|
||||
unz_s* s;
|
||||
uLong uReadThis ;
|
||||
if (file==NULL)
|
||||
|
|
|
@ -5361,7 +5361,7 @@ mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip,
|
|||
} else {
|
||||
// Temporarily allocate a read buffer.
|
||||
read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE);
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
if (((0, sizeof(size_t) == sizeof(mz_uint32))) &&
|
||||
(read_buf_size > 0x7FFFFFFF))
|
||||
#else
|
||||
|
@ -5454,7 +5454,7 @@ void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index,
|
|||
uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS);
|
||||
|
||||
alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? comp_size : uncomp_size;
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF))
|
||||
#else
|
||||
if (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF))
|
||||
|
@ -5560,7 +5560,7 @@ mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip,
|
|||
if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) {
|
||||
// The file is stored or the caller has requested the compressed data.
|
||||
if (pZip->m_pState->m_pMem) {
|
||||
#ifdef _MSC_VER
|
||||
#if defined (_MSC_VER) && !defined(__clang__)
|
||||
if (((0, sizeof(size_t) == sizeof(mz_uint32))) &&
|
||||
(file_stat.m_comp_size > 0xFFFFFFFF))
|
||||
#else
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4127 )
|
||||
#endif //_WIN32
|
||||
#endif //_MSC_VER
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -319,6 +320,10 @@ extern int zip_extract(const char *zipname, const char *dir,
|
|||
|
||||
/** @} */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif //_MSC_VER
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -39,9 +39,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
---------------------------------------------------------------------------
|
||||
*/
|
||||
#include <assimp/cimport.h>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/postprocess.h>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
|
||||
aiLogStream stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,NULL);
|
||||
aiAttachLogStream(&stream);
|
||||
|
|
|
@ -57,6 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
struct aiScene;
|
||||
struct aiImporterDesc;
|
||||
|
@ -391,6 +392,24 @@ public: // static utilities
|
|||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Utility function to move a std::vector of unique_ptrs into a aiScene array
|
||||
* @param vec The vector of unique_ptrs to be moved
|
||||
* @param out The output pointer to the allocated array.
|
||||
* @param numOut The output count of elements copied. */
|
||||
template <typename T>
|
||||
AI_FORCE_INLINE static void CopyVector(
|
||||
std::vector<std::unique_ptr<T>> &vec,
|
||||
T **&out,
|
||||
unsigned int &outLength) {
|
||||
outLength = unsigned(vec.size());
|
||||
if (outLength) {
|
||||
out = new T*[outLength];
|
||||
T** outPtr = out;
|
||||
std::for_each(vec.begin(), vec.end(), [&outPtr](std::unique_ptr<T>& uPtr){*outPtr = uPtr.release(); ++outPtr; });
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
/// Error description in case there was one.
|
||||
std::string m_ErrorText;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#endif
|
||||
|
||||
// reset packing to the original value
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
||||
#if (defined(_MSC_VER) && !defined(__clang__)) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
||||
# pragma pack( pop )
|
||||
#endif
|
||||
#undef PACK_STRUCT
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
# error poppack1.h must be included after pushpack1.h
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
||||
#if (defined(_MSC_VER) && !defined(__clang__)) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
||||
# pragma pack(push,1)
|
||||
# define PACK_STRUCT
|
||||
#elif defined( __GNUC__ ) || defined(__clang__)
|
||||
|
|
|
@ -54,6 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "cexport.h"
|
||||
#include <map>
|
||||
#include <functional>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
|
@ -107,7 +108,8 @@ public:
|
|||
}
|
||||
|
||||
ExportFormatEntry() :
|
||||
mExportFunction(), mEnforcePP() {
|
||||
mExportFunction(),
|
||||
mEnforcePP() {
|
||||
mDescription.id = nullptr;
|
||||
mDescription.description = nullptr;
|
||||
mDescription.fileExtension = nullptr;
|
||||
|
@ -147,7 +149,7 @@ public:
|
|||
* interface is the default IO handler provided by ASSIMP. The default
|
||||
* handler is active as long the application doesn't supply its own
|
||||
* custom IO handler via #SetIOHandler().
|
||||
* @return A valid IOSystem interface, never nullptr. */
|
||||
* @return A valid IOSystem interface, never NULL. */
|
||||
IOSystem *GetIOHandler() const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
@ -286,7 +288,7 @@ public:
|
|||
* @param pIndex Index of the export format to retrieve information
|
||||
* for. Valid range is 0 to #Exporter::GetExportFormatCount
|
||||
* @return A description of that specific export format.
|
||||
* nullptr if pIndex is out of range. */
|
||||
* NULL if pIndex is out of range. */
|
||||
const aiExportFormatDesc *GetExportFormatDescription(size_t pIndex) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
@ -329,6 +331,7 @@ public:
|
|||
typedef std::map<KeyType, ai_real> FloatPropertyMap;
|
||||
typedef std::map<KeyType, std::string> StringPropertyMap;
|
||||
typedef std::map<KeyType, aiMatrix4x4> MatrixPropertyMap;
|
||||
typedef std::map<KeyType, std::function<void *(void *)>> CallbackPropertyMap;
|
||||
|
||||
public:
|
||||
/** Standard constructor
|
||||
|
@ -387,6 +390,8 @@ public:
|
|||
* @see SetPropertyInteger()
|
||||
*/
|
||||
bool SetPropertyMatrix(const char *szName, const aiMatrix4x4 &sValue);
|
||||
|
||||
bool SetPropertyCallback(const char *szName, const std::function<void *(void *)> &f);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get a configuration property.
|
||||
|
@ -440,6 +445,8 @@ public:
|
|||
const aiMatrix4x4 GetPropertyMatrix(const char *szName,
|
||||
const aiMatrix4x4 &sErrorReturn = aiMatrix4x4()) const;
|
||||
|
||||
std::function<void *(void *)> GetPropertyCallback(const char* szName) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Determine a integer configuration property has been set.
|
||||
* @see HasPropertyInteger()
|
||||
|
@ -466,7 +473,8 @@ public:
|
|||
*/
|
||||
bool HasPropertyMatrix(const char *szName) const;
|
||||
|
||||
protected:
|
||||
bool HasPropertyCallback(const char *szName) const;
|
||||
|
||||
/** List of integer properties */
|
||||
IntPropertyMap mIntProperties;
|
||||
|
||||
|
@ -478,6 +486,8 @@ protected:
|
|||
|
||||
/** List of Matrix properties */
|
||||
MatrixPropertyMap mMatrixProperties;
|
||||
|
||||
CallbackPropertyMap mCallbackProperties;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
|
|
@ -53,6 +53,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <stdarg.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define AI_SIZEFMT "%Iu"
|
||||
#else
|
||||
# define AI_SIZEFMT "%zu"
|
||||
#endif
|
||||
|
||||
/// @fn ai_snprintf
|
||||
/// @brief The portable version of the function snprintf ( C99 standard ), which works on visual studio compilers 2013 and earlier.
|
||||
/// @param outBuf The buffer to write in
|
||||
|
@ -87,6 +93,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
return count;
|
||||
}
|
||||
|
||||
#elif defined(__MINGW32__)
|
||||
# define ai_snprintf __mingw_snprintf
|
||||
#else
|
||||
# define ai_snprintf snprintf
|
||||
#endif
|
||||
|
@ -150,7 +158,7 @@ std::string DecimalToHexa( T toConvert ) {
|
|||
/// @param g aiColor.g
|
||||
/// @param b aiColor.b
|
||||
/// @param a aiColor.a
|
||||
/// @param with_head #
|
||||
/// @param with_head #
|
||||
/// @return The hexadecimal string, is empty in case of an error.
|
||||
AI_FORCE_INLINE std::string Rgba2Hex(int r, int g, int b, int a, bool with_head) {
|
||||
std::stringstream ss;
|
||||
|
@ -158,7 +166,7 @@ AI_FORCE_INLINE std::string Rgba2Hex(int r, int g, int b, int a, bool with_head)
|
|||
ss << "#";
|
||||
}
|
||||
ss << std::hex << (r << 24 | g << 16 | b << 8 | a);
|
||||
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
|
|
@ -278,7 +278,7 @@ void do_motion (void)
|
|||
static int frames = 0;
|
||||
|
||||
int time = glutGet(GLUT_ELAPSED_TIME);
|
||||
angle += static_cast<float>((time-prev_time)*0.01);
|
||||
angle += (float)((time-prev_time)*0.01);
|
||||
prev_time = time;
|
||||
|
||||
frames += 1;
|
||||
|
@ -376,7 +376,7 @@ int main(int argc, char **argv)
|
|||
|
||||
// Check and validate the specified model file extension.
|
||||
model_file = argv[1];
|
||||
const char* extension = strchr(model_file, '.');
|
||||
const char* extension = strrchr(model_file, '.');
|
||||
if (!extension) {
|
||||
print_error("Please provide a file with a valid extension.");
|
||||
return EXIT_FAILURE;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -0,0 +1,142 @@
|
|||
{
|
||||
"asset": {
|
||||
"generator": "COLLADA2GLTF",
|
||||
"version": "2.0"
|
||||
},
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"children": [
|
||||
1
|
||||
],
|
||||
"matrix": [
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
-1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"NORMAL": 1,
|
||||
"POSITION": 2
|
||||
},
|
||||
"indices": 0,
|
||||
"mode": 4,
|
||||
"material": 0
|
||||
}
|
||||
],
|
||||
"name": "Mesh"
|
||||
}
|
||||
],
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"byteOffset": 0,
|
||||
"componentType": 5123,
|
||||
"count": 36,
|
||||
"max": [
|
||||
255
|
||||
],
|
||||
"min": [
|
||||
0
|
||||
],
|
||||
"type": "SCALAR"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"byteOffset": 0,
|
||||
"componentType": 5126,
|
||||
"count": 24,
|
||||
"max": [
|
||||
1.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"min": [
|
||||
-1.0,
|
||||
-1.0,
|
||||
-1.0
|
||||
],
|
||||
"type": "VEC3"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"byteOffset": 288,
|
||||
"componentType": 5126,
|
||||
"count": 24,
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.5
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
-0.5
|
||||
],
|
||||
"type": "VEC3"
|
||||
}
|
||||
],
|
||||
"materials": [
|
||||
{
|
||||
"pbrMetallicRoughness": {
|
||||
"baseColorFactor": [
|
||||
0.800000011920929,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0
|
||||
],
|
||||
"metallicFactor": 0.0
|
||||
},
|
||||
"name": "Red"
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 576,
|
||||
"byteLength": 72,
|
||||
"target": 34963
|
||||
},
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 0,
|
||||
"byteLength": 576,
|
||||
"byteStride": 12,
|
||||
"target": 34962
|
||||
}
|
||||
],
|
||||
"buffers": [
|
||||
{
|
||||
"byteLength": 648,
|
||||
"uri": "AllIndicesOutOfRange.bin"
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,142 @@
|
|||
{
|
||||
"asset": {
|
||||
"generator": "COLLADA2GLTF",
|
||||
"version": "2.0"
|
||||
},
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"children": [
|
||||
1
|
||||
],
|
||||
"matrix": [
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
-1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"NORMAL": 1,
|
||||
"POSITION": 2
|
||||
},
|
||||
"indices": 0,
|
||||
"mode": 4,
|
||||
"material": 0
|
||||
}
|
||||
],
|
||||
"name": "Mesh"
|
||||
}
|
||||
],
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"byteOffset": 0,
|
||||
"componentType": 5123,
|
||||
"count": 36,
|
||||
"max": [
|
||||
255
|
||||
],
|
||||
"min": [
|
||||
0
|
||||
],
|
||||
"type": "SCALAR"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"byteOffset": 0,
|
||||
"componentType": 5126,
|
||||
"count": 24,
|
||||
"max": [
|
||||
1.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"min": [
|
||||
-1.0,
|
||||
-1.0,
|
||||
-1.0
|
||||
],
|
||||
"type": "VEC3"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"byteOffset": 288,
|
||||
"componentType": 5126,
|
||||
"count": 24,
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.5
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
-0.5
|
||||
],
|
||||
"type": "VEC3"
|
||||
}
|
||||
],
|
||||
"materials": [
|
||||
{
|
||||
"pbrMetallicRoughness": {
|
||||
"baseColorFactor": [
|
||||
0.800000011920929,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0
|
||||
],
|
||||
"metallicFactor": 0.0
|
||||
},
|
||||
"name": "Red"
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 576,
|
||||
"byteLength": 72,
|
||||
"target": 34963
|
||||
},
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 0,
|
||||
"byteLength": 576,
|
||||
"byteStride": 12,
|
||||
"target": 34962
|
||||
}
|
||||
],
|
||||
"buffers": [
|
||||
{
|
||||
"byteLength": 648,
|
||||
"uri": "IndexOutOfRange.bin"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -44,21 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <cstdlib>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define TMP_PATH "/tmp/"
|
||||
inline FILE* MakeTmpFile(char* tmplate)
|
||||
{
|
||||
auto fd = mkstemp(tmplate);
|
||||
EXPECT_NE(-1, fd);
|
||||
if(fd == -1)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
auto fs = fdopen(fd, "w+");
|
||||
EXPECT_NE(nullptr, fs);
|
||||
return fs;
|
||||
}
|
||||
#elif defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)
|
||||
#include <io.h>
|
||||
#define TMP_PATH "./"
|
||||
inline FILE* MakeTmpFile(char* tmplate)
|
||||
|
@ -73,4 +59,18 @@ inline FILE* MakeTmpFile(char* tmplate)
|
|||
EXPECT_NE(fs, nullptr);
|
||||
return fs;
|
||||
}
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#define TMP_PATH "/tmp/"
|
||||
inline FILE* MakeTmpFile(char* tmplate)
|
||||
{
|
||||
auto fd = mkstemp(tmplate);
|
||||
EXPECT_NE(-1, fd);
|
||||
if(fd == -1)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
auto fs = fdopen(fd, "w+");
|
||||
EXPECT_NE(nullptr, fs);
|
||||
return fs;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -157,7 +157,6 @@ public:
|
|||
|
||||
static inline void CheckNodeIdNames(IdNameMap &nodeIdMap, IdNameMap &nodeNameMap, const aiNode *parent, size_t index) {
|
||||
IdNameString namePair = GetItemIdName(parent, index);
|
||||
const auto result = nodeNameMap.insert(namePair);
|
||||
IdNameString idPair = GetColladaIdName(parent, index);
|
||||
ReportDuplicate(nodeIdMap, idPair, typeid(aiNode).name());
|
||||
|
||||
|
|
|
@ -46,11 +46,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/scene.h>
|
||||
#include <assimp/Exporter.hpp>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/LogStream.hpp>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <assimp/pbrmaterial.h>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
class utglTF2ImportExport : public AbstractImportExportBase {
|
||||
|
@ -541,3 +543,34 @@ TEST_F(utglTF2ImportExport, norootnode_issue_3269) {
|
|||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/issue_3269/texcoord_crash.gltf", aiProcess_ValidateDataStructure);
|
||||
ASSERT_EQ(scene, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, indexOutOfRange) {
|
||||
// The contents of an asset should not lead to an assert.
|
||||
Assimp::Importer importer;
|
||||
|
||||
struct LogObserver : Assimp::LogStream {
|
||||
bool m_observedWarning = false;
|
||||
void write(const char *message) override {
|
||||
m_observedWarning = m_observedWarning || std::strstr(message, "faces were dropped");
|
||||
}
|
||||
};
|
||||
LogObserver logObserver;
|
||||
|
||||
DefaultLogger::get()->attachStream(&logObserver);
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/IndexOutOfRange/IndexOutOfRange.gltf", aiProcess_ValidateDataStructure);
|
||||
ASSERT_NE(scene, nullptr);
|
||||
ASSERT_NE(scene->mRootNode, nullptr);
|
||||
ASSERT_EQ(scene->mNumMeshes, 1u);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 11u);
|
||||
DefaultLogger::get()->detachStream(&logObserver);
|
||||
EXPECT_TRUE(logObserver.m_observedWarning);
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, allIndicesOutOfRange) {
|
||||
// The contents of an asset should not lead to an assert.
|
||||
Assimp::Importer importer;
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/IndexOutOfRange/AllIndicesOutOfRange.gltf", aiProcess_ValidateDataStructure);
|
||||
ASSERT_EQ(scene, nullptr);
|
||||
std::string error = importer.GetErrorString();
|
||||
ASSERT_NE(error.find("Mesh \"Mesh\" has no faces"), std::string::npos);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue