예제 #1
0
bool PxSingleActor::onNewDataBlock( GameBaseData *dptr )
{
   // Since onNewDataBlock is actually called before onAdd for client objects
   // we need to initialize this here.
   mWorld = dynamic_cast<PxWorld*>( gPhysicsPlugin->getWorld( isServerObject() ? "server" : "client" ) );
   if ( !mWorld )
      return false;

   mDataBlock = dynamic_cast<PxSingleActorData*>(dptr);

   if ( !mDataBlock || !Parent::onNewDataBlock( dptr ) )
      return false;

   if ( isClientObject() )
   {
      if ( mShapeInstance )   
         SAFE_DELETE(mShapeInstance);      
      mShapeInstance = new TSShapeInstance( mDataBlock->shape, isClientObject() );
   }

   mObjBox = mDataBlock->shape->bounds;
   resetWorldBox();

   // Create the actor.
   _createActor(); 

   // Must be called by the leaf class (of GameBase) once everything is loaded.
   scriptOnNewDataBlock();

   return true;
}
예제 #2
0
bool HoverVehicle::onNewDataBlock(GameBaseData* dptr, bool reload)
{
    mDataBlock = dynamic_cast<HoverVehicleData*>(dptr);
    if (!mDataBlock || !Parent::onNewDataBlock(dptr,reload))
        return false;

    if (isGhost())
    {
        // Create the sounds ahead of time.  This reduces runtime
        // costs and makes the system easier to understand.

        SFX_DELETE( mEngineSound );
        SFX_DELETE( mFloatSound );
        SFX_DELETE( mJetSound );

        if ( mDataBlock->sound[HoverVehicleData::EngineSound] )
            mEngineSound = SFX->createSource( mDataBlock->sound[HoverVehicleData::EngineSound], &getTransform() );

        if ( !mDataBlock->sound[HoverVehicleData::FloatSound] )
            mFloatSound = SFX->createSource( mDataBlock->sound[HoverVehicleData::FloatSound], &getTransform() );

        if ( mDataBlock->sound[HoverVehicleData::JetSound] )
            mJetSound = SFX->createSource( mDataBlock->sound[HoverVehicleData::JetSound], &getTransform() );
    }

    // Todo: Uncomment if this is a "leaf" class
    scriptOnNewDataBlock();

    return true;
}
bool MissionMarker::onNewDataBlock( GameBaseData *dptr, bool reload )
{
   mDataBlock = dynamic_cast<MissionMarkerData*>( dptr );
   if ( !mDataBlock || !Parent::onNewDataBlock( dptr, reload ) )
      return(false);
   scriptOnNewDataBlock();
   return(true);
}
예제 #4
0
bool ProximityMine::onNewDataBlock( GameBaseData* dptr, bool reload )
{
   mDataBlock = dynamic_cast<ProximityMineData*>( dptr );
   if ( !mDataBlock || !Parent::onNewDataBlock( dptr, reload ) )
      return false;

   scriptOnNewDataBlock();
   return true;
}
bool StaticShape::onNewDataBlock(GameBaseData* dptr, bool reload)
{
   mDataBlock = dynamic_cast<StaticShapeData*>(dptr);
   if (!mDataBlock || !Parent::onNewDataBlock(dptr, reload))
      return false;

   scriptOnNewDataBlock();
   return true;
}
예제 #6
0
bool Lightning::onNewDataBlock( GameBaseData *dptr, bool reload )
{
   mDataBlock = dynamic_cast<LightningData*>( dptr );
   if ( !mDataBlock || !Parent::onNewDataBlock( dptr, reload ) )
      return false;

   scriptOnNewDataBlock();
   return true;
}
예제 #7
0
//-----------------------------------------------------------------------------
// onNewDataBlock
//-----------------------------------------------------------------------------
bool ParticleEmitterNode::onNewDataBlock( GameBaseData *dptr, bool reload )
{
   mDataBlock = dynamic_cast<ParticleEmitterNodeData*>( dptr );
   if ( !mDataBlock || !Parent::onNewDataBlock( dptr, reload ) )
      return false;

   // Todo: Uncomment if this is a "leaf" class
   scriptOnNewDataBlock();
   return true;
}
예제 #8
0
bool SoftBody::onNewDataBlock(GameBaseData* dptr, bool reload)
{
	mDataBlock = dynamic_cast<SoftBodyData*>(dptr);
	if (!mDataBlock || !Parent::onNewDataBlock(dptr, reload))
		return false;

	// Update Rigid Info
	scriptOnNewDataBlock();

	return true;
}
예제 #9
0
파일: item.cpp 프로젝트: Bloodknight/GMK
bool Item::onNewDataBlock( GameBaseData *dptr, bool reload )
{
   mDataBlock = dynamic_cast<ItemData*>(dptr);
   if (!mDataBlock || !Parent::onNewDataBlock(dptr,reload))
      return false;

   if (!mSubclassItemHandlesScene)
      scriptOnNewDataBlock();

   if ( isProperlyAdded() )
      _updatePhysics();

   return true;
}
예제 #10
0
bool AITurretShape::onNewDataBlock(GameBaseData* dptr, bool reload)
{
   mDataBlock = dynamic_cast<AITurretShapeData*>(dptr);
   if (!mDataBlock || !Parent::onNewDataBlock(dptr, reload))
      return false;

   mScanHeading = mDegToRad(mDataBlock->maxScanHeading);
   if (mIsZero(mScanHeading))
      mScanHeading = M_PI_F;
   mScanPitch = mDegToRad(mDataBlock->maxScanPitch);
   if (mIsZero(mScanPitch))
      mScanPitch = M_PI_F;

   mScanDistance = mDataBlock->maxScanDistance;
   mScanDistanceSquared = mScanDistance * mScanDistance;

   mWeaponRangeSquared = mDataBlock->maxWeaponRange * mDataBlock->maxWeaponRange;
   mWeaponLeadVelocitySquared = (mDataBlock->weaponLeadVelocity > 0) ? (mDataBlock->weaponLeadVelocity * mDataBlock->weaponLeadVelocity) : 0;

   // The scan box is built such that the scanning origin is at (0,0,0) and the scanning distance
   // is out along the y axis.  When this is transformed to the turret's location is provides a
   // scanning volume in front of the turret.
   F32 scanX = mScanDistance*mSin(mScanHeading);
   F32 scanY = mScanDistance;
   F32 scanZ = mScanDistance*mSin(mScanPitch);
   mScanBox.set(-scanX, 0, -scanZ, scanX, scanY, scanZ);

   mScanTickFrequency = mDataBlock->scanTickFrequency;
   if (mScanTickFrequency < 1)
      mScanTickFrequency = 1;

   mScanTickFrequencyVariance = mDataBlock->scanTickFrequencyVariance;
   if (mScanTickFrequencyVariance < 0)
      mScanTickFrequencyVariance = 0;

   mTicksToNextScan = mScanTickFrequency;

   // For states
   mStateAnimThread = 0;
   if (mDataBlock->isAnimated)
   {
      mStateAnimThread = mShapeInstance->addThread();
      mShapeInstance->setTimeScale(mStateAnimThread,0);
   }

   scriptOnNewDataBlock();
   return true;
}
예제 #11
0
bool FlyingVehicle::onNewDataBlock(GameBaseData* dptr, bool reload)
{
   mDataBlock = dynamic_cast<FlyingVehicleData*>(dptr);
   if (!mDataBlock || !Parent::onNewDataBlock(dptr,reload))
      return false;

   // Sounds
   if ( isGhost() ) 
   {
      // Create the sounds ahead of time.  This reduces runtime
      // costs and makes the system easier to understand.

      SFX_DELETE( mJetSound );
      SFX_DELETE( mEngineSound );

      if ( mDataBlock->sound[FlyingVehicleData::EngineSound] )
         mEngineSound = SFX->createSource( mDataBlock->sound[FlyingVehicleData::EngineSound], &getTransform() );

      if ( mDataBlock->sound[FlyingVehicleData::JetSound] )
         mJetSound = SFX->createSource( mDataBlock->sound[FlyingVehicleData::JetSound], &getTransform() );
   }

   // Jet Sequences
   for (S32 i = 0; i < JetAnimCount; i++) {
      TSShape const* shape = mShapeInstance->getShape();
      mJetSeq[i] = shape->findSequence(sJetSequence[i]);
      if (mJetSeq[i] != -1) {
         if (i == BackActivate || i == BottomActivate) {
            mJetThread[i] = mShapeInstance->addThread();
            mShapeInstance->setSequence(mJetThread[i],mJetSeq[i],0);
            mShapeInstance->setTimeScale(mJetThread[i],0);
         }
      }
      else
         mJetThread[i] = 0;
   }

   scriptOnNewDataBlock();
   return true;
}
예제 #12
0
bool TurretShape::onNewDataBlock(GameBaseData* dptr, bool reload)
{
   mDataBlock = dynamic_cast<TurretShapeData*>(dptr);
   if (!mDataBlock || !Parent::onNewDataBlock(dptr, reload))
      return false;

   // Mark these nodes for control by code only (will not animate in a sequence)
   if (mDataBlock->headingNode != -1)
      mShapeInstance->setNodeAnimationState(mDataBlock->headingNode, TSShapeInstance::MaskNodeHandsOff);
   if (mDataBlock->pitchNode != -1)
      mShapeInstance->setNodeAnimationState(mDataBlock->pitchNode, TSShapeInstance::MaskNodeHandsOff);
   for (U32 i=0; i<TurretShapeData::NumMirrorDirectionNodes; ++i)
   {
      if (mDataBlock->pitchNodes[i] != -1)
      {
         mShapeInstance->setNodeAnimationState(mDataBlock->pitchNodes[i], TSShapeInstance::MaskNodeHandsOff);
      }

      if (mDataBlock->headingNodes[i] != -1)
      {
         mShapeInstance->setNodeAnimationState(mDataBlock->headingNodes[i], TSShapeInstance::MaskNodeHandsOff);
      }
   }

   if (mIsZero(mDataBlock->pitchRate))
   {
      mPitchAllowed = false;
   }
   else
   {
      mPitchAllowed = true;
      if (mDataBlock->pitchRate > 0)
      {
         mPitchRate = mDegToRad(mDataBlock->pitchRate);
      }
      else
      {
         mPitchRate = -1;
      }
   }

   if (mIsZero(mDataBlock->headingRate))
   {
      mHeadingAllowed = false;
   }
   else
   {
      mHeadingAllowed = true;
      if (mDataBlock->headingRate > 0)
      {
         mHeadingRate = mDegToRad(mDataBlock->headingRate);
      }
      else
      {
         mHeadingRate = -1;
      }
   }

   mPitchUp = -mDegToRad(mDataBlock->maxPitch);
   mPitchDown = mDegToRad(mDataBlock->minPitch);
   mHeadingMax = mDegToRad(mDataBlock->maxHeading);

   // Create Recoil thread if any recoil sequences are specified.
   // Note that the server player does not play this animation.
   mRecoilThread = 0;
   if (isGhost())
      for (U32 s = 0; s < TurretShapeData::NumRecoilSequences; s++)
         if (mDataBlock->recoilSequence[s] != -1) {
            mRecoilThread = mShapeInstance->addThread();
            mShapeInstance->setSequence(mRecoilThread, mDataBlock->recoilSequence[s], 0);
            mShapeInstance->setTimeScale(mRecoilThread, 0);
            break;
         }

   // Reset the image state driven animation thread.  This will be properly built
   // in onImageStateAnimation() when needed.
   mImageStateThread = 0;

   // Optional rotation threads.  These only play on the client.
   mPitchThread = 0;
   mHeadingThread = 0;
   if (isGhost())
   {
      if (mDataBlock->pitchSequence != -1)
      {
         mPitchThread = mShapeInstance->addThread();
         mShapeInstance->setSequence(mPitchThread, mDataBlock->pitchSequence, 0);
         mShapeInstance->setTimeScale(mPitchThread, 0);
      }
      if (mDataBlock->headingSequence != -1)
      {
         mHeadingThread = mShapeInstance->addThread();
         mShapeInstance->setSequence(mHeadingThread, mDataBlock->headingSequence, 0);
         mShapeInstance->setTimeScale(mHeadingThread, 0);
      }
   }

   if (!mSubclassTurretShapeHandlesScene)
   {
      scriptOnNewDataBlock();
   }

   return true;
}