本文整理汇总了C++中GetVectorForKey函数的典型用法代码示例。如果您正苦于以下问题:C++ GetVectorForKey函数的具体用法?C++ GetVectorForKey怎么用?C++ GetVectorForKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetVectorForKey函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalcTerrainSize
/*
================
CalcTerrainSize
================
*/
void CalcTerrainSize( vec3_t mins, vec3_t maxs, vec3_t size ) {
bspbrush_t *brush;
int i;
const char *key;
// calculate the size of the terrain
ClearBounds( mins, maxs );
for( brush = mapent->brushes; brush != NULL; brush = brush->next ) {
AddPointToBounds( brush->mins, mins, maxs );
AddPointToBounds( brush->maxs, mins, maxs );
}
key = ValueForKey( mapent, "min" );
if ( key[ 0 ] ) {
GetVectorForKey( mapent, "min", mins );
}
key = ValueForKey( mapent, "max" );
if ( key[ 0 ] ) {
GetVectorForKey( mapent, "max", maxs );
}
for( i = 0; i < 3; i++ ) {
mins[ i ] = floor( mins[ i ] + 0.1 );
maxs[ i ] = floor( maxs[ i ] + 0.1 );
}
VectorSubtract( maxs, mins, size );
if ( ( size[ 0 ] <= 0 ) || ( size[ 1 ] <= 0 ) ) {
Error ("CalcTerrainSize: Invalid terrain size: %fx%f", size[ 0 ], size[ 1 ] );
}
}
示例2: InitMacroTexture
void InitMacroTexture( const char *pBSPFilename )
{
// Get the world bounds (same ones used by minimaps and level designers know how to use).
int i = 0;
for (i = 0; i < num_entities; ++i)
{
char* pEntity = ValueForKey(&entities[i], "classname");
if( !strcmp(pEntity, "worldspawn") )
{
GetVectorForKey( &entities[i], "world_mins", g_MacroWorldMins );
GetVectorForKey( &entities[i], "world_maxs", g_MacroWorldMaxs );
break;
}
}
if ( i == num_entities )
{
Warning( "MaskOnMacroTexture: can't find worldspawn" );
return;
}
// Load the macro texture that is mapped onto everything.
char mapName[512], vtfFilename[512];
Q_FileBase( pBSPFilename, mapName, sizeof( mapName ) );
Q_snprintf( vtfFilename, sizeof( vtfFilename ), "materials/macro/%s/base.vtf", mapName );
g_pGlobalMacroTextureData = LoadMacroTextureFile( vtfFilename );
// Now load the macro texture for each face.
g_FaceMacroTextures.SetSize( numfaces );
for ( int iFace=0; iFace < numfaces; iFace++ )
{
g_FaceMacroTextures[iFace] = NULL;
if ( iFace < g_FaceMacroTextureInfos.Count() )
{
unsigned short stringID = g_FaceMacroTextureInfos[iFace].m_MacroTextureNameID;
if ( stringID != 0xFFFF )
{
const char *pMacroTextureName = &g_TexDataStringData[ g_TexDataStringTable[stringID] ];
Q_snprintf( vtfFilename, sizeof( vtfFilename ), "%smaterials/%s.vtf", gamedir, pMacroTextureName );
g_FaceMacroTextures[iFace] = FindMacroTexture( vtfFilename );
if ( !g_FaceMacroTextures[iFace] )
{
g_FaceMacroTextures[iFace] = LoadMacroTextureFile( vtfFilename );
if ( g_FaceMacroTextures[iFace] )
{
g_MacroTextureLookup.Insert( vtfFilename, g_FaceMacroTextures[iFace] );
}
}
}
}
}
}
示例3: LoadEntities
/*
==================
LoadEntities
==================
*/
void LoadEntities (void)
{
char *s, *s2;
entity_t *e;
lightentity_t *le;
int i, j;
ParseEntities ();
// go through all the entities
for (i=1 ; i<num_entities ; i++)
{
e = &entities[i];
s = ValueForKey (e, "classname");
if (strncmp (s, "light", 5))
continue;
le = &lightentities[numlightentities];
numlightentities++;
strcpy (le->classname, s);
le->light = FloatForKey (e, "light");
if (!le->light)
le->light = DEFAULTLIGHTLEVEL;
le->style = FloatForKey (e, "style");
le->angle = FloatForKey (e, "angle");
GetVectorForKey (e, "origin", le->origin);
s = ValueForKey (e, "target");
if (!s[0])
continue;
// find matching targetname
for (j=1 ; j<num_entities ; j++)
{
s2 = ValueForKey (&entities[j], "targetname");
if (!strcmp (s, s2))
{
le->targetent = true;
GetVectorForKey (&entities[j], "origin", le->targetorigin);
break;
}
}
if (j == num_entities)
printf ("WARNING: entity %i has unmatched target %s\n", i, s);
}
qprintf ("%d lightentities\n", numlightentities);
}
示例4: Map_StartPosition
//
// move the view to a start position
//
void Map_StartPosition(){
entity_t *ent = AngledEntity();
g_pParentWnd->GetCamWnd()->Camera()->angles[PITCH] = 0;
if ( ent ) {
GetVectorForKey( ent, "origin", g_pParentWnd->GetCamWnd()->Camera()->origin );
GetVectorForKey( ent, "origin", g_pParentWnd->GetXYWnd()->GetOrigin() );
g_pParentWnd->GetCamWnd()->Camera()->angles[YAW] = FloatForKey( ent, "angle" );
}
else
{
g_pParentWnd->GetCamWnd()->Camera()->angles[YAW] = 0;
VectorCopy( vec3_origin, g_pParentWnd->GetCamWnd()->Camera()->origin );
VectorCopy( vec3_origin, g_pParentWnd->GetXYWnd()->GetOrigin() );
}
}
示例5: ParseEntity
/*
================
ParseEntity
================
*/
qboolean ParseEntity (void)
{
if (!GetToken (true))
return false;
if (strcmp (token, "{") )
Error ("ParseEntity: { not found");
if (num_entities == MAX_MAP_ENTITIES)
Error ("num_entities == MAX_MAP_ENTITIES");
mapent = &entities[num_entities];
num_entities++;
do
{
fflush(stdout);
if (!GetToken (true))
Error ("ParseEntity: EOF without closing brace");
if (!strcmp (token, "}") )
break;
if (!strcmp (token, "{") )
ParseBrush ();
else
ParseEpair ();
}
while (1);
GetVectorForKey (mapent, "origin", mapent->origin);
return true;
}
示例6: ParseEpair
static void
ParseEpair(void)
{
epair_t *e;
e = AllocMem(OTHER, sizeof(epair_t), true);
e->next = map.rgEntities[map.iEntities].epairs;
map.rgEntities[map.iEntities].epairs = e;
if (strlen(token) >= MAX_KEY - 1)
Message(msgError, errEpairTooLong, linenum);
e->key = copystring(token);
ParseToken(PARSE_SAMELINE);
if (strlen(token) >= MAX_VALUE - 1)
Message(msgError, errEpairTooLong, linenum);
e->value = copystring(token);
if (!strcasecmp(e->key, "origin"))
GetVectorForKey(map.iEntities, e->key,
map.rgEntities[map.iEntities].origin);
else if (!strcasecmp(e->key, "classname")) {
if (!strcasecmp(e->value, "info_player_start")) {
if (rgfStartSpots & info_player_start)
Message(msgWarning, warnMultipleStarts);
rgfStartSpots |= info_player_start;
} else if (!strcasecmp(e->value, "info_player_deathmatch"))
rgfStartSpots |= info_player_deathmatch;
else if (!strcasecmp(e->value, "info_player_coop"))
rgfStartSpots |= info_player_coop;
}
}
示例7: ParseEpair
static void
ParseEpair(parser_t *parser, mapentity_t *ent)
{
epair_t *epair;
epair = AllocMem(OTHER, sizeof(epair_t), true);
epair->next = ent->epairs;
ent->epairs = epair;
if (strlen(parser->token) >= MAX_KEY - 1)
Error(errEpairTooLong, parser->linenum);
epair->key = copystring(parser->token);
ParseToken(parser, PARSE_SAMELINE);
if (strlen(parser->token) >= MAX_VALUE - 1)
Error(errEpairTooLong, parser->linenum);
epair->value = copystring(parser->token);
if (!strcasecmp(epair->key, "origin")) {
GetVectorForKey(ent, epair->key, ent->origin);
} else if (!strcasecmp(epair->key, "classname")) {
if (!strcasecmp(epair->value, "info_player_start")) {
if (rgfStartSpots & info_player_start)
Message(msgWarning, warnMultipleStarts);
rgfStartSpots |= info_player_start;
} else if (!strcasecmp(epair->value, "info_player_deathmatch")) {
rgfStartSpots |= info_player_deathmatch;
} else if (!strcasecmp(epair->value, "info_player_coop")) {
rgfStartSpots |= info_player_coop;
}
}
}
示例8: FixRotateOrigin
/*
=================
FixRotateOrigin
=================
*/
void FixRotateOrigin(entity_t *Ent, vec3_t offset)
{
int FoundEnt = -1, BadTarget = -1;
char *Search, Origin[100], Str[100];
static entity_t *PrevEnt = NULL; // Prevent multiple warnings for same entity
Search = ValueForKey(Ent, "target");
if (strlen(Search) != 0)
{
FoundEnt = FindTargetEntity(Search, &BadTarget);
if (FoundEnt != -1)
GetVectorForKey(&entities[FoundEnt], "origin", offset);
}
if (Ent != PrevEnt)
{
if (FoundEnt == -1)
{
Str[0] = '\0';
if (BadTarget != -1)
sprintf(Str, " (line %d)", entities[BadTarget].Line);
Message (MSGWARN, "Bad target%s for rotation entity on line %d", Str, Ent->Line);
}
PrevEnt = Ent;
}
sprintf(Origin, "%d %d %d", (int)offset[0], (int)offset[1], (int)offset[2]);
SetKeyValue(Ent, "origin", Origin);
}
示例9: BuildPatches
/*
* @brief Create surface fragments for light-emitting surfaces so that light sources
* may be computed along them.
*/
void BuildPatches(void) {
int32_t i, j, k;
winding_t *w;
vec3_t origin;
for (i = 0; i < d_bsp.num_models; i++) {
const d_bsp_model_t *mod = &d_bsp.models[i];
const entity_t *ent = EntityForModel(i);
// bmodels with origin brushes need to be offset into their
// in-use position
GetVectorForKey(ent, "origin", origin);
for (j = 0; j < mod->num_faces; j++) {
const int32_t facenum = mod->first_face + j;
d_bsp_face_t *f = &d_bsp.faces[facenum];
VectorCopy(origin, face_offset[facenum]);
if (!HasLight(f)) // no light
continue;
w = WindingForFace(f);
for (k = 0; k < w->num_points; k++) {
VectorAdd(w->points[k], origin, w->points[k]);
}
BuildPatch(facenum, w);
}
}
}
示例10: Entity_WriteSelected
//
// =======================================================================================================================
// Entity_WriteSelected to a CMemFile
// =======================================================================================================================
//
void Entity_WriteSelected(entity_t *e, CMemFile *pMemFile)
{
brush_t *b;
idVec3 origin;
char text[128];
int count;
for (b = e->brushes.onext; b != &e->brushes; b = b->onext)
{
if (IsBrushSelected(b))
{
break; // got one
}
}
if (b == &e->brushes)
{
return; // nothing selected
}
// if fixedsize, calculate a new origin based on the current brush position
if (e->eclass->fixedsize || EntityHasModel(e))
{
if (!GetVectorForKey(e, "origin", origin))
{
VectorSubtract(e->brushes.onext->mins, e->eclass->mins, origin);
sprintf(text, "%i %i %i", (int)origin[0], (int)origin[1], (int)origin[2]);
SetKeyValue(e, "origin", text);
}
}
MemFile_fprintf(pMemFile, "{\n");
count = e->epairs.GetNumKeyVals();
for (int j = 0; j < count; j++)
{
MemFile_fprintf(pMemFile, "\"%s\" \"%s\"\n", e->epairs.GetKeyVal(j)->GetKey().c_str(), e->epairs.GetKeyVal(j)->GetValue().c_str());
}
if (!EntityHasModel(e))
{
count = 0;
for (b = e->brushes.onext; b != &e->brushes; b = b->onext)
{
if (e->eclass->fixedsize && !b->entityModel)
{
continue;
}
if (IsBrushSelected(b))
{
MemFile_fprintf(pMemFile, "// brush %i\n", count);
count++;
Brush_Write( b, pMemFile, e->origin, ( g_PrefsDlg.m_bNewMapFormat != FALSE ) );
}
}
}
MemFile_fprintf(pMemFile, "}\n");
}
示例11: Entity_New
entity_t *EntityFromMapEntity(idMapEntity *mapent, CWaitDlg *dlg)
{
entity_t *ent = NULL;
if (mapent) {
ent = Entity_New();
ent->brushes.onext = ent->brushes.oprev = &ent->brushes;
ent->origin.Zero();
ent->epairs = mapent->epairs;
GetVectorForKey(ent, "origin", ent->origin);
int count = mapent->GetNumPrimitives();
long lastUpdate = 0;
idStr status;
for (int i = 0; i < count; i++) {
idMapPrimitive *prim = mapent->GetPrimitive(i);
if (prim) {
// update 20 times a second
if ((GetTickCount() - lastUpdate) > 50) {
lastUpdate = GetTickCount();
if (prim->GetType() == idMapPrimitive::TYPE_BRUSH) {
sprintf(status, "Reading primitive %i (brush)", i);
} else if (prim->GetType() == idMapPrimitive::TYPE_PATCH) {
sprintf(status, "Reading primitive %i (patch)", i);
}
dlg->SetText(status, true);
}
if (dlg->CancelPressed()) {
return ent;
}
brush_t *b = NULL;
if (prim->GetType() == idMapPrimitive::TYPE_BRUSH) {
idMapBrush *mapbrush = reinterpret_cast<idMapBrush *>(prim);
b = BrushFromMapBrush(mapbrush, ent->origin);
} else if (prim->GetType() == idMapPrimitive::TYPE_PATCH) {
idMapPatch *mappatch = reinterpret_cast<idMapPatch *>(prim);
b = BrushFromMapPatch(mappatch, ent->origin);
}
if (b) {
b->owner = ent;
// add to the end of the entity chain
b->onext = &ent->brushes;
b->oprev = ent->brushes.oprev;
ent->brushes.oprev->onext = b;
ent->brushes.oprev = b;
}
}
}
}
return ent;
}
示例12: AAS_PositionFuncRotatingBrush
//===========================================================================
// this function sets the func_rotating_door in it's final position
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
void AAS_PositionFuncRotatingBrush(entity_t *mapent, mapbrush_t *brush)
{
int spawnflags, i;
float distance;
vec3_t movedir, angles, pos1, pos2;
side_t *s;
spawnflags = FloatForKey(mapent, "spawnflags");
VectorClear(movedir);
if (spawnflags & DOOR_X_AXIS)
{
movedir[2] = 1.0; //roll
}
else if (spawnflags & DOOR_Y_AXIS)
{
movedir[0] = 1.0; //pitch
}
else // Z_AXIS
{
movedir[1] = 1.0; //yaw
}
// check for reverse rotation
if (spawnflags & DOOR_REVERSE)
{
VectorInverse(movedir);
}
distance = FloatForKey(mapent, "distance");
if (!distance)
{
distance = 90;
}
GetVectorForKey(mapent, "angles", angles);
VectorCopy(angles, pos1);
VectorMA(angles, -distance, movedir, pos2);
// if it starts open, switch the positions
if (spawnflags & DOOR_START_OPEN)
{
VectorCopy(pos2, angles);
VectorCopy(pos1, pos2);
VectorCopy(angles, pos1);
VectorInverse(movedir);
} //end if
//
for (i = 0; i < brush->numsides; i++)
{
s = &brush->original_sides[i];
s->planenum = AAS_TransformPlane(s->planenum, mapent->origin, pos2);
} //end for
//
FreeBrushWindings(brush);
AAS_MakeBrushWindings(brush);
AddBrushBevels(brush);
FreeBrushWindings(brush);
} //end of the function AAS_PositionFuncRotatingBrush
示例13: Q3_ParseBSPEntity
//===========================================================================
//===========================================================================
qboolean Q3_ParseBSPEntity(int entnum)
{
entity_t *mapent;
char *model;
int startbrush, startsides;
startbrush = nummapbrushes;
startsides = nummapbrushsides;
mapent = &entities[entnum]; //num_entities];
mapent->firstbrush = nummapbrushes;
mapent->numbrushes = 0;
mapent->modelnum = -1; //-1 = no BSP model
model = ValueForKey(mapent, "model");
if(model && strlen(model))
{
if(*model == '*')
{
//get the model number of this entity (skip the leading *)
mapent->modelnum = atoi(&model[1]);
} //end if
} //end if
GetVectorForKey(mapent, "origin", mapent->origin);
//if this is the world entity it has model number zero
//the world entity has no model key
if(!strcmp("worldspawn", ValueForKey(mapent, "classname")))
{
mapent->modelnum = 0;
} //end if
//if the map entity has a BSP model (a modelnum of -1 is used for
//entities that aren't using a BSP model)
if(mapent->modelnum >= 0)
{
//parse the bsp brushes
Q3_ParseBSPBrushes(mapent);
} //end if
//
//the origin of the entity is already taken into account
//
//func_group entities can't be in the bsp file
//
//check out the func_areaportal entities
if(!strcmp("func_areaportal", ValueForKey(mapent, "classname")))
{
c_areaportals++;
mapent->areaportalnum = c_areaportals;
return true;
} //end if
return true;
} //end of the function Q3_ParseBSPEntity
示例14: FloodEntities
/*
* @brief Marks all nodes that can be reached by entites
*/
_Bool FloodEntities(tree_t *tree) {
int32_t i;
vec3_t origin;
const char *cl;
_Bool inside;
node_t *head_node;
head_node = tree->head_node;
Com_Debug("--- FloodEntities ---\n");
inside = false;
tree->outside_node.occupied = 0;
cl = "";
for (i = 1; i < num_entities; i++) {
GetVectorForKey(&entities[i], "origin", origin);
if (VectorCompare(origin, vec3_origin))
continue;
cl = ValueForKey(&entities[i], "classname");
origin[2] += 1; // so objects on floor are ok
// nudge playerstart around if needed so clipping hulls always
// have a valid point
if (!g_strcmp0(cl, "info_player_start")) {
int32_t x, y;
for (x = -16; x <= 16; x += 16) {
for (y = -16; y <= 16; y += 16) {
origin[0] += x;
origin[1] += y;
if (PlaceOccupant(head_node, origin, &entities[i])) {
inside = true;
goto gotit;
}
origin[0] -= x;
origin[1] -= y;
}
}
gotit:
;
} else {
if (PlaceOccupant(head_node, origin, &entities[i]))
inside = true;
}
}
if (!inside) {
Com_Debug("no entities in open -- no filling\n");
} else if (tree->outside_node.occupied) {
Com_Debug("entity %s reached from outside -- no filling\n", cl);
}
return inside && !tree->outside_node.occupied;
}
示例15: Error
/*
=======================================================================================================================
Entity_Parse If onlypairs is set, the classname info will not be looked up, and the entity will not be added to the
global list. Used for parsing the project.
=======================================================================================================================
*/
entity_t *Entity_Parse(bool onlypairs, brush_t *pList) {
entity_t *ent;
if (!GetToken(true)) {
return NULL;
}
if (strcmp(token, "{")) {
Error("ParseEntity: { not found");
}
ent = Entity_New();
ent->brushes.onext = ent->brushes.oprev = &ent->brushes;
ent->origin.Zero();
int n = 0;
do {
if (!GetToken(true)) {
Warning("ParseEntity: EOF without closing brace");
return NULL;
}
if (!strcmp(token, "}")) {
break;
}
if (!strcmp(token, "{")) {
GetVectorForKey(ent, "origin", ent->origin);
brush_t *b = Brush_Parse(ent->origin);
if (b != NULL) {
b->owner = ent;
// add to the end of the entity chain
b->onext = &ent->brushes;
b->oprev = ent->brushes.oprev;
ent->brushes.oprev->onext = b;
ent->brushes.oprev = b;
}
else {
break;
}
}
else {
ParseEpair(&ent->epairs);
}
} while (1);
if (onlypairs) {
return ent;
}
return Entity_PostParse(ent, pList);
}