This repository has been archived on 2022-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
Xash3DArchive/engine/studio.h

368 lines
9.2 KiB
C
Raw Normal View History

2010-10-26 22:00:00 +02:00
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
2010-07-08 22:00:00 +02:00
#ifndef STUDIO_H
#define STUDIO_H
2009-01-11 22:00:00 +01:00
/*
==============================================================================
STUDIO MODELS
Studio models are position independent, so the cache manager can move them.
==============================================================================
*/
// header
#define STUDIO_VERSION 10
#define IDSTUDIOHEADER (('T'<<24)+('S'<<16)+('D'<<8)+'I') // little-endian "IDST"
#define IDSEQGRPHEADER (('Q'<<24)+('S'<<16)+('D'<<8)+'I') // little-endian "IDSQ"
// studio limits
#define MAXSTUDIOTRIANGLES 32768 // max triangles per model
#define MAXSTUDIOVERTS 4096 // max vertices per submodel
#define MAXSTUDIOSEQUENCES 256 // total animation sequences
#define MAXSTUDIOSKINS 128 // total textures
#define MAXSTUDIOSRCBONES 512 // bones allowed at source movement
#define MAXSTUDIOBONES 128 // total bones actually used
#define MAXSTUDIOMODELS 32 // sub-models per model
#define MAXSTUDIOBODYPARTS 32 // body parts per submodel
#define MAXSTUDIOGROUPS 16 // sequence groups (e.g. barney01.mdl, barney02.mdl, e.t.c)
#define MAXSTUDIOANIMATIONS 512 // max frames per sequence
#define MAXSTUDIOMESHES 256 // max textures per model
#define MAXSTUDIOEVENTS 1024 // events per model
#define MAXSTUDIOPIVOTS 256 // pivot points
#define MAXSTUDIOBLENDS 16 // max anim blends
2010-10-26 22:00:00 +02:00
#define MAXSTUDIOCONTROLLERS 8 // max controllers per model
#define MAXSTUDIOATTACHMENTS 4 // max attachments per model
2009-01-11 22:00:00 +01:00
2011-09-03 22:00:00 +02:00
// client-side model flags
#define STUDIO_ROCKET 0x0001 // leave a trail
#define STUDIO_GRENADE 0x0002 // leave a trail
#define STUDIO_GIB 0x0004 // leave a trail
#define STUDIO_ROTATE 0x0008 // rotate (bonus items)
#define STUDIO_TRACER 0x0010 // green split trail
#define STUDIO_ZOMGIB 0x0020 // small blood trail
#define STUDIO_TRACER2 0x0040 // orange split trail + rotate
#define STUDIO_TRACER3 0x0080 // purple trail
2011-01-08 22:00:00 +01:00
#define STUDIO_DYNAMIC_LIGHT 0x0100 // dynamically get lighting from floor or ceil (flying monsters)
#define STUDIO_TRACE_HITBOX 0x0200 // always use hitbox trace instead of bbox
2009-01-11 22:00:00 +01:00
// lighting & rendermode options
#define STUDIO_NF_FLATSHADE 0x0001
#define STUDIO_NF_CHROME 0x0002
#define STUDIO_NF_FULLBRIGHT 0x0004
#define STUDIO_NF_COLORMAP 0x0008 // can changed by colormap command
#define STUDIO_NF_BLENDED 0x0010 // rendering as semiblended
#define STUDIO_NF_ADDITIVE 0x0020 // rendering with additive mode
#define STUDIO_NF_TRANSPARENT 0x0040 // use texture with alpha channel
2009-08-30 22:00:00 +02:00
#define STUDIO_NF_NORMALMAP 0x0080 // indexed normalmap
2009-09-04 22:00:00 +02:00
#define STUDIO_NF_HEIGHTMAP 0x0100 // heightmap that can be used for parallax or normalmap
2009-08-30 22:00:00 +02:00
#define STUDIO_NF_GLOSSMAP 0x0200 // glossmap
#define STUDIO_NF_DECALMAP 0x0400 // decalmap (currently unused)
#define STUDIO_NF_GLOWMAP 0x0800 // optional luma_texture
2009-08-25 22:00:00 +02:00
#define STUDIO_NF_QUAKESKIN 0x8000 // special hack for determine alias skins
2009-01-11 22:00:00 +01:00
// motion flags
#define STUDIO_X 0x0001
#define STUDIO_Y 0x0002
#define STUDIO_Z 0x0004
#define STUDIO_XR 0x0008
#define STUDIO_YR 0x0010
#define STUDIO_ZR 0x0020
#define STUDIO_LX 0x0040
#define STUDIO_LY 0x0080
#define STUDIO_LZ 0x0100
#define STUDIO_AX 0x0200
#define STUDIO_AY 0x0400
#define STUDIO_AZ 0x0800
#define STUDIO_AXR 0x1000
#define STUDIO_AYR 0x2000
#define STUDIO_AZR 0x4000
#define STUDIO_TYPES 0x7FFF
#define STUDIO_RLOOP 0x8000 // controller that wraps shortest distance
// bonecontroller types
#define STUDIO_MOUTH 4
// sequence flags
#define STUDIO_LOOPING 0x0001
// bone flags
#define STUDIO_HAS_NORMALS 0x0001
#define STUDIO_HAS_VERTICES 0x0002
#define STUDIO_HAS_BBOX 0x0004
typedef struct
{
int ident;
int version;
char name[64];
int length;
vec3_t eyeposition; // ideal eye position
vec3_t min; // ideal movement hull size
vec3_t max;
vec3_t bbmin; // clipping bounding box
vec3_t bbmax;
int flags;
int numbones; // bones
int boneindex;
int numbonecontrollers; // bone controllers
int bonecontrollerindex;
int numhitboxes; // complex bounding boxes
int hitboxindex;
int numseq; // animation sequences
int seqindex;
int numseqgroups; // demand loaded sequences
int seqgroupindex;
int numtextures; // raw textures
int textureindex;
int texturedataindex;
int numskinref; // replaceable textures
int numskinfamilies;
int skinindex;
int numbodyparts;
int bodypartindex;
int numattachments; // queryable attachable points
int attachmentindex;
int soundtable;
int soundindex;
int soundgroups;
int soundgroupindex;
int numtransitions; // animation node to animation node transition graph
int transitionindex;
2010-07-08 22:00:00 +02:00
} studiohdr_t;
2009-01-11 22:00:00 +01:00
// header for demand loaded sequence group data
typedef struct
{
int id;
int version;
char name[64];
int length;
2010-10-26 22:00:00 +02:00
} studioseqhdr_t;
2009-01-11 22:00:00 +01:00
// bones
typedef struct
{
char name[32]; // bone name for symbolic links
int parent; // parent bone
int flags; // ??
int bonecontroller[6]; // bone controller index, -1 == none
float value[6]; // default DoF values
float scale[6]; // scale for delta DoF values
2010-07-08 22:00:00 +02:00
} mstudiobone_t;
2009-01-11 22:00:00 +01:00
// bone controllers
typedef struct
{
int bone; // -1 == 0
int type; // X, Y, Z, XR, YR, ZR, M
float start;
float end;
int rest; // byte index value at rest
int index; // 0-3 user set controller, 4 mouth
2010-07-08 22:00:00 +02:00
} mstudiobonecontroller_t;
2009-01-11 22:00:00 +01:00
// intersection boxes
typedef struct
{
int bone;
int group; // intersection group
vec3_t bbmin; // bounding box
vec3_t bbmax;
2010-07-08 22:00:00 +02:00
} mstudiobbox_t;
2009-01-11 22:00:00 +01:00
2010-11-21 22:00:00 +01:00
#ifndef CACHE_USER
#define CACHE_USER
2010-10-26 22:00:00 +02:00
typedef struct cache_user_s
{
2010-11-21 22:00:00 +01:00
void *data; // extradata
2010-10-26 22:00:00 +02:00
} cache_user_t;
2010-11-21 22:00:00 +01:00
#endif
2010-10-26 22:00:00 +02:00
2009-01-11 22:00:00 +01:00
// demand loaded sequence groups
typedef struct
{
char label[32]; // textual name
char name[64]; // file name
2010-10-26 22:00:00 +02:00
cache_user_t cache; // cache index pointer
2009-01-11 22:00:00 +01:00
int data; // hack for group 0
2010-07-08 22:00:00 +02:00
} mstudioseqgroup_t;
2009-01-11 22:00:00 +01:00
// sequence descriptions
typedef struct
{
2010-10-26 22:00:00 +02:00
char label[32]; // sequence label
2009-01-11 22:00:00 +01:00
float fps; // frames per second
int flags; // looping/non-looping flags
int activity;
int actweight;
int numevents;
int eventindex;
int numframes; // number of frames per sequence
int numpivots; // number of foot pivots
int pivotindex;
int motiontype;
int motionbone;
vec3_t linearmovement;
int automoveposindex;
int automoveangleindex;
vec3_t bbmin; // per sequence bounding box
vec3_t bbmax;
int numblends;
int animindex; // mstudioanim_t pointer relative to start of sequence group data
// [blend][bone][X, Y, Z, XR, YR, ZR]
int blendtype[2]; // X, Y, Z, XR, YR, ZR
float blendstart[2]; // starting value
float blendend[2]; // ending value
int blendparent;
int seqgroup; // sequence group for demand loading
int entrynode; // transition node at entry
int exitnode; // transition node at exit
int nodeflags; // transition rules
int nextseq; // auto advancing sequences
2010-07-08 22:00:00 +02:00
} mstudioseqdesc_t;
2009-01-11 22:00:00 +01:00
// events
#include "studio_event.h"
// pivots
typedef struct
{
vec3_t org; // pivot point
int start;
int end;
2010-07-08 22:00:00 +02:00
} mstudiopivot_t;
2009-01-11 22:00:00 +01:00
// attachment
typedef struct
{
char name[32];
int type;
int bone;
vec3_t org; // attachment point
vec3_t vectors[3];
2010-07-08 22:00:00 +02:00
} mstudioattachment_t;
2009-01-11 22:00:00 +01:00
typedef struct
{
unsigned short offset[6];
2010-07-08 22:00:00 +02:00
} mstudioanim_t;
2009-01-11 22:00:00 +01:00
// animation frames
typedef union
{
struct
{
byte valid;
byte total;
} num;
short value;
2010-07-08 22:00:00 +02:00
} mstudioanimvalue_t;
2009-01-11 22:00:00 +01:00
// body part index
typedef struct
{
char name[64];
int nummodels;
int base;
int modelindex; // index into models array
2010-07-08 22:00:00 +02:00
} mstudiobodyparts_t;
2009-01-11 22:00:00 +01:00
// skin info
2011-07-22 22:00:00 +02:00
typedef struct mstudiotex_s
2009-01-11 22:00:00 +01:00
{
char name[64];
int flags;
int width;
int height;
2010-08-15 22:00:00 +02:00
int index;
2010-07-08 22:00:00 +02:00
} mstudiotexture_t;
2009-01-11 22:00:00 +01:00
// skin families
2010-10-26 22:00:00 +02:00
// short index[skinfamilies][skinref]
2009-01-11 22:00:00 +01:00
// studio models
typedef struct
{
char name[64];
int type;
2010-10-26 22:00:00 +02:00
float boundingradius;
2009-01-11 22:00:00 +01:00
int nummesh;
int meshindex;
int numverts; // number of unique vertices
int vertinfoindex; // vertex bone info
int vertindex; // vertex vec3_t
int numnorms; // number of unique surface normals
int norminfoindex; // normal bone info
int normindex; // normal vec3_t
int numgroups; // deformation groups
int groupindex;
2010-07-08 22:00:00 +02:00
} mstudiomodel_t;
2009-01-11 22:00:00 +01:00
2010-10-26 22:00:00 +02:00
// vec3_t boundingbox[model][bone][2]; // complex intersection info
2009-01-11 22:00:00 +01:00
// meshes
typedef struct
{
int numtris;
int triindex;
int skinref;
int numnorms; // per mesh normals
int normindex; // normal vec3_t
2010-07-08 22:00:00 +02:00
} mstudiomesh_t;
2009-01-11 22:00:00 +01:00
2010-10-26 22:00:00 +02:00
// triangles
typedef struct
2010-03-06 22:00:00 +01:00
{
2010-10-26 22:00:00 +02:00
short vertindex; // index into vertex array
short normindex; // index into normal array
short s,t; // s,t position on skin
} mstudiotrivert_t;
2010-03-06 22:00:00 +01:00
2010-07-08 22:00:00 +02:00
#endif//STUDIO_H