halflife-photomode/engine/studio.h

364 lines
7.3 KiB
C
Raw Normal View History

/***
2013-08-30 13:34:05 -07: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.
*
****/
#pragma once
2013-08-30 13:34:05 -07:00
/*
==============================================================================
STUDIO MODELS
Studio models are position independent, so the cache manager can move them.
==============================================================================
*/
#define MAXSTUDIOTRIANGLES 20000 // TODO: tune this
#define MAXSTUDIOVERTS 2048 // TODO: tune this
#define MAXSTUDIOSEQUENCES 2048 // total animation sequences -- KSH incremented
#define MAXSTUDIOSKINS 100 // 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
#define MAXSTUDIOGROUPS 16
#define MAXSTUDIOANIMATIONS 2048
#define MAXSTUDIOMESHES 256
#define MAXSTUDIOEVENTS 1024
#define MAXSTUDIOPIVOTS 256
2013-08-30 13:34:05 -07:00
#define MAXSTUDIOCONTROLLERS 8
typedef struct
2013-08-30 13:34:05 -07:00
{
int id;
int version;
char name[64];
int length;
2013-08-30 13:34:05 -07:00
Vector eyeposition; // ideal eye position
Vector min; // ideal movement hull size
Vector max;
2013-08-30 13:34:05 -07:00
Vector bbmin; // clipping bounding box
Vector bbmax;
2013-08-30 13:34:05 -07:00
int flags;
2013-08-30 13:34:05 -07:00
int numbones; // bones
int boneindex;
2013-08-30 13:34:05 -07:00
int numbonecontrollers; // bone controllers
int bonecontrollerindex;
2013-08-30 13:34:05 -07:00
int numhitboxes; // complex bounding boxes
int hitboxindex;
2013-08-30 13:34:05 -07:00
int numseq; // animation sequences
int seqindex;
2013-08-30 13:34:05 -07:00
int numseqgroups; // demand loaded sequences
int seqgroupindex;
2013-08-30 13:34:05 -07:00
int numtextures; // raw textures
int textureindex;
int texturedataindex;
2013-08-30 13:34:05 -07:00
int numskinref; // replaceable textures
int numskinfamilies;
int skinindex;
2013-08-30 13:34:05 -07:00
int numbodyparts;
int bodypartindex;
2013-08-30 13:34:05 -07:00
int numattachments; // queryable attachable points
int attachmentindex;
2013-08-30 13:34:05 -07:00
int soundtable;
int soundindex;
int soundgroups;
int soundgroupindex;
2013-08-30 13:34:05 -07:00
int numtransitions; // animation node to animation node transition graph
int transitionindex;
2013-08-30 13:34:05 -07:00
} studiohdr_t;
// header for demand loaded sequence group data
typedef struct
2013-08-30 13:34:05 -07:00
{
int id;
int version;
2013-08-30 13:34:05 -07:00
char name[64];
int length;
2013-08-30 13:34:05 -07:00
} studioseqhdr_t;
// bones
typedef struct
2013-08-30 13:34:05 -07:00
{
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
2013-08-30 13:34:05 -07:00
} mstudiobone_t;
// bone controllers
typedef struct
2013-08-30 13:34:05 -07:00
{
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
2013-08-30 13:34:05 -07:00
} mstudiobonecontroller_t;
// intersection boxes
typedef struct
{
int bone;
int group; // intersection group
Vector bbmin; // bounding box
Vector bbmax;
2013-08-30 13:34:05 -07:00
} mstudiobbox_t;
#if !defined(CACHE_USER) && !defined(QUAKEDEF_H)
2013-08-30 13:34:05 -07:00
#define CACHE_USER
typedef struct cache_user_s
{
void* data;
2013-08-30 13:34:05 -07:00
} cache_user_t;
#endif
//
// demand loaded sequence groups
//
typedef struct
{
char label[32]; // textual name
char name[64]; // file name
int32 unused1; // was "cache" - index pointer
int unused2; // was "data" - hack for group 0
2013-08-30 13:34:05 -07:00
} mstudioseqgroup_t;
// sequence descriptions
typedef struct
{
char label[32]; // sequence label
float fps; // frames per second
int flags; // looping/non-looping flags
2013-08-30 13:34:05 -07:00
int activity;
int actweight;
2013-08-30 13:34:05 -07:00
int numevents;
int eventindex;
2013-08-30 13:34:05 -07:00
int numframes; // number of frames per sequence
2013-08-30 13:34:05 -07:00
int numpivots; // number of foot pivots
int pivotindex;
2013-08-30 13:34:05 -07:00
int motiontype;
int motionbone;
Vector linearmovement;
int automoveposindex;
int automoveangleindex;
2013-08-30 13:34:05 -07:00
Vector bbmin; // per sequence bounding box
Vector bbmax;
2013-08-30 13:34:05 -07:00
int numblends;
int animindex; // mstudioanim_t pointer relative to start of sequence group data
// [blend][bone][X, Y, Z, XR, YR, ZR]
2013-08-30 13:34:05 -07:00
int blendtype[2]; // X, Y, Z, XR, YR, ZR
float blendstart[2]; // starting value
float blendend[2]; // ending value
int blendparent;
2013-08-30 13:34:05 -07:00
int seqgroup; // sequence group for demand loading
2013-08-30 13:34:05 -07:00
int entrynode; // transition node at entry
int exitnode; // transition node at exit
int nodeflags; // transition rules
2013-08-30 13:34:05 -07:00
int nextseq; // auto advancing sequences
2013-08-30 13:34:05 -07:00
} mstudioseqdesc_t;
// events
#include "studio_event.h"
/*
typedef struct
{
int frame;
int event;
int type;
char options[64];
} mstudioevent_t;
*/
// pivots
typedef struct
2013-08-30 13:34:05 -07:00
{
Vector org; // pivot point
int start;
int end;
2013-08-30 13:34:05 -07:00
} mstudiopivot_t;
// attachment
typedef struct
2013-08-30 13:34:05 -07:00
{
char name[32];
int type;
int bone;
Vector org; // attachment point
Vector vectors[3];
2013-08-30 13:34:05 -07:00
} mstudioattachment_t;
typedef struct
{
unsigned short offset[6];
2013-08-30 13:34:05 -07:00
} mstudioanim_t;
// animation frames
typedef union
2013-08-30 13:34:05 -07:00
{
struct
{
byte valid;
byte total;
2013-08-30 13:34:05 -07:00
} num;
short value;
2013-08-30 13:34:05 -07:00
} mstudioanimvalue_t;
// body part index
typedef struct
{
char name[64];
int nummodels;
int base;
int modelindex; // index into models array
2013-08-30 13:34:05 -07:00
} mstudiobodyparts_t;
// skin info
typedef struct
{
char name[64];
int flags;
int width;
int height;
int index;
2013-08-30 13:34:05 -07:00
} mstudiotexture_t;
// skin families
// short index[skinfamilies][skinref]
// studio models
typedef struct
{
char name[64];
2013-08-30 13:34:05 -07:00
int type;
2013-08-30 13:34:05 -07:00
float boundingradius;
2013-08-30 13:34:05 -07:00
int nummesh;
int meshindex;
2013-08-30 13:34:05 -07:00
int numverts; // number of unique vertices
int vertinfoindex; // vertex bone info
int vertindex; // vertex Vector
int numnorms; // number of unique surface normals
int norminfoindex; // normal bone info
int normindex; // normal Vector
2013-08-30 13:34:05 -07:00
int numgroups; // deformation groups
int groupindex;
2013-08-30 13:34:05 -07:00
} mstudiomodel_t;
// Vector boundingbox[model][bone][2]; // complex intersection info
2013-08-30 13:34:05 -07:00
// meshes
typedef struct
2013-08-30 13:34:05 -07:00
{
int numtris;
int triindex;
int skinref;
int numnorms; // per mesh normals
int normindex; // normal Vector
2013-08-30 13:34:05 -07:00
} mstudiomesh_t;
// triangles
#if 0
typedef struct
{
short vertindex; // index into vertex array
short normindex; // index into normal array
short s,t; // s,t position on skin
} mstudiotrivert_t;
#endif
// lighting options
#define STUDIO_NF_FLATSHADE 0x0001
#define STUDIO_NF_CHROME 0x0002
#define STUDIO_NF_FULLBRIGHT 0x0004
#define STUDIO_NF_NOMIPS 0x0008
#define STUDIO_NF_ALPHA 0x0010
#define STUDIO_NF_ADDITIVE 0x0020
#define STUDIO_NF_MASKED 0x0040
2013-08-30 13:34:05 -07: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
2013-08-30 13:34:05 -07:00
// sequence flags
#define STUDIO_LOOPING 0x0001
2013-08-30 13:34:05 -07:00
// bone flags
#define STUDIO_HAS_NORMALS 0x0001
2013-08-30 13:34:05 -07:00
#define STUDIO_HAS_VERTICES 0x0002
#define STUDIO_HAS_BBOX 0x0004
#define STUDIO_HAS_CHROME 0x0008 // if any of the textures have chrome on them
2013-08-30 13:34:05 -07:00
#define RAD_TO_STUDIO (32768.0 / M_PI)
#define STUDIO_TO_RAD (M_PI / 32768.0)