Exemple #1
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;
}
Exemple #2
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;
}
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;
}
Exemple #4
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;
}
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;
}
VolumetricFogRTManager::VolumetricFogRTManager()
{
   setGlobalBounds();
   mTypeMask |= EnvironmentObjectType;
   mNetFlags.set(IsGhost);
   mIsInitialized = false;
   mNumFogObjects = 0;
}
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;
}
Exemple #8
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;
}
Exemple #9
0
bool WaterPlane::onAdd()
{
   if ( !Parent::onAdd() )
      return false;
   
   setGlobalBounds();
   resetWorldBox();
   addToScene();

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

   return true;
}
Exemple #10
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;
}
Exemple #11
0
bool SkyBox::onAdd()
{
   if ( !Parent::onAdd() )
      return false;

   setGlobalBounds();
   resetWorldBox();

   addToScene();

   if ( isClientObject() )
   {
      _initRender();
      _updateMaterial();
   }

   return true;
}
Exemple #12
0
bool DecalRoad::onAdd()
{
   if ( !Parent::onAdd() ) 
      return false;

   // DecalRoad is at position zero when created,
   // it sets its own position to the first node inside
   // _generateEdges but until it has at least one node
   // it will be at 0,0,0.

   MatrixF mat(true);
   Parent::setTransform( mat );

   // The client side calculates bounds based on clipped geometry.  It would 
   // be wasteful for the server to do this so the server uses global bounds.
   if ( isServerObject() )
   {
      setGlobalBounds();
      resetWorldBox();
   }

   // Set the Render Transform.
   setRenderTransform(mObjToWorld);

   // Add to Scene.
   addToScene();

   if ( isServerObject() )   
      getServerSet()->addObject( this );   

   //   
   TerrainBlock::smUpdateSignal.notify( this, &DecalRoad::_onTerrainChanged );

   //   
   if ( isClientObject() )
      _initMaterial();

   _generateEdges();
   _captureVerts();

   return true;
}
Exemple #13
0
bool Sun::onAdd()
{
   if ( !Parent::onAdd() )
      return false;

   // Register as listener to TimeOfDay update events
   TimeOfDay::getTimeOfDayUpdateSignal().notify( this, &Sun::_updateTimeOfDay );

	// Make this thing have a global bounds so that its 
   // always returned from spatial light queries.
	setGlobalBounds();
	resetWorldBox();
	setRenderTransform( mObjToWorld );
	addToScene();

   _initCorona();

   // Update the light parameters.
   _conformLights();

   return true;
}