lsb.h 4.23 KB
/******************************************************************************
**
** (C) Copyright 1991, 1992, 1993 Lightscape Graphics Software, Ltd.
**
** $Header: /root/leakn64/depot/rf/sw/n64os20l/tools/translator/lsb.h,v 1.1.1.2 2002/10/29 08:07:16 blythe Exp $
**
** $Log: lsb.h,v $
** Revision 1.1.1.2  2002/10/29 08:07:16  blythe
** n64os20l from nintendo
**
** Revision 1.1  1995/08/19 01:39:58  goslin
** Initial revision
**
 * Revision 1.1  1995/05/31  23:18:18  goslin
 * Initial revision
 *
 * Revision 1.5  95/03/31  13:18:55  goslin
 * *** empty log message ***
 * 
 * Revision 1.4  95/03/30  20:28:35  goslin
 * *** empty log message ***
 * 
 * Revision 1.3  95/03/30  00:17:30  goslin
 * *** empty log message ***
 * 
 * Revision 1.2  95/03/21  01:12:50  goslin
 * *** empty log message ***
 * 
 * Revision 1.1  95/02/12  22:31:05  goslin
 * Initial revision
 * 
 * Revision 1.2  94/10/12  17:40:43  weberh
 * converts with single structure
 * 
 * Revision 1.1  94/10/11  16:26:11  weberh
 * Initial revision
 * 
**
******************************************************************************/

#ifndef __LSB_H__
#define __LSB_H__

#include "bead.H"

/* added by weberh to get rid of performer and sgi dependence */
typedef float vec4[4];
typedef float vec3[3];
typedef float vec2[2];
typedef unsigned long ulong;
#ifndef SEEK_SET
#define SEEK_SET        0
#define SEEK_CUR        1
#define SEEK_END        2
#endif  /* SEEK_SET */
#define SETVEC4(a,b,c,d,e)  (a)[0]=(b);(a)[1]=(c);(a)[2]=(d);(a)[3]=(e);
#define SETVEC3(a,b,c,d)    (a)[0]=(b);(a)[1]=(c);(a)[2]=(d);
#define SETVEC2(a,b,c)      (a)[0]=(b);(a)[1]=(c);
#define COPYVEC4(a,b)       (a)[0]=(b)[0];(a)[1]=(b)[1];\
                            (a)[2]=(b)[2];(a)[3]=(b)[3];
/* end of added stuff -- got rid of some performer stuff below */

#define LSB_VERSION_1  1

#define LSB_SIGNATURE  "Lightscape Radiosity LSB Format"
#define LSB_BEGIN_CHAR  '!'

/* PatchCluster Flags */
#define LSB_BIG_CLUSTER  0x0001
#define LSB_TEXTURED	 0x0002

typedef struct lsbHeader {
    short LSBversion;
    short fileFlags;
    ulong numPatchClusters;
    ulong numTopNodes;
    ulong numNodes;
    ulong numTopPatchVertices;
    ulong numPatchVertices;
    ulong numMaterials;
    ulong numLayers;
    ulong numTextures;
} LSBheader;

typedef struct lsbTopPatchVertex {
    float coord[3];
    float color[3];
} LSBtopPatchVertex;

typedef struct lsbPatchVertex {
    float color[3];
} LSBpatchVertex;

typedef struct lsbTopPatchVertexTextured {
    float coord[3];
    float color[3];
    float uv[2];
} LSBtopPatchVertexTextured;

typedef struct lsbPatchCluster {
    short flags;
    vec4  plane;
    ulong materialId;
    ulong layerId;
    ulong textureId;
    ushort numTopNodes;
    ushort numNodes;
    ushort numTopVertices;
    ushort numVertices;
} LSBpatchCluster;

typedef struct lsbPatchLeaf {
    ushort vertices[4];
    ushort midVertices[4];
} LSBpatchLeaf;

typedef struct lsbPatchClusterLong {
    short flags;
    float plane[4];
    ulong materialId;
    ulong layerId;
    ulong textureId;
    ulong numTopNodes;
    ulong numNodes;
    ulong numTopVertices;
    ulong numVertices;
} LSBpatchClusterLong;

typedef struct lsbPatchLeafLong {
    ulong vertices[4];
    ulong midVertices[4];
} LSBpatchLeafLong;

#define NODE_IS_TRIANGLE(node)    ((node)->vertices[3] == (LSpatchVertex *)0)
#define NODE_IS_RECT(node)      ((node)->vertices[3] != (LSpatchVertex *)0)
#define ELEMENT_IS_TRIANGLE(e)    NODE_IS_TRIANGLE(e->node)
#define ELEMENT_IS_RECT(e)      NODE_IS_RECT(e->node)
#define NUM_NODE_VERTICES(node)    (NODE_IS_TRIANGLE(node) ? 3 : 4)
#define NUM_PATCH_VERTICES(node)  (PATCH_IS_TRIANGLE(node) ? 3 : 4)
#define NUM_ELEMENT_VERTICES(node)  (ELEMENT_IS_TRIANGLE(node) ? 3 : 4)

typedef struct lsMaterial {
    char *name;
} LSmaterial;

typedef struct lsLayer {
    char *name;
} LSlayer;

typedef struct lsTexture {
    char *name;
} LStexture;

typedef struct lsPatchVertex {
    ushort flags;
    ulong index;
} LSpatchVertex;

typedef struct lsPatchNode {
    short isLeaf;
    LSpatchVertex *vertices[4];
    struct lsPatchNode *children[4];
} LSpatchNode;

typedef struct lsPatchCluster {
    ushort flags;
    float plane[4];
    LSmaterial *material;
    LSlayer *layer;
    LStexture *texture;
} LSpatchCluster;

#endif