本文整理汇总了C++中CNavArea::GetExtent方法的典型用法代码示例。如果您正苦于以下问题:C++ CNavArea::GetExtent方法的具体用法?C++ CNavArea::GetExtent怎么用?C++ CNavArea::GetExtent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNavArea
的用法示例。
在下文中一共展示了CNavArea::GetExtent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
boost::python::list GetNavAreasAtBB( const Vector &mins, const Vector &maxs )
{
boost::python::list l;
CNavArea *area;
Extent extent;
Vector vAbsMins2, vAbsMaxs2;
// TODO: Use ForAllAreasOverlappingExtent?
FOR_EACH_VEC( TheNavAreas, it )
{
area = TheNavAreas[ it ];
area->GetExtent( &extent );
vAbsMins2 = extent.lo;
vAbsMaxs2 = extent.hi;
if( vAbsMins2[2] > vAbsMaxs2[2] )
{
float z = vAbsMaxs2[2];
vAbsMaxs2[2] = vAbsMins2[2];
vAbsMins2[2] = z;
}
else if( vAbsMins2[2] == vAbsMaxs2[2] )
{
vAbsMaxs2[2] += 1.0f;
}
// Does it intersects with our bounding box?
if( IsBoxIntersectingBox( mins, maxs,
vAbsMins2, vAbsMaxs2 ) )
{
l.append( area->GetID() );
}
}
示例2: RandomNavAreaPositionWithin
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
Vector RandomNavAreaPositionWithin( const Vector &mins, const Vector &maxs, float minimumarea, int maxtries )
{
if( maxtries < 0 )
maxtries = 1;
Vector random;
CNavArea *pArea = NULL;
Extent extent;
for( int i = 0; i < maxtries; i++ )
{
random.Init(
mins.x + ((float)rand() / RAND_MAX) * (maxs.x - mins.x),
mins.y + ((float)rand() / RAND_MAX) * (maxs.y - mins.y),
maxs.z
);
pArea = TheNavMesh->GetNearestNavArea( random, false, 10000.0f, false, false );
if( pArea )
{
pArea->GetExtent( &extent );
if( extent.Area() >= minimumarea )
break;
}
// Reset
pArea = NULL;
}
if( !pArea )
{
if( g_pynavmesh_debug.GetBool() )
DevMsg("RandomNavAreaPosition: No area found within Mins: %f %f %f, Maxs: %f %f %f, Random: %f %f %f\n",
mins.x, mins.y, mins.z, maxs.x, maxs.y, maxs.z, random.x, random.y, random.z);
return vec3_origin;
}
Vector vRandomPoint = pArea->GetRandomPoint();
vRandomPoint.z += 32.0f;
if( g_pynavmesh_debug.GetBool() )
DevMsg("RandomNavAreaPosition: Found position %f %f %f\n", vRandomPoint.x, vRandomPoint.y, vRandomPoint.z);
return vRandomPoint;
}
示例3: DrawDebugTextOverlays
//-----------------------------------------------------------------------------------------------------
int CFuncNavBlocker::DrawDebugTextOverlays( void )
{
int offset = BaseClass::DrawDebugTextOverlays();
if (m_debugOverlays & OVERLAY_TEXT_BIT)
{
CFmtStr str;
// FIRST_GAME_TEAM skips TEAM_SPECTATOR and TEAM_UNASSIGNED, so we can print
// useful team names in a non-game-specific fashion.
for ( int i=FIRST_GAME_TEAM; i<FIRST_GAME_TEAM + MAX_NAV_TEAMS; ++i )
{
if ( IsBlockingNav( i ) )
{
CTeam *team = GetGlobalTeam( i );
if ( team )
{
EntityText( offset++, str.sprintf( "blocking team %s", team->GetName() ), 0 );
}
else
{
EntityText( offset++, str.sprintf( "blocking team %d", i ), 0 );
}
}
}
NavAreaCollector collector( true );
Extent extent;
extent.Init( this );
TheNavMesh->ForAllAreasOverlappingExtent( collector, extent );
for ( int i=0; i<collector.m_area.Count(); ++i )
{
CNavArea *area = collector.m_area[i];
Extent areaExtent;
area->GetExtent( &areaExtent );
debugoverlay->AddBoxOverlay( vec3_origin, areaExtent.lo, areaExtent.hi, vec3_angle, 0, 255, 0, 10, NDEBUG_PERSIST_TILL_NEXT_SERVER );
}
}
return offset;
}
示例4: LoadNavigationMap
/* <4f19c7> ../game_shared/bot/nav_file.cpp:947 */
NavErrorType LoadNavigationMap()
{
// since the navigation map is destroyed on map change,
// if it exists it has already been loaded for this map
if (!TheNavAreaList.empty())
return NAV_OK;
// nav filename is derived from map filename
char filename[256];
Q_sprintf(filename, "maps\\%s.nav", STRING(gpGlobals->mapname));
// free previous navigation map data
DestroyNavigationMap();
placeDirectory.Reset();
IMPL_CLASS(CNavArea, m_nextID) = 1;
SteamFile navFile(filename);
if (!navFile.IsValid())
return NAV_CANT_ACCESS_FILE;
// check magic number
bool result;
unsigned int magic;
result = navFile.Read(&magic, sizeof(unsigned int));
if (!result || magic != NAV_MAGIC_NUMBER)
{
CONSOLE_ECHO("ERROR: Invalid navigation file '%s'.\n", filename);
return NAV_INVALID_FILE;
}
// read file version number
unsigned int version;
result = navFile.Read(&version, sizeof(unsigned int));
if (!result || version > 5)
{
CONSOLE_ECHO("ERROR: Unknown navigation file version.\n");
return NAV_BAD_FILE_VERSION;
}
if (version >= 4)
{
// get size of source bsp file and verify that the bsp hasn't changed
unsigned int saveBspSize;
navFile.Read(&saveBspSize, sizeof(unsigned int));
// verify size
char *bspFilename = GetBspFilename(filename);
if (bspFilename == NULL)
return NAV_INVALID_FILE;
unsigned int bspSize = (unsigned int)GET_FILE_SIZE(bspFilename);
if (bspSize != saveBspSize)
{
// this nav file is out of date for this bsp file
char *msg = "*** WARNING ***\nThe AI navigation data is from a different version of this map.\nThe CPU players will likely not perform well.\n";
HintMessageToAllPlayers(msg);
CONSOLE_ECHO("\n-----------------\n");
CONSOLE_ECHO(msg);
CONSOLE_ECHO("-----------------\n\n");
}
}
// load Place directory
if (version >= 5)
{
placeDirectory.Load(&navFile);
}
// get number of areas
unsigned int count;
result = navFile.Read(&count, sizeof(unsigned int));
Extent extent;
extent.lo.x = 9999999999.9f;
extent.lo.y = 9999999999.9f;
extent.hi.x = -9999999999.9f;
extent.hi.y = -9999999999.9f;
// load the areas and compute total extent
for (unsigned int i = 0; i < count; ++i)
{
CNavArea *area = new CNavArea;
area->Load(&navFile, version);
TheNavAreaList.push_back(area);
const Extent *areaExtent = area->GetExtent();
// check validity of nav area
if (areaExtent->lo.x >= areaExtent->hi.x || areaExtent->lo.y >= areaExtent->hi.y)
CONSOLE_ECHO("WARNING: Degenerate Navigation Area #%d at ( %g, %g, %g )\n",
area->GetID(), area->m_center.x, area->m_center.y, area->m_center.z);
if (areaExtent->lo.x < extent.lo.x)
extent.lo.x = areaExtent->lo.x;
if (areaExtent->lo.y < extent.lo.y)
//.........这里部分代码省略.........
示例5: ValidateMapData
//.........这里部分代码省略.........
m_gameScenario = SCENARIO_ESCORT_VIP;
}
if (found)
{
if (m_zoneCount < MAX_ZONES)
{
if (isLegacy)
m_zone[ m_zoneCount ].m_center = entity->pev->origin;
else
m_zone[ m_zoneCount ].m_center = (entity->pev->absmax + entity->pev->absmin) / 2.0f;
m_zone[ m_zoneCount ].m_isLegacy = isLegacy;
m_zone[ m_zoneCount ].m_index = m_zoneCount;
m_zone[ m_zoneCount ].m_entity = entity;
++m_zoneCount;
}
else
CONSOLE_ECHO("Warning: Too many zones, some will be ignored.\n");
}
}
// If there are no zones and the scenario is hostage rescue,
// use the info_player_start entities as rescue zones.
if (m_zoneCount == 0 && m_gameScenario == SCENARIO_RESCUE_HOSTAGES)
{
entity = NULL;
while ((entity = UTIL_FindEntityByClassname(entity, "info_player_start")) != NULL)
{
if (FNullEnt(entity->edict()))
break;
if (m_zoneCount < MAX_ZONES)
{
m_zone[ m_zoneCount ].m_center = entity->pev->origin;
m_zone[ m_zoneCount ].m_isLegacy = true;
m_zone[ m_zoneCount ].m_index = m_zoneCount;
m_zone[ m_zoneCount ].m_entity = entity;
++m_zoneCount;
}
else
CONSOLE_ECHO("Warning: Too many zones, some will be ignored.\n");
}
}
// Collect nav areas that overlap each zone
for (i = 0; i < m_zoneCount; i++)
{
Zone *zone = &m_zone[i];
if (zone->m_isLegacy)
{
const float legacyRange = 256.0f;
zone->m_extent.lo.x = zone->m_center.x - legacyRange;
zone->m_extent.lo.y = zone->m_center.y - legacyRange;
zone->m_extent.lo.z = zone->m_center.z - legacyRange;
zone->m_extent.hi.x = zone->m_center.x + legacyRange;
zone->m_extent.hi.y = zone->m_center.y + legacyRange;
zone->m_extent.hi.z = zone->m_center.z + legacyRange;
}
else
{
zone->m_extent.lo = zone->m_entity->pev->absmin;
zone->m_extent.hi = zone->m_entity->pev->absmax;
}
// ensure Z overlap
const float zFudge = 50.0f;
zone->m_areaCount = 0;
zone->m_extent.lo.z -= zFudge;
zone->m_extent.hi.z += zFudge;
// build a list of nav areas that overlap this zone
for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter)
{
CNavArea *area = (*iter);
const Extent *areaExtent = area->GetExtent();
if (areaExtent->hi.x >= zone->m_extent.lo.x && areaExtent->lo.x <= zone->m_extent.hi.x
&& areaExtent->hi.y >= zone->m_extent.lo.y && areaExtent->lo.y <= zone->m_extent.hi.y
&& areaExtent->hi.z >= zone->m_extent.lo.z && areaExtent->lo.z <= zone->m_extent.hi.z)
{
// area overlaps zone
zone->m_area[ zone->m_areaCount++ ] = area;
if (zone->m_areaCount == MAX_ZONE_NAV_AREAS)
{
break;
}
}
}
}
}