Ejemplo n.º 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;
}
Ejemplo n.º 2
0
bool SFXEmitter::onAdd()
{
   if ( !Parent::onAdd() )
      return false;

   if ( isServerObject() )
   {
      // Validate the data we'll be passing across
      // the network to the client.
      mDescription.validate();
   }
   else
   {
      _update();

      // Do we need to start playback?
      if ( mPlayOnAdd && mSource )
         mSource->play();
   }

   // Setup the bounds.
   mObjBox.maxExtents = mObjScale;
   mObjBox.minExtents = mObjScale;
   mObjBox.minExtents.neg();
   resetWorldBox();
   addToScene();

   return true;
}
Ejemplo n.º 3
0
bool GroundPlane::onAdd()
{
   if( !Parent::onAdd() )
      return false;

   if( isClientObject() )
      _updateMaterial();
      
   if( mSquareSize < sMIN_SQUARE_SIZE )
   {
      Con::errorf( "GroundPlane - squareSize below threshold; re-setting to %.02f", sMIN_SQUARE_SIZE );
      mSquareSize = sMIN_SQUARE_SIZE;
   }

   Parent::setScale( VectorF( 1.0f, 1.0f, 1.0f ) );
   Parent::setTransform( MatrixF::Identity );
   setGlobalBounds();
   resetWorldBox();

   addToScene();

   if ( PHYSICSMGR )
   {
      PhysicsCollision *colShape = PHYSICSMGR->createCollision();
      colShape->addPlane( PlaneF( Point3F::Zero, Point3F( 0, 0, 1 ) ) ); 

      PhysicsWorld *world = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" );
      mPhysicsRep = PHYSICSMGR->createBody();
      mPhysicsRep->init( colShape, 0, 0, this, world );
   }

   return true;
}
Ejemplo n.º 4
0
void NavPath::resize()
{
   if(!mPoints.size())
   {
      mObjBox.set(Point3F(-0.5f, -0.5f, -0.5f),
                  Point3F( 0.5f,  0.5f,  0.5f));
      resetWorldBox();
      setTransform(MatrixF(true));
      return;
   }

   Point3F max(mPoints[0]), min(mPoints[0]), pos(0.0f);
   for(U32 i = 1; i < mPoints.size(); i++)
   {
      Point3F p = mPoints[i];
      max.x = getMax(max.x, p.x);
      max.y = getMax(max.y, p.y);
      max.z = getMax(max.z, p.z);
      min.x = getMin(min.x, p.x);
      min.y = getMin(min.y, p.y);
      min.z = getMin(min.z, p.z);
      pos += p;
   }
   pos /= mPoints.size();
   min -= Point3F(0.5f, 0.5f, 0.5f);
   max += Point3F(0.5f, 0.5f, 0.5f);

   mObjBox.set(min - pos, max - pos);
   MatrixF mat = Parent::getTransform();
   mat.setPosition(pos);
   Parent::setTransform(mat);
}
Ejemplo n.º 5
0
   bool NavMesh::onAdd()
   {
      if(!Parent::onAdd())
         return false;

      mObjBox.set(Point3F(-1.0f, -1.0f, -1.0f),
         Point3F( 1.0f,  1.0f,  1.0f));
      resetWorldBox();

      addToScene();

      if(gEditingMission)
         mNetFlags.set(Ghostable);

      if(isServerObject())
      {
         mEventManager = new EventManager();
         if(!mEventManager->registerObject())
         {
            Con::errorf("Could not register EventManager for NavMesh %d!", getId());
            delete mEventManager;
         }
         else
         {
            mEventManager->setMessageQueue(mEventManager->getIdString());
            mEventManager->registerEvent("NavMeshLoad");
            mEventManager->registerEvent("NavMeshBuild");
         }
      }

      load();

      return true;
   }
Ejemplo n.º 6
0
AccumulationVolume::AccumulationVolume()
   : mTransformDirty( true ),
     mSilhouetteExtractor( mPolyhedron )
{
   VECTOR_SET_ASSOCIATION( mWSPoints );
   VECTOR_SET_ASSOCIATION( mVolumeQueryList );

   //mObjectFlags.set( VisualOccluderFlag );
   
   mNetFlags.set( Ghostable | ScopeAlways );
   mObjScale.set( 1.f, 1.f, 1.f );
   mObjBox.set(
      Point3F( -0.5f, -0.5f, -0.5f ),
      Point3F( 0.5f, 0.5f, 0.5f )
   );

   mObjToWorld.identity();
   mWorldToObj.identity();

   // Accumulation Texture.
   mTextureName = "";
   mAccuTexture = NULL;

   resetWorldBox();
}
Ejemplo n.º 7
0
void ConvexShape::updateBounds( bool recenter )
{
   if ( mGeometry.points.size() == 0 )
      return;

   Vector<Point3F> &pointListOS = mGeometry.points;
   U32 pointCount = pointListOS.size();

   Point3F volumnCenter( 0,0,0 );
   F32 areaSum = 0.0f;

   F32 faceCount = mGeometry.faces.size();

   for ( S32 i = 0; i < faceCount; i++ )   
   {
      volumnCenter += mGeometry.faces[i].centroid * mGeometry.faces[i].area;         
      areaSum += mGeometry.faces[i].area;
   }

   if ( areaSum == 0.0f )
      return;

   volumnCenter /= areaSum;
   
   mObjBox.minExtents = mObjBox.maxExtents = Point3F::Zero;
   mObjBox.setCenter( volumnCenter );

   for ( S32 i = 0; i < pointCount; i++ )      
      mObjBox.extend( pointListOS[i] );

   resetWorldBox();
}
Ejemplo n.º 8
0
bool VolumetricFog::onAdd()
{
	if (!Parent::onAdd())
		return false;

	if (!VFRTM->IsInitialized())
	{
		Con::errorf("No VolumetricFogRTManager present!!");
		return false;
	}

	resetWorldBox();

	mShapeLoaded = LoadShape();

	setRenderTransform(mObjToWorld);

	addToScene();
	ColBox.set(getTransform(), (mObjBox.getExtents() * getScale() * COLBOX_SCALE));
	mObjSize = mWorldBox.getGreatestDiagonalLength();
	mObjScale = getScale();
	mTexTiles = mAbs(mTexTiles);
	mSpeed.set(mSpeed1.x, mSpeed1.y, mSpeed2.x, mSpeed2.y);
	mInvScale = (1.0f / getMax(getMax(mObjScale.x, mObjScale.y), mObjScale.z));
	if (isClientObject())
	{
		InitTexture();
		return setupRenderer();
	}

	VFRTM->IncFogObjects();

	return true;
}
Ejemplo n.º 9
0
//-----------------------------------------------------------------------------
// onAdd
//-----------------------------------------------------------------------------
bool ParticleEmitterNode::onAdd()
{
   if( !Parent::onAdd() )
      return false;

   if( !mEmitterDatablock && mEmitterDatablockId != 0 )
   {
      if( Sim::findObject(mEmitterDatablockId, mEmitterDatablock) == false )
         Con::errorf(ConsoleLogEntry::General, "ParticleEmitterNode::onAdd: Invalid packet, bad datablockId(mEmitterDatablock): %d", mEmitterDatablockId);
   }

   if( isClientObject() )
   {
      setEmitterDataBlock( mEmitterDatablock );
   }
   else
   {
      setMaskBits( StateMask | EmitterDBMask );
   }

   mObjBox.minExtents.set(-0.5, -0.5, -0.5);
   mObjBox.maxExtents.set( 0.5,  0.5,  0.5);
   resetWorldBox();
   addToScene();

   return true;
}
Ejemplo n.º 10
0
bool SceneObject::onAdd()
{
   if ( !Parent::onAdd() )
      return false;

   mIsScopeAlways = mNetFlags.test( ScopeAlways );

   mWorldToObj = mObjToWorld;
   mWorldToObj.affineInverse();
   resetWorldBox();

   setRenderTransform(mObjToWorld);

   resolveMountPID();

   smSceneObjectAdd.trigger(this);

   //.logicking guidebot >>
   if (isServerObject())
	   createWorldObject();
   //.logicking guidebot <<
   return true;

   return true;
}
Ejemplo n.º 11
0
bool PathCamera::onAdd()
{
   if(!Parent::onAdd())
      return false;

   // Initialize from the current transform.
   if (!mNodeCount) {
      QuatF rot(getTransform());
      Point3F pos = getPosition();
      mSpline.removeAll();
      mSpline.push_back(new CameraSpline::Knot(pos,rot,1,
         CameraSpline::Knot::NORMAL, CameraSpline::Knot::SPLINE));
      mNodeCount = 1;
   }

   //
   mObjBox.maxExtents = mObjScale;
   mObjBox.minExtents = mObjScale;
   mObjBox.minExtents.neg();
   resetWorldBox();

   if (mShapeInstance)
   {
      mNetFlags.set(Ghostable);
      setScopeAlways();
   }

   addToScene();

   return true;
}
Ejemplo n.º 12
0
void SceneObject::setTransform( const MatrixF& mat )
{
   // This test is a bit expensive so turn it off in release.   
#ifdef TORQUE_DEBUG
   //AssertFatal( mat.isAffine(), "SceneObject::setTransform() - Bad transform (non affine)!" );
#endif

   PROFILE_SCOPE( SceneObject_setTransform );

   // Update the transforms.

   mObjToWorld = mWorldToObj = mat;
   mWorldToObj.affineInverse();

   // Update the world-space AABB.

   resetWorldBox();

   // If we're in a SceneManager, sync our scene state.

   if( mSceneManager != NULL )
      mSceneManager->notifyObjectDirty( this );

   setRenderTransform( mat );
}
Ejemplo n.º 13
0
bool TimeOfDay::onAdd()
{
   if ( !Parent::onAdd() )
      return false;
   
   // The server initializes to the specified starting values.
   // The client initializes itself to the server time from
   // unpackUpdate.
   if ( isServerObject() )
   {
      mTimeOfDay = mStartTimeOfDay;
   }

   // We don't use a bounds.
   setGlobalBounds();
   resetWorldBox();
   addToScene();

   // Lets receive ghost events so we can resolve
   // the sun object.
   if ( isClientObject() )
      NetConnection::smGhostAlwaysDone.notify( this, &TimeOfDay::_onGhostAlwaysDone );

   if ( isServerObject() )   
      Con::executef( this, "onAdd" );   

   return true;
}
Ejemplo n.º 14
0
bool ScatterSky::onAdd()
{
   PROFILE_SCOPE(ScatterSky_onAdd);

   // onNewDatablock for the server is called here
   // for the client it is called in unpackUpdate

   if ( !Parent::onAdd() )
      return false;

   if ( isClientObject() )
      TimeOfDay::getTimeOfDayUpdateSignal().notify( this, &ScatterSky::_updateTimeOfDay );

   setGlobalBounds();
   resetWorldBox();

   addToScene();

   if ( isClientObject() )
   {
      _initMoon();
      Sim::findObject( mNightCubemapName, mNightCubemap );
   }

   return true;
}
Ejemplo n.º 15
0
bool GroundPlane::onAdd()
{
   if( !Parent::onAdd() )
      return false;

   if( isClientObject() )
      _updateMaterial();
      
   if( mSquareSize < sMIN_SQUARE_SIZE )
   {
      Con::errorf( "GroundPlane - squareSize below threshold; re-setting to %.02f", sMIN_SQUARE_SIZE );
      mSquareSize = sMIN_SQUARE_SIZE;
   }

   setScale( VectorF( 1.0f, 1.0f, 1.0f ) );
   setGlobalBounds();
   resetWorldBox();

   addToScene();

   if( gPhysicsPlugin )
      mPhysicsRep = gPhysicsPlugin->createStatic( this );

   return true;
}
Ejemplo n.º 16
0
bool CloudLayer::onAdd()
{
   if ( !Parent::onAdd() )
      return false;

   setGlobalBounds();
   resetWorldBox();

   addToScene();

   if ( isClientObject() )
   {
      _initTexture();
      _initBuffers();

      // Find ShaderData
      ShaderData *shaderData;
      mShader = Sim::findObject( "CloudLayerShader", shaderData ) ? 
                  shaderData->getShader() : NULL;
      if ( !mShader )
      {
         Con::errorf( "CloudLayer::onAdd - could not find CloudLayerShader" );
         return false;
      }

      // Create ShaderConstBuffer and Handles
      mShaderConsts = mShader->allocConstBuffer();
      mModelViewProjSC = mShader->getShaderConstHandle( "$modelView" );
      mEyePosWorldSC = mShader->getShaderConstHandle( "$eyePosWorld" );
      mSunVecSC = mShader->getShaderConstHandle( "$sunVec" );
      mTexOffsetSC[0] = mShader->getShaderConstHandle( "$texOffset0" );
      mTexOffsetSC[1] = mShader->getShaderConstHandle( "$texOffset1" );
      mTexOffsetSC[2] = mShader->getShaderConstHandle( "$texOffset2" );
      mTexScaleSC = mShader->getShaderConstHandle( "$texScale" );
      mAmbientColorSC = mShader->getShaderConstHandle( "$ambientColor" );
      mSunColorSC = mShader->getShaderConstHandle( "$sunColor" );
      mCoverageSC = mShader->getShaderConstHandle( "$cloudCoverage" );
      mExposureSC = mShader->getShaderConstHandle( "$cloudExposure" );
      mBaseColorSC = mShader->getShaderConstHandle( "$cloudBaseColor" );
      mNormalHeightMapSC = mShader->getShaderConstHandle( "$normalHeightMap" );

      // Create StateBlocks
      GFXStateBlockDesc desc;
      desc.setCullMode( GFXCullNone );
      desc.setBlend( true );
      desc.setZReadWrite( false, false );
      desc.samplersDefined = true;
      desc.samplers[0].addressModeU = GFXAddressWrap;
      desc.samplers[0].addressModeV = GFXAddressWrap;
      desc.samplers[0].addressModeW = GFXAddressWrap;
      desc.samplers[0].magFilter = GFXTextureFilterLinear;
      desc.samplers[0].minFilter = GFXTextureFilterLinear;
      desc.samplers[0].mipFilter = GFXTextureFilterLinear;
      desc.samplers[0].textureColorOp = GFXTOPModulate;

      mStateblock = GFX->createStateBlock( desc );   
   }

   return true;
}
Ejemplo n.º 17
0
bool VolumetricFog::onAdd()
{
    if (!Parent::onAdd())
        return false;

    if (!VFRTM->IsInitialized())
    {
        Con::errorf("No VolumetricFogRTManager present!!");
        return false;
    }

    resetWorldBox();

    mShapeLoaded = LoadShape();

    setRenderTransform(mObjToWorld);

    addToScene();
    ColBox.set(getTransform(), (mObjBox.getExtents() * getScale() * COLBOX_SCALE));
    mObjSize = mWorldBox.getGreatestDiagonalLength();
    mObjScale = getScale();
    mTexTiles = mAbs(mTexTiles);
    mSpeed.set(mSpeed1.x, mSpeed1.y, mSpeed2.x, mSpeed2.y);
    mInvScale = (1.0f / getMax(getMax(mObjScale.x, mObjScale.y), mObjScale.z));

    if (isClientObject())
    {
        conn = GameConnection::getConnectionToServer();
        if (!conn)
        {
            Con::errorf("VolumetricFog::onAdd - No Serverconnection");
            return false;
        }

        glowFX = static_cast<PostEffect*>(Sim::findObject("VolFogGlowPostFx"));

        mOldLightRayStrength = Con::getFloatVariable("$LightRayPostFX::brightScalar",1.0f);

        GuiCanvas* cv = dynamic_cast<GuiCanvas*>(Sim::findObject("Canvas"));
        if (cv == NULL)
        {
            Con::errorf("VolumetricFog::onAdd - Canvas not found!!");
            return false;
        }
        mPlatformWindow = cv->getPlatformWindow();
        VolumetricFogRTManager::getVolumetricFogRTMResizeSignal().notify(this, &VolumetricFog::handleResize);
        GuiCanvas::getCanvasSizeChangeSignal().notify(this, &VolumetricFog::handleCanvasResize);

        InitTexture();
        return setupRenderer();
    }

    VFRTM->IncFogObjects();

    return true;
}
Ejemplo n.º 18
0
bool TSStatic::_createShape()
{
   // Cleanup before we create.
   mCollisionDetails.clear();
   mLOSDetails.clear();
   SAFE_DELETE( mPhysicsRep );
   SAFE_DELETE( mShapeInstance );
   mAmbientThread = NULL;
   mShape = NULL;

   if (!mShapeName || mShapeName[0] == '\0') 
   {
      Con::errorf( "TSStatic::_createShape() - No shape name!" );
      return false;
   }

   mShapeHash = _StringTable::hashString(mShapeName);

   mShape = ResourceManager::get().load(mShapeName);
   if ( bool(mShape) == false )
   {
      Con::errorf( "TSStatic::_createShape() - Unable to load shape: %s", mShapeName );
      return false;
   }

   if (  isClientObject() && 
         !mShape->preloadMaterialList(mShape.getPath()) && 
         NetConnection::filesWereDownloaded() )
      return false;

   mObjBox = mShape->bounds;
   resetWorldBox();

   mShapeInstance = new TSShapeInstance( mShape, isClientObject() );

   if( isGhost() )
   {
      // Reapply the current skin
      mAppliedSkinName = "";
      reSkin();
   }

   prepCollision();

   // Find the "ambient" animation if it exists
   S32 ambientSeq = mShape->findSequence("ambient");

   if ( ambientSeq > -1 && !mAmbientThread )
      mAmbientThread = mShapeInstance->addThread();

   if ( mAmbientThread )
      mShapeInstance->setSequence( mAmbientThread, ambientSeq, 0);

   return true;
}
Ejemplo n.º 19
0
void PxCloth::_updateStaticCloth()
{
   // Setup the unsimulated world bounds.
   mObjBox.set(   0, mThickness * -0.5f, 0, 
                  mPatchSize.x, mThickness * 0.5f, mPatchSize.y );
   resetWorldBox();

   // If we don't have render buffers then we're done.
   if ( !mVertexRenderBuffer || !mIndexRenderBuffer )
      return;

   // Make sure the VBs are updated.
   mIsVBDirty = true;

   F32 patchWidth = mPatchSize.x / (F32)(mPatchVerts.x-1);
   F32 patchHeight = mPatchSize.y / (F32)(mPatchVerts.y-1);

   Point3F normal( 0, 1, 0 );
   getTransform().mulV( normal );

   GFXVertexPNTT *vert = mVertexRenderBuffer;

   for (U32 y = 0; y < mPatchVerts.y; y++) 
   {        
      for (U32 x = 0; x < mPatchVerts.x; x++) 
      {            
         vert->point.set( patchWidth * x, 0.0f, patchHeight * y );
         getTransform().mulP( vert->point );
         vert->normal = normal;
         vert++;
      }
   }

   U16 *index = mIndexRenderBuffer;
   mNumIndices = (mPatchVerts.x-1) * (mPatchVerts.y-1) * 6;
   U16 yOffset = mPatchVerts.x;

   for (U32 y = 0; y < mPatchVerts.y-1; y++) 
   {   
      for (U32 x = 0; x < mPatchVerts.x-1; x++) 
      {       
         U16 base = x + ( yOffset * y );

         index[0] = base;
         index[1] = base + 1;
         index[2] = base + 1 + yOffset;

         index[3] = base + 1 + yOffset;
         index[4] = base + yOffset;
         index[5] = base;

         index += 6;
      }
   }
}
SceneRootZone::SceneRootZone()
{
   setGlobalBounds();
   resetWorldBox();

   // Clear netflags we have inherited.  We don't
   // network scene roots.
   mNetFlags.clear( Ghostable | ScopeAlways );

   // Clear type flags we have inherited.
   mTypeMask &= ~StaticObjectType;
}
Ejemplo n.º 21
0
void ForestWindEmitter::unpackUpdate(NetConnection * con, BitStream * stream)
{
   // Unpack Parent.
   Parent::unpackUpdate( con, stream );

   MatrixF xfm;
   mathRead( *stream, &xfm );
   Parent::setTransform( xfm );

   U32 windMask = 0;

   if ( stream->readFlag() ) // EnabledMask
      mEnabled = stream->readFlag();

   if ( stream->readFlag() ) // WindMask
   {
      stream->read( &mWindStrength );
      stream->read( &mWindRadius );
      
      mRadialEmitter = stream->readFlag();

      stream->read( &mWindGustStrength );
      stream->read( &mWindGustFrequency );
      
      stream->read( &mWindGustYawAngle );
      stream->read( &mWindGustYawFrequency );
      stream->read( &mWindGustWobbleStrength );

      stream->read( &mWindTurbulenceStrength );
      stream->read( &mWindTurbulenceFrequency );

      stream->readNormalVector( &mWindDirection, 8 );
      windMask |= WindMask;

      mHasMount = stream->readFlag();
   }

   // This does nothing if the masks are not set!
   if ( windMask != 0 && isProperlyAdded() )
   {
      Point3F boxRad( 0, 0, 0 );

      if ( !isRadialEmitter() )
         boxRad.set( 10000.0f, 10000.0f, 10000.0f );
      else
         boxRad.set( mWindRadius, mWindRadius, mWindRadius ); 
         
      mObjBox.set( -boxRad, boxRad );
      resetWorldBox();
      
      _initWind( windMask );
   }
}
Ejemplo n.º 22
0
bool BasicClouds::onAdd()
{
   if ( !Parent::onAdd() )
      return false;

   setGlobalBounds();
   resetWorldBox();

   addToScene();

   if ( isClientObject() )
   {
      _initTexture();
      _initBuffers();

      // Find ShaderData
      ShaderData *shaderData;
      mShader = Sim::findObject( "BasicCloudsShader", shaderData ) ? shaderData->getShader() : NULL;
      if ( !mShader )
      {
         Con::errorf( "BasicClouds::onAdd - could not find BasicCloudsShader" );
         return false;
      }

      // Create ShaderConstBuffer and Handles
      mShaderConsts = mShader->allocConstBuffer();
      mModelViewProjSC = mShader->getShaderConstHandle( "$modelView" );
      mTimeSC = mShader->getShaderConstHandle( "$accumTime" );
      mTexScaleSC = mShader->getShaderConstHandle( "$texScale" );
      mTexDirectionSC = mShader->getShaderConstHandle( "$texDirection" );
      mTexOffsetSC = mShader->getShaderConstHandle( "$texOffset" );
      mDiffuseMapSC = mShader->getShaderConstHandle( "$diffuseMap" );

      // Create StateBlocks
      GFXStateBlockDesc desc;
      desc.setCullMode( GFXCullNone );
      desc.setBlend( true );
      desc.setZReadWrite( false, false );
      desc.samplersDefined = true;
      desc.samplers[0].addressModeU = GFXAddressWrap;
      desc.samplers[0].addressModeV = GFXAddressWrap;
      desc.samplers[0].addressModeW = GFXAddressWrap;
      desc.samplers[0].magFilter = GFXTextureFilterLinear;
      desc.samplers[0].minFilter = GFXTextureFilterLinear;
      desc.samplers[0].mipFilter = GFXTextureFilterLinear;
      desc.samplers[0].textureColorOp = GFXTOPModulate;
      
      mStateblock = GFX->createStateBlock( desc );      
   }

   return true;
}
Ejemplo n.º 23
0
//--------------------------------------------------------------------------
// OnAdd
//--------------------------------------------------------------------------
bool Splash::onAdd()
{
   // first check if we have a server connection, if we dont then this is on the server
   //  and we should exit, then check if the parent fails to add the object
   NetConnection* conn = NetConnection::getConnectionToServer();
   if(!conn || !Parent::onAdd())
      return false;

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

   mDelayMS = mDataBlock->delayMS + sgRandom.randI( -mDataBlock->delayVariance, mDataBlock->delayVariance );
   mEndingMS = mDataBlock->lifetimeMS + sgRandom.randI( -mDataBlock->lifetimeVariance, mDataBlock->lifetimeVariance );

   mVelocity = mDataBlock->velocity;
   mHeight = mDataBlock->height;
   mTimeSinceLastRing = 1.0 / mDataBlock->ejectionFreq;

   for( U32 i=0; i<SplashData::NUM_EMITTERS; i++ )
   {
      if( mDataBlock->emitterList[i] != NULL )
      {
         ParticleEmitter * pEmitter = new ParticleEmitter;
         pEmitter->onNewDataBlock( mDataBlock->emitterList[i], false );
         if( !pEmitter->registerObject() )
         {
            Con::warnf( ConsoleLogEntry::General, "Could not register emitter for particle of class: %s", mDataBlock->getName() );
            delete pEmitter;
            pEmitter = NULL;
         }
         mEmitterList[i] = pEmitter;
      }
   }

   spawnExplosion();

   mObjBox.minExtents = Point3F( -1, -1, -1 );
   mObjBox.maxExtents = Point3F(  1,  1,  1 );
   resetWorldBox();

   gClientSceneGraph->addObjectToScene(this);

   removeFromProcessList();
   ClientProcessList::get()->addObject(this);

   conn->addObject(this);

   return true;
}
Ejemplo n.º 24
0
//--------------------------------------------------------------------------
bool Lightning::onAdd()
{
   if(!Parent::onAdd())
      return false;

   mObjBox.minExtents.set( -0.5f, -0.5f, -0.5f );
   mObjBox.maxExtents.set(  0.5f,  0.5f,  0.5f );

   resetWorldBox();
   addToScene();

   return true;
}
Ejemplo n.º 25
0
bool WaterPlane::onAdd()
{
   if ( !Parent::onAdd() )
      return false;
   
   setGlobalBounds();
   resetWorldBox();
   addToScene();

   mWaterFogData.plane.set( 0, 0, 1, -getPosition().z );

   return true;
}
Ejemplo n.º 26
0
bool Forest::onAdd()
{
   if (!Parent::onAdd())
      return false;

   const char *name = getName();
   if(name && name[0] && getClassRep())
   {
      Namespace *parent = getClassRep()->getNameSpace();
      Con::linkNamespaces(parent->mName, name);
      mNameSpace = Con::lookupNamespace(name);
   }

   setGlobalBounds();
   resetWorldBox();

   // TODO: Make sure this calls the script "onAdd" which will
   // populate the object with forest entries before creation.
   addToScene();

   // If we don't have a file name and the editor is 
   // enabled then create an empty forest data file.
   if ( isServerObject() && ( !mDataFileName || !mDataFileName[0] ) )
      createNewFile();
   else
   {
      // Try to load the forest file.
      mData = ResourceManager::get().load( mDataFileName );
      if ( !mData )
      {
         if ( isClientObject() )
            NetConnection::setLastError( "You are missing a file needed to play this mission: %s", mDataFileName );

         return false;
      }
   }

   updateCollision();

   smCreatedSignal.trigger( this );

   if ( isClientObject() )
   {
      mZoningDirty = true;
      SceneZoneSpaceManager::getZoningChangedSignal().notify( this, &Forest::_onZoningChanged );

      ForestWindMgr::getAdvanceSignal().notify( this, &Forest::getLocalWindTrees );
   }

   return true;
}
Ejemplo n.º 27
0
void GroundPlane::inspectPostApply()
{
   Parent::inspectPostApply();
   setMaskBits( UpdateMask );

   if( mSquareSize < sMIN_SQUARE_SIZE )
   {
      Con::errorf( "GroundPlane - squareSize below threshold; re-setting to %.02f", sMIN_SQUARE_SIZE );
      mSquareSize = sMIN_SQUARE_SIZE;
   }

   setScale( VectorF( 1.0f, 1.0f, 1.0f ) );
   resetWorldBox();
}
Ejemplo n.º 28
0
void GroundPlane::setTransform( const MatrixF &mat )
{
   Parent::setTransform( mat );

   // Parent::setTransforms ends up setting our worldBox to something other than
   // global, so we have to set it back... but we can't actually call setGlobalBounds
   // again because it does extra work adding and removing us from the container.

   mGlobalBounds = true;
   mObjBox.minExtents.set(-1e10, -1e10, -1e10);
   mObjBox.maxExtents.set( 1e10,  1e10,  1e10);
   resetWorldBox();

   mPlaneBox = getPlaneBox();
}
Ejemplo n.º 29
0
void PxCloth::processTick( const Move *move )
{
   // Make sure the cloth is created.
   if ( !mCloth )
      return;

   // TODO: Remove this hack!
   const bool enableWind = Con::getBoolVariable( "$PxCloth::enableWind", false );

   if ( enableWind )
   {
      NxVec3 windVec(   25.0f + NxMath::rand(-5.0f, 5.0f),
			                     NxMath::rand(-5.0f, 5.0f),
			                     NxMath::rand(-5.0f, 5.0f) );

      mCloth->setWindAcceleration( windVec );

      // Wake the cloth!
      mCloth->wakeUp();
   }
   else
      mCloth->setWindAcceleration( NxVec3( 0, 0, 0 ) );

   // Update bounds.
   if ( mWorld->getEnabled() )
   {
      NxBounds3 box;
      mCloth->getWorldBounds( box ); 

      Point3F min = pxCast<Point3F>( box.min );
      Point3F max = pxCast<Point3F>( box.max );

      mWorldBox.set( min, max );
      mObjBox = mWorldBox;

      getWorldTransform().mul( mObjBox );
   }
   else
   {
      mObjBox.set(   0, mThickness * -0.5f, 0, 
                     mPatchSize.x, mThickness * 0.5f, mPatchSize.y );
   }

   resetWorldBox();

   // Update the VB on the next render.
   mIsVBDirty = true;
}
Ejemplo n.º 30
0
bool RenderObjectExample::onAdd()
{
   if ( !Parent::onAdd() )
      return false;

   // Set up a 1x1x1 bounding box
   mObjBox.set( Point3F( -0.5f, -0.5f, -0.5f ),
                Point3F(  0.5f,  0.5f,  0.5f ) );

   resetWorldBox();

   // Add this object to the scene
   addToScene();

   return true;
}