本文整理汇总了C++中MoverPtr::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ MoverPtr::getPosition方法的具体用法?C++ MoverPtr::getPosition怎么用?C++ MoverPtr::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoverPtr
的用法示例。
在下文中一共展示了MoverPtr::getPosition方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: markRadiusSeenToTeams
void Team::markRadiusSeenToTeams(Stuff::Vector3D& location, float radius, bool shrinkForNight)
{
if(radius < 0.0)
radius = fireVisualRange;
if(shrinkForNight)
radius -= (radius * 0.25f);
bool didTeam[MAX_TEAMS] = {false, false, false, false, false, false, false, false};
for(size_t i = 0; i < ObjectManager->getNumMovers(); i++)
{
MoverPtr mover = ObjectManager->getMover(i);
if(mover->getTeam() && !didTeam[mover->getTeamId()] && !isFriendly(mover->getTeam()))
{
Stuff::Vector3D result;
result.x = location.x - mover->getPosition().x;
result.y = location.y - mover->getPosition().y;
result.z = 0.0;
float dist = result.GetLength() * metersPerWorldUnit;
if(dist < maxVisualRange)
{
markRadiusSeen(location, radius);
didTeam[mover->getTeamId()] = true;
}
}
}
}
示例2: getContacts
long TeamSensorSystem::getContacts (GameObjectPtr looker, long* contactList, long contactCriteria, long sortType) {
if ((sortType != CONTACT_SORT_NONE) && !looker)
return(0);
static float sortValues[MAX_CONTACTS_PER_SENSOR];
float CV = 0;
long numValidContacts = 0;
long handleList[MAX_CONTACTS_PER_SENSOR];
for (long i = 0; i < numContacts; i++) {
MoverPtr mover = (MoverPtr)ObjectManager->get(contacts[i]);
if (!meetsCriteria(looker, mover, contactCriteria))
continue;
handleList[numValidContacts] = mover->getHandle();
switch (sortType) {
case CONTACT_SORT_NONE:
sortValues[numValidContacts] = 0.0;
break;
case CONTACT_SORT_CV:
CV = (float)mover->getCurCV();
sortValues[numValidContacts] = CV;
break;
case CONTACT_SORT_DISTANCE:
sortValues[numValidContacts] = looker->distanceFrom(mover->getPosition());
break;
}
numValidContacts++;
}
if ((numValidContacts > 0) && (sortType != CONTACT_SORT_NONE)) {
//---------------------------------------------------------
// BIG ASSUMPTION HERE: That a mech will not have more than
// MAX_CONTACTS_PER_SENSOR contacts.
if (!SensorSystem::sortList) {
SensorSystem::sortList = new SortList;
if (!SensorSystem::sortList)
Fatal(0, " Unable to create Contact sortList ");
SensorSystem::sortList->init(MAX_CONTACTS_PER_SENSOR);
}
bool descendSort = true;
if (sortType == CONTACT_SORT_DISTANCE)
descendSort = false;
SensorSystem::sortList->clear(descendSort);
for (long contact = 0; contact < numValidContacts; contact++) {
SensorSystem::sortList->setId(contact, handleList[contact]);
SensorSystem::sortList->setValue(contact, sortValues[contact]);
}
SensorSystem::sortList->sort(descendSort);
for (contact = 0; contact < numValidContacts; contact++)
contactList[contact] = SensorSystem::sortList->getId(contact);
}
else if (contactList)
for (long contact = 0; contact < numValidContacts; contact++)
contactList[contact] = handleList[contact];
return(numValidContacts);
}
示例3: activate
//---------------------------------------------------------------------------
int32_t GameCamera::activate(void)
{
//------------------------------------------
// If camera is already active, just return
if (ready && active)
return (NO_ERROR);
//---------------------------------------------------------
// Camera always starts pointing at first mover in lists
// CANNOT be infinite because we don't allow missions without at least 1
// player mech!!
MoverPtr firstMover = nullptr;
if (ObjectManager->getNumMovers() > 0)
{
int32_t i = 0;
firstMover = ObjectManager->getMover(i);
while (firstMover &&
((firstMover->getCommander()->getId() != Commander::home->getId()) ||
!firstMover->isOnGUI()))
{
i++;
if (i == ObjectManager->getNumMovers())
break;
firstMover = ObjectManager->getMover(i);
}
}
if (firstMover)
{
Stuff::Vector3D newPosition(firstMover->getPosition());
setPosition(newPosition);
}
if (land)
{
land->update();
}
allNormal();
// updateDaylight(true);
lastShadowLightPitch = lightPitch;
// Startup the SKYBox
int32_t appearanceType = (GENERIC_APPR_TYPE << 24);
AppearanceTypePtr genericAppearanceType = nullptr;
genericAppearanceType = appearanceTypeList->getAppearance(appearanceType, "skybox");
if (!genericAppearanceType)
{
char msg[1024];
sprintf(msg, "No Generic Appearance Named %s", "skybox");
Fatal(0, msg);
}
theSky = new GenericAppearance;
gosASSERT(theSky != nullptr);
//--------------------------------------------------------------
gosASSERT(genericAppearanceType->getAppearanceClass() == GENERIC_APPR_TYPE);
theSky->init((GenericAppearanceType*)genericAppearanceType, nullptr);
theSky->setSkyNumber(mission->theSkyNumber);
return NO_ERROR;
}
示例4:
Stuff::Vector3D Team::calcEscapeVector(MoverPtr mover, float threatRange)
{
static float distance[100];
static Stuff::Vector3D delta[100];
Stuff::Vector3D escapeVector;
escapeVector.Zero();
//------------------------------
// Get the initial delta info...
int32_t shortest = 0;
int32_t longest = 0;
for(size_t i = 0; i < rosterSize; i++)
{
GameObjectPtr obj = ObjectManager->getByWatchID(roster[i]);
if(obj)
{
float distanceToObj = mover->distanceFrom(obj->getPosition());
if(distanceToObj <= threatRange)
{
delta[i].Subtract(mover->getPosition(), obj->getPosition());
distance[i] = distanceToObj;
if(distance[i] > longest)
longest = i;
if(distance[i] < shortest)
shortest = i;
}
else
distance[i] = -999.0;
}
else
distance[i] = -999.0;
}
//-----------------------------------------------------------------
// Now, find the furthest enemy and scale the deltas accordingly...
for(i = 0; i < rosterSize; i++)
if(distance[i] >= 0.0)
{
float scale = distance[longest] / distance[i];
delta[i] *= scale;
escapeVector += delta[i];
}
//--------------------------------------------------------------------------------
// We don't care about the length, just the direction (we assume you want to go as
// FAR as necessary)...
escapeVector.Normalize(escapeVector);
return(escapeVector);
}
示例5: calcContactStatus
long SensorSystem::calcContactStatus (MoverPtr mover) {
if (!owner->getTeam())
return(CONTACT_NONE);
if (mover->getFlag(OBJECT_FLAG_REMOVED)) {
return(CONTACT_NONE);
}
//----------------------------------------------------------
//If object we are looking for is at the edge, NO CONTACT!!
if (!Terrain::IsGameSelectTerrainPosition(mover->getPosition()))
return CONTACT_NONE;
//-------------------------------------------------------------
// Should be properly set when active probes are implemented...
long newContactStatus = CONTACT_NONE;
if (!notShutdown || (range == 0.0) && !broken)
{
if (owner->lineOfSight(mover) && !mover->isDisabled())
newContactStatus = CONTACT_VISUAL;
return(newContactStatus);
}
if ((masterIndex == -1) || (range < 0.0)) {
return(CONTACT_NONE);
}
if (owner->isMover()) {
MoverPtr mover = (MoverPtr)owner;
if ((mover->sensor == 255) || mover->inventory[mover->sensor].disabled || broken) {
return(CONTACT_NONE);
}
}
if (mover->getFlag(OBJECT_FLAG_SENSOR) && !mover->isDisabled())
{
bool moverNotContact = mover->hasNullSignature() || (mover->getEcmRange() != 0.0f);
bool moverInvisible = (mover->getStatus() == OBJECT_STATUS_SHUTDOWN);
if (!moverInvisible && !moverNotContact)
{
float distanceToMover = owner->distanceFrom(mover->getPosition());
float sensorRange = getEffectiveRange();
if (distanceToMover <= sensorRange)
{
//-------------------------------------------
//No need to check shutdown and probe AGAIN!
newContactStatus = getSensorQuality();
//---------------------------------------
// If ecm affecting me, my skill drops...
// CUT, per Mitch 2/10/00
if ((ecmEffect < 1.0) && (newContactStatus > CONTACT_SENSOR_QUALITY_1))
newContactStatus--;
//---------------------------------------------------
// We now we are within sensor range, check visual.
float startRadius = 0.0f;
if (!owner->isMover())
startRadius = owner->getAppearRadius();
if (hasLOSCapability && owner->lineOfSight(mover,startRadius))
newContactStatus = CONTACT_VISUAL;
}
else //Still need to check if visual!!! ECM and Lookout Towers!!
{
float startRadius = 0.0f;
if (!owner->isMover())
startRadius = owner->getAppearRadius();
if (hasLOSCapability && owner->lineOfSight(mover,startRadius))
newContactStatus = CONTACT_VISUAL;
}
}
else
{
//Target is shutdown, can ONLY be visual cause this platform has no probe.
float startRadius = 0.0f;
if (!owner->isMover())
startRadius = owner->getAppearRadius();
if (hasLOSCapability && owner->lineOfSight(mover,startRadius))
newContactStatus = CONTACT_VISUAL;
}
}
//Let us know that we can see something, sensor or otherwise!!
if (mover->getTeam() && (owner->getTeam() == Team::home) && mover->getTeam()->isEnemy(Team::home) &&
(newContactStatus != CONTACT_NONE))
{
SensorSystemManager::enemyInLOS = true;
}
return(newContactStatus);
}
示例6: render
//.........这里部分代码省略.........
if ( pSensor->owner->getTeam()->isNeutral( Team::home ) )
{
colorBlip = pSensor->owner->getSelected() ? 0xff4c4cff : 0xff0000ff;
colorRing = 0xff0000ff;
}
else if ( pSensor->owner->getTeam()->isEnemy( Team::home ) ) // enemy
{
{
colorBlip = pSensor->owner->getSelected() ? 0xffff3f3f : 0xffff0000;
colorRing = 0xffff0000;
}
}
if ( objClass != BATTLEMECH && objClass != GROUNDVEHICLE)
{
if ( objClass == ARTILLERY )
{
// blink
s_lastBlinkTime += g_deltaTime;
if ( s_lastBlinkTime > s_blinkLength )
{
colorBlip = 0;
colorRing = 0;
s_lastBlinkTime = 0.f;
}
}
colors[count] = colorBlip;
ringColors[count] = colorRing;
ranges[count] = pSensor->getRange();
selected[count] = 0;
positions[count] = pSensor->owner->getPosition();
count++;
}
}
}
}
unsigned long colorBlip, colorRing;
//-----------------------------------------------------
// draw the movers
for (i=0;i<(ObjectManager->numMovers);i++)
{
MoverPtr mover = ObjectManager->getMover(i);
if (mover && mover->getExists() && !(mover->isDestroyed() || mover->isDisabled()))
{
SensorSystem* pSensor = mover->getSensorSystem();
float range = pSensor ? pSensor->getRange() : 0;
long contactStatus = mover->getContactStatus(Team::home->getId(), true);
if (mover->getTeamId() == Team::home->id)
{
if (mover->getCommanderId() == Commander::home->getId())
{
if (mover->isOnGUI())
{
colorBlip = mover->getSelected() ? 0xff4bff4b : 0xff00cc00;
mover->getStatus() == OBJECT_STATUS_SHUTDOWN ? colorRing = 0 : colorRing = 0xff00cc00;
}
else
continue;
}
else
示例7: teamLineOfSight
//---------------------------------------------------------------------------
bool Team::teamLineOfSight(Stuff::Vector3D tPos, float extRad)
{
//-----------------------------------------------------------
// For each member of the team, check LOS to point provided.
for(size_t i = 0; i < rosterSize; i++)
{
MoverPtr obj = (MoverPtr)ObjectManager->getByWatchID(roster[i]);
if(!obj->isDisabled() && !obj->isDestroyed() && (obj->getStatus() != OBJECT_STATUS_SHUTDOWN))
{
Stuff::Vector3D distance;
distance.Subtract(tPos, obj->getPosition());
float dist = distance.GetApproximateLength();
//Figure out altitude above minimum terrain altitude and look up in table.
float baseElevation = MapData::waterDepth;
if(MapData::waterDepth < Terrain::userMin)
baseElevation = Terrain::userMin;
float altitude = obj->getPosition().z - baseElevation;
float altitudeIntegerRange = (Terrain::userMax - baseElevation) * 0.00390625f;
int32_t altLevel = 0;
if(altitudeIntegerRange > Stuff::SMALL)
altLevel = altitude / altitudeIntegerRange;
if(altLevel < 0)
altLevel = 0;
if(altLevel > 255)
altLevel = 255;
float radius = visualRangeTable[altLevel];
//Scouting specialty skill.
if(obj->isMover())
{
MoverPtr mover = (MoverPtr)obj;
if(mover->pilot && mover->pilot->isScout())
radius += (radius * 0.2f);
radius *= mover->getLOSFactor();
}
if(dist <= (radius * 25.0f * worldUnitsPerMeter))
{
if(lineOfSight(obj->getLOSPosition(), tPos, id, extRad, 0.0f, false))
return true;
}
}
}
//-------------------------------------------------------------------------
// Check the lookout towers now. You can find them in special Buildings!!
for(size_t spBuilding = 0; spBuilding < ObjectManager->numSpecialBuildings; spBuilding++)
{
if(ObjectManager->specialBuildings[spBuilding] &&
ObjectManager->specialBuildings[spBuilding]->getExists() &&
ObjectManager->specialBuildings[spBuilding]->isLookoutTower() &&
(ObjectManager->specialBuildings[spBuilding]->getTeamId() == id))
{
GameObjectPtr obj = ObjectManager->specialBuildings[spBuilding];
if(!obj->isDisabled() && !obj->isDestroyed() && (obj->getStatus() != OBJECT_STATUS_SHUTDOWN))
{
Stuff::Vector3D distance;
distance.Subtract(tPos, obj->getPosition());
float dist = distance.GetApproximateLength();
//Figure out altitude above minimum terrain altitude and look up in table.
float baseElevation = MapData::waterDepth;
if(MapData::waterDepth < Terrain::userMin)
baseElevation = Terrain::userMin;
float altitude = obj->getPosition().z - baseElevation;
float altitudeIntegerRange = (Terrain::userMax - baseElevation) * 0.00390625f;
int32_t altLevel = 0;
if(altitudeIntegerRange > Stuff::SMALL)
altLevel = altitude / altitudeIntegerRange;
if(altLevel < 0)
altLevel = 0;
if(altLevel > 255)
altLevel = 255;
float radius = visualRangeTable[altLevel];
//Scouting specialty skill.
if(obj->isMover())
{
MoverPtr mover = (MoverPtr)obj;
if(mover->pilot && mover->pilot->isScout())
radius += (radius * 0.2f);
radius *= mover->getLOSFactor();
}
if(dist <= (radius * 25.0f * worldUnitsPerMeter))
{
if(lineOfSight(obj->getLOSPosition(), tPos, id, 0.0f, obj->getAppearRadius(), false))
return true;
}
}
}
}
return false;
}