#include "rwcore.h" #ifndef RW_DFF_H #define RW_DFF_H #ifdef __cplusplus extern "C" { #endif enum { rwID_MORPH = 0x105, rwID_SKYMIPMAP = 0x110, rwID_SKIN = 0x116, rwID_PARTICLES = 0x118, rwID_HANIM = 0x11E, rwID_MATERIALEFFECTS = 0x120, rwID_ADCPLG = 0x134, rwID_BINMESH = 0x50E, rwID_NATIVEDATA = 0x510, rwID_SPECULARMAT = 0x253F2F6, rwID_NIGHTVERTEXCOLOR = 0x253F2F9, rwID_COLLISIONMODEL = 0x253F2FA, rwID_REFLECTIONMAT = 0x253F2FC, rwID_MESHEXTENSION = 0x253F2FD, rwID_FRAME = 0x253F2FE, }; enum { rpGEOMETRYTRISTRIP = 0x01, rpGEOMETRYPOSITIONS = 0x02, rpGEOMETRYTEXTURED = 0x04, rpGEOMETRYPRELIT = 0x08, rpGEOMETRYNORMALS = 0x10, rpGEOMETRYLIGHT = 0x20, rpGEOMETRYMODULATEMATERIALCOLOR = 0x40, rpGEOMETRYTEXTURED2 = 0x80, }; enum { GTA3_1 = 0x00000302, GTA3_2 = 0x00000304, GTA3_3 = 0x00000310, GTA3_4 = 0x0800FFFF, VCPS2 = 0x0C02FFFF, SA = 0x1803FFFF }; #define VCNORMSCALE (RwReal) 1/128 #define SAVERTSCALE1 (RwReal) 1/128 /* normally used */ #define SAVERTSCALE2 (RwReal) 1/1024 /* used by cars and peds */ #define SAUVSCALE (RwReal) 1/4096 #define SANORMSCALE (RwReal) 1/128 typedef RwUInt8 Color4b[4]; typedef RwUInt16 Face4i[4]; typedef RwReal Vector2f[2]; typedef RwReal Vector3f[3]; typedef RwReal Vector4f[4]; typedef struct RpAtomic RpAtomic; struct RpAtomic { RwInt32 FrmIndex; RwInt32 GeoIndex; RwInt32 Unknown0; RwInt32 Unknown1; }; typedef struct RpMesh RpMesh; struct RpMesh { RwUInt32 numIndices; RwUInt32 MatIndex; RwUInt32 *Indices; }; typedef struct RpMaterial RpMaterial; struct RpMaterial { RwInt32 Flags; Color4b Color; RwInt32 Unused; RwBool HasTex; RwReal SurfaceProps[3]; RwBool TexRead; RwTexture Tex; RwBool HasRef; RwTexture Reflection; /* San Andreas only */ RwReal RefImageAmount[4]; RwReal RefIntensity; RwReal SpecLevel; RwChar *SpecName; }; typedef struct RpGeometry RpGeometry; struct RpGeometry { RwUInt16 Flags; RwUInt8 numUVs; RwUInt8 isPs2; RwUInt32 numTriangles; RwUInt32 numVertices; RwUInt32 numMorphTargets; Color4b *VColor; Color4b *NightVColor; Vector2f *UV; Vector2f *UV2; Face4i *Face; Vector3f *Vertex; Vector3f *Normal; /* Bounding shpere */ RwSphere BoundingSphere; RwInt32 BsPos; RwInt32 BsNor; RwUInt32 numMaterials; RpMaterial *Mat; RwUInt32 FaceType; RwUInt32 numSplits; RwUInt32 numIndices; RpMesh *Split; }; typedef struct RwFrame RwFrame; struct RwFrame { Vector3f Rotation[3]; Vector3f Position; RwInt32 Parent; RwInt32 Unknown; RwChar *Name; }; typedef struct RpClump RpClump; struct RpClump { RwInt32 numAtomics; RpAtomic *Atm; RwInt32 numFrames; RwFrame *Frm; RwInt32 numGeometries; RpGeometry *Geo; /* Not used */ RwInt32 numLights; RwInt32 numCameras; }; struct ps2split { RwUInt32 vertexc; RwUInt8 **vc; // RwUInt8 **nvc; RwReal **uv; RwReal **uv2; RwReal **vertices; RwReal **normals; RwUInt16 *flags; RwUInt32 extraverts; RwInt32 hasNVC; }; void ParseChunk(RpClump &, RwChunkHeaderInfo *, RwUInt32, RwStream *); void ReadChunk(RpClump &, RwChunkHeaderInfo *, RwStream *); void ReadStruct(RpClump &, RwChunkHeaderInfo *, RwUInt32, RwStream *); void ReadFrame(RwFrame &, RwUInt32, RwStream *); void ReadMatfx(RpClump &, RwChunkHeaderInfo *, RwUInt32, RwStream *); void ReadNativeDataVcPs2(RpGeometry &, RwStream *); void ReadNativeDataSaPs2(RpGeometry &, RwStream *); RwBool IsSaCompression(RpGeometry &, RwStream *); void MakeNormals(RpGeometry &, RpMesh &); void CalcNormal(Vector3f *, Vector3f *, Vector3f *, Vector3f *); void Ps2ToPc(RpGeometry *, struct ps2split *); RwBool IsSameVert(RwReal *, RwReal *); RwReal GetSaVertScale(RpGeometry *); RpClump *RpClumpStreamRead(RwStream *); RpClump *RpClumpCreate(void); void RpClumpDestroy(RpClump *); RwUInt32 RpClumpGetNumAtomics(RpClump *); #ifdef __cplusplus } #endif #endif