Lephisto/src/sbre/sbre_int.h
Rtch90 4ae98085e2 [Add] Body::OrientOnSurface for placing things on planets.
[Add] Small start on ground based starports.
[Fix] ToggleButton.
2018-01-20 22:37:38 +00:00

186 lines
4.9 KiB
C

#pragma once
#include "jjtypes.h"
#include "jjvector.h"
#include "sbre.h"
/******************************************************************************/
enum vtxtype {
VTYPE_PLAIN = 0,
VTYPE_DIR,
VTYPE_CROSS,
VTYPE_NORM,
VTYPE_ANIMLIN,
VTYPE_ANIMCUBIC,
VTYPE_ANIMHERM,
VTYPE_ANIMROTATE,
};
struct PlainVertex {
uint32 type;
Vector pos;
};
struct CompoundVertex {
uint16 type;
uint16 pParam[5];
};
/******************************************************************************/
struct Thruster {
uint16 pos; /* Index into vertices. */
uint16 dir;
float power;
int detail; /* 0 - min, 1 - mid, 2 - max. */
};
struct Model {
float scale;
float radius; /* Scale multiplies this too. */
int numPVtx;
PlainVertex* pPVtx;
int cvStart;
int numCVtx;
CompoundVertex* pCVtx;
int numCache; /* Number of cached primitives. */
struct {
float pixrad; /* Size in screen pixels below which LOD applies. */
uint16* pData1; /* pixrad <= 0.0f is top LOD - kinda backwards. */
uint16* pData2;
int numThrusters;
Thruster* pThruster;
} pLOD[4];
int* pNumVtx, *pNumIdx; /* Caches. */
Vector** ppVCache;
uint16** ppICache;
};
/******************************************************************************/
/* AnimFuncs. */
enum animmod {
AMOD_CLIP = 0, /* Just clip result to 0-1. */
AMOD_MOD1, /* fmod(1), then clip. */
AMOD_REF, /* fmod(2), reflect around 1, then clip. */
};
struct AnimFunc {
int src;
int mod;
float order0;
float order1;
float order2;
float order3;
};
enum animfunc {
AFUNC_GEAR = 0,
AFUNC_GFLAP,
AFUNC_THRUSTPULSE,
AFUNC_LIN4SEC,
};
const AnimFunc pAFunc[] = {
{ ASRC_GEAR, AMOD_CLIP, -1.0f, 2.0f, 0.0f, 0.0f },
{ ASRC_GEAR, AMOD_CLIP, 0.0f, 2.0f, 0.0f, 0.0f },
{ ASRC_MINFRAC, AMOD_REF, 0.0f, 30.0f, 0.0f, 0.0f },
{ ASRC_MINFRAC, AMOD_MOD1, 0.0f, 15.0f, 0.0f, 0.0f },
};
/******************************************************************************/
/* From simtriang.cpp. */
#define TRIANG_MAXPOINTS 64
#define TRIANG_MAXSTEPS 5
void ResolveLinearInterp(Vector* p0, Vector* p1, float t, Vector* pRes);
void ResolveQuadraticSpline(Vector* p0, Vector* p1, Vector* p2, float t, Vector* pRes);
void ResolveCubicSpline(Vector* p0, Vector* p1, Vector* p2, Vector* p3, float t, Vector* pRes);
void ResolveHermiteSpline(Vector* p0, Vector* p1, Vector* n0, Vector* n1, float t, Vector* pRes);
void ResolveHermiteNormal(Vector* p0, Vector* p1, Vector* n0, Vector* n1, float t, Vector* pRes);
void TriangAddPoint(Vector* pPos, Vector* pNorm);
void Triangulate(Vector* pCPos, Vector* pCNorm, int steps,
Vector** ppVtx, int* pNV, uint16** ppIndex, int* pNI);
/******************************************************************************/
/* Random Rendering stuff. */
struct RState {
Model* pModel; /* Original model. */
Vector* pVtx; /* Transformed vertices. */
Vector campos; /* Camera pos relative to model. */
Vector objpos; /* Object pos relative to camera. */
Matrix objorient; /* Object orient relative to camera. */
float scale; /* Current GL modelview scale. */
ObjParams* pObjParam; /* Dynamic object parameters. */
float dn, df; /* Near/far depth range. */
Vector compos; /* Object relative center of mass. */
/* Collision output stuff. */
CollMesh* pCMesh;
void(*pCallback)(int nv, int ni, Vector* pVertex, uint16* pIndex, uint16 flags, RState*);
};
enum primtype {
PTYPE_END = 0,
PTYPE_MATANIM,
PTYPE_MATFIXED,
PTYPE_MATVAR,
PTYPE_ZBIAS,
PTYPE_TRIFLAT,
PTYPE_QUADFLAT,
PTYPE_COMPFLAT,
PTYPE_COMPSMOOTH,
PTYPE_CIRCLE,
PTYPE_CYLINDER,
PTYPE_TUBE,
PTYPE_SUBOBJECT,
PTYPE_TEXT,
PTYPE_EXTRUSION,
PTYPE_SETCFLAG,
};
extern int (*pPrimFuncTable[])(uint16*, Model*, RState*);
extern int (*pCollFuncTable[])(uint16*, Model*, RState*);
static const int RFLAG_XREF = 0x8000;
static const int RFLAG_INVISIBLE = 0x4000;
static const int SUBOBJ_THRUST = 0x4000;
static const int THRUST_XREF = 0x8000;
static const int THRUST_NOANG = 0x4000;
//static const float SBRE_ZBIAS = 0.00002f;
static const float SBRE_AMB = 0.3f;
extern float SBRE_ZBIAS;
enum comptype {
COMP_END = 0,
COMP_LINE,
COMP_HERMITE,
COMP_HERM_NOTAN,
COMP_HERM_AUTOTAN,
COMP_STEPS,
};
const int pCompSize[] = { 1, 3, 5, 3, 3, 2 };
const char pModelString[][256] = {
"IZRILGOOD", "Rawr", "", "", "", "", "", "", "", "",
/* 10 - Landing pad messages. */
"1"
};
void RenderThrusters(RState* pState, int numThrusters, Thruster* pThrusters);
float ResolveAnim (ObjParams* pObjParam, uint16 type);
void GenCollMeshInternal(Vector* pPos, Matrix* pOrient, int model, ObjParams* pParam,
float s, CollMesh* pCMesh);