openmohaa/code/tiki/tiki_shared.h

434 lines
12 KiB
C
Raw Normal View History

2016-03-27 11:49:47 +02:00
/*
===========================================================================
2023-11-06 18:08:21 +01:00
Copyright (C) 2023 the OpenMoHAA team
2016-03-27 11:49:47 +02:00
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// tiki_shared.h : Skeletor
2023-02-01 00:28:40 +01:00
#pragma once
2016-03-27 11:49:47 +02:00
#ifdef __cplusplus
2023-11-06 18:08:21 +01:00
# include "../skeletor/skeletor_name_lists.h"
2016-03-27 11:49:47 +02:00
#endif
2023-02-01 00:28:40 +01:00
#include "../skeletor/skeletor_model_file_format.h"
2016-03-27 11:49:47 +02:00
// animation flags
2023-11-06 18:08:21 +01:00
#define TAF_RANDOM 0x1 // random
#define TAF_NOREPEAT 0x2 // no loop
#define TAF_DONTREPEAT (TAF_RANDOM | TAF_NOREPEAT) // don't repeat
#define TAF_DEFAULT_ANGLES 0x8 // ?
#define TAF_NOTIMECHECK 0x10 // don't check for timing
#define TAF_DELTADRIVEN 0x20 // animation is based on skeletor animation's delta
#define TAF_AUTOSTEPS 0x400 // footsteps for dogs
#define TAF_AUTOSTEPS_RUNNING 0x800 // footsteps for dogs
#define TAF_AUTOSTEPS_EQUIPMENT 0x1000
2016-03-27 11:49:47 +02:00
// skeletor animation flags
2023-11-06 18:08:21 +01:00
#define TAF_HASDELTA 0x40
#define TAF_HASMORPH 0x80
#define TAF_HASUPPER 0x100
2016-03-27 11:49:47 +02:00
// tiki anim command frames
2023-11-06 18:08:21 +01:00
#define TIKI_FRAME_LAST -5 // exec at last
#define TIKI_FRAME_END -4 // exec at end
#define TIKI_FRAME_ENTRY -3 // exec at entry
#define TIKI_FRAME_EXIT -2 // exec at exit
#define TIKI_FRAME_EVERY -1 // exec each frame
#define TIKI_FRAME_FIRST 0 // exec at first frame
#define TIKI_FRAME_MAXFRAMERATE 60
2016-03-27 11:49:47 +02:00
2024-06-07 22:38:45 +02:00
#define TIKI_SKEL_LOD_INDEXES 10
2016-03-27 11:49:47 +02:00
// skb skeletor
2023-11-06 18:08:21 +01:00
#define TIKI_SKB_HEADER_IDENT (*(int *)"SKL ")
#define TIKI_SKB_HEADER_VER_3 3
#define TIKI_SKB_HEADER_VERSION 4
2016-03-27 11:49:47 +02:00
// skd skeletor
2023-11-06 18:08:21 +01:00
#define TIKI_SKD_HEADER_IDENT (*(int *)"SKMD")
#define TIKI_SKD_HEADER_OLD_VERSION 5
#define TIKI_SKD_HEADER_VERSION 6
2016-03-27 11:49:47 +02:00
// skc skeletor animations
2023-11-06 18:08:21 +01:00
#define TIKI_SKC_HEADER_IDENT (*(int *)"SKAN")
#define TIKI_SKC_HEADER_OLD_VERSION 13
#define TIKI_SKC_HEADER_VERSION 14
2016-03-27 11:49:47 +02:00
// tiki limitations
2024-06-07 22:38:45 +02:00
#define TIKI_MAX_BONES 100
#define TIKI_MAX_VERTEXES 1000
#define TIKI_MAX_TRIANGLES 2000
#define TIKI_MAX_SKELCACHE 1024
#define TIKI_MAX_COMMANDS 128
2016-03-27 11:49:47 +02:00
2024-02-20 20:44:55 +01:00
#define TIKI_MAX_ENTITIES 2048
#define TIKI_MAX_ENTITY_CACHE_PER_ENT 2
#define TIKI_MAX_ENTITY_CACHE (TIKI_MAX_ENTITIES*TIKI_MAX_ENTITY_CACHE_PER_ENT)
2016-03-27 11:49:47 +02:00
// tiki surface flags
2023-11-06 18:08:21 +01:00
#define TIKI_SURF_SKIN1 (1 << 0)
#define TIKI_SURF_SKIN2 (1 << 1)
#define TIKI_SURF_SKIN3 (TIKI_SURF_SKIN1 | TIKI_SURF_SKIN2)
#define TIKI_SURF_NODRAW (1 << 2)
#define TIKI_SURF_CROSSFADE (1 << 6)
#define TIKI_SURF_NODAMAGE (1 << 7)
#define TIKI_SURF_NOMIPMAPS (1 << 8)
#define TIKI_SURF_NOPICMIP (1 << 9)
#define MAX_SKELMODELS 12
#define MAX_TIKI_SHADER 4
#define MAX_TIKI_ALIASES 4095
#define MAX_GLOBAL_FROM_LOCAL 200
2023-11-06 18:08:21 +01:00
2024-06-22 15:28:58 +02:00
#define MAX_LOD_CURVE_POINTS 5
#define MAX_LOD_CURVE_CONSTS 4
2023-11-06 18:08:21 +01:00
typedef struct AliasList_s AliasList_t;
2016-03-27 11:49:47 +02:00
typedef struct AliasListNode_s AliasListNode_t;
typedef struct tiki_singlecmd_s {
2023-11-06 18:08:21 +01:00
int num_args;
char **args;
2016-03-27 11:49:47 +02:00
} tiki_singlecmd_t;
typedef struct tiki_cmd_s {
2023-11-06 18:08:21 +01:00
int num_cmds;
tiki_singlecmd_t cmds[TIKI_MAX_COMMANDS];
2016-03-27 11:49:47 +02:00
} tiki_cmd_t;
#ifdef __cplusplus
2023-11-06 18:08:21 +01:00
typedef class skelChannelList_s
{
2016-03-27 11:49:47 +02:00
public:
2023-11-06 18:08:21 +01:00
short int m_numChannels;
2016-03-27 11:49:47 +02:00
private:
2023-11-06 18:08:21 +01:00
short int m_numLocalFromGlobal;
short int *m_chanLocalFromGlobal;
2016-03-27 11:49:47 +02:00
public:
short int m_chanGlobalFromLocal[MAX_GLOBAL_FROM_LOCAL];
2023-11-06 18:08:21 +01:00
int NumChannels(void) const;
void ZeroChannels(void);
void PackChannels(void);
void InitChannels(void);
void CleanUpChannels();
int GlobalChannel(int localchannel) const;
int LocalChannel(int channel) const;
int GetLocalFromGlobal(int globalChannel) const;
void SetLocalFromGlobal(int channel, int localchannel);
qboolean HasChannel(ChannelNameTable *nameTable, const char *channelName) const;
qboolean HasChannel(int channel) const;
int AddChannel(int newGlobalChannelNum);
const char *ChannelName(ChannelNameTable *nameTable, int localChannelNum) const;
2016-03-27 11:49:47 +02:00
} skelChannelList_c;
#else
typedef struct skelChannelList_s {
2023-11-06 18:08:21 +01:00
short int m_numChannels;
short int m_numLocalFromGlobal;
short int *m_chanLocalFromGlobal;
2024-06-13 21:25:02 +02:00
short int m_chanGlobalFromLocal[MAX_GLOBAL_FROM_LOCAL];
2016-03-27 11:49:47 +02:00
} skelChannelList_c;
#endif
typedef struct dtikianim_s {
2023-11-06 18:08:21 +01:00
char *name;
int num_anims;
void *alias_list;
int num_client_initcmds;
struct dtikicmd_s *client_initcmds;
int num_server_initcmds;
struct dtikicmd_s *server_initcmds;
byte *modelData;
size_t modelDataSize;
2023-11-06 18:11:12 +01:00
vec3_t mins;
vec3_t maxs;
2023-11-06 18:08:21 +01:00
short int *m_aliases;
char *headmodels;
char *headskins;
qboolean bIsCharacter;
struct dtikianimdef_s *animdefs[1];
2016-03-27 11:49:47 +02:00
} dtikianim_t;
typedef struct dtiki_s {
2023-11-06 18:08:21 +01:00
char *name;
dtikianim_t *a;
void *skeletor;
int num_surfaces;
struct dtikisurface_s *surfaces;
float load_scale;
float lod_scale;
float lod_bias;
2023-11-06 18:11:12 +01:00
vec3_t light_offset;
vec3_t load_origin;
2023-11-06 18:08:21 +01:00
float radius;
skelChannelList_c m_boneList;
int numMeshes;
short int mesh[1];
2016-03-27 11:49:47 +02:00
#ifdef __cplusplus
2023-11-06 18:08:21 +01:00
int GetBoneNumFromName(const char *name);
const char *GetBoneNameFromNum(int num) const;
2016-03-27 11:49:47 +02:00
#endif
} dtiki_t;
typedef struct {
2024-06-08 00:08:54 +02:00
int ident;
int version;
char name[64];
int numSurfaces;
int numBones;
int ofsBones;
int ofsSurfaces;
int ofsEnd;
int lodIndex[TIKI_SKEL_LOD_INDEXES];
int numBoxes;
int ofsBoxes;
int numMorphTargets;
int ofsMorphTargets;
// Added in 2.0 (SKD version 6)
float scale;
2016-03-27 11:49:47 +02:00
} skelHeader_t;
typedef struct {
2023-11-06 18:08:21 +01:00
short int parent;
short int boxIndex;
int flags;
char name[64];
2016-03-27 11:49:47 +02:00
} skelBoneName_t;
typedef struct {
2023-11-06 18:08:21 +01:00
int ident;
char name[64];
int numTriangles;
int numVerts;
int staticSurfProcessed;
int ofsTriangles;
int ofsVerts;
int ofsCollapse;
int ofsEnd;
int ofsCollapseIndex;
2016-03-27 11:49:47 +02:00
} skelSurface_t;
typedef short int skelIndex_t;
2023-11-06 18:08:21 +01:00
typedef struct skelSurfaceGame_s {
int ident;
char name[MAX_QPATH];
int numTriangles;
int numVerts;
vec4_t *pStaticXyz;
vec4_t *pStaticNormal;
vec2_t (*pStaticTexCoords)[2];
skelIndex_t *pTriangles;
struct skeletorVertex_s *pVerts;
skelIndex_t *pCollapse;
struct skelSurfaceGame_s *pNext;
skelIndex_t *pCollapseIndex;
2016-03-27 11:49:47 +02:00
#ifdef __cplusplus
2023-11-06 18:08:21 +01:00
skelSurfaceGame_s();
2016-03-27 11:49:47 +02:00
#endif
} skelSurfaceGame_t;
typedef struct skelHeaderGame_s {
2023-11-06 18:08:21 +01:00
int version;
char name[64];
int numSurfaces;
int numBones;
struct boneData_s *pBones;
skelSurfaceGame_t *pSurfaces;
2024-06-07 22:38:45 +02:00
int lodIndex[TIKI_SKEL_LOD_INDEXES];
2023-11-06 18:08:21 +01:00
int numBoxes;
struct skelHitBox_s *pBoxes;
struct lodControl_s *pLOD;
int numMorphTargets;
char *pMorphTargets;
2024-11-11 18:12:50 +01:00
float scale;
2016-03-27 11:49:47 +02:00
} skelHeaderGame_t;
typedef struct boneData_s {
2023-11-06 18:08:21 +01:00
short int channel;
boneType_t boneType;
short int parent;
short int numChannels;
short int numRefs;
short int channelIndex[2];
short int refIndex[2];
vec3_t offset;
float length;
float weight;
float bendRatio;
float bendMax;
float spinRatio;
2016-03-27 11:49:47 +02:00
} boneData_t;
typedef struct tikiSurface_s {
2023-11-06 18:08:21 +01:00
int ident;
char name[64];
int numFrames;
int numVerts;
int minLod;
int numTriangles;
int ofsTriangles;
int ofsCollapseMap;
int ofsSt;
int ofsXyzNormals;
int ofsEnd;
2016-03-27 11:49:47 +02:00
} tikiSurface_t;
typedef struct dtikisurface_s {
2023-11-06 18:08:21 +01:00
char name[MAX_QPATH];
char shader[MAX_TIKI_SHADER][MAX_QPATH];
int hShader[MAX_TIKI_SHADER];
int numskins;
int flags;
float damage_multiplier;
2016-03-27 11:49:47 +02:00
} dtikisurface_t;
/*typedef struct tikiFrame_s {
vec3_t bounds[ 2 ];
vec3_t scale;
vec3_t offset;
vec3_t delta;
float radius;
float frametime;
} tikiFrame_t;*/
typedef struct tiki_tess_data_s {
2023-11-06 18:08:21 +01:00
int ident;
tikiSurface_t *newsurface;
tikiSurface_t *oldsurface;
2016-03-27 11:49:47 +02:00
} tiki_tess_data_t;
typedef struct skelWeight_s {
2023-11-06 18:08:21 +01:00
int boneIndex;
float boneWeight;
vec3_t offset;
2016-03-27 11:49:47 +02:00
} skelWeight_t;
typedef struct skelVertex_s {
2023-11-06 18:08:21 +01:00
vec3_t normal;
vec2_t texCoords;
int numWeights;
skelWeight_t weights[1];
2016-03-27 11:49:47 +02:00
} skelVertex_t;
typedef struct skeletorVertex_s {
2023-11-06 18:08:21 +01:00
vec3_t normal;
vec2_t texCoords;
int numWeights;
int numMorphs;
2016-03-27 11:49:47 +02:00
} skeletorVertex_t;
typedef struct skeletorVertexGame_s {
2023-11-06 18:08:21 +01:00
vec3_t normal;
vec2_t texCoords;
int numWeights;
int numMorphs;
2016-03-27 11:49:47 +02:00
} skeletorVertexGame_t;
2023-05-08 14:33:37 +02:00
typedef struct staticSurface_s {
2023-11-06 18:08:21 +01:00
int ident;
int ofsStaticData;
skelSurfaceGame_t *surface;
int meshNum;
2016-03-27 11:49:47 +02:00
} staticSurface_t;
typedef struct {
2023-11-06 18:08:21 +01:00
int morphIndex;
vec3_t offset;
2016-03-27 11:49:47 +02:00
} skeletorMorph_t;
typedef struct dtikianimdef_s {
2023-11-06 18:08:21 +01:00
char alias[48];
float weight;
float blendtime;
int flags;
int num_client_cmds;
struct dtikicmd_s *client_cmds;
int num_server_cmds;
struct dtikicmd_s *server_cmds;
2016-03-27 11:49:47 +02:00
} dtikianimdef_t;
typedef struct {
2023-11-06 18:08:21 +01:00
short int shortQuat[4];
short int shortOffset[3];
short int pad;
2016-03-27 11:49:47 +02:00
} skelBone_t;
typedef struct {
2023-11-06 18:11:12 +01:00
vec3_t bounds[2];
2023-11-06 18:08:21 +01:00
float radius;
2023-11-06 18:11:12 +01:00
vec3_t delta;
2023-11-06 18:08:21 +01:00
skelBone_t bones[1];
2016-03-27 11:49:47 +02:00
} skelFrame_t;
typedef struct {
2023-11-06 18:11:12 +01:00
int ident;
int version;
char name[64];
int type;
int numFrames;
int numbones;
float totaltime;
float frametime;
vec3_t totaldelta;
int ofsFrames;
2016-03-27 11:49:47 +02:00
} skelAnimHeader_t;
typedef struct {
2023-11-06 18:08:21 +01:00
float offset[4];
float matrix[3][4];
2016-03-27 11:49:47 +02:00
} skelBoneCache_t;
typedef struct {
2023-11-06 18:08:21 +01:00
float pos;
float val;
2016-03-27 11:49:47 +02:00
} lodCurvePoint_t;
typedef struct {
2023-11-06 18:08:21 +01:00
float base;
float scale;
float cutoff;
2016-03-27 11:49:47 +02:00
} lodCurvePointConstants_t;
typedef struct lodControl_s {
2023-11-06 18:08:21 +01:00
float minMetric;
float maxMetric;
2024-06-22 15:28:58 +02:00
lodCurvePoint_t curve[MAX_LOD_CURVE_POINTS];
lodCurvePointConstants_t consts[MAX_LOD_CURVE_CONSTS];
2016-03-27 11:49:47 +02:00
} lodControl_t;
typedef struct {
2023-11-06 18:08:21 +01:00
char path[96];
skelHeaderGame_t *skel;
size_t size;
int numuses;
2016-03-27 11:49:47 +02:00
} skelcache_t;
typedef int skeletorMorphCache_t;