codemp/game/bg_g2_utils.c File Reference

#include "q_shared.h"
#include "bg_public.h"
#include "bg_strap.h"
#include "../cgame/cg_local.h"
#include "../namespace_begin.h"
#include "../namespace_end.h"

Go to the source code of this file.

Defines

#define MAX_VARIANTS   8

Functions

void BG_AttachToRancor (void *ghoul2, float rancYaw, vec3_t rancOrigin, int time, qhandle_t *modelList, vec3_t modelScale, qboolean inMouth, vec3_t out_origin, vec3_t out_angles, vec3_t out_axis[3])
qboolean BG_GetRootSurfNameWithVariant (void *ghoul2, const char *rootSurfName, char *returnSurfName, int returnSize)


Define Documentation

#define MAX_VARIANTS   8
 

Definition at line 100 of file bg_g2_utils.c.

Referenced by BG_GetRootSurfNameWithVariant().


Function Documentation

void BG_AttachToRancor void *  ghoul2,
float  rancYaw,
vec3_t  rancOrigin,
int  time,
qhandle_t modelList,
vec3_t  modelScale,
qboolean  inMouth,
vec3_t  out_origin,
vec3_t  out_angles,
vec3_t  out_axis[3]
 

Definition at line 25 of file bg_g2_utils.c.

References NEGATIVE_X, NEGATIVE_Y, ORIGIN, PITCH, POSITIVE_X, POSITIVE_Z, qhandle_t, ROLL, trap_G2API_AddBolt(), trap_G2API_GetBoltMatrix(), vec3_t, vectoangles(), and VectorSet.

Referenced by CG_Player(), and G_HeldByMonster().

00035 {
00036         mdxaBone_t      boltMatrix;
00037         int boltIndex;
00038         vec3_t rancAngles;
00039         vec3_t temp_angles;
00040         // Getting the bolt here
00041         if ( inMouth )
00042         {//in mouth
00043                 boltIndex = trap_G2API_AddBolt(ghoul2, 0, "jaw_bone");
00044         }
00045         else
00046         {//in right hand
00047                 boltIndex = trap_G2API_AddBolt(ghoul2, 0, "*r_hand");
00048         }
00049         VectorSet( rancAngles, 0, rancYaw, 0 );
00050         trap_G2API_GetBoltMatrix( ghoul2, 0, boltIndex, 
00051                         &boltMatrix, rancAngles, rancOrigin, time,
00052                         modelList, modelScale );
00053         // Storing ent position, bolt position, and bolt axis
00054         if ( out_origin )
00055         {
00056                 BG_GiveMeVectorFromMatrix( &boltMatrix, ORIGIN, out_origin );
00057         }
00058         if ( out_axis )
00059         {
00060                 if ( inMouth )
00061                 {//in mouth
00062                         BG_GiveMeVectorFromMatrix( &boltMatrix, POSITIVE_Z, out_axis[0] );
00063                         BG_GiveMeVectorFromMatrix( &boltMatrix, NEGATIVE_Y, out_axis[1] );
00064                         BG_GiveMeVectorFromMatrix( &boltMatrix, NEGATIVE_X, out_axis[2] );
00065                 }
00066                 else
00067                 {//in hand
00068                         BG_GiveMeVectorFromMatrix( &boltMatrix, NEGATIVE_Y, out_axis[0] );
00069                         BG_GiveMeVectorFromMatrix( &boltMatrix, POSITIVE_X, out_axis[1] );
00070                         BG_GiveMeVectorFromMatrix( &boltMatrix, POSITIVE_Z, out_axis[2] );
00071                 }
00072                 //FIXME: this is messing up our axis and turning us inside-out?
00073                 if ( out_angles )
00074                 {
00075                         vectoangles( out_axis[0], out_angles );
00076                         vectoangles( out_axis[2], temp_angles );
00077                         out_angles[ROLL] = -temp_angles[PITCH];
00078                 }
00079         }
00080         else if ( out_angles )
00081         {
00082                 vec3_t temp_axis[3];
00083                 if ( inMouth )
00084                 {//in mouth
00085                         BG_GiveMeVectorFromMatrix( &boltMatrix, POSITIVE_Z, temp_axis[0] );
00086                         BG_GiveMeVectorFromMatrix( &boltMatrix, NEGATIVE_X, temp_axis[2] );
00087                 }
00088                 else
00089                 {//in hand
00090                         BG_GiveMeVectorFromMatrix( &boltMatrix, NEGATIVE_Y, temp_axis[0] );
00091                         BG_GiveMeVectorFromMatrix( &boltMatrix, POSITIVE_Z, temp_axis[2] );
00092                 }
00093                 //FIXME: this is messing up our axis and turning us inside-out?
00094                 vectoangles( temp_axis[0], out_angles );
00095                 vectoangles( temp_axis[2], temp_angles );
00096                 out_angles[ROLL] = -temp_angles[PITCH];
00097         }
00098 }

qboolean BG_GetRootSurfNameWithVariant void *  ghoul2,
const char *  rootSurfName,
char *  returnSurfName,
int  returnSize
 

Definition at line 101 of file bg_g2_utils.c.

References Com_sprintf(), MAX_VARIANTS, Q_strncpyz(), qboolean, qfalse, qtrue, and trap_G2API_GetSurfaceRenderStatus().

Referenced by G_Dismember().

00102 {
00103         if ( !ghoul2 || !trap_G2API_GetSurfaceRenderStatus( ghoul2, 0, rootSurfName ) )
00104         {//see if the basic name without variants is on
00105                 Q_strncpyz( returnSurfName, rootSurfName, returnSize );
00106                 return qtrue;
00107         }
00108         else
00109         {//check variants
00110                 int i;
00111                 for ( i = 0; i < MAX_VARIANTS; i++ )
00112                 {
00113                         Com_sprintf( returnSurfName, returnSize, "%s%c", rootSurfName, 'a'+i );
00114                         if ( !trap_G2API_GetSurfaceRenderStatus( ghoul2, 0, returnSurfName ) )
00115                         {
00116                                 return qtrue;
00117                         }
00118                 }
00119         }
00120         Q_strncpyz( returnSurfName, rootSurfName, returnSize );
00121         return qfalse;
00122 }