Fix OBJ rendering in software renderers, and other things
Pass surf->vbStart to SetupFrame instead of 0, and pass 0 to DrawArrays instead of surf->vbStart. Use a potentially faster method of modifying the OBJ file text buffer by modifying it directly. Add RealignVector and FixUV methods to begin work on re-aligning OBJ models to the same orientation as MD3 models. Re-align OBJ models to match MD3 models Fix normal calculation for re-aligned OBJs Ensure AddSkins does not go out of bounds of surfaceskinIDs Do not precache skins that were replaced by the user. Fix OBJs with a large number of materials not being fully rendered Print a warning message if a material referenced by the OBJ could not be found. Free surface triangles once they are no longer needed Also, use continue instead of return so that surfaces after those with missing materials are still rendered. Fail if a face side has no vertex reference. Vertex references are required for a valid OBJ. Clean up OBJ model code Remove commented code, mainly Printf's that aren't used any more. Add more documentation comments, and tweak existing documentation comments Replace ParseVector2 and ParseVector3 with a template ParseVector function
This commit is contained in:
parent
bb8c66b3a0
commit
a38b0813cf
3 changed files with 162 additions and 80 deletions
|
|
@ -29,7 +29,6 @@
|
|||
class FOBJModel : public FModel
|
||||
{
|
||||
private:
|
||||
int mLumpNum;
|
||||
const char *newSideSep = "$"; // OBJ side separator is /, which is parsed as a line comment by FScanner if two of them are next to each other.
|
||||
|
||||
enum class FaceElement
|
||||
|
|
@ -47,7 +46,7 @@ private:
|
|||
};
|
||||
struct OBJFace
|
||||
{
|
||||
int sideCount;
|
||||
unsigned int sideCount;
|
||||
OBJFaceSide sides[4];
|
||||
};
|
||||
struct OBJSurface // 1 surface per 'usemtl'
|
||||
|
|
@ -68,12 +67,13 @@ private:
|
|||
TArray<OBJSurface> surfaces;
|
||||
FScanner sc;
|
||||
|
||||
void ParseVector2(TArray<FVector2> &array);
|
||||
void ParseVector3(TArray<FVector3> &array);
|
||||
void ParseFaceSide(const FString &side, OBJFace &face, int sidx);
|
||||
template<typename T, size_t L> void ParseVector(TArray<T> &array);
|
||||
bool ParseFaceSide(const FString &side, OBJFace &face, int sidx);
|
||||
void ConstructSurfaceTris(OBJSurface &surf);
|
||||
int ResolveIndex(int origIndex, FaceElement el);
|
||||
void TriangulateQuad(const OBJFace &quad, OBJFace *tris);
|
||||
FVector3 RealignVector(FVector3 vecToRealign);
|
||||
FVector2 FixUV(FVector2 vecToRealign);
|
||||
public:
|
||||
FOBJModel() {}
|
||||
~FOBJModel();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue