diff --git a/ReflexToQ3/libraries.h b/ReflexToQ3/libraries.h index 1c87177..8689217 100644 --- a/ReflexToQ3/libraries.h +++ b/ReflexToQ3/libraries.h @@ -14,6 +14,7 @@ #endif // Platform Libraries +#define NOMINMAX #define WIN32_LEAN_AND_MEAN #include diff --git a/ReflexToQ3/main.cpp b/ReflexToQ3/main.cpp index ee45449..b2c5146 100644 --- a/ReflexToQ3/main.cpp +++ b/ReflexToQ3/main.cpp @@ -32,11 +32,17 @@ TPlanePoints GetPlanePoints(const TVector3f* _kpPoints, const size_t _kNumPoints } const TVector3f kCenter = ScalarMultiply(TVector3f(), Temp, (1.0f / (float)_kNumPoints)); + float fWidth = 1.0f; + for(size_t i = 0; i < _kNumPoints; ++i) + { + fWidth = std::max(fWidth, VectorMagnitude(Subtract(TVector3f(), _kpPoints[i], kCenter))); + } + // Find Tangent - const TVector3f kTangent = ScalarMultiply(TVector3f(), Normalize(TVector3f(), Subtract(TVector3f(), _kpPoints[1], _kpPoints[0])), 8192.0f); + const TVector3f kTangent = ScalarMultiply(TVector3f(), Normalize(TVector3f(), Subtract(TVector3f(), _kpPoints[1], _kpPoints[0])), fWidth); // Find BiTangent - const TVector3f kBiTangent = ScalarMultiply(TVector3f(), Normalize(TVector3f(), CrossProduct(TVector3f(), kNormal, kTangent)), 8192.0f); + const TVector3f kBiTangent = ScalarMultiply(TVector3f(), Normalize(TVector3f(), CrossProduct(TVector3f(), kNormal, kTangent)), fWidth); PlanePoints.m_A = Add(TVector3f(), kCenter, kBiTangent); PlanePoints.m_B = kCenter; diff --git a/ReflexToQ3/mapparser.cpp b/ReflexToQ3/mapparser.cpp index da18d8d..6239239 100644 --- a/ReflexToQ3/mapparser.cpp +++ b/ReflexToQ3/mapparser.cpp @@ -140,7 +140,7 @@ EParserState CMapParser::ParseBrush(const std::string _Line) EParserState CMapParser::ParseVertex(const std::string _Line) { - const size_t kszLineSize = 256; + const size_t kszLineSize = 2048; char pcLine[kszLineSize]; const char* kpcDelim = " \t"; char* pcToken; @@ -184,7 +184,7 @@ EParserState CMapParser::ParseVertex(const std::string _Line) EParserState CMapParser::ParseFace(const std::string _Line) { - const size_t kszLineSize = 256; + const size_t kszLineSize = 2048; char pcLine[kszLineSize]; const char* kpcDelim = " \t"; char* pcToken; @@ -195,6 +195,8 @@ EParserState CMapParser::ParseFace(const std::string _Line) int iTokenNum = 0; + std::string material; + std::vector Indices; while(pcToken != nullptr) { @@ -209,7 +211,7 @@ EParserState CMapParser::ParseFace(const std::string _Line) return(PARSERSTATE_BRUSH); } } - else if(iTokenNum < 9) + else { if(std::isdigit(pcToken[0], std::locale()) || pcToken[0] == '-') { @@ -218,7 +220,7 @@ EParserState CMapParser::ParseFace(const std::string _Line) } else { - return(PARSERSTATE_BRUSH); + material = pcToken; } } @@ -228,6 +230,7 @@ EParserState CMapParser::ParseFace(const std::string _Line) TFace Face; Face.m_Indices = Indices; + Face.m_Material = material; this->m_WorldSpawn.m_Brushes[this->m_WorldSpawn.m_Brushes.size()-1].m_Faces.push_back(Face); return(PARSERSTATE_FACE); } \ No newline at end of file