2015-01-25 21:27:03 +00:00
|
|
|
namespace rw {
|
2014-12-23 14:59:14 +00:00
|
|
|
|
|
|
|
struct Object
|
|
|
|
{
|
|
|
|
uint8 type;
|
|
|
|
uint8 subType;
|
|
|
|
uint8 flags;
|
|
|
|
void *parent;
|
|
|
|
};
|
|
|
|
|
2015-01-09 19:17:32 +00:00
|
|
|
struct Frame : PluginBase<Frame>, Object
|
|
|
|
{
|
|
|
|
typedef Frame *(*Callback)(Frame *f, void *data);
|
|
|
|
float32 matrix[16];
|
|
|
|
float32 ltm[16];
|
|
|
|
|
|
|
|
Frame *child;
|
|
|
|
Frame *next;
|
|
|
|
Frame *root;
|
|
|
|
|
|
|
|
// temporary
|
|
|
|
int32 matflag;
|
2015-01-12 16:42:44 +00:00
|
|
|
bool dirty;
|
2015-01-09 19:17:32 +00:00
|
|
|
|
|
|
|
Frame(void);
|
|
|
|
Frame(Frame *f);
|
|
|
|
~Frame(void);
|
|
|
|
Frame *addChild(Frame *f);
|
|
|
|
Frame *removeChild(void);
|
|
|
|
Frame *forAllChildren(Callback cb, void *data);
|
|
|
|
int32 count(void);
|
2015-01-12 16:42:44 +00:00
|
|
|
void updateLTM(void);
|
2015-01-17 14:15:03 +00:00
|
|
|
void setDirty(void);
|
2015-01-09 19:17:32 +00:00
|
|
|
};
|
|
|
|
|
2015-01-17 14:15:03 +00:00
|
|
|
struct HAnimNodeInfo
|
|
|
|
{
|
|
|
|
int32 id;
|
|
|
|
int32 index;
|
|
|
|
int32 flags;
|
|
|
|
Frame *frame;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HAnimHierarchy
|
|
|
|
{
|
|
|
|
int32 flags;
|
|
|
|
int32 numNodes;
|
|
|
|
float *matrices;
|
|
|
|
float *matricesUnaligned;
|
|
|
|
HAnimNodeInfo *nodeInfo;
|
|
|
|
Frame *parentFrame;
|
|
|
|
HAnimHierarchy *parentHierarchy; // mostly unused
|
|
|
|
|
|
|
|
// temporary
|
|
|
|
int32 maxInterpKeyFrameSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HAnimData
|
|
|
|
{
|
|
|
|
int32 id;
|
|
|
|
HAnimHierarchy *hierarchy;
|
|
|
|
};
|
|
|
|
|
2015-01-25 21:27:03 +00:00
|
|
|
extern int32 hAnimOffset;
|
|
|
|
void registerHAnimPlugin(void);
|
2015-01-17 14:15:03 +00:00
|
|
|
|
2014-12-25 15:02:57 +00:00
|
|
|
struct Image
|
|
|
|
{
|
|
|
|
int32 flags;
|
|
|
|
int32 width, height;
|
|
|
|
int32 depth;
|
|
|
|
int32 stride;
|
|
|
|
uint8 *pixels;
|
|
|
|
uint8 *palette;
|
|
|
|
|
|
|
|
Image(int32 width, int32 height, int32 depth);
|
|
|
|
~Image(void);
|
|
|
|
void allocate(void);
|
|
|
|
void free(void);
|
|
|
|
void setPixels(uint8 *pixels);
|
|
|
|
void setPalette(uint8 *palette);
|
2015-01-20 13:48:18 +00:00
|
|
|
|
|
|
|
static void setSearchPath(const char*);
|
|
|
|
static void printSearchPath(void);
|
|
|
|
static char *getFilename(const char*);
|
2014-12-25 15:02:57 +00:00
|
|
|
};
|
2014-12-25 18:37:36 +00:00
|
|
|
Image *readTGA(const char *filename);
|
|
|
|
void writeTGA(Image *image, const char *filename);
|
2014-12-25 15:02:57 +00:00
|
|
|
|
2015-01-20 13:48:18 +00:00
|
|
|
struct Raster : PluginBase<Raster>
|
|
|
|
{
|
|
|
|
int32 type; // hardly used
|
|
|
|
int32 width, height, depth;
|
|
|
|
int32 stride;
|
|
|
|
int32 format;
|
|
|
|
uint8 *texels;
|
|
|
|
uint8 *palette;
|
|
|
|
|
|
|
|
Raster(void);
|
|
|
|
~Raster(void);
|
|
|
|
|
|
|
|
static Raster *createFromImage(Image *image);
|
|
|
|
|
|
|
|
enum Format {
|
|
|
|
DEFAULT = 0,
|
|
|
|
C1555 = 0x100,
|
|
|
|
C565 = 0x200,
|
|
|
|
C4444 = 0x300,
|
|
|
|
LUM8 = 0x400,
|
|
|
|
C8888 = 0x500,
|
|
|
|
C888 = 0x600,
|
|
|
|
D16 = 0x700,
|
|
|
|
D24 = 0x800,
|
|
|
|
D32 = 0x900,
|
|
|
|
C555 = 0xa00,
|
|
|
|
AUTOMIPMAP = 0x1000,
|
|
|
|
PAL8 = 0x2000,
|
|
|
|
PAL4 = 0x4000,
|
|
|
|
MIPMAP = 0x8000
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// TODO: link into texdict
|
2014-12-23 14:59:14 +00:00
|
|
|
struct Texture : PluginBase<Texture>
|
|
|
|
{
|
|
|
|
char name[32];
|
|
|
|
char mask[32];
|
|
|
|
uint32 filterAddressing;
|
2015-01-20 13:48:18 +00:00
|
|
|
Raster *raster;
|
2014-12-23 14:59:14 +00:00
|
|
|
int32 refCount;
|
|
|
|
|
2015-01-20 18:22:57 +00:00
|
|
|
// temporary - pointer to next tex in dictionary
|
|
|
|
Texture *next;
|
|
|
|
|
2014-12-23 14:59:14 +00:00
|
|
|
Texture(void);
|
|
|
|
~Texture(void);
|
|
|
|
void decRef(void);
|
2014-12-27 22:18:10 +00:00
|
|
|
static Texture *streamRead(Stream *stream);
|
|
|
|
bool streamWrite(Stream *stream);
|
2014-12-23 14:59:14 +00:00
|
|
|
uint32 streamGetSize(void);
|
2015-01-20 18:22:57 +00:00
|
|
|
static Texture *read(const char *name, const char *mask);
|
2014-12-23 14:59:14 +00:00
|
|
|
|
|
|
|
enum FilterMode {
|
|
|
|
NEAREST = 1,
|
|
|
|
LINEAR,
|
|
|
|
MIPNEAREST,
|
|
|
|
MIPLINEAR,
|
|
|
|
LINEARMIPNEAREST,
|
|
|
|
LINEARMIPLINEAR
|
|
|
|
};
|
|
|
|
enum Addressing {
|
|
|
|
WRAP = 1,
|
|
|
|
MIRROR,
|
|
|
|
CLAMP,
|
|
|
|
BORDER
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Material : PluginBase<Material>
|
|
|
|
{
|
|
|
|
Texture *texture;
|
|
|
|
uint8 color[4];
|
|
|
|
float32 surfaceProps[3];
|
2015-01-10 21:13:27 +00:00
|
|
|
Pipeline *pipeline;
|
2014-12-23 14:59:14 +00:00
|
|
|
int32 refCount;
|
|
|
|
|
|
|
|
Material(void);
|
|
|
|
Material(Material *m);
|
|
|
|
void decRef(void);
|
|
|
|
~Material(void);
|
2014-12-27 22:18:10 +00:00
|
|
|
static Material *streamRead(Stream *stream);
|
|
|
|
bool streamWrite(Stream *stream);
|
2014-12-23 14:59:14 +00:00
|
|
|
uint32 streamGetSize(void);
|
|
|
|
};
|
|
|
|
|
2015-01-25 21:27:03 +00:00
|
|
|
void registerMaterialRightsPlugin(void);
|
2015-01-10 21:13:27 +00:00
|
|
|
|
2015-01-09 19:17:32 +00:00
|
|
|
struct MatFX
|
|
|
|
{
|
|
|
|
enum Flags {
|
|
|
|
NOTHING = 0,
|
|
|
|
BUMPMAP,
|
|
|
|
ENVMAP,
|
|
|
|
BUMPENVMAP,
|
|
|
|
DUAL,
|
|
|
|
UVTRANSFORM,
|
|
|
|
DUALUVTRANSFORM
|
|
|
|
};
|
|
|
|
struct Bump {
|
|
|
|
Frame *frame;
|
|
|
|
Texture *bumpedTex;
|
|
|
|
Texture *tex;
|
|
|
|
float coefficient;
|
|
|
|
};
|
|
|
|
struct Env {
|
|
|
|
Frame *frame;
|
|
|
|
Texture *tex;
|
|
|
|
float coefficient;
|
|
|
|
int32 fbAlpha;
|
|
|
|
};
|
|
|
|
struct Dual {
|
|
|
|
Texture *tex;
|
|
|
|
int32 srcBlend;
|
|
|
|
int32 dstBlend;
|
|
|
|
};
|
|
|
|
struct UVtransform {
|
|
|
|
float *baseTransform;
|
|
|
|
float *dualTransform;
|
|
|
|
};
|
|
|
|
struct {
|
|
|
|
uint32 type;
|
|
|
|
union {
|
|
|
|
Bump bump;
|
|
|
|
Env env;
|
|
|
|
Dual dual;
|
|
|
|
UVtransform uvtransform;
|
|
|
|
};
|
|
|
|
} fx[2];
|
|
|
|
uint32 flags;
|
|
|
|
|
|
|
|
void setEffects(uint32 flags);
|
|
|
|
int32 getEffectIndex(uint32 type);
|
|
|
|
};
|
|
|
|
|
2015-01-25 21:27:03 +00:00
|
|
|
struct MatFXGlobals
|
2015-01-10 21:13:27 +00:00
|
|
|
{
|
|
|
|
int32 atomicOffset;
|
|
|
|
int32 materialOffset;
|
2015-08-02 18:31:01 +01:00
|
|
|
ObjPipeline *pipelines[NUM_PLATFORMS];
|
2015-01-10 21:13:27 +00:00
|
|
|
};
|
2015-01-25 21:27:03 +00:00
|
|
|
extern MatFXGlobals matFXGlobals;
|
|
|
|
void registerMatFXPlugin(void);
|
2015-01-09 19:17:32 +00:00
|
|
|
|
2014-12-23 14:59:14 +00:00
|
|
|
struct Mesh
|
|
|
|
{
|
|
|
|
uint16 *indices;
|
|
|
|
uint32 numIndices;
|
|
|
|
Material *material;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MeshHeader
|
|
|
|
{
|
|
|
|
uint32 flags;
|
|
|
|
uint16 numMeshes;
|
|
|
|
// RW has uint16 serialNum here
|
|
|
|
uint32 totalIndices;
|
|
|
|
Mesh *mesh; // RW has a byte offset here
|
2015-09-07 22:00:28 +01:00
|
|
|
|
|
|
|
void allocateIndices(void);
|
2014-12-23 14:59:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MorphTarget
|
|
|
|
{
|
|
|
|
float32 boundingSphere[4];
|
|
|
|
float32 *vertices;
|
|
|
|
float32 *normals;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct InstanceDataHeader
|
|
|
|
{
|
|
|
|
uint32 platform;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Geometry : PluginBase<Geometry>, Object
|
|
|
|
{
|
|
|
|
uint32 geoflags;
|
|
|
|
int32 numTriangles;
|
|
|
|
int32 numVertices;
|
|
|
|
int32 numMorphTargets;
|
|
|
|
int32 numTexCoordSets;
|
|
|
|
|
|
|
|
uint16 *triangles;
|
|
|
|
uint8 *colors;
|
|
|
|
float32 *texCoords[8];
|
|
|
|
|
|
|
|
MorphTarget *morphTargets;
|
|
|
|
|
|
|
|
int32 numMaterials;
|
|
|
|
Material **materialList;
|
|
|
|
|
|
|
|
MeshHeader *meshHeader;
|
|
|
|
|
|
|
|
InstanceDataHeader *instData;
|
|
|
|
|
|
|
|
int32 refCount;
|
|
|
|
|
|
|
|
Geometry(int32 numVerts, int32 numTris, uint32 flags);
|
|
|
|
void decRef(void);
|
|
|
|
~Geometry(void);
|
2014-12-27 22:18:10 +00:00
|
|
|
static Geometry *streamRead(Stream *stream);
|
|
|
|
bool streamWrite(Stream *stream);
|
2014-12-23 14:59:14 +00:00
|
|
|
uint32 streamGetSize(void);
|
|
|
|
void addMorphTargets(int32 n);
|
2015-08-11 19:57:43 +01:00
|
|
|
void allocateData(void);
|
|
|
|
void generateTriangles(void);
|
2014-12-23 14:59:14 +00:00
|
|
|
|
|
|
|
enum Flags
|
|
|
|
{
|
|
|
|
TRISTRIP = 0x01,
|
|
|
|
POSITIONS = 0x02,
|
|
|
|
TEXTURED = 0x04,
|
|
|
|
PRELIT = 0x08,
|
|
|
|
NORMALS = 0x10,
|
|
|
|
LIGHT = 0x20,
|
|
|
|
MODULATE = 0x40,
|
|
|
|
TEXTURED2 = 0x80,
|
|
|
|
NATIVE = 0x01000000,
|
|
|
|
NATIVEINSTANCE = 0x02000000
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-01-25 21:27:03 +00:00
|
|
|
void registerMeshPlugin(void);
|
|
|
|
void registerNativeDataPlugin(void);
|
2015-01-10 21:13:27 +00:00
|
|
|
|
2015-01-07 22:06:44 +00:00
|
|
|
struct Skin
|
|
|
|
{
|
|
|
|
int32 numBones;
|
|
|
|
int32 numUsedBones;
|
2015-09-07 09:22:54 +01:00
|
|
|
int32 numWeights;
|
2015-01-07 22:06:44 +00:00
|
|
|
uint8 *usedBones;
|
|
|
|
float *inverseMatrices;
|
|
|
|
uint8 *indices;
|
|
|
|
float *weights;
|
|
|
|
uint8 *data; // only used by delete
|
2015-08-15 22:22:51 +01:00
|
|
|
void *platformData; // a place to store platform specific stuff
|
2015-08-11 19:57:43 +01:00
|
|
|
|
2015-09-07 09:22:54 +01:00
|
|
|
void init(int32 numBones, int32 numUsedBones, int32 numVertices);
|
|
|
|
void findNumWeights(int32 numVertices);
|
|
|
|
void findUsedBones(int32 numVertices);
|
2015-01-07 22:06:44 +00:00
|
|
|
};
|
|
|
|
|
2015-01-25 21:27:03 +00:00
|
|
|
struct SkinGlobals
|
2015-01-10 21:13:27 +00:00
|
|
|
{
|
|
|
|
int32 offset;
|
2015-08-02 18:31:01 +01:00
|
|
|
ObjPipeline *pipelines[NUM_PLATFORMS];
|
2015-01-10 21:13:27 +00:00
|
|
|
};
|
2015-01-25 21:27:03 +00:00
|
|
|
extern SkinGlobals skinGlobals;
|
|
|
|
void registerSkinPlugin(void);
|
2014-12-23 14:59:14 +00:00
|
|
|
|
|
|
|
struct Clump;
|
|
|
|
|
|
|
|
struct Light : PluginBase<Light>, Object
|
|
|
|
{
|
|
|
|
Frame *frame;
|
|
|
|
float32 radius;
|
|
|
|
float32 color[4];
|
|
|
|
float32 minusCosAngle;
|
|
|
|
Clump *clump;
|
|
|
|
|
|
|
|
Light(void);
|
|
|
|
Light(Light *l);
|
|
|
|
~Light(void);
|
2014-12-27 22:18:10 +00:00
|
|
|
static Light *streamRead(Stream *stream);
|
|
|
|
bool streamWrite(Stream *stream);
|
2014-12-23 14:59:14 +00:00
|
|
|
uint32 streamGetSize(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Atomic : PluginBase<Atomic>, Object
|
|
|
|
{
|
|
|
|
Frame *frame;
|
|
|
|
Geometry *geometry;
|
|
|
|
Clump *clump;
|
2015-08-02 18:31:01 +01:00
|
|
|
ObjPipeline *pipeline;
|
2014-12-23 14:59:14 +00:00
|
|
|
|
|
|
|
Atomic(void);
|
|
|
|
Atomic(Atomic *a);
|
|
|
|
~Atomic(void);
|
2014-12-27 22:18:10 +00:00
|
|
|
static Atomic *streamReadClump(Stream *stream,
|
2014-12-23 14:59:14 +00:00
|
|
|
Frame **frameList, Geometry **geometryList);
|
2014-12-27 22:18:10 +00:00
|
|
|
bool streamWriteClump(Stream *stream,
|
2014-12-23 14:59:14 +00:00
|
|
|
Frame **frameList, int32 numFrames);
|
|
|
|
uint32 streamGetSize(void);
|
2015-08-03 17:30:10 +01:00
|
|
|
ObjPipeline *getPipeline(void);
|
|
|
|
|
|
|
|
static void init(void);
|
2014-12-23 14:59:14 +00:00
|
|
|
};
|
|
|
|
|
2015-08-03 17:30:10 +01:00
|
|
|
extern ObjPipeline *defaultPipelines[NUM_PLATFORMS];
|
|
|
|
|
2015-01-25 21:27:03 +00:00
|
|
|
void registerAtomicRightsPlugin(void);
|
2015-01-09 19:17:32 +00:00
|
|
|
|
2014-12-23 14:59:14 +00:00
|
|
|
struct Clump : PluginBase<Clump>, Object
|
|
|
|
{
|
|
|
|
int32 numAtomics;
|
|
|
|
Atomic **atomicList;
|
|
|
|
int32 numLights;
|
|
|
|
Light **lightList;
|
|
|
|
int32 numCameras;
|
|
|
|
// cameras not implemented
|
|
|
|
|
|
|
|
Clump(void);
|
|
|
|
Clump(Clump *c);
|
|
|
|
~Clump(void);
|
2014-12-27 22:18:10 +00:00
|
|
|
static Clump *streamRead(Stream *stream);
|
|
|
|
bool streamWrite(Stream *stream);
|
2014-12-23 14:59:14 +00:00
|
|
|
uint32 streamGetSize(void);
|
|
|
|
|
|
|
|
private:
|
2014-12-27 22:18:10 +00:00
|
|
|
void frameListStreamRead(Stream *stream, Frame ***flp, int32 *nf);
|
|
|
|
void frameListStreamWrite(Stream *stream, Frame **flp, int32 nf);
|
2014-12-23 14:59:14 +00:00
|
|
|
};
|
|
|
|
|
2015-01-20 18:22:57 +00:00
|
|
|
struct TexDictionary
|
|
|
|
{
|
|
|
|
Texture *first;
|
|
|
|
|
|
|
|
TexDictionary(void);
|
|
|
|
void add(Texture *tex);
|
|
|
|
Texture *find(const char *name);
|
|
|
|
};
|
|
|
|
|
2015-09-09 22:26:16 +01:00
|
|
|
struct Animation;
|
|
|
|
|
|
|
|
struct AnimInterpolatorInfo
|
|
|
|
{
|
|
|
|
int32 id;
|
|
|
|
int32 keyFrameSize;
|
|
|
|
int32 customDataSize;
|
|
|
|
void (*streamRead)(Stream *stream, Animation *anim);
|
|
|
|
void (*streamWrite)(Stream *stream, Animation *anim);
|
|
|
|
uint32 (*streamGetSize)(Animation *anim);
|
|
|
|
};
|
|
|
|
|
|
|
|
void registerAnimInterpolatorInfo(AnimInterpolatorInfo *interpInfo);
|
|
|
|
|
|
|
|
struct Animation
|
|
|
|
{
|
|
|
|
AnimInterpolatorInfo *interpInfo;
|
|
|
|
int32 numFrames;
|
|
|
|
int32 flags;
|
|
|
|
float duration;
|
|
|
|
void *keyframes;
|
|
|
|
void *customData;
|
|
|
|
|
|
|
|
Animation(AnimInterpolatorInfo*, int32 numFrames, int32 flags, float duration);
|
|
|
|
static Animation *streamRead(Stream *stream);
|
|
|
|
bool streamWrite(Stream *stream);
|
|
|
|
uint32 streamGetSize(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AnimInterpolator
|
|
|
|
{
|
|
|
|
// only a stub right now
|
|
|
|
Animation *anim;
|
|
|
|
|
|
|
|
AnimInterpolator(Animation *anim);
|
|
|
|
};
|
|
|
|
|
2015-01-25 21:27:03 +00:00
|
|
|
extern TexDictionary *currentTexDictionary;
|
2015-01-20 18:22:57 +00:00
|
|
|
|
2015-09-09 22:26:16 +01:00
|
|
|
struct UVAnimKeyFrame
|
|
|
|
{
|
|
|
|
UVAnimKeyFrame *prev;
|
|
|
|
float time;
|
|
|
|
float uv[6];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UVAnimCustomData
|
|
|
|
{
|
|
|
|
char name[32];
|
|
|
|
int32 nodeToUVChannel[8];
|
|
|
|
// RW has a refcount
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UVAnimDictionary
|
|
|
|
{
|
|
|
|
int32 numAnims;
|
|
|
|
Animation **anims;
|
|
|
|
|
|
|
|
static UVAnimDictionary *streamRead(Stream *stream);
|
|
|
|
bool streamWrite(Stream *stream);
|
|
|
|
uint32 streamGetSize(void);
|
|
|
|
Animation *find(const char *name);
|
|
|
|
};
|
|
|
|
|
|
|
|
extern UVAnimDictionary *currentUVAnimDictionary;
|
|
|
|
|
|
|
|
extern int32 uvAnimOffset;
|
|
|
|
|
|
|
|
void registerUVAnimPlugin(void);
|
|
|
|
|
2015-01-06 22:17:05 +00:00
|
|
|
}
|