Initial commit.
This commit is contained in:
201
code/ghoul2/G2.h
Normal file
201
code/ghoul2/G2.h
Normal file
@@ -0,0 +1,201 @@
|
||||
#pragma once
|
||||
#if !defined(G2_H_INC)
|
||||
#define G2_H_INC
|
||||
|
||||
class CMiniHeap;
|
||||
|
||||
// defines to setup the
|
||||
#define ENTITY_WIDTH 12
|
||||
#define MODEL_WIDTH 10
|
||||
#define BOLT_WIDTH 10
|
||||
|
||||
#define MODEL_AND ((1<<MODEL_WIDTH)-1)
|
||||
#define BOLT_AND ((1<<BOLT_WIDTH)-1)
|
||||
#define ENTITY_AND ((1<<ENTITY_WIDTH)-1)
|
||||
|
||||
#define BOLT_SHIFT 0
|
||||
#define MODEL_SHIFT (BOLT_SHIFT + BOLT_WIDTH)
|
||||
#define ENTITY_SHIFT (MODEL_SHIFT + MODEL_WIDTH)
|
||||
|
||||
//rww - RAGDOLL_BEGIN
|
||||
class CRagDollUpdateParams;
|
||||
//rww - RAGDOLL_END
|
||||
|
||||
struct model_s;
|
||||
// internal surface calls G2_surfaces.cpp
|
||||
qboolean G2_SetSurfaceOnOff (CGhoul2Info *ghlInfo, const char *surfaceName, const int offFlags);
|
||||
qboolean G2_SetRootSurface( CGhoul2Info_v &ghoul2, const int modelIndex,const char *surfaceName);
|
||||
int G2_AddSurface(CGhoul2Info *ghoul2, int surfaceNumber, int polyNumber, float BarycentricI, float BarycentricJ, int lod );
|
||||
qboolean G2_RemoveSurface(surfaceInfo_v &slist, const int index);
|
||||
const surfaceInfo_t *G2_FindOverrideSurface(int surfaceNum, const surfaceInfo_v &surfaceList);
|
||||
int G2_IsSurfaceLegal(const model_s *, const char *surfaceName, int *flags);
|
||||
int G2_GetParentSurface(CGhoul2Info *ghlInfo, const int index);
|
||||
int G2_GetSurfaceIndex(CGhoul2Info *ghlInfo, const char *surfaceName);
|
||||
int G2_IsSurfaceRendered(CGhoul2Info *ghlInfo, const char *surfaceName, surfaceInfo_v &slist);
|
||||
|
||||
// internal bone calls - G2_Bones.cpp
|
||||
qboolean G2_Set_Bone_Angles(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, const float *angles, const int flags,
|
||||
const Eorientations up, const Eorientations left, const Eorientations forward,
|
||||
const int blendTime, const int currentTime);
|
||||
qboolean G2_Remove_Bone (CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName);
|
||||
qboolean G2_Remove_Bone_Index (boneInfo_v &blist, int index);
|
||||
qboolean G2_Set_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, const int startFrame,
|
||||
const int endFrame, const int flags, const float animSpeed, const int currentTime, const float setFrame, const int blendTime);
|
||||
qboolean G2_Get_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, const int currentTime,
|
||||
float *currentFrame, int *startFrame, int *endFrame, int *flags, float *retAnimSpeed);
|
||||
qboolean G2_Get_Bone_Anim_Range(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, int *startFrame, int *endFrame);
|
||||
qboolean G2_Get_Bone_Anim_Range_Index(boneInfo_v &blist, const int boneIndex, int *startFrame, int *endFrame);
|
||||
qboolean G2_Pause_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, const int currentTime);
|
||||
qboolean G2_Pause_Bone_Anim_Index(boneInfo_v &blist, const int boneIndex, const int currentTime,int numFrames );
|
||||
qboolean G2_IsPaused(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName);
|
||||
qboolean G2_Stop_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName);
|
||||
qboolean G2_Stop_Bone_Angles(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName);
|
||||
//rww - RAGDOLL_BEGIN
|
||||
void G2_Animate_Bone_List(CGhoul2Info_v &ghoul2, const int currentTime, const int index,CRagDollUpdateParams *params);
|
||||
//rww - RAGDOLL_END
|
||||
|
||||
void G2_Init_Bone_List(boneInfo_v &blist);
|
||||
int G2_Find_Bone_In_List(boneInfo_v &blist, const int boneNum);
|
||||
qboolean G2_Set_Bone_Angles_Matrix(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, const mdxaBone_t &matrix,
|
||||
const int flags, const int blendTime, const int currentTime);
|
||||
int G2_Get_Bone_Index(CGhoul2Info *ghoul2, const char *boneName, qboolean bAddIfNotFound);
|
||||
qboolean G2_Set_Bone_Angles_Index(CGhoul2Info *ghlInfo, boneInfo_v &blist, const int index,
|
||||
const float *angles, const int flags, const Eorientations yaw,
|
||||
const Eorientations pitch, const Eorientations roll,
|
||||
const int blendTime, const int currentTime);
|
||||
qboolean G2_Set_Bone_Angles_Matrix_Index(boneInfo_v &blist, const int index,
|
||||
const mdxaBone_t &matrix, const int flags,
|
||||
const int blendTime, const int currentTime);
|
||||
qboolean G2_Stop_Bone_Anim_Index(boneInfo_v &blist, const int index);
|
||||
qboolean G2_Stop_Bone_Angles_Index(boneInfo_v &blist, const int index);
|
||||
qboolean G2_Set_Bone_Anim_Index(boneInfo_v &blist, const int index, const int startFrame,
|
||||
const int endFrame, const int flags, const float animSpeed, const int currentTime, const float setFrame, const int blendTime,int numFrames);
|
||||
qboolean G2_Get_Bone_Anim_Index( boneInfo_v &blist, const int index, const int currentTime,
|
||||
float *currentFrame, int *startFrame, int *endFrame, int *flags, float *retAnimSpeed,int numFrames);
|
||||
|
||||
// misc functions G2_misc.cpp
|
||||
void G2_List_Model_Surfaces(const char *fileName);
|
||||
void G2_List_Model_Bones(const char *fileName, int frame);
|
||||
qboolean G2_GetAnimFileName(const char *fileName, char **filename);
|
||||
#ifdef _G2_GORE
|
||||
void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, CCollisionRecord *collRecMap, int entNum, EG2_Collision eG2TraceType, int useLod, float fRadius, float ssize,float tsize,float theta,int shader, SSkinGoreData *gore);
|
||||
#else
|
||||
void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, CCollisionRecord *collRecMap, int entNum, EG2_Collision eG2TraceType, int useLod, float fRadius);
|
||||
#endif
|
||||
void TransformAndTranslatePoint (const vec3_t in, vec3_t out, mdxaBone_t *mat);
|
||||
#ifdef _G2_GORE
|
||||
void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, CMiniHeap *G2VertSpace, int useLod, bool ApplyGore);
|
||||
#else
|
||||
void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, CMiniHeap *G2VertSpace, int useLod);
|
||||
#endif
|
||||
void G2_GenerateWorldMatrix(const vec3_t angles, const vec3_t origin);
|
||||
void TransformPoint (const vec3_t in, vec3_t out, mdxaBone_t *mat);
|
||||
void Inverse_Matrix(mdxaBone_t *src, mdxaBone_t *dest);
|
||||
void *G2_FindSurface(const model_s *, int index, int lod);
|
||||
void G2_SaveGhoul2Models(CGhoul2Info_v &ghoul2);
|
||||
void G2_LoadGhoul2Model(CGhoul2Info_v &ghoul2, char *buffer);
|
||||
|
||||
// internal bolt calls. G2_bolts.cpp
|
||||
int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, const char *boneName);
|
||||
qboolean G2_Remove_Bolt (boltInfo_v &bltlist, int index);
|
||||
void G2_Init_Bolt_List(boltInfo_v &bltlist);
|
||||
int G2_Find_Bolt_Bone_Num(boltInfo_v &bltlist, const int boneNum);
|
||||
int G2_Find_Bolt_Surface_Num(boltInfo_v &bltlist, const int surfaceNum, const int flags);
|
||||
int G2_Add_Bolt_Surf_Num(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, const int surfNum);
|
||||
|
||||
|
||||
// API calls - G2_API.cpp
|
||||
qhandle_t G2API_PrecacheGhoul2Model(const char *fileName);
|
||||
|
||||
int G2API_InitGhoul2Model(CGhoul2Info_v &ghoul2, const char *fileName, int modelIndex, qhandle_t customSkin = NULL,
|
||||
qhandle_t customShader = NULL, int modelFlags = 0, int lodBias = 0);
|
||||
qboolean G2API_SetLodBias(CGhoul2Info *ghlInfo, int lodBias);
|
||||
qboolean G2API_SetSkin(CGhoul2Info *ghlInfo, qhandle_t customSkin, qhandle_t renderSkin = 0);
|
||||
qboolean G2API_SetShader(CGhoul2Info *ghlInfo, qhandle_t customShader);
|
||||
qboolean G2API_RemoveGhoul2Model(CGhoul2Info_v &ghlInfo, const int modelIndex);
|
||||
qboolean G2API_SetSurfaceOnOff(CGhoul2Info *ghlInfo, const char *surfaceName, const int flags);
|
||||
qboolean G2API_SetRootSurface(CGhoul2Info_v &ghlInfo, const int modelIndex, const char *surfaceName);
|
||||
qboolean G2API_RemoveSurface(CGhoul2Info *ghlInfo, const int index);
|
||||
int G2API_AddSurface(CGhoul2Info *ghlInfo, int surfaceNumber, int polyNumber, float BarycentricI, float BarycentricJ, int lod );
|
||||
qboolean G2API_SetBoneAnim(CGhoul2Info *ghlInfo, const char *boneName, const int startFrame, const int endFrame,
|
||||
const int flags, const float animSpeed, const int currentTime, const float setFrame = -1, const int blendTime = -1);
|
||||
qboolean G2API_GetBoneAnim(CGhoul2Info *ghlInfo, const char *boneName, const int currentTime, float *currentFrame,
|
||||
int *startFrame, int *endFrame, int *flags, float *animSpeed, qhandle_t *modelList);
|
||||
qboolean G2API_GetBoneAnimIndex(CGhoul2Info *ghlInfo, const int iBoneIndex, const int currentTime, float *currentFrame,
|
||||
int *startFrame, int *endFrame, int *flags, float *animSpeed, qhandle_t *modelList);
|
||||
qboolean G2API_GetAnimRange(CGhoul2Info *ghlInfo, const char *boneName, int *startFrame, int *endFrame);
|
||||
qboolean G2API_GetAnimRangeIndex(CGhoul2Info *ghlInfo, const int boneIndex, int *startFrame, int *endFrame);
|
||||
qboolean G2API_PauseBoneAnim(CGhoul2Info *ghlInfo, const char *boneName, const int currentTime);
|
||||
qboolean G2API_PauseBoneAnimIndex(CGhoul2Info *ghlInfo, const int boneIndex, const int currentTime);
|
||||
qboolean G2API_IsPaused(CGhoul2Info *ghlInfo, const char *boneName);
|
||||
qboolean G2API_StopBoneAnim(CGhoul2Info *ghlInfo, const char *boneName);
|
||||
qboolean G2API_SetBoneAngles(CGhoul2Info *ghlInfo, const char *boneName, const vec3_t angles, const int flags,
|
||||
const Eorientations up, const Eorientations right, const Eorientations forward, qhandle_t *modelList,
|
||||
int blendTime = 0, int currentTime = 0);
|
||||
qboolean G2API_StopBoneAngles(CGhoul2Info *ghlInfo, const char *boneName);
|
||||
qboolean G2API_RemoveBone(CGhoul2Info *ghlInfo, const char *boneName);
|
||||
qboolean G2API_RemoveBolt(CGhoul2Info *ghlInfo, const int index);
|
||||
int G2API_AddBolt(CGhoul2Info *ghlInfo, const char *boneName);
|
||||
int G2API_AddBoltSurfNum(CGhoul2Info *ghlInfo, const int surfIndex);
|
||||
qboolean G2API_AttachG2Model(CGhoul2Info *ghlInfo, CGhoul2Info *ghlInfoTo, int toBoltIndex, int toModel);
|
||||
qboolean G2API_DetachG2Model(CGhoul2Info *ghlInfo);
|
||||
qboolean G2API_AttachEnt(int *boltInfo, CGhoul2Info *ghlInfoTo, int toBoltIndex, int entNum, int toModelNum);
|
||||
void G2API_DetachEnt(int *boltInfo);
|
||||
|
||||
qboolean G2API_GetBoltMatrix(CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix,
|
||||
const vec3_t angles, const vec3_t position, const int frameNum, qhandle_t *modelList, const vec3_t scale);
|
||||
|
||||
void G2API_ListSurfaces(CGhoul2Info *ghlInfo);
|
||||
void G2API_ListBones(CGhoul2Info *ghlInfo, int frame);
|
||||
qboolean G2API_HaveWeGhoul2Models(CGhoul2Info_v &ghoul2);
|
||||
void G2API_SetGhoul2ModelIndexes(CGhoul2Info_v &ghoul2, qhandle_t *modelList, qhandle_t *skinList);
|
||||
qboolean G2API_SetGhoul2ModelFlags(CGhoul2Info *ghlInfo, const int flags);
|
||||
int G2API_GetGhoul2ModelFlags(CGhoul2Info *ghlInfo);
|
||||
|
||||
qboolean G2API_GetAnimFileName(CGhoul2Info *ghlInfo, char **filename);
|
||||
void G2API_CollisionDetect(CCollisionRecord *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position,
|
||||
int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, CMiniHeap *G2VertSpace,
|
||||
EG2_Collision eG2TraceType, int useLod, float fRadius);
|
||||
void G2API_GiveMeVectorFromMatrix(mdxaBone_t &boltMatrix, Eorientations flags, vec3_t &vec);
|
||||
void G2API_CopyGhoul2Instance(CGhoul2Info_v &Ghoul2From, CGhoul2Info_v &Ghoul2To, int modelIndex = -1);
|
||||
void G2API_CleanGhoul2Models(CGhoul2Info_v &ghoul2);
|
||||
int G2API_GetParentSurface(CGhoul2Info *ghlInfo, const int index);
|
||||
int G2API_GetSurfaceIndex(CGhoul2Info *ghlInfo, const char *surfaceName);
|
||||
char *G2API_GetSurfaceName(CGhoul2Info *ghlInfo, int surfNumber);
|
||||
char *G2API_GetGLAName(CGhoul2Info *ghlInfo);
|
||||
qboolean G2API_SetBoneAnglesMatrix(CGhoul2Info *ghlInfo, const char *boneName, const mdxaBone_t &matrix, const int flags,
|
||||
qhandle_t *modelList, int blendTime = 0, int currentTime = 0);
|
||||
qboolean G2API_SetNewOrigin(CGhoul2Info *ghlInfo, const int boltIndex);
|
||||
int G2API_GetBoneIndex(CGhoul2Info *ghlInfo, const char *boneName, qboolean bAddIfNotFound);
|
||||
qboolean G2API_StopBoneAnglesIndex(CGhoul2Info *ghlInfo, const int index);
|
||||
qboolean G2API_StopBoneAnimIndex(CGhoul2Info *ghlInfo, const int index);
|
||||
qboolean G2API_SetBoneAnglesIndex(CGhoul2Info *ghlInfo, const int index, const vec3_t angles, const int flags,
|
||||
const Eorientations yaw, const Eorientations pitch, const Eorientations roll,
|
||||
qhandle_t *modelList, int blendTime, int currentTime);
|
||||
qboolean G2API_SetBoneAnglesMatrixIndex(CGhoul2Info *ghlInfo, const int index, const mdxaBone_t &matrix,
|
||||
const int flags, qhandle_t *modelList, int blendTime, int currentTime);
|
||||
qboolean G2API_SetBoneAnimIndex(CGhoul2Info *ghlInfo, const int index, const int startFrame, const int endFrame, const int flags, const float animSpeed, const int currentTime, const float setFrame, const int blendTime);
|
||||
qboolean G2API_SetAnimIndex(CGhoul2Info *ghlInfo, const int index);
|
||||
int G2API_GetAnimIndex(CGhoul2Info *ghlInfo);
|
||||
void G2API_SaveGhoul2Models(CGhoul2Info_v &ghoul2);
|
||||
void G2API_LoadGhoul2Models(CGhoul2Info_v &ghoul2, char *buffer);
|
||||
void G2API_LoadSaveCodeDestructGhoul2Info(CGhoul2Info_v &ghoul2);
|
||||
char *G2API_GetAnimFileNameIndex(qhandle_t modelIndex);
|
||||
char *G2API_GetAnimFileInternalNameIndex(qhandle_t modelIndex);
|
||||
int G2API_GetSurfaceRenderStatus(CGhoul2Info *ghlInfo, const char *surfaceName);
|
||||
|
||||
// From tr_ghoul2.cpp
|
||||
void G2_ConstructGhoulSkeleton( CGhoul2Info_v &ghoul2,const int frameNum,bool checkForNewOrigin,const vec3_t scale);
|
||||
void G2_GetBoltMatrixLow(CGhoul2Info &ghoul2,int boltNum,const vec3_t scale,mdxaBone_t &retMatrix);
|
||||
void G2_TimingModel(boneInfo_t &bone,int time,int numFramesInFile,int ¤tFrame,int &newFrame,float &lerp);
|
||||
|
||||
|
||||
bool G2_SetupModelPointers(CGhoul2Info_v &ghoul2); // returns true if any model is properly set up
|
||||
bool G2_SetupModelPointers(CGhoul2Info *ghlInfo); // returns true if the model is properly set up
|
||||
|
||||
//#ifdef _G2_GORE // These exist regardless, non-gore versions are empty
|
||||
void G2API_AddSkinGore(CGhoul2Info_v &ghoul2,SSkinGoreData &gore);
|
||||
void G2API_ClearSkinGore ( CGhoul2Info_v &ghoul2 );
|
||||
//#endif
|
||||
|
||||
#endif // G2_H_INC
|
||||
2145
code/ghoul2/G2_API.cpp
Normal file
2145
code/ghoul2/G2_API.cpp
Normal file
File diff suppressed because it is too large
Load Diff
253
code/ghoul2/G2_bolts.cpp
Normal file
253
code/ghoul2/G2_bolts.cpp
Normal file
@@ -0,0 +1,253 @@
|
||||
// leave this as first line for PCH reasons...
|
||||
//
|
||||
#include "../server/exe_headers.h"
|
||||
|
||||
|
||||
|
||||
#ifndef __Q_SHARED_H
|
||||
#include "../game/q_shared.h"
|
||||
#endif
|
||||
|
||||
#if !defined(TR_LOCAL_H)
|
||||
#include "../renderer/tr_local.h"
|
||||
#endif
|
||||
|
||||
#if !defined(G2_H_INC)
|
||||
#include "G2.h"
|
||||
#endif
|
||||
|
||||
#define G2_MODEL_OK(g) ((g)&&(g)->mValid&&(g)->aHeader&&(g)->currentModel&&(g)->animModel)
|
||||
|
||||
//=====================================================================================================================
|
||||
// Bolt List handling routines - so entities can attach themselves to any part of the model in question
|
||||
|
||||
// Given a bone number, see if that bone is already in our bone list
|
||||
int G2_Find_Bolt_Bone_Num(boltInfo_v &bltlist, const int boneNum)
|
||||
{
|
||||
int i;
|
||||
|
||||
// look through entire list
|
||||
for(i=0; i<bltlist.size(); i++)
|
||||
{
|
||||
if (bltlist[i].boneNumber == boneNum)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// didn't find it
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Given a bone number, see if that surface is already in our surfacelist list
|
||||
int G2_Find_Bolt_Surface_Num(boltInfo_v &bltlist, const int surfaceNum, const int flags)
|
||||
{
|
||||
int i;
|
||||
|
||||
// look through entire list
|
||||
for(i=0; i<bltlist.size(); i++)
|
||||
{
|
||||
if ((bltlist[i].surfaceNumber == surfaceNum) && ((bltlist[i].surfaceType & flags) == flags))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// didn't find it
|
||||
return -1;
|
||||
}
|
||||
|
||||
//=========================================================================================
|
||||
//// Public Bolt Routines
|
||||
int G2_Add_Bolt_Surf_Num(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, const int surfNum)
|
||||
{
|
||||
assert(ghlInfo&&ghlInfo->mValid);
|
||||
boltInfo_t tempBolt;
|
||||
int i;
|
||||
|
||||
assert(surfNum>=0&&surfNum<slist.size());
|
||||
// ensure surface num is valid
|
||||
if (surfNum >= slist.size())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// look through entire list - see if it's already there first
|
||||
for(i=0; i<bltlist.size(); i++)
|
||||
{
|
||||
// already there??
|
||||
if (bltlist[i].surfaceNumber == surfNum)
|
||||
{
|
||||
// increment the usage count
|
||||
bltlist[i].boltUsed++;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// we have a surface
|
||||
// look through entire list - see if it's already there first
|
||||
for(i=0; i<bltlist.size(); i++)
|
||||
{
|
||||
// if this surface entry has info in it, bounce over it
|
||||
if (bltlist[i].boneNumber == -1 && bltlist[i].surfaceNumber == -1)
|
||||
{
|
||||
// if we found an entry that had a -1 for the bone / surface number, then we hit a surface / bone slot that was empty
|
||||
bltlist[i].surfaceNumber = surfNum;
|
||||
bltlist[i].surfaceType = G2SURFACEFLAG_GENERATED;
|
||||
bltlist[i].boltUsed = 1;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// ok, we didn't find an existing surface of that name, or an empty slot. Lets add an entry
|
||||
tempBolt.surfaceNumber = surfNum;
|
||||
tempBolt.surfaceType = G2SURFACEFLAG_GENERATED;
|
||||
tempBolt.boneNumber = -1;
|
||||
tempBolt.boltUsed = 1;
|
||||
bltlist.push_back(tempBolt);
|
||||
return bltlist.size()-1;
|
||||
|
||||
}
|
||||
|
||||
void G2_Bolt_Not_Found(const char *boneName,const char *modName);
|
||||
int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, const char *boneName)
|
||||
{
|
||||
assert(ghlInfo&&ghlInfo->mValid);
|
||||
int i, x, surfNum = -1;
|
||||
mdxaSkel_t *skel;
|
||||
mdxaSkelOffsets_t *offsets;
|
||||
mdxmHierarchyOffsets_t *surfOffsets;
|
||||
boltInfo_t tempBolt;
|
||||
int flags;
|
||||
|
||||
assert(G2_MODEL_OK(ghlInfo));
|
||||
|
||||
surfOffsets = (mdxmHierarchyOffsets_t *)((byte*)ghlInfo->currentModel->mdxm + sizeof(mdxmHeader_t));
|
||||
// first up, we'll search for that which this bolt names in all the surfaces
|
||||
surfNum = G2_IsSurfaceLegal(ghlInfo->currentModel, boneName, &flags);
|
||||
|
||||
// did we find it as a surface?
|
||||
if (surfNum != -1)
|
||||
{
|
||||
// look through entire list - see if it's already there first
|
||||
for(i=0; i<bltlist.size(); i++)
|
||||
{
|
||||
// already there??
|
||||
if (bltlist[i].surfaceNumber == surfNum)
|
||||
{
|
||||
// increment the usage count
|
||||
bltlist[i].boltUsed++;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// look through entire list - see if we can re-use one
|
||||
for(i=0; i<bltlist.size(); i++)
|
||||
{
|
||||
// if this surface entry has info in it, bounce over it
|
||||
if (bltlist[i].boneNumber == -1 && bltlist[i].surfaceNumber == -1)
|
||||
{
|
||||
// if we found an entry that had a -1 for the bone / surface number, then we hit a surface / bone slot that was empty
|
||||
bltlist[i].surfaceNumber = surfNum;
|
||||
bltlist[i].boltUsed = 1;
|
||||
bltlist[i].surfaceType = 0;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// ok, we didn't find an existing surface of that name, or an empty slot. Lets add an entry
|
||||
tempBolt.surfaceNumber = surfNum;
|
||||
tempBolt.boneNumber = -1;
|
||||
tempBolt.boltUsed = 1;
|
||||
tempBolt.surfaceType = 0;
|
||||
bltlist.push_back(tempBolt);
|
||||
return bltlist.size()-1;
|
||||
}
|
||||
|
||||
// no, check to see if it's a bone then
|
||||
|
||||
offsets = (mdxaSkelOffsets_t *)((byte *)ghlInfo->aHeader + sizeof(mdxaHeader_t));
|
||||
|
||||
// walk the entire list of bones in the gla file for this model and see if any match the name of the bone we want to find
|
||||
for (x=0; x< ghlInfo->aHeader->numBones; x++)
|
||||
{
|
||||
skel = (mdxaSkel_t *)((byte *)ghlInfo->aHeader + sizeof(mdxaHeader_t) + offsets->offsets[x]);
|
||||
// if name is the same, we found it
|
||||
if (!stricmp(skel->name, boneName))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// check to see we did actually make a match with a bone in the model
|
||||
if (x == ghlInfo->aHeader->numBones)
|
||||
{
|
||||
// didn't find it? Error
|
||||
//assert(0&&x == mod_a->mdxa->numBones);
|
||||
#if _DEBUG
|
||||
G2_Bolt_Not_Found(boneName,ghlInfo->mFileName);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
// look through entire list - see if it's already there first
|
||||
for(i=0; i<bltlist.size(); i++)
|
||||
{
|
||||
// already there??
|
||||
if (bltlist[i].boneNumber == x)
|
||||
{
|
||||
// increment the usage count
|
||||
bltlist[i].boltUsed++;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// look through entire list - see if we can re-use it
|
||||
for(i=0; i<bltlist.size(); i++)
|
||||
{
|
||||
// if this bone entry has info in it, bounce over it
|
||||
if (bltlist[i].boneNumber == -1 && bltlist[i].surfaceNumber == -1)
|
||||
{
|
||||
// if we found an entry that had a -1 for the bonenumber, then we hit a bone slot that was empty
|
||||
bltlist[i].boneNumber = x;
|
||||
bltlist[i].boltUsed = 1;
|
||||
bltlist[i].surfaceType = 0;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// ok, we didn't find an existing bone of that name, or an empty slot. Lets add an entry
|
||||
tempBolt.boneNumber = x;
|
||||
tempBolt.surfaceNumber = -1;
|
||||
tempBolt.boltUsed = 1;
|
||||
tempBolt.surfaceType = 0;
|
||||
bltlist.push_back(tempBolt);
|
||||
return bltlist.size()-1;
|
||||
|
||||
}
|
||||
|
||||
// Given a model handle, and a bone name, we want to remove this bone from the bone override list
|
||||
qboolean G2_Remove_Bolt (boltInfo_v &bltlist, int index)
|
||||
{
|
||||
assert(index>=0&&index<bltlist.size());
|
||||
// did we find it?
|
||||
if (index != -1)
|
||||
{
|
||||
bltlist[index].boltUsed--;
|
||||
if (!bltlist[index].boltUsed)
|
||||
{
|
||||
// set this bone to not used
|
||||
bltlist[index].boneNumber = -1;
|
||||
bltlist[index].surfaceNumber = -1;
|
||||
}
|
||||
return qtrue;
|
||||
}
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
// set the bolt list to all unused so the bone transformation routine ignores it.
|
||||
void G2_Init_Bolt_List(boltInfo_v &bltlist)
|
||||
{
|
||||
bltlist.clear();
|
||||
}
|
||||
|
||||
4756
code/ghoul2/G2_bones.cpp
Normal file
4756
code/ghoul2/G2_bones.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1873
code/ghoul2/G2_misc.cpp
Normal file
1873
code/ghoul2/G2_misc.cpp
Normal file
File diff suppressed because it is too large
Load Diff
428
code/ghoul2/G2_surfaces.cpp
Normal file
428
code/ghoul2/G2_surfaces.cpp
Normal file
@@ -0,0 +1,428 @@
|
||||
// leave this as first line for PCH reasons...
|
||||
//
|
||||
#include "../server/exe_headers.h"
|
||||
|
||||
|
||||
|
||||
#ifndef __Q_SHARED_H
|
||||
#include "../game/q_shared.h"
|
||||
#endif
|
||||
|
||||
#if !defined(TR_LOCAL_H)
|
||||
#include "../renderer/tr_local.h"
|
||||
#endif
|
||||
|
||||
#if !defined(G2_H_INC)
|
||||
#include "G2.h"
|
||||
#endif
|
||||
|
||||
#define G2_MODEL_OK(g) ((g)&&(g)->mValid&&(g)->aHeader&&(g)->currentModel&&(g)->animModel)
|
||||
|
||||
#pragma warning(disable : 4512) //assignment op could not be genereated
|
||||
|
||||
class CQuickOverride
|
||||
{
|
||||
int mOverride[512];
|
||||
int mAt[512];
|
||||
int mCurrentTouch;
|
||||
public:
|
||||
CQuickOverride()
|
||||
{
|
||||
mCurrentTouch=1;
|
||||
int i;
|
||||
for (i=0;i<512;i++)
|
||||
{
|
||||
mOverride[i]=0;
|
||||
}
|
||||
}
|
||||
void Invalidate()
|
||||
{
|
||||
mCurrentTouch++;
|
||||
}
|
||||
void Set(int index,int pos)
|
||||
{
|
||||
if (index==10000)
|
||||
{
|
||||
return;
|
||||
}
|
||||
assert(index>=0&&index<512);
|
||||
mOverride[index]=mCurrentTouch;
|
||||
mAt[index]=pos;
|
||||
}
|
||||
int Test(int index)
|
||||
{
|
||||
assert(index>=0&&index<512);
|
||||
if (mOverride[index]!=mCurrentTouch)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return mAt[index];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static CQuickOverride QuickOverride;
|
||||
|
||||
|
||||
// find a particular surface in the surface override list
|
||||
const surfaceInfo_t *G2_FindOverrideSurface(int surfaceNum,const surfaceInfo_v &surfaceList)
|
||||
{
|
||||
|
||||
if (surfaceNum<0)
|
||||
{
|
||||
// starting a new lookup
|
||||
QuickOverride.Invalidate();
|
||||
int i;
|
||||
for(i=0; i<surfaceList.size(); i++)
|
||||
{
|
||||
if (surfaceList[i].surface>=0)
|
||||
{
|
||||
QuickOverride.Set(surfaceList[i].surface,i);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
int idx=QuickOverride.Test(surfaceNum);
|
||||
if (idx<0)
|
||||
{
|
||||
unsigned int i;
|
||||
if (surfaceNum==10000)
|
||||
{
|
||||
for(i=0; i<surfaceList.size(); i++)
|
||||
{
|
||||
if (surfaceList[i].surface == surfaceNum)
|
||||
{
|
||||
return &surfaceList[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
#if _DEBUG
|
||||
// look through entire list
|
||||
for(i=0; i<surfaceList.size(); i++)
|
||||
{
|
||||
if (surfaceList[i].surface == surfaceNum)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
// didn't find it.
|
||||
assert(i==surfaceList.size()); // our quickoverride is not working right
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
assert(idx>=0&&idx<surfaceList.size());
|
||||
assert(surfaceList[idx].surface == surfaceNum);
|
||||
return &surfaceList[idx];
|
||||
}
|
||||
|
||||
|
||||
// given a surface name, lets see if it's legal in the model
|
||||
int G2_IsSurfaceLegal(const model_s *mod_m, const char *surfaceName, int *flags)
|
||||
{
|
||||
assert(mod_m);
|
||||
assert(mod_m->mdxm);
|
||||
// damn include file dependancies
|
||||
mdxmSurfHierarchy_t *surf;
|
||||
surf = (mdxmSurfHierarchy_t *) ( (byte *)mod_m->mdxm + mod_m->mdxm->ofsSurfHierarchy );
|
||||
|
||||
for ( int i = 0 ; i < mod_m->mdxm->numSurfaces ; i++)
|
||||
{
|
||||
if (!stricmp(surfaceName, surf->name))
|
||||
{
|
||||
*flags = surf->flags;
|
||||
return i;
|
||||
}
|
||||
// find the next surface
|
||||
surf = (mdxmSurfHierarchy_t *)( (byte *)surf + (int)( &((mdxmSurfHierarchy_t *)0)->childIndexes[ surf->numChildren ] ));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************************************
|
||||
* G2_FindSurface
|
||||
* find a surface in a ghoul2 surface override list based on it's name
|
||||
*
|
||||
* Input
|
||||
* filename of model, surface list of model instance, name of surface, int to be filled in
|
||||
* with the index of this surface (defaults to NULL)
|
||||
*
|
||||
* Output
|
||||
* pointer to surface if successful, false otherwise
|
||||
*
|
||||
************************************************************************************************/
|
||||
const mdxmSurface_t *G2_FindSurface(CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const char *surfaceName,
|
||||
int *surfIndex/*NULL*/)
|
||||
{
|
||||
int i = 0;
|
||||
// find the model we want
|
||||
assert(G2_MODEL_OK(ghlInfo));
|
||||
|
||||
const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)ghlInfo->currentModel->mdxm + sizeof(mdxmHeader_t));
|
||||
|
||||
// first find if we already have this surface in the list
|
||||
for (i = slist.size() - 1; i >= 0; i--)
|
||||
{
|
||||
if ((slist[i].surface != 10000) && (slist[i].surface != -1))
|
||||
{
|
||||
const mdxmSurface_t *surf = (mdxmSurface_t *)G2_FindSurface(ghlInfo->currentModel, slist[i].surface, 0);
|
||||
// back track and get the surfinfo struct for this surface
|
||||
const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surf->thisSurfaceIndex]);
|
||||
|
||||
// are these the droids we're looking for?
|
||||
if (!stricmp (surfInfo->name, surfaceName))
|
||||
{
|
||||
// yup
|
||||
if (surfIndex)
|
||||
{
|
||||
*surfIndex = i;
|
||||
}
|
||||
return surf;
|
||||
}
|
||||
}
|
||||
}
|
||||
// didn't find it
|
||||
if (surfIndex)
|
||||
{
|
||||
*surfIndex = -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// set a named surface offFlags - if it doesn't find a surface with this name in the list then it will add one.
|
||||
qboolean G2_SetSurfaceOnOff (CGhoul2Info *ghlInfo, const char *surfaceName, const int offFlags)
|
||||
{
|
||||
int surfIndex = -1;
|
||||
surfaceInfo_t temp_slist_entry;
|
||||
|
||||
// find the model we want
|
||||
// first find if we already have this surface in the list
|
||||
const mdxmSurface_t *surf = G2_FindSurface(ghlInfo, ghlInfo->mSlist, surfaceName, &surfIndex);
|
||||
if (surf)
|
||||
{
|
||||
// set descendants value
|
||||
|
||||
// slist[surfIndex].offFlags = offFlags;
|
||||
// seems to me that we shouldn't overwrite the other flags.
|
||||
// the only bit we really care about in the incoming flags is the off bit
|
||||
ghlInfo->mSlist[surfIndex].offFlags &= ~(G2SURFACEFLAG_OFF | G2SURFACEFLAG_NODESCENDANTS);
|
||||
ghlInfo->mSlist[surfIndex].offFlags |= offFlags & (G2SURFACEFLAG_OFF | G2SURFACEFLAG_NODESCENDANTS);
|
||||
return qtrue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ok, not in the list already - in that case, lets verify this surface exists in the model mesh
|
||||
int flags;
|
||||
int surfaceNum = G2_IsSurfaceLegal(ghlInfo->currentModel, surfaceName, &flags);
|
||||
if (surfaceNum != -1)
|
||||
{
|
||||
int newflags = flags;
|
||||
// the only bit we really care about in the incoming flags is the off bit
|
||||
newflags &= ~(G2SURFACEFLAG_OFF | G2SURFACEFLAG_NODESCENDANTS);
|
||||
newflags |= offFlags & (G2SURFACEFLAG_OFF | G2SURFACEFLAG_NODESCENDANTS);
|
||||
|
||||
if (newflags != flags)
|
||||
{ // insert here then because it changed, no need to add an override otherwise
|
||||
temp_slist_entry.offFlags = newflags;
|
||||
temp_slist_entry.surface = surfaceNum;
|
||||
|
||||
ghlInfo->mSlist.push_back(temp_slist_entry);
|
||||
}
|
||||
return qtrue;
|
||||
}
|
||||
}
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
void G2_FindRecursiveSurface(const model_t *currentModel, int surfaceNum, surfaceInfo_v &rootList, int *activeSurfaces)
|
||||
{
|
||||
assert(currentModel);
|
||||
assert(currentModel->mdxm);
|
||||
int i;
|
||||
const mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface(currentModel, surfaceNum, 0);
|
||||
const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->mdxm + sizeof(mdxmHeader_t));
|
||||
const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]);
|
||||
|
||||
// see if we have an override surface in the surface list
|
||||
const surfaceInfo_t *surfOverride = G2_FindOverrideSurface(surfaceNum, rootList);
|
||||
|
||||
// really, we should use the default flags for this surface unless it's been overriden
|
||||
int offFlags = surfInfo->flags;
|
||||
|
||||
// set the off flags if we have some
|
||||
if (surfOverride)
|
||||
{
|
||||
offFlags = surfOverride->offFlags;
|
||||
}
|
||||
|
||||
// if this surface is not off, indicate as such in the active surface list
|
||||
if (!(offFlags & G2SURFACEFLAG_OFF))
|
||||
{
|
||||
activeSurfaces[surfaceNum] = 1;
|
||||
}
|
||||
else
|
||||
// if we are turning off all descendants, then stop this recursion now
|
||||
if (offFlags & G2SURFACEFLAG_NODESCENDANTS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// now recursively call for the children
|
||||
for (i=0; i< surfInfo->numChildren; i++)
|
||||
{
|
||||
surfaceNum = surfInfo->childIndexes[i];
|
||||
G2_FindRecursiveSurface(currentModel, surfaceNum, rootList, activeSurfaces);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
qboolean G2_SetRootSurface( CGhoul2Info_v &ghoul2, const int modelIndex, const char *surfaceName)
|
||||
{
|
||||
int surf;
|
||||
int flags;
|
||||
assert(modelIndex>=0&&modelIndex<ghoul2.size());
|
||||
assert(ghoul2[modelIndex].currentModel);
|
||||
assert(ghoul2[modelIndex].currentModel->mdxm);
|
||||
// first find if we already have this surface in the list
|
||||
surf = G2_IsSurfaceLegal(ghoul2[modelIndex].currentModel, surfaceName, &flags);
|
||||
if (surf != -1)
|
||||
{
|
||||
ghoul2[modelIndex].mSurfaceRoot = surf;
|
||||
return qtrue;
|
||||
}
|
||||
assert(0);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
|
||||
extern int G2_DecideTraceLod(CGhoul2Info &ghoul2, int useLod);
|
||||
int G2_AddSurface(CGhoul2Info *ghoul2, int surfaceNumber, int polyNumber, float BarycentricI, float BarycentricJ, int lod )
|
||||
{
|
||||
lod = G2_DecideTraceLod(*ghoul2, lod);
|
||||
|
||||
// first up, see if we have a free one already set up - look only from the end of the constant surfaces onwards
|
||||
unsigned int i;
|
||||
for (i=0; i<ghoul2->mSlist.size(); i++)
|
||||
{
|
||||
// is the surface count -1? That would indicate it's free
|
||||
if (ghoul2->mSlist[i].surface == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i==ghoul2->mSlist.size())
|
||||
{
|
||||
ghoul2->mSlist.push_back(surfaceInfo_t());
|
||||
}
|
||||
ghoul2->mSlist[i].offFlags = G2SURFACEFLAG_GENERATED;
|
||||
ghoul2->mSlist[i].surface = 10000; // no model will ever have 10000 surfaces
|
||||
ghoul2->mSlist[i].genBarycentricI = BarycentricI;
|
||||
ghoul2->mSlist[i].genBarycentricJ = BarycentricJ;
|
||||
ghoul2->mSlist[i].genPolySurfaceIndex = ((polyNumber & 0xffff) << 16) | (surfaceNumber & 0xffff);
|
||||
ghoul2->mSlist[i].genLod = lod;
|
||||
return i;
|
||||
}
|
||||
|
||||
qboolean G2_RemoveSurface(surfaceInfo_v &slist, const int index)
|
||||
{
|
||||
if (index != -1)
|
||||
{
|
||||
slist[index].surface = -1;
|
||||
return qtrue;
|
||||
}
|
||||
assert(0);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
|
||||
int G2_GetParentSurface(CGhoul2Info *ghlInfo, const int index)
|
||||
{
|
||||
assert(ghlInfo->currentModel);
|
||||
assert(ghlInfo->currentModel->mdxm);
|
||||
const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)ghlInfo->currentModel->mdxm + sizeof(mdxmHeader_t));
|
||||
|
||||
// walk each surface and see if this index is listed in it's children
|
||||
const mdxmSurface_t *surf = (mdxmSurface_t *)G2_FindSurface(ghlInfo->currentModel, index, 0);
|
||||
const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surf->thisSurfaceIndex]);
|
||||
|
||||
return surfInfo->parentIndex;
|
||||
|
||||
}
|
||||
|
||||
int G2_GetSurfaceIndex(CGhoul2Info *ghlInfo, const char *surfaceName)
|
||||
{
|
||||
int flags;
|
||||
assert(ghlInfo->currentModel);
|
||||
return G2_IsSurfaceLegal(ghlInfo->currentModel, surfaceName, &flags);
|
||||
}
|
||||
|
||||
int G2_IsSurfaceRendered(CGhoul2Info *ghlInfo, const char *surfaceName, surfaceInfo_v &slist)
|
||||
{
|
||||
int flags = 0;//, surfFlags = 0;
|
||||
int surfIndex = 0;
|
||||
assert(ghlInfo->currentModel);
|
||||
assert(ghlInfo->currentModel->mdxm);
|
||||
if (!ghlInfo->currentModel->mdxm)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// now travel up the skeleton to see if any of it's ancestors have a 'no descendants' turned on
|
||||
|
||||
// find the original surface in the surface list
|
||||
int surfNum = G2_IsSurfaceLegal(ghlInfo->currentModel, surfaceName, &flags);
|
||||
if ( surfNum != -1 )
|
||||
{//must be legal
|
||||
const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)ghlInfo->currentModel->mdxm + sizeof(mdxmHeader_t));
|
||||
const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surfNum]);
|
||||
surfNum = surfInfo->parentIndex;
|
||||
// walk the surface hierarchy up until we hit the root
|
||||
while (surfNum != -1)
|
||||
{
|
||||
const mdxmSurface_t *parentSurf;
|
||||
int parentFlags;
|
||||
const mdxmSurfHierarchy_t *parentSurfInfo;
|
||||
|
||||
parentSurfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surfNum]);
|
||||
|
||||
// find the original surface in the surface list
|
||||
//G2 was bug, above comment was accurate, but we don't want the original flags, we want the parent flags
|
||||
G2_IsSurfaceLegal(ghlInfo->currentModel, parentSurfInfo->name, &parentFlags);
|
||||
|
||||
// now see if we already have overriden this surface in the slist
|
||||
parentSurf = G2_FindSurface(ghlInfo, slist, parentSurfInfo->name, &surfIndex);
|
||||
if (parentSurf)
|
||||
{
|
||||
// set descendants value
|
||||
parentFlags = slist[surfIndex].offFlags;
|
||||
}
|
||||
// now we have the parent flags, lets see if any have the 'no descendants' flag set
|
||||
if (parentFlags & G2SURFACEFLAG_NODESCENDANTS)
|
||||
{
|
||||
flags |= G2SURFACEFLAG_OFF;
|
||||
break;
|
||||
}
|
||||
// set up scan of next parent
|
||||
surfNum = parentSurfInfo->parentIndex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if ( flags == 0 )
|
||||
{//it's not being overridden by a parent
|
||||
// now see if we already have overriden this surface in the slist
|
||||
const mdxmSurface_t *surf = G2_FindSurface(ghlInfo, slist, surfaceName, &surfIndex);
|
||||
if (surf)
|
||||
{
|
||||
// set descendants value
|
||||
flags = slist[surfIndex].offFlags;
|
||||
}
|
||||
// ok, at this point in flags we have what this surface is set to, and the index of the surface itself
|
||||
}
|
||||
return flags;
|
||||
|
||||
}
|
||||
191
code/ghoul2/ghoul2_gore.h
Normal file
191
code/ghoul2/ghoul2_gore.h
Normal file
@@ -0,0 +1,191 @@
|
||||
#ifdef _G2_GORE
|
||||
|
||||
#define MAX_LODS (8)
|
||||
struct GoreTextureCoordinates
|
||||
{
|
||||
float *tex[MAX_LODS];
|
||||
|
||||
GoreTextureCoordinates()
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<MAX_LODS;i++)
|
||||
{
|
||||
tex[i]=0;
|
||||
}
|
||||
}
|
||||
~GoreTextureCoordinates()
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<MAX_LODS;i++)
|
||||
{
|
||||
if ( tex[i] )
|
||||
{
|
||||
extern int Z_Free(void *pvAddress);
|
||||
Z_Free(tex[i]);
|
||||
tex[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
int AllocGoreRecord();
|
||||
GoreTextureCoordinates *FindGoreRecord(int tag);
|
||||
void DeleteGoreRecord(int tag);
|
||||
|
||||
struct SGoreSurface
|
||||
{
|
||||
int shader;
|
||||
int mGoreTag;
|
||||
int mDeleteTime;
|
||||
int mFadeTime;
|
||||
bool mFadeRGB;
|
||||
|
||||
int mGoreGrowStartTime;
|
||||
int mGoreGrowEndTime; // set this to -1 to disable growing
|
||||
//curscale = (curtime-mGoreGrowStartTime)*mGoreGrowFactor + mGoreGrowOffset;
|
||||
float mGoreGrowFactor;
|
||||
float mGoreGrowOffset;
|
||||
};
|
||||
|
||||
class CGoreSet
|
||||
{
|
||||
public:
|
||||
int mMyGoreSetTag;
|
||||
unsigned char mRefCount;
|
||||
multimap<int,SGoreSurface> mGoreRecords; // a map from surface index
|
||||
CGoreSet(int tag) : mMyGoreSetTag(tag), mRefCount(0) {}
|
||||
~CGoreSet();
|
||||
};
|
||||
|
||||
CGoreSet *FindGoreSet(int goreSetTag);
|
||||
CGoreSet *NewGoreSet();
|
||||
void DeleteGoreSet(int goreSetTag);
|
||||
|
||||
#endif // _G2_GORE
|
||||
|
||||
//rww - RAGDOLL_BEGIN
|
||||
#pragma warning(disable: 4512)
|
||||
|
||||
struct SRagDollEffectorCollision
|
||||
{
|
||||
vec3_t effectorPosition;
|
||||
const trace_t &tr;
|
||||
bool useTracePlane;
|
||||
SRagDollEffectorCollision(const vec3_t effectorPos,const trace_t &t) :
|
||||
tr(t),
|
||||
useTracePlane(false)
|
||||
{
|
||||
VectorCopy(effectorPos,effectorPosition);
|
||||
}
|
||||
};
|
||||
|
||||
class CRagDollUpdateParams
|
||||
{
|
||||
public:
|
||||
vec3_t angles;
|
||||
vec3_t position;
|
||||
vec3_t scale;
|
||||
vec3_t velocity;
|
||||
//CServerEntity *me;
|
||||
int me; //index!
|
||||
int settleFrame;
|
||||
|
||||
int groundEnt;
|
||||
|
||||
virtual void EffectorCollision(const SRagDollEffectorCollision &data)
|
||||
{
|
||||
assert(0); // you probably meant to override this
|
||||
}
|
||||
virtual void RagDollBegin()
|
||||
{
|
||||
assert(0); // you probably meant to override this
|
||||
}
|
||||
virtual void RagDollSettled()
|
||||
{
|
||||
assert(0); // you probably meant to override this
|
||||
}
|
||||
|
||||
virtual void Collision()
|
||||
{
|
||||
assert(0); // you probably meant to override this
|
||||
// we had a collision, uhh I guess call SetRagDoll RP_DEATH_COLLISION
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void DebugLine(vec3_t p1,vec3_t p2,int color,bool bbox) {assert(0);}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
class CRagDollParams
|
||||
{
|
||||
public:
|
||||
|
||||
enum ERagPhase
|
||||
{
|
||||
RP_START_DEATH_ANIM,
|
||||
RP_END_DEATH_ANIM,
|
||||
RP_DEATH_COLLISION,
|
||||
RP_CORPSE_SHOT,
|
||||
RP_GET_PELVIS_OFFSET, // this actually does nothing but set the pelvisAnglesOffset, and pelvisPositionOffset
|
||||
RP_SET_PELVIS_OFFSET, // this actually does nothing but set the pelvisAnglesOffset, and pelvisPositionOffset
|
||||
RP_DISABLE_EFFECTORS // this removes effectors given by the effectorsToTurnOff member
|
||||
};
|
||||
vec3_t angles;
|
||||
vec3_t position;
|
||||
vec3_t scale;
|
||||
vec3_t pelvisAnglesOffset; // always set on return, an argument for RP_SET_PELVIS_OFFSET
|
||||
vec3_t pelvisPositionOffset; // always set on return, an argument for RP_SET_PELVIS_OFFSET
|
||||
|
||||
float fImpactStrength; //should be applicable when RagPhase is RP_DEATH_COLLISION
|
||||
float fShotStrength; //should be applicable for setting velocity of corpse on shot (probably only on RP_CORPSE_SHOT)
|
||||
//CServerEntity *me;
|
||||
int me;
|
||||
|
||||
int groundEnt;
|
||||
|
||||
//rww - we have convenient animation/frame access in the game, so just send this info over from there.
|
||||
int startFrame;
|
||||
int endFrame;
|
||||
|
||||
int collisionType; // 1 = from a fall, 0 from effectors, this will be going away soon, hence no enum
|
||||
|
||||
bool CallRagDollBegin; // a return value, means that we are now begininng ragdoll and the NPC stuff needs to happen
|
||||
|
||||
ERagPhase RagPhase;
|
||||
|
||||
// effector control, used for RP_DISABLE_EFFECTORS call
|
||||
|
||||
enum ERagEffector
|
||||
{
|
||||
RE_MODEL_ROOT= 0x00000001, //"model_root"
|
||||
RE_PELVIS= 0x00000002, //"pelvis"
|
||||
RE_LOWER_LUMBAR= 0x00000004, //"lower_lumbar"
|
||||
RE_UPPER_LUMBAR= 0x00000008, //"upper_lumbar"
|
||||
RE_THORACIC= 0x00000010, //"thoracic"
|
||||
RE_CRANIUM= 0x00000020, //"cranium"
|
||||
RE_RHUMEROUS= 0x00000040, //"rhumerus"
|
||||
RE_LHUMEROUS= 0x00000080, //"lhumerus"
|
||||
RE_RRADIUS= 0x00000100, //"rradius"
|
||||
RE_LRADIUS= 0x00000200, //"lradius"
|
||||
RE_RFEMURYZ= 0x00000400, //"rfemurYZ"
|
||||
RE_LFEMURYZ= 0x00000800, //"lfemurYZ"
|
||||
RE_RTIBIA= 0x00001000, //"rtibia"
|
||||
RE_LTIBIA= 0x00002000, //"ltibia"
|
||||
RE_RHAND= 0x00004000, //"rhand"
|
||||
RE_LHAND= 0x00008000, //"lhand"
|
||||
RE_RTARSAL= 0x00010000, //"rtarsal"
|
||||
RE_LTARSAL= 0x00020000, //"ltarsal"
|
||||
RE_RTALUS= 0x00040000, //"rtalus"
|
||||
RE_LTALUS= 0x00080000, //"ltalus"
|
||||
RE_RRADIUSX= 0x00100000, //"rradiusX"
|
||||
RE_LRADIUSX= 0x00200000, //"lradiusX"
|
||||
RE_RFEMURX= 0x00400000, //"rfemurX"
|
||||
RE_LFEMURX= 0x00800000, //"lfemurX"
|
||||
RE_CEYEBROW= 0x01000000 //"ceyebrow"
|
||||
};
|
||||
|
||||
ERagEffector effectorsToTurnOff; // set this to an | of the above flags for a RP_DISABLE_EFFECTORS
|
||||
|
||||
};
|
||||
//rww - RAGDOLL_END
|
||||
Reference in New Issue
Block a user