00001
00002
00003
00004
00005 #include "q_shared.h"
00006 #include "bg_public.h"
00007 #include "bg_strap.h"
00008
00009 #ifdef QAGAME
00010 #include "g_local.h"
00011 #endif
00012
00013 #ifdef UI_EXPORTS
00014 #include "../ui/ui_local.h"
00015 #endif
00016
00017 #ifndef UI_EXPORTS
00018 #ifndef QAGAME
00019 #include "../cgame/cg_local.h"
00020 #endif
00021 #endif
00022
00023 #include "../namespace_begin.h"
00024
00025 void BG_AttachToRancor( void *ghoul2,
00026 float rancYaw,
00027 vec3_t rancOrigin,
00028 int time,
00029 qhandle_t *modelList,
00030 vec3_t modelScale,
00031 qboolean inMouth,
00032 vec3_t out_origin,
00033 vec3_t out_angles,
00034 vec3_t out_axis[3] )
00035 {
00036 mdxaBone_t boltMatrix;
00037 int boltIndex;
00038 vec3_t rancAngles;
00039 vec3_t temp_angles;
00040
00041 if ( inMouth )
00042 {
00043 boltIndex = trap_G2API_AddBolt(ghoul2, 0, "jaw_bone");
00044 }
00045 else
00046 {
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
00054 if ( out_origin )
00055 {
00056 BG_GiveMeVectorFromMatrix( &boltMatrix, ORIGIN, out_origin );
00057 }
00058 if ( out_axis )
00059 {
00060 if ( inMouth )
00061 {
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 {
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
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 {
00085 BG_GiveMeVectorFromMatrix( &boltMatrix, POSITIVE_Z, temp_axis[0] );
00086 BG_GiveMeVectorFromMatrix( &boltMatrix, NEGATIVE_X, temp_axis[2] );
00087 }
00088 else
00089 {
00090 BG_GiveMeVectorFromMatrix( &boltMatrix, NEGATIVE_Y, temp_axis[0] );
00091 BG_GiveMeVectorFromMatrix( &boltMatrix, POSITIVE_Z, temp_axis[2] );
00092 }
00093
00094 vectoangles( temp_axis[0], out_angles );
00095 vectoangles( temp_axis[2], temp_angles );
00096 out_angles[ROLL] = -temp_angles[PITCH];
00097 }
00098 }
00099
00100 #define MAX_VARIANTS 8
00101 qboolean BG_GetRootSurfNameWithVariant( void *ghoul2, const char *rootSurfName, char *returnSurfName, int returnSize )
00102 {
00103 if ( !ghoul2 || !trap_G2API_GetSurfaceRenderStatus( ghoul2, 0, rootSurfName ) )
00104 {
00105 Q_strncpyz( returnSurfName, rootSurfName, returnSize );
00106 return qtrue;
00107 }
00108 else
00109 {
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 }
00123
00124 #include "../namespace_end.h"