|
From: <axl...@us...> - 2008-12-31 20:17:34
|
Revision: 129
http://hgengine.svn.sourceforge.net/hgengine/?rev=129&view=rev
Author: axlecrusher
Date: 2008-12-31 20:17:29 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
fake normals if they don't exist
Modified Paths:
--------------
Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp
Modified: Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp
===================================================================
--- Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp 2008-12-31 20:15:14 UTC (rev 128)
+++ Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp 2008-12-31 20:17:29 UTC (rev 129)
@@ -46,6 +46,7 @@
*/
void LineParser(const string &line)
{
+ if (line.empty()) return;
string token = line.substr(0,2);
if (token == "v ")
{
@@ -57,6 +58,7 @@
{
MercuryPoint tv;
sscanf(line.c_str(), "vt %f %f", &tv.x, &tv.y);
+ tv.y = 1 - tv.y; //XXX reverse
vt.push_back(tv);
}
else if (token == "vn")
@@ -68,8 +70,18 @@
else if (token == "f ")
{
uint32_t iv[3], ivt[3], ivn[3];
- sscanf(line.c_str(), "f %d/%d/%d %d/%d/%d %d/%d/%d", &iv[0], &ivt[0], &ivn[0], &iv[1], &ivt[1], &ivn[1], &iv[2], &ivt[2], &ivn[2]);
+ int r;
+ r = sscanf(line.c_str(), "f %d/%d/%d %d/%d/%d %d/%d/%d", &iv[0], &ivt[0], &ivn[0], &iv[1], &ivt[1], &ivn[1], &iv[2], &ivt[2], &ivn[2]);
+
+ if (r != 9)
+ {
+ r = sscanf(line.c_str(), "f %d/%d %d/%d %d/%d", &iv[0], &ivt[0], &iv[1], &ivt[1], &iv[2], &ivt[2]);
+ ivn[0] = ivn[1] = ivn[2] = 1;
+ MercuryPoint tv;
+ vn.push_back(tv);
+ }
+
Vertex tv[3];
for (int i=0; i < 3; ++i)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|