2016-01-26 12:53:08 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
|
2015-01-25 21:27:03 +00:00
|
|
|
namespace rw {
|
2014-12-23 14:59:14 +00:00
|
|
|
|
2016-01-13 07:58:15 +00:00
|
|
|
struct RGBA
|
|
|
|
{
|
|
|
|
uint8 red;
|
|
|
|
uint8 green;
|
|
|
|
uint8 blue;
|
|
|
|
uint8 alpha;
|
|
|
|
};
|
|
|
|
|
2016-01-14 22:49:00 +00:00
|
|
|
struct RGBAf
|
|
|
|
{
|
|
|
|
float32 red;
|
|
|
|
float32 green;
|
|
|
|
float32 blue;
|
|
|
|
float32 alpha;
|
|
|
|
};
|
|
|
|
|
2016-01-13 07:58:15 +00:00
|
|
|
struct V2d
|
|
|
|
{
|
|
|
|
float32 x, y;
|
2016-01-14 22:49:00 +00:00
|
|
|
void set(float32 x, float32 y){
|
|
|
|
this->x = x; this->y = y; }
|
2016-01-13 07:58:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct V3d
|
|
|
|
{
|
|
|
|
float32 x, y, z;
|
2016-01-14 22:49:00 +00:00
|
|
|
void set(float32 x, float32 y, float32 z){
|
|
|
|
this->x = x; this->y = y; this->z = z; }
|
2016-01-13 07:58:15 +00:00
|
|
|
};
|
|
|
|
|
2016-01-11 10:23:26 +00:00
|
|
|
struct LLLink
|
|
|
|
{
|
|
|
|
LLLink *next;
|
|
|
|
LLLink *prev;
|
|
|
|
void init(void){
|
|
|
|
this->next = NULL;
|
|
|
|
this->prev = NULL;
|
|
|
|
}
|
|
|
|
void remove(void){
|
|
|
|
this->prev->next = this->next;
|
|
|
|
this->next->prev = this->prev;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#define LLLinkGetData(linkvar,type,entry) \
|
|
|
|
((type*)(((uint8*)(linkvar))-offsetof(type,entry)))
|
|
|
|
|
2016-01-14 22:49:00 +00:00
|
|
|
// Have to be careful since the link might be deleted.
|
|
|
|
#define FORLIST(_link, _list) \
|
2016-02-06 17:11:31 +00:00
|
|
|
for(rw::LLLink *_next = NULL, *_link = (_list).link.next; \
|
2016-01-14 22:49:00 +00:00
|
|
|
_next = (_link)->next, (_link) != (_list).end(); \
|
|
|
|
(_link) = _next)
|
|
|
|
|
2016-01-11 10:23:26 +00:00
|
|
|
struct LinkList
|
|
|
|
{
|
|
|
|
LLLink link;
|
|
|
|
void init(void){
|
|
|
|
this->link.next = &this->link;
|
|
|
|
this->link.prev = &this->link;
|
|
|
|
}
|
|
|
|
bool32 isEmpty(void){
|
|
|
|
return this->link.next == &this->link;
|
|
|
|
}
|
|
|
|
void add(LLLink *link){
|
|
|
|
link->next = this->link.next;
|
|
|
|
link->prev = &this->link;
|
|
|
|
this->link.next->prev = link;
|
|
|
|
this->link.next = link;
|
|
|
|
}
|
2016-01-11 17:22:59 +00:00
|
|
|
void append(LLLink *link){
|
|
|
|
link->next = &this->link;
|
|
|
|
link->prev = this->link.prev;
|
|
|
|
this->link.prev->next = link;
|
|
|
|
this->link.prev = link;
|
|
|
|
}
|
2016-01-11 10:23:26 +00:00
|
|
|
LLLink *end(void){
|
|
|
|
return &this->link;
|
|
|
|
}
|
2016-01-14 22:49:00 +00:00
|
|
|
int32 count(void){
|
|
|
|
int32 n = 0;
|
|
|
|
FORLIST(lnk, (*this))
|
|
|
|
n++;
|
|
|
|
return n;
|
|
|
|
}
|
2016-01-11 10:23:26 +00:00
|
|
|
};
|
|
|
|
|
2014-12-23 14:59:14 +00:00
|
|
|
struct Object
|
|
|
|
{
|
|
|
|
uint8 type;
|
|
|
|
uint8 subType;
|
|
|
|
uint8 flags;
|
2016-01-11 10:23:26 +00:00
|
|
|
uint8 privateFlags;
|
2014-12-23 14:59:14 +00:00
|
|
|
void *parent;
|
2016-01-11 10:23:26 +00:00
|
|
|
|
|
|
|
void init(uint8 type, uint8 subType){
|
|
|
|
this->type = type;
|
|
|
|
this->subType = subType;
|
|
|
|
this->flags = 0;
|
|
|
|
this->privateFlags = 0;
|
|
|
|
this->parent = NULL;
|
|
|
|
}
|
2016-01-11 23:38:36 +00:00
|
|
|
void copy(Object *o){
|
|
|
|
this->type = o->type;
|
|
|
|
this->subType = o->subType;
|
|
|
|
this->flags = o->flags;
|
|
|
|
this->privateFlags = o->privateFlags;
|
|
|
|
this->parent = NULL;
|
|
|
|
}
|
2014-12-23 14:59:14 +00:00
|
|
|
};
|
|
|
|
|
2016-01-11 10:23:26 +00:00
|
|
|
struct Frame : PluginBase<Frame>
|
2015-01-09 19:17:32 +00:00
|
|
|
{
|
|
|
|
typedef Frame *(*Callback)(Frame *f, void *data);
|
2016-01-11 10:23:26 +00:00
|
|
|
|
2016-01-13 07:58:15 +00:00
|
|
|
enum { ID = 0 };
|
2016-01-11 10:23:26 +00:00
|
|
|
Object object;
|
|
|
|
LinkList objectList;
|
2015-01-09 19:17:32 +00:00
|
|
|
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
|
|
|
|
2016-01-11 17:22:59 +00:00
|
|
|
static Frame *create(void);
|
2016-01-11 23:38:36 +00:00
|
|
|
Frame *cloneHierarchy(void);
|
2016-01-11 17:22:59 +00:00
|
|
|
void destroy(void);
|
2016-01-11 23:38:36 +00:00
|
|
|
void destroyHierarchy(void);
|
2016-01-24 00:42:51 +00:00
|
|
|
Frame *addChild(Frame *f, bool32 append = 0);
|
2015-01-09 19:17:32 +00:00
|
|
|
Frame *removeChild(void);
|
|
|
|
Frame *forAllChildren(Callback cb, void *data);
|
2016-01-11 23:38:36 +00:00
|
|
|
Frame *getParent(void){
|
2016-01-13 07:58:15 +00:00
|
|
|
return (Frame*)this->object.parent; }
|
2015-01-09 19:17:32 +00:00
|
|
|
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);
|
2016-01-11 23:38:36 +00:00
|
|
|
|
|
|
|
void setHierarchyRoot(Frame *root);
|
|
|
|
Frame *cloneAndLink(Frame *clonedroot);
|
|
|
|
void purgeClone(void);
|
2016-01-24 00:42:51 +00:00
|
|
|
|
|
|
|
// private flags:
|
|
|
|
// #define rwFRAMEPRIVATEHIERARCHYSYNCLTM 0x01
|
|
|
|
// #define rwFRAMEPRIVATEHIERARCHYSYNCOBJ 0x02
|
|
|
|
// #define rwFRAMEPRIVATESUBTREESYNCLTM 0x04
|
|
|
|
// #define rwFRAMEPRIVATESUBTREESYNCOBJ 0x08
|
|
|
|
// #define rwFRAMEPRIVATESTATIC 0x10
|
2015-01-09 19:17:32 +00:00
|
|
|
};
|
|
|
|
|
2015-12-18 00:10:42 +00:00
|
|
|
Frame **makeFrameList(Frame *frame, Frame **flist);
|
|
|
|
|
2016-01-11 10:23:26 +00:00
|
|
|
struct ObjectWithFrame : Object
|
|
|
|
{
|
|
|
|
LLLink inFrame;
|
|
|
|
void setFrame(Frame *f){
|
|
|
|
if(this->parent)
|
|
|
|
this->inFrame.remove();
|
|
|
|
this->parent = f;
|
|
|
|
if(f)
|
|
|
|
f->objectList.add(&this->inFrame);
|
|
|
|
}
|
2016-01-13 07:58:15 +00:00
|
|
|
static ObjectWithFrame *fromFrame(LLLink *lnk){
|
|
|
|
return LLLinkGetData(lnk, ObjectWithFrame, inFrame);
|
|
|
|
}
|
2016-01-11 10:23:26 +00:00
|
|
|
};
|
|
|
|
|
2015-09-11 11:32:06 +01:00
|
|
|
struct HAnimKeyFrame
|
|
|
|
{
|
|
|
|
HAnimKeyFrame *prev;
|
|
|
|
float time;
|
|
|
|
float q[4];
|
|
|
|
float t[3];
|
|
|
|
};
|
|
|
|
|
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;
|
2016-01-24 00:42:51 +00:00
|
|
|
|
|
|
|
static HAnimHierarchy *create(int32 numNodes, int32 *nodeFlags, int32 *nodeIDs, int32 flags, int32 maxKeySize);
|
|
|
|
void destroy(void);
|
|
|
|
void attachByIndex(int32 id);
|
|
|
|
void attach(void);
|
|
|
|
int32 getIndex(int32 id);
|
|
|
|
|
|
|
|
static HAnimHierarchy *get(Frame *f);
|
|
|
|
static HAnimHierarchy *find(Frame *f);
|
|
|
|
|
|
|
|
enum NodeFlag {
|
|
|
|
POP = 1,
|
|
|
|
PUSH
|
|
|
|
};
|
2015-01-17 14:15:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct HAnimData
|
|
|
|
{
|
|
|
|
int32 id;
|
|
|
|
HAnimHierarchy *hierarchy;
|
2016-01-24 00:42:51 +00:00
|
|
|
|
|
|
|
static HAnimData *get(Frame *f);
|
2015-01-17 14:15:03 +00:00
|
|
|
};
|
|
|
|
|
2015-01-25 21:27:03 +00:00
|
|
|
extern int32 hAnimOffset;
|
2016-01-24 00:42:51 +00:00
|
|
|
extern bool32 hAnimDoStream;
|
2015-01-25 21:27:03 +00:00
|
|
|
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;
|
|
|
|
|
2016-01-11 17:22:59 +00:00
|
|
|
static Image *create(int32 width, int32 height, int32 depth);
|
|
|
|
void destroy(void);
|
2014-12-25 15:02:57 +00:00
|
|
|
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-09-15 07:29:57 +01:00
|
|
|
// used to emulate d3d and xbox textures
|
|
|
|
struct RasterLevels
|
|
|
|
{
|
|
|
|
int32 numlevels;
|
|
|
|
uint32 format;
|
|
|
|
struct Level {
|
|
|
|
int32 width, height, size;
|
|
|
|
uint8 *data;
|
|
|
|
} levels[1]; // 0 is illegal :/
|
|
|
|
};
|
|
|
|
|
2015-01-20 13:48:18 +00:00
|
|
|
struct Raster : PluginBase<Raster>
|
|
|
|
{
|
2015-09-13 19:23:22 +01:00
|
|
|
int32 platform;
|
|
|
|
|
2015-01-20 13:48:18 +00:00
|
|
|
int32 type; // hardly used
|
2015-09-13 19:23:22 +01:00
|
|
|
int32 flags;
|
|
|
|
int32 format;
|
2015-01-20 13:48:18 +00:00
|
|
|
int32 width, height, depth;
|
|
|
|
int32 stride;
|
|
|
|
uint8 *texels;
|
|
|
|
uint8 *palette;
|
|
|
|
|
2015-09-19 18:28:23 +01:00
|
|
|
static int32 nativeOffsets[NUM_PLATFORMS];
|
|
|
|
|
2016-01-11 17:22:59 +00:00
|
|
|
static Raster *create(int32 width, int32 height, int32 depth, int32 format, int32 platform = 0);
|
|
|
|
void destroy(void);
|
2015-01-20 13:48:18 +00:00
|
|
|
static Raster *createFromImage(Image *image);
|
2015-09-13 19:23:22 +01:00
|
|
|
uint8 *lock(int32 level);
|
|
|
|
void unlock(int32 level);
|
|
|
|
int32 getNumLevels(void);
|
2015-09-15 07:29:57 +01:00
|
|
|
static int32 calculateNumLevels(int32 width, int32 height);
|
2015-01-20 13:48:18 +00:00
|
|
|
|
|
|
|
enum Format {
|
2015-09-13 19:23:22 +01:00
|
|
|
DEFAULT = 0,
|
|
|
|
C1555 = 0x0100,
|
|
|
|
C565 = 0x0200,
|
|
|
|
C4444 = 0x0300,
|
|
|
|
LUM8 = 0x0400,
|
|
|
|
C8888 = 0x0500,
|
|
|
|
C888 = 0x0600,
|
|
|
|
D16 = 0x0700,
|
|
|
|
D24 = 0x0800,
|
|
|
|
D32 = 0x0900,
|
|
|
|
C555 = 0x0A00,
|
2015-01-20 13:48:18 +00:00
|
|
|
AUTOMIPMAP = 0x1000,
|
|
|
|
PAL8 = 0x2000,
|
|
|
|
PAL4 = 0x4000,
|
|
|
|
MIPMAP = 0x8000
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-02-06 17:11:31 +00:00
|
|
|
extern bool32 loadTextures;
|
|
|
|
|
|
|
|
#define IGNORERASTERIMP 0
|
2015-12-14 17:52:50 +00:00
|
|
|
|
2015-09-19 18:28:23 +01:00
|
|
|
struct NativeRaster
|
|
|
|
{
|
2016-01-10 19:10:53 +00:00
|
|
|
virtual void create(Raster*)
|
2016-02-06 17:11:31 +00:00
|
|
|
{ assert(IGNORERASTERIMP && "NativeRaster::create unimplemented"); };
|
2016-01-10 19:10:53 +00:00
|
|
|
virtual uint8 *lock(Raster*, int32)
|
2016-02-06 17:11:31 +00:00
|
|
|
{ assert(IGNORERASTERIMP && "NativeRaster::lock unimplemented"); return NULL; };
|
2016-01-10 19:10:53 +00:00
|
|
|
virtual void unlock(Raster*, int32)
|
2016-02-06 17:11:31 +00:00
|
|
|
{ assert(IGNORERASTERIMP && "NativeRaster::unlock unimplemented"); };
|
2016-01-10 19:10:53 +00:00
|
|
|
virtual int32 getNumLevels(Raster*)
|
2016-02-06 17:11:31 +00:00
|
|
|
{ assert(IGNORERASTERIMP && "NativeRaster::getNumLevels unimplemented"); return 0; };
|
|
|
|
virtual void fromImage(Raster*, Image *img)
|
|
|
|
{ assert(IGNORERASTERIMP && "NativeRaster::fromImage unimplemented"); };
|
2015-09-19 18:28:23 +01:00
|
|
|
};
|
|
|
|
|
2016-01-11 17:22:59 +00:00
|
|
|
struct TexDictionary;
|
|
|
|
|
2014-12-23 14:59:14 +00:00
|
|
|
struct Texture : PluginBase<Texture>
|
|
|
|
{
|
2016-01-11 10:23:26 +00:00
|
|
|
Raster *raster;
|
2016-01-11 17:22:59 +00:00
|
|
|
TexDictionary *dict;
|
|
|
|
LLLink inDict;
|
2014-12-23 14:59:14 +00:00
|
|
|
char name[32];
|
|
|
|
char mask[32];
|
2015-09-11 11:32:06 +01:00
|
|
|
uint32 filterAddressing; // VVVVUUUU FFFFFFFF
|
2014-12-23 14:59:14 +00:00
|
|
|
int32 refCount;
|
|
|
|
|
2016-01-11 17:22:59 +00:00
|
|
|
static Texture *create(Raster *raster);
|
|
|
|
void destroy(void);
|
|
|
|
static Texture *fromDict(LLLink *lnk){
|
2016-01-13 07:58:15 +00:00
|
|
|
return LLLinkGetData(lnk, Texture, inDict); }
|
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);
|
2015-09-13 19:23:22 +01:00
|
|
|
static Texture *streamReadNative(Stream *stream);
|
|
|
|
void streamWriteNative(Stream *stream);
|
|
|
|
uint32 streamGetSizeNative(void);
|
2014-12-23 14:59:14 +00:00
|
|
|
|
|
|
|
enum FilterMode {
|
|
|
|
NEAREST = 1,
|
|
|
|
LINEAR,
|
|
|
|
MIPNEAREST,
|
|
|
|
MIPLINEAR,
|
|
|
|
LINEARMIPNEAREST,
|
|
|
|
LINEARMIPLINEAR
|
|
|
|
};
|
|
|
|
enum Addressing {
|
|
|
|
WRAP = 1,
|
|
|
|
MIRROR,
|
|
|
|
CLAMP,
|
|
|
|
BORDER
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-01-09 21:01:21 +00:00
|
|
|
struct SurfaceProperties
|
|
|
|
{
|
|
|
|
float32 ambient;
|
|
|
|
float32 specular;
|
|
|
|
float32 diffuse;
|
|
|
|
};
|
|
|
|
|
2014-12-23 14:59:14 +00:00
|
|
|
struct Material : PluginBase<Material>
|
|
|
|
{
|
|
|
|
Texture *texture;
|
2016-01-13 07:58:15 +00:00
|
|
|
RGBA color;
|
2016-01-09 21:01:21 +00:00
|
|
|
SurfaceProperties surfaceProps;
|
2015-01-10 21:13:27 +00:00
|
|
|
Pipeline *pipeline;
|
2014-12-23 14:59:14 +00:00
|
|
|
int32 refCount;
|
|
|
|
|
2016-01-11 17:22:59 +00:00
|
|
|
static Material *create(void);
|
|
|
|
Material *clone(void);
|
|
|
|
void destroy(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
|
|
|
|
{
|
2016-01-09 21:01:21 +00:00
|
|
|
enum {
|
2015-01-09 19:17:32 +00:00
|
|
|
NOTHING = 0,
|
|
|
|
BUMPMAP,
|
|
|
|
ENVMAP,
|
2016-01-24 00:42:51 +00:00
|
|
|
BUMPENVMAP, // BUMP | ENV
|
2015-01-09 19:17:32 +00:00
|
|
|
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];
|
2016-01-09 21:01:21 +00:00
|
|
|
uint32 type;
|
2015-01-09 19:17:32 +00:00
|
|
|
|
|
|
|
void setEffects(uint32 flags);
|
2016-02-06 17:11:31 +00:00
|
|
|
static uint32 getEffects(Material *m);
|
|
|
|
uint32 getEffectIndex(uint32 type);
|
2016-01-24 00:42:51 +00:00
|
|
|
void setBumpTexture(Texture *t);
|
|
|
|
void setBumpCoefficient(float32 coef);
|
2016-01-10 17:18:03 +00:00
|
|
|
void setEnvTexture(Texture *t);
|
|
|
|
void setEnvCoefficient(float32 coef);
|
2016-01-24 00:42:51 +00:00
|
|
|
void setDualTexture(Texture *t);
|
|
|
|
void setDualSrcBlend(int32 blend);
|
|
|
|
void setDualDestBlend(int32 blend);
|
|
|
|
|
|
|
|
static void enableEffects(Atomic *atomic);
|
2015-01-09 19:17:32 +00:00
|
|
|
};
|
|
|
|
|
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
|
|
|
|
{
|
2016-01-24 00:42:51 +00:00
|
|
|
enum {
|
|
|
|
TRISTRIP = 1
|
|
|
|
};
|
2014-12-23 14:59:14 +00:00
|
|
|
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);
|
2015-12-20 12:05:32 +00:00
|
|
|
~MeshHeader(void);
|
2014-12-23 14:59:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MorphTarget
|
|
|
|
{
|
|
|
|
float32 boundingSphere[4];
|
|
|
|
float32 *vertices;
|
|
|
|
float32 *normals;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct InstanceDataHeader
|
|
|
|
{
|
|
|
|
uint32 platform;
|
|
|
|
};
|
|
|
|
|
2016-01-24 00:42:51 +00:00
|
|
|
struct Triangle
|
|
|
|
{
|
|
|
|
uint16 v[3];
|
|
|
|
uint16 matId;
|
|
|
|
};
|
|
|
|
|
2016-01-11 10:23:26 +00:00
|
|
|
struct Geometry : PluginBase<Geometry>
|
2014-12-23 14:59:14 +00:00
|
|
|
{
|
2016-01-13 07:58:15 +00:00
|
|
|
enum { ID = 8 };
|
2016-01-11 10:23:26 +00:00
|
|
|
Object object;
|
|
|
|
uint32 geoflags; // TODO: rename
|
2014-12-23 14:59:14 +00:00
|
|
|
int32 numTriangles;
|
|
|
|
int32 numVertices;
|
|
|
|
int32 numMorphTargets;
|
|
|
|
int32 numTexCoordSets;
|
|
|
|
|
2016-01-24 00:42:51 +00:00
|
|
|
Triangle *triangles;
|
2014-12-23 14:59:14 +00:00
|
|
|
uint8 *colors;
|
|
|
|
float32 *texCoords[8];
|
|
|
|
|
|
|
|
MorphTarget *morphTargets;
|
|
|
|
|
2016-01-11 10:23:26 +00:00
|
|
|
// TODO: struct
|
2014-12-23 14:59:14 +00:00
|
|
|
int32 numMaterials;
|
|
|
|
Material **materialList;
|
|
|
|
|
|
|
|
MeshHeader *meshHeader;
|
|
|
|
|
|
|
|
InstanceDataHeader *instData;
|
|
|
|
|
|
|
|
int32 refCount;
|
|
|
|
|
2016-01-11 17:22:59 +00:00
|
|
|
static Geometry *create(int32 numVerts, int32 numTris, uint32 flags);
|
|
|
|
void destroy(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-12-19 16:05:39 +00:00
|
|
|
void calculateBoundingSphere(void);
|
|
|
|
bool32 hasColoredMaterial(void);
|
2015-08-11 19:57:43 +01:00
|
|
|
void allocateData(void);
|
2015-12-16 19:25:22 +00:00
|
|
|
void generateTriangles(int8 *adc = NULL);
|
2016-01-24 00:42:51 +00:00
|
|
|
void buildMeshes(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);
|
2016-01-24 00:42:51 +00:00
|
|
|
static void setPipeline(Atomic *a, int32 type);
|
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;
|
|
|
|
|
2016-01-13 07:58:15 +00:00
|
|
|
struct Atomic : PluginBase<Atomic>
|
|
|
|
{
|
|
|
|
enum { ID = 1 };
|
|
|
|
ObjectWithFrame object;
|
|
|
|
Geometry *geometry;
|
|
|
|
Clump *clump;
|
|
|
|
LLLink inClump;
|
|
|
|
ObjPipeline *pipeline;
|
|
|
|
|
|
|
|
static Atomic *create(void);
|
|
|
|
Atomic *clone(void);
|
|
|
|
void destroy(void);
|
|
|
|
void setFrame(Frame *f) { this->object.setFrame(f); }
|
|
|
|
Frame *getFrame(void) { return (Frame*)this->object.parent; }
|
|
|
|
static Atomic *fromClump(LLLink *lnk){
|
|
|
|
return LLLinkGetData(lnk, Atomic, inClump); }
|
|
|
|
static Atomic *streamReadClump(Stream *stream,
|
|
|
|
Frame **frameList, Geometry **geometryList);
|
|
|
|
bool streamWriteClump(Stream *stream,
|
|
|
|
Frame **frameList, int32 numframes);
|
|
|
|
uint32 streamGetSize(void);
|
|
|
|
ObjPipeline *getPipeline(void);
|
|
|
|
|
|
|
|
static void init(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
extern ObjPipeline *defaultPipelines[NUM_PLATFORMS];
|
|
|
|
|
|
|
|
void registerAtomicRightsPlugin(void);
|
|
|
|
|
2016-01-11 10:23:26 +00:00
|
|
|
struct Light : PluginBase<Light>
|
2014-12-23 14:59:14 +00:00
|
|
|
{
|
2016-01-13 07:58:15 +00:00
|
|
|
enum { ID = 3 };
|
2016-01-11 10:23:26 +00:00
|
|
|
ObjectWithFrame object;
|
2014-12-23 14:59:14 +00:00
|
|
|
float32 radius;
|
2016-01-14 22:49:00 +00:00
|
|
|
RGBAf color;
|
2014-12-23 14:59:14 +00:00
|
|
|
float32 minusCosAngle;
|
2016-01-11 10:23:26 +00:00
|
|
|
|
|
|
|
// clump link handled by plugin in RW
|
2014-12-23 14:59:14 +00:00
|
|
|
Clump *clump;
|
2016-01-11 17:22:59 +00:00
|
|
|
LLLink inClump;
|
2014-12-23 14:59:14 +00:00
|
|
|
|
2016-01-11 17:22:59 +00:00
|
|
|
static Light *create(int32 type);
|
|
|
|
void destroy(void);
|
2016-01-11 10:23:26 +00:00
|
|
|
void setFrame(Frame *f) { this->object.setFrame(f); }
|
2016-01-13 07:58:15 +00:00
|
|
|
Frame *getFrame(void){ return (Frame*)this->object.parent; }
|
2016-01-11 17:22:59 +00:00
|
|
|
static Light *fromClump(LLLink *lnk){
|
2016-01-13 07:58:15 +00:00
|
|
|
return LLLinkGetData(lnk, Light, inClump); }
|
|
|
|
void setAngle(float32 angle);
|
|
|
|
float32 getAngle(void);
|
|
|
|
void setColor(float32 r, float32 g, float32 b);
|
2016-01-14 22:49:00 +00:00
|
|
|
int32 getType(void){ return this->object.subType; }
|
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);
|
2016-01-13 07:58:15 +00:00
|
|
|
|
|
|
|
enum Type {
|
|
|
|
DIRECTIONAL = 1,
|
|
|
|
AMBIENT,
|
|
|
|
POINT = 0x80, // positioned
|
|
|
|
SPOT,
|
|
|
|
SOFTSPOT,
|
|
|
|
};
|
|
|
|
enum Flags {
|
|
|
|
LIGHTATOMICS = 1,
|
|
|
|
LIGHTWORLD = 2
|
|
|
|
};
|
2014-12-23 14:59:14 +00:00
|
|
|
};
|
|
|
|
|
2016-01-13 07:58:15 +00:00
|
|
|
struct Camera : PluginBase<Camera>
|
2014-12-23 14:59:14 +00:00
|
|
|
{
|
2016-01-13 07:58:15 +00:00
|
|
|
enum { ID = 4 };
|
2016-01-11 10:23:26 +00:00
|
|
|
ObjectWithFrame object;
|
2016-01-13 07:58:15 +00:00
|
|
|
V2d viewWindow;
|
|
|
|
V2d viewOffset;
|
2016-01-14 22:49:00 +00:00
|
|
|
float32 nearPlane, farPlane;
|
2016-01-13 07:58:15 +00:00
|
|
|
float32 fogPlane;
|
|
|
|
int32 projection;
|
|
|
|
|
2014-12-23 14:59:14 +00:00
|
|
|
Clump *clump;
|
2016-01-11 17:22:59 +00:00
|
|
|
LLLink inClump;
|
2014-12-23 14:59:14 +00:00
|
|
|
|
2016-01-13 07:58:15 +00:00
|
|
|
static Camera *create(void);
|
|
|
|
Camera *clone(void);
|
2016-01-11 17:22:59 +00:00
|
|
|
void destroy(void);
|
2016-01-11 10:23:26 +00:00
|
|
|
void setFrame(Frame *f) { this->object.setFrame(f); }
|
2016-01-13 07:58:15 +00:00
|
|
|
Frame *getFrame(void){ return (Frame*)this->object.parent; }
|
|
|
|
static Camera *fromClump(LLLink *lnk){
|
|
|
|
return LLLinkGetData(lnk, Camera, inClump); }
|
|
|
|
static Camera *streamRead(Stream *stream);
|
|
|
|
bool streamWrite(Stream *stream);
|
2014-12-23 14:59:14 +00:00
|
|
|
uint32 streamGetSize(void);
|
|
|
|
};
|
|
|
|
|
2016-01-11 10:23:26 +00:00
|
|
|
struct Clump : PluginBase<Clump>
|
2014-12-23 14:59:14 +00:00
|
|
|
{
|
2016-01-13 07:58:15 +00:00
|
|
|
enum { ID = 2 };
|
2016-01-14 22:49:00 +00:00
|
|
|
Object object;
|
2016-01-11 17:22:59 +00:00
|
|
|
LinkList atomics;
|
|
|
|
LinkList lights;
|
2016-01-13 07:58:15 +00:00
|
|
|
LinkList cameras;
|
2014-12-23 14:59:14 +00:00
|
|
|
|
2016-01-11 17:22:59 +00:00
|
|
|
static Clump *create(void);
|
|
|
|
Clump *clone(void);
|
|
|
|
void destroy(void);
|
2016-01-14 22:49:00 +00:00
|
|
|
int32 countAtomics(void) { return this->atomics.count(); }
|
2016-01-11 17:22:59 +00:00
|
|
|
void addAtomic(Atomic *a){
|
|
|
|
a->clump = this;
|
|
|
|
this->atomics.append(&a->inClump);
|
|
|
|
}
|
2016-01-14 22:49:00 +00:00
|
|
|
int32 countLights(void) { return this->lights.count(); }
|
2016-01-11 17:22:59 +00:00
|
|
|
void addLight(Light *l){
|
|
|
|
l->clump = this;
|
|
|
|
this->lights.append(&l->inClump);
|
|
|
|
}
|
2016-01-14 22:49:00 +00:00
|
|
|
int32 countCameras(void) { return this->cameras.count(); }
|
2016-01-13 07:58:15 +00:00
|
|
|
void addCamera(Camera *c){
|
|
|
|
c->clump = this;
|
|
|
|
this->cameras.append(&c->inClump);
|
2016-01-11 23:38:36 +00:00
|
|
|
}
|
2016-01-13 07:58:15 +00:00
|
|
|
void setFrame(Frame *f){
|
|
|
|
this->object.parent = f; }
|
2016-01-11 23:38:36 +00:00
|
|
|
Frame *getFrame(void){
|
2016-01-13 07:58:15 +00:00
|
|
|
return (Frame*)this->object.parent; }
|
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);
|
|
|
|
|
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-09-17 09:44:07 +01:00
|
|
|
struct TexDictionary : PluginBase<TexDictionary>
|
2015-01-20 18:22:57 +00:00
|
|
|
{
|
2016-01-13 07:58:15 +00:00
|
|
|
enum { ID = 6 };
|
2016-01-11 10:23:26 +00:00
|
|
|
Object object;
|
2016-01-11 17:22:59 +00:00
|
|
|
LinkList textures;
|
2015-01-20 18:22:57 +00:00
|
|
|
|
2016-01-11 17:22:59 +00:00
|
|
|
static TexDictionary *create(void);
|
|
|
|
void destroy(void);
|
2016-01-14 22:49:00 +00:00
|
|
|
int32 count(void) { return this->textures.count(); }
|
2016-01-11 17:22:59 +00:00
|
|
|
void add(Texture *t){
|
|
|
|
t->dict = this;
|
|
|
|
this->textures.append(&t->inDict);
|
|
|
|
}
|
2015-01-20 18:22:57 +00:00
|
|
|
Texture *find(const char *name);
|
2015-09-13 19:23:22 +01:00
|
|
|
static TexDictionary *streamRead(Stream *stream);
|
|
|
|
void streamWrite(Stream *stream);
|
|
|
|
uint32 streamGetSize(void);
|
2015-01-20 18:22:57 +00:00
|
|
|
};
|
|
|
|
|
2016-01-13 07:58:15 +00:00
|
|
|
extern TexDictionary *currentTexDictionary;
|
|
|
|
|
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);
|
2015-12-20 00:04:31 +00:00
|
|
|
AnimInterpolatorInfo *findAnimInterpolatorInfo(int32 id);
|
2015-09-09 22:26:16 +01:00
|
|
|
|
|
|
|
struct Animation
|
|
|
|
{
|
|
|
|
AnimInterpolatorInfo *interpInfo;
|
|
|
|
int32 numFrames;
|
|
|
|
int32 flags;
|
|
|
|
float duration;
|
|
|
|
void *keyframes;
|
|
|
|
void *customData;
|
|
|
|
|
2016-01-14 22:49:00 +00:00
|
|
|
static Animation *create(AnimInterpolatorInfo*, int32 numFrames, int32 flags, float duration);
|
|
|
|
void destroy(void);
|
2015-09-09 22:26:16 +01:00
|
|
|
static Animation *streamRead(Stream *stream);
|
2015-09-11 11:32:06 +01:00
|
|
|
static Animation *streamReadLegacy(Stream *stream);
|
2015-09-09 22:26:16 +01:00
|
|
|
bool streamWrite(Stream *stream);
|
2015-09-11 11:32:06 +01:00
|
|
|
bool streamWriteLegacy(Stream *stream);
|
2015-09-09 22:26:16 +01:00
|
|
|
uint32 streamGetSize(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AnimInterpolator
|
|
|
|
{
|
|
|
|
// only a stub right now
|
|
|
|
Animation *anim;
|
|
|
|
|
|
|
|
AnimInterpolator(Animation *anim);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UVAnimKeyFrame
|
|
|
|
{
|
|
|
|
UVAnimKeyFrame *prev;
|
|
|
|
float time;
|
|
|
|
float uv[6];
|
|
|
|
};
|
|
|
|
|
2016-01-14 22:49:00 +00:00
|
|
|
struct UVAnimDictionary;
|
|
|
|
|
|
|
|
// RW does it differently...maybe we should implement RtDict
|
|
|
|
// and make it more general?
|
|
|
|
|
2015-09-09 22:26:16 +01:00
|
|
|
struct UVAnimCustomData
|
|
|
|
{
|
|
|
|
char name[32];
|
|
|
|
int32 nodeToUVChannel[8];
|
2016-01-14 22:49:00 +00:00
|
|
|
int32 refCount;
|
|
|
|
|
|
|
|
void destroy(Animation *anim);
|
|
|
|
};
|
|
|
|
|
|
|
|
// This should be more general probably
|
|
|
|
struct UVAnimDictEntry
|
|
|
|
{
|
|
|
|
Animation *anim;
|
|
|
|
LLLink inDict;
|
|
|
|
static UVAnimDictEntry *fromDict(LLLink *lnk){
|
|
|
|
return LLLinkGetData(lnk, UVAnimDictEntry, inDict); }
|
2015-09-09 22:26:16 +01:00
|
|
|
};
|
|
|
|
|
2016-01-14 22:49:00 +00:00
|
|
|
// This too
|
2015-09-09 22:26:16 +01:00
|
|
|
struct UVAnimDictionary
|
|
|
|
{
|
2016-01-14 22:49:00 +00:00
|
|
|
LinkList animations;
|
|
|
|
|
|
|
|
static UVAnimDictionary *create(void);
|
|
|
|
void destroy(void);
|
|
|
|
int32 count(void) { return this->animations.count(); }
|
|
|
|
void add(Animation *anim);
|
|
|
|
Animation *find(const char *name);
|
2015-09-09 22:26:16 +01:00
|
|
|
|
|
|
|
static UVAnimDictionary *streamRead(Stream *stream);
|
|
|
|
bool streamWrite(Stream *stream);
|
|
|
|
uint32 streamGetSize(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
extern UVAnimDictionary *currentUVAnimDictionary;
|
|
|
|
|
2016-01-24 00:42:51 +00:00
|
|
|
struct UVAnim
|
|
|
|
{
|
|
|
|
AnimInterpolator *interp[8];
|
|
|
|
};
|
|
|
|
|
2015-09-09 22:26:16 +01:00
|
|
|
extern int32 uvAnimOffset;
|
|
|
|
|
|
|
|
void registerUVAnimPlugin(void);
|
|
|
|
|
2015-01-06 22:17:05 +00:00
|
|
|
}
|