optimized rendering, fixed dff
This commit is contained in:
@@ -23,30 +23,26 @@ public:
|
||||
~DffLoader();
|
||||
|
||||
void load(MeshFrame *o_result, char *t_fileName, float t_scale, u8 t_invertT);
|
||||
void serialize(RwClump &t_clump, u8 *t_data, float t_scale);
|
||||
|
||||
static u8 readByteFromArrayLE(u8 *t_buffer, u32 &t_ptrPos);
|
||||
static u16 readWordFromArrayLE(u8 *t_buffer, u32 &t_ptrPos);
|
||||
static u32 readDwordFromArrayLE(u8 *t_buffer, u32 &t_ptrPos);
|
||||
static float readFloatFromArrayLE(u8 *t_buffer, u32 &t_ptrPos);
|
||||
static u8 *readData(u8 *t_buffer, u32 &t_ptrPos, u32 t_dataSize);
|
||||
static char *readString(u8 *t_buffer, u32 &t_ptrPos, u32 t_dataSize = 0);
|
||||
|
||||
void readSectionHeader(RwSectionHeader &t_sh, u8 *t_buffer, u32 &t_ptrPos);
|
||||
void serialize(MeshFrame *o_result, u8 t_invertT, u8 *t_data, float t_scale);
|
||||
|
||||
private:
|
||||
void convert(MeshFrame *frames, RwClump &t_clump, u8 t_invertT);
|
||||
// ---
|
||||
void readFrameListData(RwFrameListData &t_frd, u8 *t_buffer, u32 &t_ptrPos);
|
||||
void readClumpData(RwClumpData &t_cd, u8 *t_buffer, u32 &t_ptrPos);
|
||||
void readGeometryListData(RwGeometryListData &t_gld, u8 *t_buffer, u32 &t_ptrPos);
|
||||
void readGeometryExtension(RwGeometryExtension &t_ge, u8 *t_buffer, u32 &t_ptrPos);
|
||||
void readGeometryData(RwGeometryData &t_gd, u8 *t_buffer, u32 &t_ptrPos, float t_scale);
|
||||
void readGeometryExtension(MeshFrame *o_frame, char **materialNames, u8 *t_buffer, u32 &t_ptrPos);
|
||||
void readGeometryData(MeshFrame *o_frame, u8 t_invertT, u8 *t_buffer, u32 &t_ptrPos, float t_scale);
|
||||
void readMaterialListData(RwMaterialListData &t_mld, u8 *t_buffer, u32 &t_ptrPos);
|
||||
void readMaterialData(RwMaterialData &t_md, u8 *t_buffer, u32 &t_ptrPos);
|
||||
void readTextureData(RwTextureData &t_td, u8 *t_buffer, u32 &t_ptrPos);
|
||||
void readStringData(RwString &t_s, u8 *bt_uffer, u32 &t_ptrPos);
|
||||
void readSectionHeader(RwSectionHeader &t_sh, u8 *t_buffer, u32 &t_ptrPos);
|
||||
// ---
|
||||
u8 readByteFromArrayLE(u8 *t_buffer, u32 &t_ptrPos);
|
||||
u16 readWordFromArrayLE(u8 *t_buffer, u32 &t_ptrPos);
|
||||
u32 readDwordFromArrayLE(u8 *t_buffer, u32 &t_ptrPos);
|
||||
float readFloatFromArrayLE(u8 *t_buffer, u32 &t_ptrPos);
|
||||
char *readString(u8 *t_buffer, u32 &t_ptrPos, u32 t_dataSize = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
class RwFrameListChunk
|
||||
{
|
||||
public:
|
||||
~RwFrameListChunk() { delete[] rotationalMatrix; }
|
||||
~RwFrameListChunk() {}
|
||||
float *rotationalMatrix; // [ROT_MAT_DIM]
|
||||
float coordinatesOffsetX;
|
||||
float coordinatesOffsetY;
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
class RwFrameListData : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
~RwFrameListData() { delete frameInformation; }
|
||||
~RwFrameListData() {}
|
||||
static const u32 ROT_MAT_DIM = 9;
|
||||
u32 frameCount;
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
class RwFrame : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
~RwFrame() { delete[] frameName; }
|
||||
~RwFrame() {}
|
||||
u8 *frameName; // [sectionSize] - should be interpreted as string
|
||||
};
|
||||
|
||||
@@ -74,7 +74,7 @@ class RwFrameList : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
RwFrameListData data;
|
||||
~RwFrameList() { delete[] extensions; }
|
||||
~RwFrameList() {}
|
||||
RwFrameListExtension *extensions;
|
||||
};
|
||||
// ---
|
||||
@@ -89,50 +89,65 @@ public:
|
||||
u32 morphTargetCount;
|
||||
};
|
||||
|
||||
class RwGeometryDataLightingHeader
|
||||
struct RwGeometryDataLightingHeader
|
||||
{ // IF versionNumber = 4099 - according to not complete documentation
|
||||
public:
|
||||
float ambient;
|
||||
float diffuse;
|
||||
float specular;
|
||||
};
|
||||
|
||||
class RwGeometryDataColorInformationChunk
|
||||
struct RwGeometryDataColorInformationChunk
|
||||
{ // if rwOBJECT_VERTEX_PREILIT in flags
|
||||
public:
|
||||
|
||||
u8 red;
|
||||
u8 green;
|
||||
u8 blue;
|
||||
u8 alpha;
|
||||
};
|
||||
|
||||
class RwGeometryDataTextureMappingInformationChunk
|
||||
struct RwGeometryDataTextureMappingInformationChunk
|
||||
{ // if rwOBJECT_VERTEX_TEXTURED in flags
|
||||
public:
|
||||
float u;
|
||||
float v;
|
||||
};
|
||||
|
||||
class RwGeometryDataFaceInformation
|
||||
struct RwGeometryDataFaceInformation
|
||||
{
|
||||
public:
|
||||
u16 vertex2; // this
|
||||
u16 vertex1; // is
|
||||
u16 flags; // weird
|
||||
u16 vertex3; // order
|
||||
};
|
||||
|
||||
class RwGeometryDataNonameInfo
|
||||
{
|
||||
public:
|
||||
float boundingSphereX;
|
||||
float boundingSphereY;
|
||||
float boundingSphereZ;
|
||||
float boundingSphereR;
|
||||
u32 hasPosition;
|
||||
u32 hasNormals;
|
||||
};
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Section: Geometry
|
||||
class RwGeometryData : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
~RwGeometryData()
|
||||
{
|
||||
delete colorInformation;
|
||||
delete textureMappingInformation;
|
||||
delete faceInformation;
|
||||
delete vertexInformation;
|
||||
delete normalInformation;
|
||||
// if (dataHeader.flags & rwOBJECT_VERTEX_NORMALS)
|
||||
// delete[] normalInformation;
|
||||
// delete[] vertexInformation;
|
||||
// free(vertexInformation);
|
||||
// delete[] faceInformation;
|
||||
// if (dataHeader.flags & rwOBJECT_VERTEX_PRELIT)
|
||||
// delete[] colorInformation;
|
||||
// if (dataHeader.flags & rwOBJECT_VERTEX_TEXTURED)
|
||||
// delete[] textureMappingInformation;
|
||||
}
|
||||
RwGeometryDataHeader dataHeader;
|
||||
|
||||
@@ -144,16 +159,7 @@ public:
|
||||
|
||||
RwGeometryDataFaceInformation *faceInformation; // [triangleCount]
|
||||
|
||||
class RwGeometryDataNonameInfo
|
||||
{
|
||||
public:
|
||||
float boundingSphereX;
|
||||
float boundingSphereY;
|
||||
float boundingSphereZ;
|
||||
float boundingSphereR;
|
||||
u32 hasPosition;
|
||||
u32 hasNormals;
|
||||
} nonameInfo;
|
||||
RwGeometryDataNonameInfo nonameInfo;
|
||||
|
||||
Vector3 *vertexInformation; // [vertexCount]
|
||||
|
||||
@@ -211,7 +217,7 @@ class RwMaterialExtension : public RwSectionHeader
|
||||
class RwMaterial : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
~RwMaterial() { delete[] textures; }
|
||||
~RwMaterial() {}
|
||||
RwMaterialData data;
|
||||
RwTexture *textures;
|
||||
RwMaterialExtension extension;
|
||||
@@ -220,7 +226,7 @@ public:
|
||||
class RwMaterialListData : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
~RwMaterialListData() { delete[] arrayOfUnks; }
|
||||
~RwMaterialListData() {}
|
||||
u32 materialCount;
|
||||
u32 *arrayOfUnks; // Filled with '-1's, [materialCount] - it wasn't mentioned in docs.
|
||||
};
|
||||
@@ -228,7 +234,7 @@ public:
|
||||
class RwMaterialList : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
~RwMaterialList() { delete[] materials; }
|
||||
~RwMaterialList() {}
|
||||
RwMaterialListData data;
|
||||
RwMaterial *materials;
|
||||
};
|
||||
@@ -242,24 +248,26 @@ public:
|
||||
class RwGeometryListInfoChunk
|
||||
{
|
||||
public:
|
||||
~RwGeometryListInfoChunk() { delete vertexInformation; }
|
||||
~RwGeometryListInfoChunk() {}
|
||||
u32 faceIndex;
|
||||
u32 materialIndex;
|
||||
|
||||
RwGeometryListVertexInfoChunk *vertexInformation; // [faceIndex]
|
||||
};
|
||||
|
||||
class RwMaterialSplitHeader
|
||||
{
|
||||
public:
|
||||
u32 triangleStrip;
|
||||
u32 splitCount;
|
||||
u32 faceCount;
|
||||
};
|
||||
|
||||
class RwMaterialSplit
|
||||
{
|
||||
public:
|
||||
~RwMaterialSplit() { delete splitInformation; }
|
||||
class Header
|
||||
{
|
||||
public:
|
||||
u32 triangleStrip;
|
||||
u32 splitCount;
|
||||
u32 faceCount;
|
||||
} header;
|
||||
~RwMaterialSplit() {}
|
||||
RwMaterialSplitHeader header;
|
||||
|
||||
RwGeometryListInfoChunk *splitInformation; // [splitCount]
|
||||
};
|
||||
@@ -289,7 +297,7 @@ public:
|
||||
class RwGeometryList : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
~RwGeometryList() { delete[] geometries; }
|
||||
~RwGeometryList() {}
|
||||
RwGeometryListData data;
|
||||
RwGeometry *geometries;
|
||||
};
|
||||
|
||||
@@ -33,11 +33,16 @@ public:
|
||||
float scale;
|
||||
u8 shouldBeLighted, shouldBeBackfaceCulled, shouldBeFrustumCulled;
|
||||
color_t color;
|
||||
clutbuffer_t clut;
|
||||
lod_t lod;
|
||||
|
||||
// ----
|
||||
// Getters
|
||||
// ----
|
||||
|
||||
/** Auto generated unique Id. */
|
||||
const u32 &getId() const { return id; };
|
||||
|
||||
/** Array of materials. Size of getMaterialsCount() */
|
||||
MeshMaterial *getMaterials() const { return frames[0].getMaterials(); };
|
||||
|
||||
@@ -46,6 +51,28 @@ public:
|
||||
/** Returns material, which is a mesh "subgroup". */
|
||||
MeshMaterial &getMaterial(const u32 &i) const { return frames[0].getMaterial(i); };
|
||||
|
||||
/** Auto count of frames. Static object (not animated) will have only 1 frame. */
|
||||
const u32 &getFramesCount() const { return framesCount; };
|
||||
|
||||
/** Count of vertices. */
|
||||
u32 getVertexCount() { return frames[0].getVertexCount(); };
|
||||
|
||||
/** Returns single frame. */
|
||||
MeshFrame &getFrame(const u32 &i) const { return frames[i]; };
|
||||
|
||||
/** Array of frames. Size of getFramesCount() */
|
||||
MeshFrame *getFrames() const { return frames; };
|
||||
|
||||
const u32 &getCurrentAnimationFrame() const { return animState.currentFrame; };
|
||||
|
||||
const u32 &getNextAnimationFrame() const { return animState.nextFrame; };
|
||||
|
||||
const u32 &getStartAnimationFrame() const { return animState.startFrame; };
|
||||
|
||||
const u32 &getEndAnimationFrame() const { return animState.endFrame; };
|
||||
|
||||
const u32 &getStayAnimationFrame() const { return animState.stayFrame; };
|
||||
|
||||
/**
|
||||
* Returns material, which is a mesh "subgroup".
|
||||
* NULL if not found.
|
||||
@@ -130,38 +157,43 @@ public:
|
||||
/** Play animation from startFrame to endFrame and after loop in stayFrame */
|
||||
void playAnimation(const u32 &t_startFrame, const u32 &t_endFrame, const u32 &t_stayFrame);
|
||||
|
||||
void setAnimSpeed(const float &t_value) { animState.speed = t_value; }
|
||||
|
||||
/**
|
||||
* Check if this class loaded mesh data first.
|
||||
* Meshes which use loadFrom() method have false there.
|
||||
*/
|
||||
const u8 &isMother() const { return _isMother; };
|
||||
|
||||
// TODO
|
||||
/**
|
||||
* Check if this class loaded mesh data first.
|
||||
* Meshes which use loadFrom() method have false there.
|
||||
*/
|
||||
const u8 &isStayAnimationSet() const { return animState.isStayFrameSet; };
|
||||
|
||||
// void getMinMax(Vector3 *t_min, Vector3 *t_max);
|
||||
u32 getVertexCount();
|
||||
void setAnimSpeed(float t_value);
|
||||
/** Check if mesh is visible in view frustum */
|
||||
u8 isInFrustum(Plane *t_frustumPlanes);
|
||||
|
||||
clutbuffer_t clut;
|
||||
lod_t lod;
|
||||
u32 id;
|
||||
|
||||
// NOWE TODO
|
||||
|
||||
u32 framesCount;
|
||||
MeshFrame *frames;
|
||||
AnimState animState;
|
||||
/**
|
||||
* Do not call this method unless you know what you do.
|
||||
* Should be called by renderer.
|
||||
*/
|
||||
void animate();
|
||||
|
||||
/**
|
||||
* Do not call this method unless you know what you do.
|
||||
* Should be called by renderer.
|
||||
*/
|
||||
u32 getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, Vector3 &t_cameraPos);
|
||||
u32 getFacesCount();
|
||||
u8 isMemoryAllocated;
|
||||
|
||||
private:
|
||||
AnimState animState;
|
||||
MeshFrame *frames;
|
||||
u32 id, framesCount;
|
||||
u8 _isMother;
|
||||
Vector3 calc3Vectors[3];
|
||||
void setupLodAndClut();
|
||||
void setDefaultColor();
|
||||
void setDefaultLODAndClut();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user