本文整理汇总了C++中SimGroup::addObject方法的典型用法代码示例。如果您正苦于以下问题:C++ SimGroup::addObject方法的具体用法?C++ SimGroup::addObject怎么用?C++ SimGroup::addObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimGroup
的用法示例。
在下文中一共展示了SimGroup::addObject方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: spawnObject
SimObject* SpawnSphere::spawnObject(String additionalProps)
{
SimObject* spawnObject = Sim::spawnObject(mSpawnClass, mSpawnDataBlock, mSpawnName,
mSpawnProperties + " " + additionalProps, mSpawnScript);
// If we have a spawnObject add it to the MissionCleanup group
if (spawnObject)
{
if (mSpawnTransform)
{
if(SceneObject *s = dynamic_cast<SceneObject*>(spawnObject))
s->setTransform(getTransform());
}
SimObject* cleanup = Sim::findObject("MissionCleanup");
if (cleanup)
{
SimGroup* missionCleanup = dynamic_cast<SimGroup*>(cleanup);
missionCleanup->addObject(spawnObject);
}
}
return spawnObject;
}
示例2: deepClone
SimGroup* SimGroup::deepClone()
{
// Clone the group object.
SimObject* object = Parent::deepClone();
SimGroup* group = dynamic_cast< SimGroup* >( object );
if( !group )
{
object->deleteObject();
return NULL;
}
// Clone all child objects.
for( iterator iter = begin(); iter != end(); ++ iter )
group->addObject( ( *iter )->deepClone() );
return group;
}
示例3: createInteriorVolume
void MissionLighting::createInteriorVolume()
{
VolumeRWStream vol;
// create the volume
_assert( vol.createVolume( volumeFile.c_str() ), "Failed to create volume: %s\n",
volumeFile.c_str() );
SimGroup * group = NULL;
// go through and see if the volume has been added alredy
for( int i = 0; i < m_volumes.size(); i++ )
{
if( ( m_volumes[i]->getName() ) && ( !stricmp( m_volumes[i]->getName(), lightVolName ) ) )
{
// remove the volume
print( V_LOW, "Removing MissionLighting volume.\n" );
group = m_volumes[i]->getGroup();
if( group )
group->removeObject( m_volumes[i] );
}
}
print( V_MEDIUM, "Adding SimVolume to mission ( %s )\n",
volumeFile.c_str() );
// add to the mission in the volumes group
SimVolume * simVolume = new SimVolume;
manager->addObject( simVolume, lightVolName );
simVolume->open( stripPath( volumeFile.c_str() ) );
// try and place in a volumes group
if( !group )
{
group = dynamic_cast<SimGroup*>( mission->findObject( "Volumes" ) );
if( !group )
group = mission;
}
group->addObject( simVolume, lightVolName );
}
示例4: pos
static const char *c_spawnPlayer(CMDConsole *, int, int argc, const char **argv)
{
if(!sg.playerManager || !sg.manager || argc != 4)
return "-1";
Point3F pos(0, 0, 0), rot(0, 0, 0);
sscanf( argv[2], "%f %f %f", &pos.x, &pos.y, &pos.z);
sscanf( argv[3], "%f %f %f", &rot.x, &rot.y, &rot.z);
Player *player = new Player();
player->setInitInfo(argv[1], pos, rot);
if(!sg.manager->registerObject(player))
{
delete player;
return "-1";
}
SimGroup *cleanupGroup = (SimGroup *) sg.manager->findObject("MissionCleanup");
if(cleanupGroup)
cleanupGroup->addObject(player);
return intToStr(player->getId());
}
示例5: screenPos
//.........这里部分代码省略.........
mMode = mAddNodeMode;
mSelNode = mSelRoad->insertNode( tPos, mDefaultWidth, mAddNodeIdx );
mIsDirty = true;
return;
}
else if ( clickedNodeIdx == clickedRoadPtr->mNodes.size() - 1 )
{
setSelectedRoad( clickedRoadPtr );
setSelectedNode( clickedNodeIdx );
mAddNodeIdx = U32_MAX;
mMode = mAddNodeMode;
mSelNode = mSelRoad->addNode( tPos, mDefaultWidth );
mIsDirty = true;
setSelectedNode( mSelNode );
return;
}
}
DecalRoad *newRoad = new DecalRoad;
newRoad->mMaterialName = mMaterialName;
newRoad->registerObject();
// Add to MissionGroup
SimGroup *missionGroup;
if ( !Sim::findObject( "MissionGroup", missionGroup ) )
Con::errorf( "GuiDecalRoadEditorCtrl - could not find MissionGroup to add new DecalRoad" );
else
missionGroup->addObject( newRoad );
newRoad->insertNode( tPos, mDefaultWidth, 0 );
U32 newNode = newRoad->insertNode( tPos, mDefaultWidth, 1 );
// Always add to the end of the road, the first node is the start.
mAddNodeIdx = U32_MAX;
setSelectedRoad( newRoad );
setSelectedNode( newNode );
mMode = mAddNodeMode;
// Disable the hover node while in addNodeMode, we
// don't want some random node enlarged.
mHoverNode = -1;
// Grab the mission editor undo manager.
UndoManager *undoMan = NULL;
if ( !Sim::findObject( "EUndoManager", undoMan ) )
{
Con::errorf( "GuiRoadEditorCtrl::on3DMouseDown() - EUndoManager not found!" );
return;
}
// Create the UndoAction.
MECreateUndoAction *action = new MECreateUndoAction("Create Road");
action->addObject( newRoad );
// Submit it.
undoMan->addAction( action );
//send a callback to script after were done here if one exists
示例6: AIManager
const char * AIPlugin::consoleCallback(CMDConsole*,int id,int argc,const char *argv[])
{
const char * returnTxt = 0;
HandleCmdFunc listableCommand = 0;
if( (aim = AIManager::it) == NULL )
{
if( sg.manager )
{
SimGroup * cleanupGroup = (SimGroup *) sg.manager->findObject(missionCleanup);
if( cleanupGroup == NULL ){
console->printf( "No cleanup group yet, can't install AI manager and, "
"therefore, cannot execute command %s", argv[0] );
return returnTxt;
}
aim = new AIManager();
AssertFatal( aim, "ai: couldn't new() the AIManager." );
if( ! sg.manager->registerObject(aim) ){
delete aim;
aim = 0;
console->printf( "Couldn't register AI manager... "
"Cannot execute command %s", argv[0] );
return returnTxt;
}
else{//success
sg.manager->assignId(aim,AIManagerId);
cleanupGroup->addObject(aim);
}
}
else{
console->printf("No server manager yet, can't install AI manager thus, "
"cannot execute command %s.", argv[0] );
return returnTxt;
}
}
switch( id )
{
onCommand(SpawnAI); // create an AI.
onCommand(List); // list all AIs in manager.
onCommand(GetAICount); // return list size.
onCommand(GetId); // return rep Id.
onCommand(GetTarget); // return rep Id.
onCommand(FetchObject); // return SimObjectId
onListableCommand(AttackPlayer);
onListableCommand(DeleteAI);
onListableCommand(CallWithId);
onListableCommand(SetVariable);
onListableCommand(FollowDirective); // follow the specified player
onListableCommand(WaypointDirective); // add waypoint to list
onListableCommand(TargetDirective); // add Target (player rep Id) to list.
onListableCommand(TargetDirectiveLaser); // Use Laser as target (Pt Ok).
onListableCommand(TargetDirectivePoint); // Fire at given Point.
//onListableCommand(GuardDirective); // guard this point or player.
onListableCommand(RemoveDirective); // remove using order number.
onListableCommand(ListDirectives);
onListableCommand(DirectiveCallback1);
onListableCommand(DirectiveCallback2);
onListableCommand(DirectiveCallback3);
onListableCommand(DirectiveCallback4);
onListableCommand(CallbackDied);
onListableCommand(CallbackPeriodic);
onListableCommand(SetAutomaticTargets);
onListableCommand(SetSciptedTargets);
# if INCLUDE_AI_GRAPH_CODE
onCommand(GraphAddNode);
onCommand(GraphNodeCount);
onCommand(GraphLoadNode);
onCommand(GraphPrintNode);
# endif
}
if( aim )
{
if( listableCommand )
{
if( argc > 1 )
{
// Execute command an all AIs which match the name spec.
AIManager::iterator itr;
for( itr = aim->begin(); itr != aim->end(); itr++ )
if( (*itr)->nameMatches( argv[1] ) )
returnTxt = (this->*listableCommand)( *itr, argc-2, argv+2 );
}
else
{
// Just give help:
returnTxt = (this->*listableCommand)( NULL, 0, 0 );
}
}
}
//.........这里部分代码省略.........
示例7: pos
const char * AIPlugin::onSpawnAI(int argc, const char **argv)
{
if ( argc < 4 )
{
console->printf(
"AI::spawn: <AI name> <armor type> <position> [rotation] [display name] [voice]");
console->printf( "Create an AI of the given name and armor type at position." );
console->printf( "If not given, display name is the same as the AI name." );
console->printf( "Voice defaults to male1 if not supplied here." );
return falseTxt;
}
if( !sg.playerManager || !sg.manager )
{
console->printf("Requisite manager(s) not found.");
return falseTxt;
}
SimGroup * cleanupGroup = (SimGroup *) sg.manager->findObject(missionCleanup);
AssertFatal( cleanupGroup, "ai: should know there's a cleanup group by the time." );
if( getAI( argv[1] ) != NULL )
{
console->printf("An AI named %s already exists!", argv[1] );
return falseTxt;
}
const char * displayName = NULL;
const char * voice = stringTable.insert("male1");
Point3F pos(0, 0, 0), rot(0, 0, 0);
sscanf( argv[3], scan3fTxt, &pos.x, &pos.y, &pos.z);
if( argc > 4 ){
sscanf( argv[4], scan3fTxt, &rot.x, &rot.y, &rot.z);
if( argc > 5 ){
displayName = argv[5];
if( argc > 6 ){
voice = stringTable.insert( argv[6] );
}
}
}
Player * player = new Player();
player->setInitInfo( argv[2], pos, rot );
player->setAIControlled(true);
player->assignName( displayName ? displayName : argv[1] );
if(!sg.manager->registerObject(player))
return falseTxt;
// GameBase method, sets map name.
player->setName( displayName ? displayName : argv[1] );
AIObj * ai = new AIObj();
strncpy ( ai->name, argv[1], AIObj::MaxNameLen );
ai->player = player;
ai->voice = voice;
if( !sg.manager->registerObject(ai))
{
player->deleteObject();
return falseTxt;
}
ai->deleteNotify ( player );
aim->deleteNotify ( ai );
aim->push_back( ai );
ai->addVariables( console );
cleanupGroup->addObject(ai->player);
cleanupGroup->addObject(ai);
return trueTxt;
}
示例8: if
//.........这里部分代码省略.........
setSelectedNode( clickedNodeIdx );
mAddNodeIdx = U32_MAX;
mMode = mAddNodeMode;
mSelNode = mSelRiver->addNode( tPos, mDefaultWidth, mDefaultDepth, mDefaultNormal);
mIsDirty = true;
setSelectedNode( mSelNode );
return;
}
}
if ( !isMethod( "createRiver" ) )
{
Con::errorf( "GuiRiverEditorCtrl::on3DMouseDown - createRiver method does not exist." );
return;
}
const char *res = Con::executef( this, "createRiver" );
River *newRiver;
if ( !Sim::findObject( res, newRiver ) )
{
Con::errorf( "GuiRiverEditorCtrl::on3DMouseDown - createRiver method did not return a river object." );
return;
}
// Add to MissionGroup
SimGroup *missionGroup;
if ( !Sim::findObject( "MissionGroup", missionGroup ) )
Con::errorf( "GuiRiverEditorCtrl - could not find MissionGroup to add new River" );
else
missionGroup->addObject( newRiver );
Point3F pos( endPnt );
pos.z += mDefaultDepth * 0.5f;
newRiver->insertNode( pos, mDefaultWidth, mDefaultDepth, mDefaultNormal, 0 );
U32 newNode = newRiver->insertNode( pos, mDefaultWidth, mDefaultDepth, mDefaultNormal, 1 );
// Always add to the end of the road, the first node is the start.
mAddNodeIdx = U32_MAX;
setSelectedRiver( newRiver );
setSelectedNode( newNode );
mMode = mAddNodeMode;
// Disable the hover node while in addNodeMode, we
// don't want some random node enlarged.
mHoverNode = -1;
// Grab the mission editor undo manager.
UndoManager *undoMan = NULL;
if ( !Sim::findObject( "EUndoManager", undoMan ) )
{
Con::errorf( "GuiMeshRoadEditorCtrl::on3DMouseDown() - EUndoManager not found!" );
return;
}
// Create the UndoAction.
MECreateUndoAction *action = new MECreateUndoAction("Create MeshRoad");
action->addObject( newRiver );
// Submit it.
示例9: shoot
//.........这里部分代码省略.........
// be set...
//
float myFov = (fov / 2.0) * data->targetableFovRatio;
float compCos = cos(myFov);
if (compCos > 0.996f) // hack for single precision math. It's very
compCos = 0.996; // hard to get more precise answers from the dot prod.
if (pClosest != NULL && closestVal > compCos)
bullet->setTarget(pClosest);
}
}
if (data->maxGunEnergy)
{
float e;
e = energy > data->maxGunEnergy ? data->maxGunEnergy : energy;
float pofm = e / float(data->maxGunEnergy);
bullet->setEnergy (e, pofm);
energy -= e;
setEnergy (energy);
}
SimGroup *grp = NULL;
if(SimObject *obj = manager->findObject("MissionCleanup"))
grp = dynamic_cast<SimGroup*>(obj);
if(!manager->registerObject(bullet))
delete bullet;
else
{
if(grp)
grp->addObject(bullet);
else
manager->addObject(bullet);
}
waitTime = manager->getCurrentTime() + data->reloadDelay;
if (animThread)
{
setFireThread ();
animThread->SetPosition (0.0);
}
fireCount++;
setMaskBits (ShootingMask);
}
}
} else {
if (data && data->projectile.type == -1) {
if (!isGhost())
if (const char* script = scriptName("onFire"))
Console->executef(2, script, scriptThis());
}
else {
float energy = getEnergy();
if (waitTime <= manager->getCurrentTime() && data && energy >= data->minGunEnergy && data->projectile.type != -1) {
TMat3F muzzleTransform;
getMuzzleTransform(0, &muzzleTransform);
Projectile* bullet = createProjectile(data->projectile);
if (!playerControlled && data->deflection) {
static Random random;
EulerF angles;