Пример #1
0
bool
FlyingCamera::onAdd()
{
   // Check to make sure that the manager is connected to the server
   //  via loopback transport...
   //
   if (cg.packetStream == NULL)
      return false;
   if (cg.packetStream->getVC() != NULL) {
      if (dynamic_cast<DNet::LOOPTransport*>(cg.packetStream->getVC()->getTransport()) == NULL)
         return false;
   } else {
      if (cg.packetStream->getStreamMode() != Net::PacketStream::PlaybackMode)
         return false;
   }
   deleteNotify(cg.packetStream);
   watchPacketStream = cg.packetStream;

   SimContainer *root;

   if (Parent::onAdd() == false)
   {
      return (false);
   }

   root = findObject(manager, SimRootContainerId, root);
   root->addObject(this);

   return (true);
}
Пример #2
0
void playDelegate::preRender(void)
{
   if(!gameActive)
      return;

   // try to find a new palette to set in the game:
   if(!currentPalette)
   {
      SimGroup *group = (SimGroup *) manager->findObject("GhostGroup");
      if(group)
      {
         SimGroup::iterator i;
         for(i = group->begin(); i != group->end(); i++)
         {
            SimPalette *pal = dynamic_cast<SimPalette *>(*i);
            if(pal)
            {
               currentPalette = pal;
               deleteNotify(pal);
               hPal = pal->getPalette();
               pal->setInGame();
               break;
            }
         }  
      }
   }
}
Пример #3
0
void Trigger::potentialEnterObject(GameBase* enter)
{
   if( (!mDataBlock || mDataBlock->isClientSide) && isServerObject() )
      return;
   if( (mDataBlock && !mDataBlock->isClientSide) && isGhost() )
      return;

   for (U32 i = 0; i < mObjects.size(); i++) {
      if (mObjects[i] == enter)
         return;
   }

   if (testObject(enter) == true) {
      mObjects.push_back(enter);
      deleteNotify(enter);

      if(!mEnterCommand.isEmpty())
      {
         String command = String("%obj = ") + enter->getIdString() + ";" + mEnterCommand;
         Con::evaluate(command.c_str());
      }

      if( mDataBlock )
         mDataBlock->onEnterTrigger_callback( this, enter );
   }
}
Пример #4
0
void Item::setCollisionTimeout(ShapeBase* obj)
{
   if (mCollisionObject)
      clearNotify(mCollisionObject);
   deleteNotify(obj);
   mCollisionObject = obj;
   mCollisionTimeout = sCollisionTimeout;
   setMaskBits(ThrowSrcMask);
}
Пример #5
0
void SceneObject::onMount( SceneObject *obj, S32 node )
{   
   deleteNotify( obj );

   if ( !isGhost() ) 
   {      
      setMaskBits( MountedMask );      
      //onMount_callback( node );
   }
}
void ForestWindEmitter::attachToObject( SceneObject *obj )
{
   if ( !obj )
      return;

   mMountObject = obj;
   mIsMounted = true;

   if ( isServerObject() )
      deleteNotify( mMountObject );
}
void GhostManager::setScopeObject(SimNetObject *obj)
{
   if(obj == scopeObject)
      return;

   if(scopeObject)
      clearNotify(scopeObject);
   scopeObject = obj;
   if(scopeObject)
      deleteNotify(scopeObject);
}
Пример #8
0
void SimFire::finishAddToManager()
{
   if (onObj)
      deleteNotify(onObj);

   // don't know shape size yet, fake it for now
   bbox.fMin.set(-1,-1,-1);
   bbox.fMax.set(1,1,1);
   if (!faceCam && !followCam)
      image.transform.identity();
   Point3F & p = image.transform.p;
   image.transform.flags |= TMat3F::Matrix_HasTranslation; // will keep this flag setting
   getPosition(p);
   updateBBox(p);
   updateBox = false;
    fireHeight = 0;

   // set fire start and end time
   prevAnimTime = manager->getCurrentTime();
   fireOut += prevAnimTime;

   // set next smoke time
   if (producesSmoke)
      nextSmokeTime = smokeToSmoke*.5f + prevAnimTime;

   // add to timer set
   addToSet(SimTimerSetId);

   // add to container db so we get render query
   SimContainer *root = NULL;
   
   root = findObject(manager, SimRootContainerId,root);
   root->addObject(this);

   // start sound if there is one
   if (soundID != -1)
      hSound = Sfx::Manager::PlayAt( manager, soundID, TMat3F(EulerF(0, 0, 0), p), Point3F(0, 0, 0));
      
   // prepare the light
   if (lightRange > 0.0f && SimFire::DynamicLighting)
   {
      glow.setType(TS::Light::LightPoint);
      glow.setIntensity(lightColor);
      glow.setRange(lightRange);
      glow.setPosition(p);
      
      addToSet(SimLightSetId);
   }
}
Пример #9
0
void GameBase::onMount( SceneObject *obj, S32 node )
{      
   deleteNotify( obj );

   // Are we mounting to a GameBase object?
   GameBase *gbaseObj = dynamic_cast<GameBase*>( obj );

   if ( gbaseObj && gbaseObj->getControlObject() != this )
      processAfter( gbaseObj );

   if (!isGhost()) {
      setMaskBits(MountedMask);
      mDataBlock->onMount_callback( this, obj, node );
   }
}
Пример #10
0
void GuiControlProfile::setChildrenProfile(GuiControlProfile *prof)
{
   if(prof == mChildrenProfile)
      return;

   // Clear the delete notification we previously set up
   if (mChildrenProfile)
      clearNotify(mChildrenProfile);

   mChildrenProfile = prof;

   // Make sure that the new profile will notify us when it is deleted
   if (mChildrenProfile)
      deleteNotify(mChildrenProfile);
}
Пример #11
0
void SimSet::pushObject( SimObject* obj )
{
   if( obj == this )
      return;
      
   lock();
   
   bool added = objectList.pushBackForce( obj );
   if( added )
      deleteNotify( obj );
      
   unlock();

   if( added )
   {
      getSetModificationSignal().trigger( SetObjectAdded, this, obj );
      if( obj->isProperlyAdded() )
         onObjectAdded_callback( obj );
   }
}
Пример #12
0
void SimSet::addObject( SimObject* obj )
{
   // Prevent SimSet being added to itself.
   if( obj == this )
      return;
      
   lock();
   
   const bool added = objectList.pushBack( obj );
   if( added )
      deleteNotify( obj );
   
   unlock();

   if( added )
   {
      getSetModificationSignal().trigger( SetObjectAdded, this, obj );
      if( obj->isProperlyAdded() )
         onObjectAdded_callback( obj );
   }
}
Пример #13
0
bool afxEA_PhysicalZone::ea_update(F32 dt)
{
  if (!physical_zone)
  {
    // create and register effect
    physical_zone = new PhysicalZone();
    physical_zone->mVelocityMod = zone_data->mVelocityMod;
    physical_zone->mGravityMod = zone_data->mGravityMod;
    physical_zone->mAppliedForce = zone_data->mAppliedForce;
    physical_zone->force_type = zone_data->force_type;
    physical_zone->orient_force = zone_data->orient_force;
    physical_zone->setField("polyhedron", zone_data->mPolyhedron);

    if (!physical_zone->registerObject())
    {
      delete physical_zone;
      physical_zone = 0;
      Con::errorf("afxEA_PhysicalZone::ea_update() -- effect failed to register.");
      return false;
    }
    deleteNotify(physical_zone);
    physical_zone->activate();
  }

  if (physical_zone)
  {
    if (zone_data->exclude_cons_obj)
    {
      afxConstraint* pos_constraint = getPosConstraint();
      set_cons_object((pos_constraint) ? pos_constraint->getSceneObject() : 0);
    }

    if (do_fades)
      physical_zone->setFadeAmount(fade_value);
    physical_zone->setTransform(updated_xfm);
  }

  return true;
}
Пример #14
0
NotifyObject::NotifyObject(MainWindow *mainWin) : QObject(mainWin)
{
    this->mainWin = mainWin;

    // DBus interfaces

    QDBusConnection dbus = QDBusConnection::sessionBus();

    notifierBus = new DBusNotificationsIf(HD_NOTIFICATION_MANAGER_DBUS_NAME,
                                          HD_NOTIFICATION_MANAGER_DBUS_PATH,
                                          dbus,this);

    sndVibBus = new DBusNokiaHildonSVNDIf(HD_SV_NOTIFICATION_DAEMON_DBUS_NAME,
                                          HD_SV_NOTIFICATION_DAEMON_DBUS_PATH,
                                          dbus,this);

    connect(notifierBus,SIGNAL(ActionInvoked(uint,QString)),
            this,SLOT(notifyCallback(uint,QString)));

    connect(notifierBus,SIGNAL(NotificationClosed(uint,uint)),
            this,SLOT(deleteNotify(uint,uint)));
}
Пример #15
0
void Player::setMountObject (GameBase *object, int in_mountPoint)
{
   if(mount)
      clearNotify(mount);

   setMaskBits(MountMask);
   mount = object;
   mountPoint = in_mountPoint;
   if(mount)
		{
	      deleteNotify(mount);

		   TMat3F tmat;
			mount->getObjectMountTransform(mountPoint, &tmat);
			if (!mountPoint)
				{
					Point3F rot = getRot ();
					tmat.set (EulerF (rot.x, rot.y, rot.z), tmat.p);
				}
		   setTransform(tmat);
			EulerF angles;
			tmat.angles(&angles);
			if (mountPoint < 1)
				setRot (Point3F (0, 0, angles.z));
			else
				if (mountPoint == 1)
					setRot (Point3F (0, 0, 0));
				else
					{
						Point3F rot = getRot ();
						rot.z -= angles.z;
						setRot (rot);
					}

         setImageTriggerUp(0);

			setLinearVelocity (Point3F (0, 0, 0));
		}
}
//------------------------------------------------------------------------------
bool FGStandardComboBox::onAdd()
{
   if(!Parent::onAdd())
      return false;

   popUpCtrl = new FGStandardPopUp(this);
   AssertFatal(popUpCtrl, "could not allocate memory");
   manager->addObject(popUpCtrl);
   deleteNotify(popUpCtrl);
   
   //ensure the entries are sorted
   setSort(TRUE);
   
   //set the bmps
   char buf[256];
   sprintf(buf, "%s_DF.BMP", mBitmapRootName);
   mTitleBMP = SimResource::get(manager)->load(buf);
   sprintf(buf, "%s_BD.BMP", mBitmapRootName);
   mTitleGhostBMP = SimResource::get(manager)->load(buf);
   
   return true;
}  
Пример #17
0
void CompoundUndoAction::addAction( UndoAction *action )
{
   //AssertFatal( action->mUndoManager == NULL, "CompoundUndoAction::addAction, action already had an UndoManager." );
   mChildren.push_back( action );
   deleteNotify( action );
}
Пример #18
0
bool afxEA_ParticleEmitter::ea_start()
{
  if (!emitter_data)
  {
    Con::errorf("afxEA_ParticleEmitter::ea_start() -- missing or incompatible datablock.");
    return false;
  }

  do_runtime_substitutions();

#if defined(STOCK_TGE_PARTICLES)
  emitter = new ParticleEmitter();
  emitter->onNewDataBlock(emitter_data);
#else
   afxParticleEmitterData* afx_emitter_db = dynamic_cast<afxParticleEmitterData*>(emitter_data);
   if (afx_emitter_db)
   {
      if (dynamic_cast<afxParticleEmitterVectorData*>(emitter_data))
      {
         afxParticleEmitterVector* pe = new afxParticleEmitterVector();
         pe->onNewDataBlock(afx_emitter_db, false);
         pe->setAFXOwner(choreographer);
         emitter = pe;
      }
      else if (dynamic_cast<afxParticleEmitterConeData*>(emitter_data))
      {
         afxParticleEmitterCone* pe = new afxParticleEmitterCone();
         pe->onNewDataBlock(afx_emitter_db, false);
         pe->setAFXOwner(choreographer);
         emitter = pe;
      }
      else if (dynamic_cast<afxParticleEmitterPathData*>(emitter_data))
      {
         afxParticleEmitterPath* pe = new afxParticleEmitterPath();
         pe->onNewDataBlock(afx_emitter_db, false);
         pe->setAFXOwner(choreographer);
         emitter = pe;
      }
      else if (dynamic_cast<afxParticleEmitterDiscData*>(emitter_data))
      {
         afxParticleEmitterDisc* pe = new afxParticleEmitterDisc();
         pe->onNewDataBlock(afx_emitter_db, false);
         pe->setAFXOwner(choreographer);
         emitter = pe;
      }
   }
   else
   {
      emitter = new ParticleEmitter();
      emitter->onNewDataBlock(emitter_data, false);
   }
#endif

#if defined(AFX_CAP_PARTICLE_POOLS)
  // here we find or create any required particle-pools
  if (emitter_data->pool_datablock)
  { 
    afxParticlePool* pool = choreographer->findParticlePool(emitter_data->pool_datablock, emitter_data->pool_index);
    if (!pool)
    {
      afxParticlePoolData* pool_data = emitter_data->pool_datablock;
      if (pool_data->getSubstitutionCount() > 0)
      {
        // clone the datablock and perform substitutions
        afxParticlePoolData* orig_db = pool_data;
        pool_data = new afxParticlePoolData(*orig_db, true);
        orig_db->performSubstitutions(pool_data, choreographer, group_index);
      }

      pool = new afxParticlePool();
      pool->onNewDataBlock(pool_data, false);
      pool->setKeyBlock(emitter_data->pool_datablock, emitter_data->pool_index);
      if (!pool->registerObject())
      {
        Con::errorf("afxEA_ParticleEmitter::ea_start() -- Failed to register Particle Pool.");
        delete pool;
        pool = 0;
      }
      if (pool)
      {
        pool->setChoreographer(choreographer);
        choreographer->registerParticlePool(pool);
      }
    }
    if (pool)
      emitter->setPool(pool);
  }
#endif

  if (!emitter->registerObject())
  {
    delete emitter;
    emitter = NULL;
    Con::errorf("afxEA_ParticleEmitter::ea_start() -- effect failed to register.");
    return false;
  }

  if (datablock->forced_bbox.isValidBox())
  {
    do_bbox_update = true;
  }

  emitter->setSortPriority(datablock->sort_priority);
  deleteNotify(emitter);

  return true;
}
Пример #19
0
void Turret::shoot (bool playerControlled, Player* targetPlayer)
{
   if (data && data->isSustained == false) {
	   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;
	   					   muzzleTransform.angles (&angles);
	   						angles.x += (random.getFloat() - 0.5) * M_2PI * data->deflection;
	   						angles.z += (random.getFloat() - 0.5) * M_2PI * data->deflection;
	   						muzzleTransform.set (angles, muzzleTransform.p);
	   					}
	   				else
	   					if (playerControlled)
	   						{
	   							Point3F start = muzzleTransform.p;
	   							muzzleTransform = getEyeTransform ();
	   							aimedTransform (&muzzleTransform, start);
	   							muzzleTransform.p = start;
	   						}

	   				bullet->initProjectile (muzzleTransform, Point3F (0, 0, 0), getId());

	   	         if (bullet->isTargetable() == true) {
	   	            if (targetPlayer != NULL) {
	   						if (GameBase* mo = targetPlayer->getMountObject())
	   		               bullet->setTarget(static_cast<ShapeBase*>(mo));
	   						else
	   		               bullet->setTarget(targetPlayer);
                     } else if (playerControlled) {
                        ShapeBase* pClosest   = NULL;
                        Point3F    closeHisPos;
                        float      closestVal = -2.0f;
                        SimSet::iterator itr;
                     
                        Point3F lookDir;
                        getEyeTransform().getRow(1, &lookDir);
                        lookDir.normalize();

                        SimContainerQuery collisionQuery;
                        SimCollisionInfo  info;
                        collisionQuery.id     = getId();
                        collisionQuery.type   = -1;
                        collisionQuery.mask   = Projectile::csm_collisionMask;
                        collisionQuery.detail = SimContainerQuery::DefaultDetail;
                        collisionQuery.box.fMin = getEyeTransform().p;
                        SimContainer* pRoot = (SimContainer*)manager->findObject(SimRootContainerId);

                        SimSet* pSet = dynamic_cast<SimSet*>(manager->findObject(PlayerSetId));
                        AssertFatal(pSet != NULL, "No player set?");
                        for (itr = pSet->begin(); itr != pSet->end(); itr++) {
                           Player* pPlayer = dynamic_cast<Player*>(*itr);

                           if (!pPlayer || pPlayer->getVisibleToTeam(getTeam()) == false)
                              continue;

                           collisionQuery.box.fMax = pPlayer->getBoxCenter();
                           if (pRoot->findLOS(collisionQuery, &info, SimCollisionImageQuery::High) == true) {
                              if (info.object != (SimObject*)pPlayer)
                                 continue;
                           }

                           Point3F hisPos = pPlayer->getBoxCenter();
                           hisPos -= getLinearPosition();
                           hisPos.normalize();

                           float prod = m_dot(hisPos, lookDir);
                           if (prod > 0.0f && prod > closestVal) {
                              closestVal = prod;
                              pClosest   = pPlayer;
                              closeHisPos = hisPos;
                           }
                        }

                        pSet = dynamic_cast<SimSet*>(manager->findObject(MoveableSetId));
                        AssertFatal(pSet != NULL, "No moveable set?");
                        for (itr = pSet->begin(); itr != pSet->end(); itr++) {
                           if (((*itr)->getType() & VehicleObjectType) == 0)
                              continue;

                           ShapeBase* pObject = dynamic_cast<ShapeBase*>(*itr);
                           
                           if (pObject->getVisibleToTeam(getTeam()) == false)
                              continue;

                           collisionQuery.box.fMax = pObject->getBoxCenter();
                           if (pRoot->findLOS(collisionQuery, &info, SimCollisionImageQuery::High) == true) {
                              if (info.object != (SimObject*)pObject)
                                 continue;
                           }

                           Point3F hisPos = pObject->getBoxCenter();
                           hisPos -= getLinearPosition();
                           hisPos.normalize();

                           float prod = m_dot(hisPos, lookDir);
                           if (prod > 0.0f && prod > closestVal) {
                              closestVal = prod;
                              closeHisPos = hisPos;
                              pClosest   = pObject;
                           }
                        }

                        // We need to find the current FOV, and take the percentage of
                        //  it specified in the .dat file for this turret.  Only if the
                        //  do product is greater than this, do we allow the target to
                        //  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;
               muzzleTransform.angles (&angles);
               angles.x += (random.getFloat() - 0.5) * M_2PI * data->deflection;
               angles.z += (random.getFloat() - 0.5) * M_2PI * data->deflection;
               muzzleTransform.set (angles, muzzleTransform.p);
            } else if (playerControlled) {
               Point3F start = muzzleTransform.p;
               muzzleTransform = getEyeTransform ();
               aimedTransform (&muzzleTransform, start);
               muzzleTransform.p = start;
            }

            bullet->initProjectile (muzzleTransform, Point3F (0, 0, 0), getId());
            AssertFatal(bullet->isSustained() == true, "Error, must be sustained bullet");
            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);
            }

            if (animThread) {
               setFireThread ();
               animThread->SetPosition (0.0);
            }
            
            fireCount++;
            setMaskBits (ShootingMask);

            m_fireState  = Firing;
            m_beganState = wg->currentTime;

            m_pProjectile = bullet;
            m_pTarget     = targetPlayer;
            
            if (m_pTarget)
               deleteNotify(m_pTarget);
         }
      }
   }
}
Пример #20
0
void GhostManager::readPacket(BitStream *bstream, DWORD)
{
   bool ghostAlwaysMode = bstream->readFlag();

   int idSize;
   idSize = bstream->readInt( 3);
   idSize += 3;

   if(!ghostAlwaysMode && scopeAlwaysList.size())
      flushScopeAlwaysObjects();

   // while there's an object waiting...

   while(bstream->readFlag())
   {
      if(!allowGhosts)
      {
         // houston, we have a problem - a client is trying to make
         // ghosts on us - NOone tries to make ghosts on us.
         setLastError("Invalid packet.");
         return;
      }
      DWORD index;
      int startPos = bstream->getCurPos();
      index = (DWORD) bstream->readInt(idSize);

      if(bstream->readFlag()) // is this ghost being deleted?
         freeGhost(index);
      else
      {
         if(!ghostRefs[index].localGhost) // it's a new ghost... cool
         {
            DWORD tag;
            int oNumber;

            if(ghostAlwaysMode)
               oNumber = bstream->readInt(32);

            tag = (DWORD) bstream->readInt( 10);

            SimNetObject *obj = (SimNetObject *) Persistent::create(tag);
            if(!obj)
            {
               setLastError("Invalid packet.");
               return;
            }
            obj->netFlags.set(SimNetObject::IsGhost);

            // object gets initial update before adding to the manager

            obj->netIndex = index;
            ghostRefs[index].localGhost = obj;
            ghostRefs[index].localGhost->unpackUpdate(this, bstream);
            
            if(!cleanupGroup)
            {
               cleanupGroup = new SimGroup();
               manager->addObject(cleanupGroup, "GhostGroup");
            	deleteNotify(cleanupGroup);
            }
            if(ghostAlwaysMode)
            {
               scopeAlwaysList.push_back(AddListEntry(oNumber, obj));
            }
            else
            {
               if(!manager->registerObject(obj))
               {
                  if(!getLastError()[0])
                     setLastError("Invalid packet.");
                  return;
               }
               cleanupGroup->addObject(obj);
               if(obj->netFlags.test(SimNetObject::PolledGhost))
                  owner->getEventManager()->addPolledObject(obj);
            }
         }
         else
            ghostRefs[index].localGhost->unpackUpdate(this, bstream);

         PacketStream::getStats()->addBits(PacketStats::Receive, bstream->getCurPos() - startPos, ghostRefs[index].localGhost->getPersistTag());
#ifdef DEBUG_NET
         int checksum = bstream->readInt(32);
         AssertFatal( (checksum ^ DebugChecksum) == index,
            avar("unpackUpdate did not match packUpdate for object of class %s.",
               ghostRefs[index].localGhost->getClassName()) );          
#endif
         if(getLastError()[0])
            return;
      }
   }
   if(ghostAlwaysMode)
   {
      if(bstream->readFlag())
         flushScopeAlwaysObjects();
   }
}
bool afxEA_ZodiacPlane::ea_update(F32 dt)
{
  if (!pzode)
  {
    // create and register effect
    pzode = new afxZodiacPlane();
    pzode->onNewDataBlock(zode_data, false);
    if (!pzode->registerObject())
    {
      delete pzode;
      pzode = 0;
      Con::errorf("afxEA_ZodiacPlane::ea_update() -- effect failed to register.");
      return false;
    }
    deleteNotify(pzode);

    ///pzode->setSequenceRateFactor(datablock->rate_factor/prop_time_factor);
    ///pzode->setSortPriority(datablock->sort_priority);
  }

  if (pzode)
  {
    //ColorF zode_color = zode_data->color;
    ColorF zode_color = updated_color;

    if (live_color_factor > 0.0)
       zode_color.interpolate(zode_color, live_color, live_color_factor);

    if (do_fades)
    {
      if (zode_data->blend_flags == afxZodiacDefs::BLEND_SUBTRACTIVE)
        zode_color *= fade_value*live_fade_factor;
      else
        zode_color.alpha *= fade_value*live_fade_factor;
    }

    // scale and grow zode
    //F32 zode_radius = zode_data->radius_xy*updated_scale.x + life_elapsed*zode_data->growth_rate;
    F32 zode_radius = zode_data->radius_xy + life_elapsed*zode_data->growth_rate;

    // zode is growing
    if (life_elapsed < zode_data->grow_in_time)
    {
      F32 t = life_elapsed/zode_data->grow_in_time;
      zode_radius = afxEase::eq(t, 0.001f, zode_radius, 0.2f, 0.8f);
    }
    // zode is shrinking
    else if (full_lifetime - life_elapsed < zode_data->shrink_out_time)
    {
      F32 t = (full_lifetime - life_elapsed)/zode_data->shrink_out_time;
      zode_radius = afxEase::eq(t, 0.001f, zode_radius, 0.0f, 0.9f);
    }

    zode_radius *= live_scale_factor;

    if (zode_data->respect_ori_cons && !zode_data->use_full_xfm)
    {
      VectorF shape_vec;
      updated_xfm.getColumn(1, &shape_vec);
      shape_vec.normalize();

      F32 ang;

      switch (zode_data->face_dir)
      {
      case afxZodiacPlaneData::FACES_FORWARD:
      case afxZodiacPlaneData::FACES_BACK:
        ang = mAtan2(shape_vec.x, shape_vec.z);
        break;  
      case afxZodiacPlaneData::FACES_RIGHT:
      case afxZodiacPlaneData::FACES_LEFT:
        ang = mAtan2(shape_vec.y, shape_vec.z);
        break;  
      case afxZodiacPlaneData::FACES_UP:
      case afxZodiacPlaneData::FACES_DOWN:
      default:
        ang = mAtan2(shape_vec.x, shape_vec.y);
        break;  
      }

      if (ang < 0.0f)
        ang += M_2PI_F;

      switch (zode_data->face_dir)
      {
      case afxZodiacPlaneData::FACES_DOWN:
      case afxZodiacPlaneData::FACES_BACK:
      case afxZodiacPlaneData::FACES_LEFT:
        ang = -ang;
        break;  
      }

      zode_angle_offset = mRadToDeg(ang); 
    }

    F32 zode_angle = zode_data->calcRotationAngle(life_elapsed, datablock->rate_factor/prop_time_factor);
    zode_angle = mFmod(zode_angle + zode_angle_offset, 360.0f); 
    aa_rot.angle = mDegToRad(zode_angle);
    
    MatrixF spin_xfm; 
    aa_rot.setMatrix(&spin_xfm);

    // set color, radius
    pzode->setColor(zode_color);
    pzode->setRadius(zode_radius);
    if (zode_data->use_full_xfm)
    {
      updated_xfm.mul(spin_xfm);
      pzode->setTransform(updated_xfm);
    }
    else
      pzode->setTransform(spin_xfm);
    pzode->setPosition(updated_pos);
    pzode->setScale(updated_scale);
  }

  return true;
}
Пример #22
0
bool Projectile::onAdd()
{
   if(!Parent::onAdd())
      return false;

   if( !mDataBlock )
   {
      Con::errorf("Projectile::onAdd - Fail - Not datablock");
      return false;
   }

   if (isServerObject())
   {
      ShapeBase* ptr;
      if (Sim::findObject(mSourceObjectId, ptr))
      {
         mSourceObject = ptr;

         // Since we later do processAfter( mSourceObject ) we must clearProcessAfter
         // if it is deleted. SceneObject already handles this in onDeleteNotify so
         // all we need to do is register for the notification.
         deleteNotify( ptr );
      }
      else
      {
         if (mSourceObjectId != -1)
            Con::errorf(ConsoleLogEntry::General, "Projectile::onAdd: mSourceObjectId is invalid");
         mSourceObject = NULL;
      }

      // If we're on the server, we need to inherit some of our parent's velocity
      //
      mCurrTick = 0;
   }
   else
   {
      if (bool(mDataBlock->projectileShape))
      {
         mProjectileShape = new TSShapeInstance(mDataBlock->projectileShape, isClientObject());

         if (mDataBlock->activateSeq != -1)
         {
            mActivateThread = mProjectileShape->addThread();
            mProjectileShape->setTimeScale(mActivateThread, 1);
            mProjectileShape->setSequence(mActivateThread, mDataBlock->activateSeq, 0);
         }
      }
      if (mDataBlock->particleEmitter != NULL)
      {
         ParticleEmitter* pEmitter = new ParticleEmitter;
         pEmitter->onNewDataBlock(mDataBlock->particleEmitter,false);
         if (pEmitter->registerObject() == false)
         {
            Con::warnf(ConsoleLogEntry::General, "Could not register particle emitter for particle of class: %s", mDataBlock->getName());
            delete pEmitter;
            pEmitter = NULL;
         }
         mParticleEmitter = pEmitter;
      }

      if (mDataBlock->particleWaterEmitter != NULL)
      {
         ParticleEmitter* pEmitter = new ParticleEmitter;
         pEmitter->onNewDataBlock(mDataBlock->particleWaterEmitter,false);
         if (pEmitter->registerObject() == false)
         {
            Con::warnf(ConsoleLogEntry::General, "Could not register particle emitter for particle of class: %s", mDataBlock->getName());
            delete pEmitter;
            pEmitter = NULL;
         }
         mParticleWaterEmitter = pEmitter;
      }
   }
   if (mSourceObject.isValid())
      processAfter(mSourceObject);

   // Setup our bounding box
   if (bool(mDataBlock->projectileShape) == true)
      mObjBox = mDataBlock->projectileShape->bounds;
   else
      mObjBox = Box3F(Point3F(0, 0, 0), Point3F(0, 0, 0));

   MatrixF initialTransform( true );
   initialTransform.setPosition( mCurrPosition );
   setTransform( initialTransform );   // calls resetWorldBox

   addToScene();

   if ( PHYSICSMGR )
      mPhysicsWorld = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" );

   return true;
}