Merge pull request #2081 from aavenel/Fix2077
Fix #2077 - add a lot of unit-tests for gltf2 importerpull/2083/head^2
commit
cc1221240a
|
@ -117,13 +117,9 @@ bool glTF2Importer::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool
|
|||
|
||||
if (pIOHandler) {
|
||||
glTF2::Asset asset(pIOHandler);
|
||||
try {
|
||||
asset.Load(pFile, extension == "glb");
|
||||
std::string version = asset.asset.version;
|
||||
return !version.empty() && version[0] == '2';
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -550,9 +546,18 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r)
|
|||
case PrimitiveMode_TRIANGLE_STRIP: {
|
||||
nFaces = count - 2;
|
||||
faces = new aiFace[nFaces];
|
||||
SetFace(faces[0], data.GetUInt(0), data.GetUInt(1), data.GetUInt(2));
|
||||
for (unsigned int i = 3; i < count; ++i) {
|
||||
SetFace(faces[i - 2], faces[i - 1].mIndices[1], faces[i - 1].mIndices[2], data.GetUInt(i));
|
||||
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));
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -560,8 +565,8 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r)
|
|||
nFaces = count - 2;
|
||||
faces = new aiFace[nFaces];
|
||||
SetFace(faces[0], data.GetUInt(0), data.GetUInt(1), data.GetUInt(2));
|
||||
for (unsigned int i = 3; i < count; ++i) {
|
||||
SetFace(faces[i - 2], faces[0].mIndices[0], faces[i - 1].mIndices[2], data.GetUInt(i));
|
||||
for (unsigned int i = 1; i < nFaces; ++i) {
|
||||
SetFace(faces[i], faces[0].mIndices[0], faces[i - 1].mIndices[2], data.GetUInt(i + 2));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -615,9 +620,18 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r)
|
|||
case PrimitiveMode_TRIANGLE_STRIP: {
|
||||
nFaces = count - 2;
|
||||
faces = new aiFace[nFaces];
|
||||
SetFace(faces[0], 0, 1, 2);
|
||||
for (unsigned int i = 3; i < count; ++i) {
|
||||
SetFace(faces[i - 2], faces[i - 1].mIndices[1], faces[i - 1].mIndices[2], i);
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
//For odd n, vertices n, n+1, and n+2 define triangle n
|
||||
SetFace(faces[i], i, i+1, i+2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -625,8 +639,8 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r)
|
|||
nFaces = count - 2;
|
||||
faces = new aiFace[nFaces];
|
||||
SetFace(faces[0], 0, 1, 2);
|
||||
for (unsigned int i = 3; i < count; ++i) {
|
||||
SetFace(faces[i - 2], faces[0].mIndices[0], faces[i - 1].mIndices[2], i);
|
||||
for (unsigned int i = 1; i < nFaces; ++i) {
|
||||
SetFace(faces[i], faces[0].mIndices[0], faces[i - 1].mIndices[2], i + 2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -848,12 +862,6 @@ void glTF2Importer::InternReadFile(const std::string& pFile, aiScene* pScene, IO
|
|||
|
||||
ImportNodes(asset);
|
||||
|
||||
// TODO: it does not split the loaded vertices, should it?
|
||||
//pScene->mFlags |= AI_SCENE_FLAGS_NON_VERBOSE_FORMAT;
|
||||
MakeVerboseFormatProcess process;
|
||||
process.Execute(pScene);
|
||||
|
||||
|
||||
if (pScene->mNumMeshes == 0) {
|
||||
pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
|
||||
}
|
||||
|
|
|
@ -740,11 +740,6 @@ void glTFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOS
|
|||
|
||||
ImportNodes(asset);
|
||||
|
||||
// TODO: it does not split the loaded vertices, should it?
|
||||
//pScene->mFlags |= AI_SCENE_FLAGS_NON_VERBOSE_FORMAT;
|
||||
MakeVerboseFormatProcess process;
|
||||
process.Execute(pScene);
|
||||
|
||||
|
||||
if (pScene->mNumMeshes == 0) {
|
||||
pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Gary Hsu
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
Binary file not shown.
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"componentType": 5126,
|
||||
"count": 1024,
|
||||
"type": "VEC3",
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
0.0
|
||||
],
|
||||
"name": "Positions Accessor"
|
||||
}
|
||||
],
|
||||
"asset": {
|
||||
"generator": "glTF Asset Generator",
|
||||
"version": "2.0"
|
||||
},
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "Mesh_PrimitiveMode_00.bin",
|
||||
"byteLength": 12288
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteLength": 12288,
|
||||
"name": "Positions"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"POSITION": 0
|
||||
},
|
||||
"mode": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"componentType": 5126,
|
||||
"count": 8,
|
||||
"type": "VEC3",
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
0.0
|
||||
],
|
||||
"name": "Positions Accessor"
|
||||
}
|
||||
],
|
||||
"asset": {
|
||||
"generator": "glTF Asset Generator",
|
||||
"version": "2.0"
|
||||
},
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "Mesh_PrimitiveMode_01.bin",
|
||||
"byteLength": 96
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteLength": 96,
|
||||
"name": "Positions"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"POSITION": 0
|
||||
},
|
||||
"mode": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"componentType": 5126,
|
||||
"count": 4,
|
||||
"type": "VEC3",
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
0.0
|
||||
],
|
||||
"name": "Positions Accessor"
|
||||
}
|
||||
],
|
||||
"asset": {
|
||||
"generator": "glTF Asset Generator",
|
||||
"version": "2.0"
|
||||
},
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "Mesh_PrimitiveMode_02.bin",
|
||||
"byteLength": 48
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteLength": 48,
|
||||
"name": "Positions"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"POSITION": 0
|
||||
},
|
||||
"mode": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"componentType": 5126,
|
||||
"count": 5,
|
||||
"type": "VEC3",
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
0.0
|
||||
],
|
||||
"name": "Positions Accessor"
|
||||
}
|
||||
],
|
||||
"asset": {
|
||||
"generator": "glTF Asset Generator",
|
||||
"version": "2.0"
|
||||
},
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "Mesh_PrimitiveMode_03.bin",
|
||||
"byteLength": 60
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteLength": 60,
|
||||
"name": "Positions"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"POSITION": 0
|
||||
},
|
||||
"mode": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"componentType": 5126,
|
||||
"count": 4,
|
||||
"type": "VEC3",
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
0.0
|
||||
],
|
||||
"name": "Positions Accessor"
|
||||
}
|
||||
],
|
||||
"asset": {
|
||||
"generator": "glTF Asset Generator",
|
||||
"version": "2.0"
|
||||
},
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "Mesh_PrimitiveMode_04.bin",
|
||||
"byteLength": 48
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteLength": 48,
|
||||
"name": "Positions"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"POSITION": 0
|
||||
},
|
||||
"mode": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"componentType": 5126,
|
||||
"count": 4,
|
||||
"type": "VEC3",
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
0.0
|
||||
],
|
||||
"name": "Positions Accessor"
|
||||
}
|
||||
],
|
||||
"asset": {
|
||||
"generator": "glTF Asset Generator",
|
||||
"version": "2.0"
|
||||
},
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "Mesh_PrimitiveMode_05.bin",
|
||||
"byteLength": 48
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteLength": 48,
|
||||
"name": "Positions"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"POSITION": 0
|
||||
},
|
||||
"mode": 6
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"componentType": 5126,
|
||||
"count": 6,
|
||||
"type": "VEC3",
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
0.0
|
||||
],
|
||||
"name": "Positions Accessor"
|
||||
}
|
||||
],
|
||||
"asset": {
|
||||
"generator": "glTF Asset Generator",
|
||||
"version": "2.0"
|
||||
},
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "Mesh_PrimitiveMode_06.bin",
|
||||
"byteLength": 72
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteLength": 72,
|
||||
"name": "Positions"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"POSITION": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,77 @@
|
|||
{
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"componentType": 5126,
|
||||
"count": 1024,
|
||||
"type": "VEC3",
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
0.0
|
||||
],
|
||||
"name": "Positions Accessor"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"componentType": 5125,
|
||||
"count": 1024,
|
||||
"type": "SCALAR",
|
||||
"name": "Indices Accessor"
|
||||
}
|
||||
],
|
||||
"asset": {
|
||||
"generator": "glTF Asset Generator",
|
||||
"version": "2.0"
|
||||
},
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "Mesh_PrimitiveMode_07.bin",
|
||||
"byteLength": 16384
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteLength": 12288,
|
||||
"name": "Positions"
|
||||
},
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 12288,
|
||||
"byteLength": 4096,
|
||||
"name": "Indices"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"POSITION": 0
|
||||
},
|
||||
"indices": 1,
|
||||
"mode": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,77 @@
|
|||
{
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"componentType": 5126,
|
||||
"count": 4,
|
||||
"type": "VEC3",
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
0.0
|
||||
],
|
||||
"name": "Positions Accessor"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"componentType": 5125,
|
||||
"count": 8,
|
||||
"type": "SCALAR",
|
||||
"name": "Indices Accessor"
|
||||
}
|
||||
],
|
||||
"asset": {
|
||||
"generator": "glTF Asset Generator",
|
||||
"version": "2.0"
|
||||
},
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "Mesh_PrimitiveMode_08.bin",
|
||||
"byteLength": 80
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteLength": 48,
|
||||
"name": "Positions"
|
||||
},
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 48,
|
||||
"byteLength": 32,
|
||||
"name": "Indices"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"POSITION": 0
|
||||
},
|
||||
"indices": 1,
|
||||
"mode": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,77 @@
|
|||
{
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"componentType": 5126,
|
||||
"count": 4,
|
||||
"type": "VEC3",
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
0.0
|
||||
],
|
||||
"name": "Positions Accessor"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"componentType": 5125,
|
||||
"count": 4,
|
||||
"type": "SCALAR",
|
||||
"name": "Indices Accessor"
|
||||
}
|
||||
],
|
||||
"asset": {
|
||||
"generator": "glTF Asset Generator",
|
||||
"version": "2.0"
|
||||
},
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "Mesh_PrimitiveMode_09.bin",
|
||||
"byteLength": 64
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteLength": 48,
|
||||
"name": "Positions"
|
||||
},
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 48,
|
||||
"byteLength": 16,
|
||||
"name": "Indices"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"POSITION": 0
|
||||
},
|
||||
"indices": 1,
|
||||
"mode": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,77 @@
|
|||
{
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"componentType": 5126,
|
||||
"count": 4,
|
||||
"type": "VEC3",
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
0.0
|
||||
],
|
||||
"name": "Positions Accessor"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"componentType": 5125,
|
||||
"count": 5,
|
||||
"type": "SCALAR",
|
||||
"name": "Indices Accessor"
|
||||
}
|
||||
],
|
||||
"asset": {
|
||||
"generator": "glTF Asset Generator",
|
||||
"version": "2.0"
|
||||
},
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "Mesh_PrimitiveMode_10.bin",
|
||||
"byteLength": 68
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteLength": 48,
|
||||
"name": "Positions"
|
||||
},
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 48,
|
||||
"byteLength": 20,
|
||||
"name": "Indices"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"POSITION": 0
|
||||
},
|
||||
"indices": 1,
|
||||
"mode": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,77 @@
|
|||
{
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"componentType": 5126,
|
||||
"count": 4,
|
||||
"type": "VEC3",
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
0.0
|
||||
],
|
||||
"name": "Positions Accessor"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"componentType": 5125,
|
||||
"count": 4,
|
||||
"type": "SCALAR",
|
||||
"name": "Indices Accessor"
|
||||
}
|
||||
],
|
||||
"asset": {
|
||||
"generator": "glTF Asset Generator",
|
||||
"version": "2.0"
|
||||
},
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "Mesh_PrimitiveMode_11.bin",
|
||||
"byteLength": 64
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteLength": 48,
|
||||
"name": "Positions"
|
||||
},
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 48,
|
||||
"byteLength": 16,
|
||||
"name": "Indices"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"POSITION": 0
|
||||
},
|
||||
"indices": 1,
|
||||
"mode": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,77 @@
|
|||
{
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"componentType": 5126,
|
||||
"count": 4,
|
||||
"type": "VEC3",
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
0.0
|
||||
],
|
||||
"name": "Positions Accessor"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"componentType": 5125,
|
||||
"count": 4,
|
||||
"type": "SCALAR",
|
||||
"name": "Indices Accessor"
|
||||
}
|
||||
],
|
||||
"asset": {
|
||||
"generator": "glTF Asset Generator",
|
||||
"version": "2.0"
|
||||
},
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "Mesh_PrimitiveMode_12.bin",
|
||||
"byteLength": 64
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteLength": 48,
|
||||
"name": "Positions"
|
||||
},
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 48,
|
||||
"byteLength": 16,
|
||||
"name": "Indices"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"POSITION": 0
|
||||
},
|
||||
"indices": 1,
|
||||
"mode": 6
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,76 @@
|
|||
{
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"componentType": 5126,
|
||||
"count": 4,
|
||||
"type": "VEC3",
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
0.0
|
||||
],
|
||||
"name": "Positions Accessor"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"componentType": 5125,
|
||||
"count": 6,
|
||||
"type": "SCALAR",
|
||||
"name": "Indices Accessor"
|
||||
}
|
||||
],
|
||||
"asset": {
|
||||
"generator": "glTF Asset Generator",
|
||||
"version": "2.0"
|
||||
},
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "Mesh_PrimitiveMode_13.bin",
|
||||
"byteLength": 72
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteLength": 48,
|
||||
"name": "Positions"
|
||||
},
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 48,
|
||||
"byteLength": 24,
|
||||
"name": "Indices"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"POSITION": 0
|
||||
},
|
||||
"indices": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,76 @@
|
|||
{
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"componentType": 5126,
|
||||
"count": 4,
|
||||
"type": "VEC3",
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
0.0
|
||||
],
|
||||
"name": "Positions Accessor"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"componentType": 5121,
|
||||
"count": 6,
|
||||
"type": "SCALAR",
|
||||
"name": "Indices Accessor"
|
||||
}
|
||||
],
|
||||
"asset": {
|
||||
"generator": "glTF Asset Generator",
|
||||
"version": "2.0"
|
||||
},
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "Mesh_PrimitiveMode_14.bin",
|
||||
"byteLength": 54
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteLength": 48,
|
||||
"name": "Positions"
|
||||
},
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 48,
|
||||
"byteLength": 6,
|
||||
"name": "Indices"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"POSITION": 0
|
||||
},
|
||||
"indices": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,76 @@
|
|||
{
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"componentType": 5126,
|
||||
"count": 4,
|
||||
"type": "VEC3",
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.0
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
0.0
|
||||
],
|
||||
"name": "Positions Accessor"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"componentType": 5123,
|
||||
"count": 6,
|
||||
"type": "SCALAR",
|
||||
"name": "Indices Accessor"
|
||||
}
|
||||
],
|
||||
"asset": {
|
||||
"generator": "glTF Asset Generator",
|
||||
"version": "2.0"
|
||||
},
|
||||
"buffers": [
|
||||
{
|
||||
"uri": "Mesh_PrimitiveMode_15.bin",
|
||||
"byteLength": 60
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteLength": 48,
|
||||
"name": "Positions"
|
||||
},
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 48,
|
||||
"byteLength": 12,
|
||||
"name": "Indices"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"POSITION": 0
|
||||
},
|
||||
"indices": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
These models are intended to test indices, vertexes without indices, and using mode to render different primitive types.
|
||||
|
||||
All values of Byte, Short, and Int are unsigned.
|
||||
|
||||
All model indices relate to vertices as shown by the Indices figure below, except for models using Points Mode:
|
||||
|
||||
| Indices | Indices (For Points Mode) |
|
||||
| :---: | :---: |
|
||||
| <img src="Figures/Indices.png" height="144" width="144" align="middle"> | <img src="Figures/Indices_Points.png" height="144" width="144" align="middle"> |
|
||||
|
||||
<br>
|
||||
|
||||
The following table shows the properties that are set for a given model.
|
||||
|
||||
| | Sample Image | Mode | Indices Values | Indices Component Type |
|
||||
| :---: | :---: | :---: | :---: | :---: |
|
||||
| [00](Mesh_PrimitiveMode_00.gltf)<br>[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=0) | [<img src="Figures/Thumbnails/Mesh_PrimitiveMode_00.png" align="middle">](Figures/SampleImages/Mesh_PrimitiveMode_00.png) | Points | | |
|
||||
| [01](Mesh_PrimitiveMode_01.gltf)<br>[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=1) | [<img src="Figures/Thumbnails/Mesh_PrimitiveMode_01.png" align="middle">](Figures/SampleImages/Mesh_PrimitiveMode_01.png) | Lines | | |
|
||||
| [02](Mesh_PrimitiveMode_02.gltf)<br>[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=2) | [<img src="Figures/Thumbnails/Mesh_PrimitiveMode_02.png" align="middle">](Figures/SampleImages/Mesh_PrimitiveMode_02.png) | Line Loop | | |
|
||||
| [03](Mesh_PrimitiveMode_03.gltf)<br>[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=3) | [<img src="Figures/Thumbnails/Mesh_PrimitiveMode_03.png" align="middle">](Figures/SampleImages/Mesh_PrimitiveMode_03.png) | Line Strip | | |
|
||||
| [04](Mesh_PrimitiveMode_04.gltf)<br>[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=4) | [<img src="Figures/Thumbnails/Mesh_PrimitiveMode_04.png" align="middle">](Figures/SampleImages/Mesh_PrimitiveMode_04.png) | Triangle Strip | | |
|
||||
| [05](Mesh_PrimitiveMode_05.gltf)<br>[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=5) | [<img src="Figures/Thumbnails/Mesh_PrimitiveMode_05.png" align="middle">](Figures/SampleImages/Mesh_PrimitiveMode_05.png) | Triangle Fan | | |
|
||||
| [06](Mesh_PrimitiveMode_06.gltf)<br>[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=6) | [<img src="Figures/Thumbnails/Mesh_PrimitiveMode_06.png" align="middle">](Figures/SampleImages/Mesh_PrimitiveMode_06.png) | Triangles | | |
|
||||
| [07](Mesh_PrimitiveMode_07.gltf)<br>[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=7) | [<img src="Figures/Thumbnails/Mesh_PrimitiveMode_07.png" align="middle">](Figures/SampleImages/Mesh_PrimitiveMode_07.png) | Points | [0 - 1023] | Int |
|
||||
| [08](Mesh_PrimitiveMode_08.gltf)<br>[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=8) | [<img src="Figures/Thumbnails/Mesh_PrimitiveMode_08.png" align="middle">](Figures/SampleImages/Mesh_PrimitiveMode_08.png) | Lines | [0, 3, 3, 2, 2, 1, 1, 0] | Int |
|
||||
| [09](Mesh_PrimitiveMode_09.gltf)<br>[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=9) | [<img src="Figures/Thumbnails/Mesh_PrimitiveMode_09.png" align="middle">](Figures/SampleImages/Mesh_PrimitiveMode_09.png) | Line Loop | [0, 3, 2, 1] | Int |
|
||||
| [10](Mesh_PrimitiveMode_10.gltf)<br>[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=10) | [<img src="Figures/Thumbnails/Mesh_PrimitiveMode_10.png" align="middle">](Figures/SampleImages/Mesh_PrimitiveMode_10.png) | Line Strip | [0, 3, 2, 1, 0] | Int |
|
||||
| [11](Mesh_PrimitiveMode_11.gltf)<br>[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=11) | [<img src="Figures/Thumbnails/Mesh_PrimitiveMode_11.png" align="middle">](Figures/SampleImages/Mesh_PrimitiveMode_11.png) | Triangle Strip | [0, 3, 1, 2] | Int |
|
||||
| [12](Mesh_PrimitiveMode_12.gltf)<br>[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=12) | [<img src="Figures/Thumbnails/Mesh_PrimitiveMode_12.png" align="middle">](Figures/SampleImages/Mesh_PrimitiveMode_12.png) | Triangle Fan | [0, 3, 2, 1] | Int |
|
||||
| [13](Mesh_PrimitiveMode_13.gltf)<br>[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=13) | [<img src="Figures/Thumbnails/Mesh_PrimitiveMode_13.png" align="middle">](Figures/SampleImages/Mesh_PrimitiveMode_13.png) | Triangles | [1, 0, 3, 1, 3, 2] | Int |
|
||||
| [14](Mesh_PrimitiveMode_14.gltf)<br>[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=14) | [<img src="Figures/Thumbnails/Mesh_PrimitiveMode_14.png" align="middle">](Figures/SampleImages/Mesh_PrimitiveMode_14.png) | Triangles | [1, 0, 3, 1, 3, 2] | Byte |
|
||||
| [15](Mesh_PrimitiveMode_15.gltf)<br>[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=12&model=15) | [<img src="Figures/Thumbnails/Mesh_PrimitiveMode_15.png" align="middle">](Figures/SampleImages/Mesh_PrimitiveMode_15.png) | Triangles | [1, 0, 3, 1, 3, 2] | Short |
|
||||
|
|
@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/Exporter.hpp>
|
||||
#include <assimp/postprocess.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <array>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
@ -100,6 +101,234 @@ TEST_F( utglTF2ImportExport, importBinaryglTF2FromFileTest ) {
|
|||
EXPECT_TRUE( binaryImporterTest() );
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModePointsWithoutIndices) {
|
||||
Assimp::Importer importer;
|
||||
//Points without indices
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_00.gltf", aiProcess_ValidateDataStructure);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 1024);
|
||||
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 1);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], i);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLinesWithoutIndices) {
|
||||
Assimp::Importer importer;
|
||||
//Lines without indices
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_01.gltf", aiProcess_ValidateDataStructure);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 8);
|
||||
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 2);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], i*2);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], i*2 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLinesLoopWithoutIndices) {
|
||||
Assimp::Importer importer;
|
||||
//Lines loop without indices
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_02.gltf", aiProcess_ValidateDataStructure);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4);
|
||||
|
||||
std::array<int, 5> l1 = {{ 0, 1, 2, 3, 0 }};
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2);
|
||||
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 2);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLinesStripWithoutIndices) {
|
||||
Assimp::Importer importer;
|
||||
//Lines strip without indices
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_03.gltf", aiProcess_ValidateDataStructure);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 5);
|
||||
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2);
|
||||
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 2);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], i);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesStripWithoutIndices) {
|
||||
Assimp::Importer importer;
|
||||
//Triangles strip without indices
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_04.gltf", aiProcess_ValidateDataStructure);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4);
|
||||
std::array<int, 3> f1 = {{ 0, 1, 2 }};
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
|
||||
}
|
||||
|
||||
std::array<int, 3> f2 = {{ 2, 1, 3 }};
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesFanWithoutIndices) {
|
||||
Assimp::Importer importer;
|
||||
//Triangles fan without indices
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_05.gltf", aiProcess_ValidateDataStructure);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4);
|
||||
std::array<int, 3> f1 = {{ 0, 1, 2 }};
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
|
||||
}
|
||||
|
||||
std::array<int, 3> f2 = {{ 0, 2, 3 }};
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesWithoutIndices) {
|
||||
Assimp::Importer importer;
|
||||
//Triangles without indices
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_06.gltf", aiProcess_ValidateDataStructure);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 6);
|
||||
std::array<int, 3> f1 = {{ 0, 1, 2 }};
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
|
||||
}
|
||||
|
||||
std::array<int, 3> f2 = {{ 3, 4, 5 }};
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModePoints) {
|
||||
Assimp::Importer importer;
|
||||
//Line loop
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_07.gltf", aiProcess_ValidateDataStructure);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 1024);
|
||||
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 1);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], i);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLines) {
|
||||
Assimp::Importer importer;
|
||||
//Lines
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.gltf", aiProcess_ValidateDataStructure);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4);
|
||||
std::array<int, 5> l1 = {{ 0, 3, 2, 1, 0 }};
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2);
|
||||
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineLoop) {
|
||||
Assimp::Importer importer;
|
||||
//Line loop
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_09.gltf", aiProcess_ValidateDataStructure);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4);
|
||||
std::array<int, 5> l1 = {{ 0, 3, 2, 1, 0 }};
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2);
|
||||
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i+1]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineStrip) {
|
||||
Assimp::Importer importer;
|
||||
//Lines Strip
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_10.gltf", aiProcess_ValidateDataStructure);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4);
|
||||
std::array<int, 5> l1 = {{ 0, 3, 2, 1, 0 }};
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2);
|
||||
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesStrip) {
|
||||
Assimp::Importer importer;
|
||||
//Triangles strip
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_11.gltf", aiProcess_ValidateDataStructure);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4);
|
||||
std::array<int, 3> f1 = {{ 0, 3, 1 }};
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
|
||||
}
|
||||
|
||||
std::array<int, 3> f2 = {{ 1, 3, 2 }};
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesFan) {
|
||||
Assimp::Importer importer;
|
||||
//Triangles fan
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_12.gltf", aiProcess_ValidateDataStructure);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2);
|
||||
std::array<int, 3> f1 = {{ 0, 3, 2 }};
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
|
||||
}
|
||||
|
||||
std::array<int, 3> f2 = {{ 0, 2, 1 }};
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
TEST_F( utglTF2ImportExport, exportglTF2FromFileTest ) {
|
||||
EXPECT_TRUE( exporterTest() );
|
||||
|
|
Loading…
Reference in New Issue