Merge branch 'master' into obj-pbr-explicit
commit
aa814a522d
|
@ -284,7 +284,7 @@ static aiMaterial *ImportMaterial(std::vector<int> &embeddedTexIdxs, Asset &r, M
|
|||
aimat->AddProperty(&alphaMode, AI_MATKEY_GLTF_ALPHAMODE);
|
||||
aimat->AddProperty(&mat.alphaCutoff, 1, AI_MATKEY_GLTF_ALPHACUTOFF);
|
||||
|
||||
//pbrSpecularGlossiness
|
||||
// pbrSpecularGlossiness
|
||||
if (mat.pbrSpecularGlossiness.isPresent) {
|
||||
PbrSpecularGlossiness &pbrSG = mat.pbrSpecularGlossiness.value;
|
||||
|
||||
|
@ -606,7 +606,10 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
|||
}
|
||||
}
|
||||
if (needTangents) {
|
||||
if (target.tangent[0]->count != aim->mNumVertices) {
|
||||
if (!aiAnimMesh.HasNormals()) {
|
||||
// prevent nullptr access to aiAnimMesh.mNormals below when no normals are available
|
||||
ASSIMP_LOG_WARN("Bitangents of target ", i, " in mesh \"", mesh.name, "\" can't be computed, because mesh has no normals.");
|
||||
} else if (target.tangent[0]->count != aim->mNumVertices) {
|
||||
ASSIMP_LOG_WARN("Tangents of target ", i, " in mesh \"", mesh.name, "\" does not match the vertex count");
|
||||
} else {
|
||||
Tangent *tangent = nullptr;
|
||||
|
@ -698,12 +701,12 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
|||
nFaces = count - 2;
|
||||
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
|
||||
// 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
|
||||
// For even n, vertices n + 1, n, and n + 2 define triangle n
|
||||
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
|
||||
// For odd n, vertices n, n+1, and n+2 define triangle n
|
||||
SetFaceAndAdvance3(facePtr, aim->mNumVertices, data.GetUInt(i), data.GetUInt(i + 1), data.GetUInt(i + 2));
|
||||
}
|
||||
}
|
||||
|
@ -776,12 +779,12 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
|||
nFaces = count - 2;
|
||||
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
|
||||
// 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
|
||||
// For even n, vertices n + 1, n, and n + 2 define triangle n
|
||||
SetFaceAndAdvance3(facePtr, aim->mNumVertices, i + 1, i, i + 2);
|
||||
} else {
|
||||
//For odd n, vertices n, n+1, and n+2 define triangle n
|
||||
// For odd n, vertices n, n+1, and n+2 define triangle n
|
||||
SetFaceAndAdvance3(facePtr, aim->mNumVertices, i, i + 1, i + 2);
|
||||
}
|
||||
}
|
||||
|
@ -904,14 +907,14 @@ void glTF2Importer::ImportLights(glTF2::Asset &r) {
|
|||
ail->mAttenuationLinear = 0.0;
|
||||
ail->mAttenuationQuadratic = 0.0;
|
||||
} else {
|
||||
//in PBR attenuation is calculated using inverse square law which can be expressed
|
||||
//using assimps equation: 1/(att0 + att1 * d + att2 * d*d) with the following parameters
|
||||
//this is correct equation for the case when range (see
|
||||
//https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual)
|
||||
//is not present. When range is not present it is assumed that it is infinite and so numerator is 1.
|
||||
//When range is present then numerator might be any value in range [0,1] and then assimps equation
|
||||
//will not suffice. In this case range is added into metadata in ImportNode function
|
||||
//and its up to implementation to read it when it wants to
|
||||
// in PBR attenuation is calculated using inverse square law which can be expressed
|
||||
// using assimps equation: 1/(att0 + att1 * d + att2 * d*d) with the following parameters
|
||||
// this is correct equation for the case when range (see
|
||||
// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual)
|
||||
// is not present. When range is not present it is assumed that it is infinite and so numerator is 1.
|
||||
// When range is present then numerator might be any value in range [0,1] and then assimps equation
|
||||
// will not suffice. In this case range is added into metadata in ImportNode function
|
||||
// and its up to implementation to read it when it wants to
|
||||
ail->mAttenuationConstant = 0.0;
|
||||
ail->mAttenuationLinear = 0.0;
|
||||
ail->mAttenuationQuadratic = 1.0;
|
||||
|
@ -1161,8 +1164,8 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector<unsigned int> &
|
|||
if (node.light) {
|
||||
pScene->mLights[node.light.GetIndex()]->mName = ainode->mName;
|
||||
|
||||
//range is optional - see https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
|
||||
//it is added to meta data of parent node, because there is no other place to put it
|
||||
// range is optional - see https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
|
||||
// it is added to meta data of parent node, because there is no other place to put it
|
||||
if (node.light->range.isPresent) {
|
||||
if (!ainode->mMetaData) {
|
||||
ainode->mMetaData = aiMetadata::Alloc(1);
|
||||
|
@ -1556,9 +1559,9 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) {
|
|||
if (ext) {
|
||||
if (strcmp(ext, "jpeg") == 0) {
|
||||
ext = "jpg";
|
||||
} else if (strcmp(ext, "ktx2") == 0) { //basisu: ktx remains
|
||||
} else if (strcmp(ext, "ktx2") == 0) { // basisu: ktx remains
|
||||
ext = "kx2";
|
||||
} else if (strcmp(ext, "basis") == 0) { //basisu
|
||||
} else if (strcmp(ext, "basis") == 0) { // basisu
|
||||
ext = "bu";
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
output
|
|
@ -1,28 +1,76 @@
|
|||
@echo off
|
||||
|
||||
set ASSIMP_PATH=D:\projects\asset-importer-lib\assimp
|
||||
set CMAKE_PATH="C:\Program Files\CMake\bin\cmake.exe"
|
||||
set ANDROID_NDK_PATH=C:\Users\kimkulling\AppData\Local\Android\Sdk\ndk-bundle
|
||||
set ANDROID_CMAKE_PATH=contrib\android-cmake
|
||||
set ANDROID_PLATFORM=21
|
||||
set /p ANDROID_PLATFORM="Enter Android platform - Enter to use %ANDROID_PLATFORM%: "
|
||||
|
||||
pushd %ASSIMP_PATH%
|
||||
set ANDROID_ABI=armeabi-v7a
|
||||
set /p ANDROID_ABI="Enter Android ABI ( armeabi-v7a, arm64-v8a , x86 , x86_64 ) - Enter to use %ANDROID_ABI% : "
|
||||
|
||||
rmdir /s /q build
|
||||
mkdir build
|
||||
cd build
|
||||
set COMMON_CXX_FLAGS=-DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fexceptions -frtti -stdlib=libc++
|
||||
set COMMON_C_FLAGS=-DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fexceptions
|
||||
|
||||
%CMAKE_PATH% .. ^
|
||||
-G"MinGW Makefiles" ^
|
||||
if %ANDROID_ABI% == armeabi-v7a (
|
||||
set CXX_FLAGS="%COMMON_CXX_FLAGS% -march=armv7-a -mthumb --target=armv7-none-linux-androideabi%ANDROID_PLATFORM%"
|
||||
set C_FLAGS="%COMMON_C_FLAGS% -march=armv7-a -mthumb --target=armv7-none-linux-androideabi%ANDROID_PLATFORM%"
|
||||
)
|
||||
if %ANDROID_ABI% == arm64-v8a (
|
||||
set CXX_FLAGS="%COMMON_CXX_FLAGS% -march=armv8-a --target=aarch64-none-linux-android%ANDROID_PLATFORM%"
|
||||
set C_FLAGS="%COMMON_C_FLAGS% -march=armv8-a --target=aarch64-none-linux-android%ANDROID_PLATFORM%"
|
||||
)
|
||||
if %ANDROID_ABI% == x86 (
|
||||
set CXX_FLAGS="%COMMON_CXX_FLAGS% --target=i686-none-linux-android%ANDROID_PLATFORM%"
|
||||
set C_FLAGS="%COMMON_C_FLAGS% --target=i686-none-linux-android%ANDROID_PLATFORM%"
|
||||
)
|
||||
if %ANDROID_ABI% == x86_64 (
|
||||
set CXX_FLAGS="%COMMON_CXX_FLAGS%"
|
||||
set C_FLAGS="%COMMON_C_FLAGS%"
|
||||
)
|
||||
|
||||
set CMAKE_PATH="%ProgramFiles%\CMake\bin\cmake.exe"
|
||||
if exist %CMAKE_PATH% (
|
||||
echo Found cmake at %CMAKE_PATH%
|
||||
) else (
|
||||
set /p CMAKE_PATH="Enter cmake.exe path: "
|
||||
)
|
||||
|
||||
set ANDROID_NDK_PATH=""
|
||||
FOR /F "tokens=* USEBACKQ" %%F IN (`dir "%LocalAppData%\Android\Sdk\ndk" /b /o:n /a:d`) DO (
|
||||
SET ANDROID_NDK_PATH="%LocalAppData%\Android\Sdk\ndk\%%F"
|
||||
)
|
||||
if exist %ANDROID_NDK_PATH% (
|
||||
echo Found NDK at %ANDROID_NDK_PATH%
|
||||
) else (
|
||||
set /p ANDROID_NDK_PATH="Enter ndk path: "
|
||||
)
|
||||
|
||||
set BUILD_FOLDER=build
|
||||
rmdir /s /q %BUILD_FOLDER%
|
||||
mkdir %BUILD_FOLDER%
|
||||
|
||||
%CMAKE_PATH% ^
|
||||
-G"Unix Makefiles" ^
|
||||
-DCMAKE_BUILD_TYPE=Release ^
|
||||
-DCMAKE_TOOLCHAIN_FILE=%ANDROID_CMAKE_PATH%\android.toolchain.cmake ^
|
||||
-DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK_PATH%\build\cmake\android.toolchain.cmake ^
|
||||
-DCMAKE_MAKE_PROGRAM=%ANDROID_NDK_PATH%\prebuilt\windows-x86_64\bin\make.exe ^
|
||||
-DANDROID_NDK=%ANDROID_NDK_PATH% ^
|
||||
-DANDROID_NATIVE_API_LEVEL=android-9 ^
|
||||
-DOPERATING_SYSTEM="Android" ^
|
||||
-DANDROID_PLATFORM=%ANDROID_PLATFORM% ^
|
||||
-DANDROID_ABI=%ANDROID_ABI% ^
|
||||
-DASSIMP_ANDROID_JNIIOSYSTEM=ON ^
|
||||
-DANDROID_ABI=arm64-v8a ^
|
||||
-DASSIMP_BUILD_ZLIB=ON ^
|
||||
-DASSIMP_BUILD_TESTS=OFF
|
||||
-DASSIMP_BUILD_TESTS=OFF ^
|
||||
-DCMAKE_CXX_FLAGS=%CXX_FLAGS% ^
|
||||
-DMAKE_C_FLAGS=%C_FLAGS% ^
|
||||
-S "..\.." ^
|
||||
-B ".\%BUILD_FOLDER%\"
|
||||
|
||||
%CMAKE_PATH% --build .
|
||||
%CMAKE_PATH% --build ".\%BUILD_FOLDER%\"" -- -j 4"
|
||||
|
||||
popd
|
||||
set OUTPUT_FOLDER=.\output\
|
||||
mkdir %OUTPUT_FOLDER%
|
||||
mkdir "%OUTPUT_FOLDER%\lib\%ANDROID_ABI%"
|
||||
|
||||
copy "%BUILD_FOLDER%\bin\libassimp.so" "%OUTPUT_FOLDER%\lib\%ANDROID_ABI%\"
|
||||
xcopy %BUILD_FOLDER%\include\assimp\ %OUTPUT_FOLDER%\include\assimp\ /y /s /e
|
||||
xcopy ..\..\include\assimp\ %OUTPUT_FOLDER%\include\assimp\ /y /s /e
|
||||
|
||||
rmdir /s /q %BUILD_FOLDER%
|
Loading…
Reference in New Issue