示例#1
0
void SkyBox::unpackUpdate( NetConnection *conn, BitStream *stream )
{
   Parent::unpackUpdate( conn, stream );

   String tmpString( "" );
   stream->read( &tmpString );
   if ( !tmpString.equal( mMatName, String::NoCase ) )
   {
      mMatName = tmpString;
      _updateMaterial();
   }

   bool drawBottom = stream->readFlag();
   F32 bandHeight = 0;
   stream->read( &bandHeight );

   // If this flag has changed
   // we need to update the vertex buffer.
   if (  drawBottom != mDrawBottom || 
         bandHeight != mFogBandHeight )
   {
      mDrawBottom = drawBottom;
      mFogBandHeight = bandHeight;
      mIsVBDirty = true;
      _initRender();
   }
}
示例#2
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;
}
示例#3
0
void DecalData::unpackData( BitStream *stream )
{
   Parent::unpackData( stream );

   stream->read( &lookupName );
   stream->read( &size );  
   stream->read( &materialName );
   _updateMaterial();
   stream->read( &lifeSpan );
   stream->read( &fadeTime );
	stream->read( &texCoordCount );

   for (S32 i = 0; i < texCoordCount; i++)
      mathRead(*stream, &texRect[i]);

   stream->read( &fadeStartPixelSize );
   stream->read( &fadeEndPixelSize );
   stream->read( &renderPriority );
   stream->read( &clippingMasks );
   stream->read( &clippingAngle );
   
	stream->read( &texRows );
   stream->read( &texCols );
	stream->read( &frame );
	stream->read( &randomize );
}
示例#4
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;
}
示例#5
0
void GroundPlane::unpackUpdate( NetConnection* connection, BitStream* stream )
{
   Parent::unpackUpdate( connection, stream );

   stream->read( &mSquareSize );
   stream->read( &mScaleU );
   stream->read( &mScaleV );
   stream->read( &mMaterialName );

   if( stream->readFlag() ) // UpdateMask
   {
      MatrixF mat;
      mathRead( *stream, &mat );
      setTransform( mat );
   }

   // If we're added then something possibly changed in 
   // the editor... do an update of the material and the
   // geometry.
   if ( isProperlyAdded() )
   {
      _updateMaterial();
      mVertexBuffer = NULL;
   }
}
示例#6
0
Material* DecalData::getMaterial()
{
   if ( !material )
   {
      _updateMaterial();
      if ( !material )
         material = static_cast<Material*>( Sim::findObject("WarningMaterial") );
   }

   return material;
}
示例#7
0
bool SkyBox::onAdd()
{
   if ( !Parent::onAdd() )
      return false;

   setGlobalBounds();
   resetWorldBox();

   addToScene();

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

   return true;
}
示例#8
0
void ConvexShape::unpackUpdate( NetConnection *conn, BitStream *stream )
{
   Parent::unpackUpdate( conn, stream );

   if ( stream->readFlag() )  // TransformMask
   {
      mathRead(*stream, &mObjToWorld);
      mathRead(*stream, &mObjScale);

      setTransform( mObjToWorld );
      setScale( mObjScale );
   }

   if ( stream->readFlag() ) // UpdateMask
   {
      stream->read( &mMaterialName );      

      if ( isProperlyAdded() )
         _updateMaterial();

      mSurfaces.clear();

      const U32 surfCount = stream->readInt( 32 );
      for ( S32 i = 0; i < surfCount; i++ )
      {
         mSurfaces.increment();
         MatrixF &mat = mSurfaces.last();

         QuatF quat;
         Point3F pos;

         mathRead( *stream, &quat );
         mathRead( *stream, &pos ); 

         quat.setMatrix( &mat );
         mat.setPosition( pos );
      }

      if ( isProperlyAdded() )
         _updateGeometry( true );
   }
}
示例#9
0
void DecalData::onStaticModified( const char *slotName, const char *newValue )
{
   Parent::onStaticModified( slotName, newValue );

   if ( !isProperlyAdded() )
      return;

   // To allow changing materials live.
   if ( dStricmp( slotName, "material" ) == 0 )
   {
      materialName = newValue;
      _updateMaterial();
   }
   // To allow changing name live.
   else if ( dStricmp( slotName, "name" ) == 0 )
   {
      lookupName = getName();
   }
   else if ( dStricmp( slotName, "renderPriority" ) == 0 )
   {
      renderPriority = getMax( renderPriority, (U8)1 );
   }
}
示例#10
0
void SkyBox::inspectPostApply()
{
   Parent::inspectPostApply();
   _updateMaterial();
}
示例#11
0
bool ConvexShape::onAdd()
{
   if ( !Parent::onAdd() )
      return false;
   
   //mObjBox.set( -0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f );
   //resetWorldBox();   

   // Face Order:
   // Top, Bottom, Front, Back, Left, Right

   // X Axis
   static const Point3F cubeTangents[6] =
   {
      Point3F( 1,  0,  0 ),
      Point3F(-1,  0,  0 ),
      Point3F( 1,  0,  0 ),
      Point3F(-1,  0,  0 ),
      Point3F( 0,  1,  0 ),
      Point3F( 0, -1,  0 )      
   };

   // Y Axis
   static const Point3F cubeBinormals[6] =
   {
      Point3F( 0,  1,  0 ),
      Point3F( 0,  1,  0 ),
      Point3F( 0,  0, -1 ),
      Point3F( 0,  0, -1 ),
      Point3F( 0,  0, -1 ),
      Point3F( 0,  0, -1 )
   };

   // Z Axis
   static const Point3F cubeNormals[6] = 
   {
      Point3F( 0,  0,  1),
      Point3F( 0,  0, -1),
      Point3F( 0,  1,  0),
      Point3F( 0, -1,  0),
      Point3F(-1,  0,  0),
      Point3F( 1,  0,  0),      
   };

   if ( mSurfaces.empty() )
   {      
      for ( S32 i = 0; i < 6; i++ )
      {
         mSurfaces.increment();
         MatrixF &surf = mSurfaces.last();

         surf.identity();
         
         surf.setColumn( 0, cubeTangents[i] );
         surf.setColumn( 1, cubeBinormals[i] );
         surf.setColumn( 2, cubeNormals[i] );
         surf.setPosition( cubeNormals[i] * 0.5f );         
      }
   }

   if ( isClientObject() )   
      _updateMaterial();      
   
   _updateGeometry( true );

   addToScene();

   return true;
}