mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
Merge pull request #412 from Nodrev/master
Fixing geometryc for meshes exported without uv coordinates
This commit is contained in:
commit
54c5c6b428
1 changed files with 10 additions and 6 deletions
|
@ -510,8 +510,8 @@ int main(int _argc, const char* _argv[])
|
||||||
for (uint32_t edge = 0, numEdges = argc-1; edge < numEdges; ++edge)
|
for (uint32_t edge = 0, numEdges = argc-1; edge < numEdges; ++edge)
|
||||||
{
|
{
|
||||||
Index3 index;
|
Index3 index;
|
||||||
index.m_texcoord = 0;
|
index.m_texcoord = -1;
|
||||||
index.m_normal = 0;
|
index.m_normal = -1;
|
||||||
index.m_vertexIndex = -1;
|
index.m_vertexIndex = -1;
|
||||||
|
|
||||||
char* vertex = argv[edge+1];
|
char* vertex = argv[edge+1];
|
||||||
|
@ -528,9 +528,13 @@ int main(int _argc, const char* _argv[])
|
||||||
index.m_normal = (nn < 0) ? nn+numNormals : nn-1;
|
index.m_normal = (nn < 0) ? nn+numNormals : nn-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://en.wikipedia.org/wiki/Wavefront_.obj_file#Vertex_Normal_Indices_Without_Texture_Coordinate_Indices
|
||||||
|
if(*texcoord != '\0')
|
||||||
|
{
|
||||||
const int tex = atoi(texcoord);
|
const int tex = atoi(texcoord);
|
||||||
index.m_texcoord = (tex < 0) ? tex+numTexcoords : tex-1;
|
index.m_texcoord = (tex < 0) ? tex+numTexcoords : tex-1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const int pos = atoi(vertex);
|
const int pos = atoi(vertex);
|
||||||
index.m_position = (pos < 0) ? pos+numPositions : pos-1;
|
index.m_position = (pos < 0) ? pos+numPositions : pos-1;
|
||||||
|
@ -716,8 +720,8 @@ int main(int _argc, const char* _argv[])
|
||||||
bool hasTexcoord;
|
bool hasTexcoord;
|
||||||
{
|
{
|
||||||
Index3Map::const_iterator it = indexMap.begin();
|
Index3Map::const_iterator it = indexMap.begin();
|
||||||
hasNormal = 0 != it->second.m_normal;
|
hasNormal = -1 != it->second.m_normal;
|
||||||
hasTexcoord = 0 != it->second.m_texcoord;
|
hasTexcoord = -1 != it->second.m_texcoord;
|
||||||
|
|
||||||
if (!hasTexcoord
|
if (!hasTexcoord
|
||||||
&& texcoords.size() == positions.size() )
|
&& texcoords.size() == positions.size() )
|
||||||
|
|
Loading…
Reference in a new issue