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

   MatrixF mat;
   Point3F scale;
   mathRead( *stream, &mat );
   mathRead( *stream, &scale );
   setScale( scale);
   setTransform(mat);

   mShapeName = stream->readSTString();

   if ( stream->readFlag() ) // UpdateCollisionMask
   {
      U32 collisionType = CollisionMesh;

      stream->read( &collisionType );

      // Handle it if we have changed CollisionType's
      if ( (MeshType)collisionType != mCollisionType )
      {
         mCollisionType = (MeshType)collisionType;

         if ( isProperlyAdded() && mShapeInstance )
            prepCollision();
      }
   }

   if (stream->readFlag())    // SkinMask
   {
      NetStringHandle skinDesiredNameHandle = con->unpackNetStringHandleU(stream);;
      if (mSkinNameHandle != skinDesiredNameHandle)
      {
         mSkinNameHandle = skinDesiredNameHandle;
         reSkin();
      }
   }

   stream->read( (U32*)&mDecalType );

   mAllowPlayerStep = stream->readFlag();
   mMeshCulling = stream->readFlag();   
   mUseOriginSort = stream->readFlag();

   stream->read( &mRenderNormalScalar );

   stream->read( &mForceDetail );

   mPlayAmbient = stream->readFlag();

   if ( mLightPlugin )
   {
      mLightPlugin->unpackUpdate(this, con, stream);
   }

   if ( isProperlyAdded() )
      _updateShouldTick();
}
示例#2
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;
}
示例#3
0
void CollisionComponent::inspectPostApply()
{
   // Apply any transformations set in the editor
   Parent::inspectPostApply();

   if (isServerObject())
   {
      setMaskBits(ColliderMask);
      prepCollision();
   }
}
示例#4
0
void TSStatic::inspectPostApply()
{
   // Apply any transformations set in the editor
   Parent::inspectPostApply();

   if(isServerObject()) 
   {
      setMaskBits(AdvancedStaticOptionsMask);
      prepCollision();
   }

   _updateShouldTick();
}
示例#5
0
void CollisionComponent::componentRemovedFromOwner(Component *comp)
{
   if (comp->getId() == getId()) //?????????
      return;

   //test if this is a shape component!
   RenderComponentInterface *renderInterface = dynamic_cast<RenderComponentInterface*>(comp);
   if (renderInterface)
   {
      renderInterface->onShapeInstanceChanged.remove(this, &CollisionComponent::targetShapeChanged);
      mOwnerRenderInterface = NULL;
      prepCollision();
   }

   //physicsInterface
   PhysicsComponentInterface *physicsInterface = dynamic_cast<PhysicsComponentInterface*>(comp);
   if (physicsInterface)
   {
      mPhysicsRep = PHYSICSMGR->createBody();

      prepCollision();
   }
}
示例#6
0
void CollisionComponent::componentAddedToOwner(Component *comp)
{
   if (comp->getId() == getId())
      return;

   //test if this is a shape component!
   RenderComponentInterface *renderInterface = dynamic_cast<RenderComponentInterface*>(comp);
   if (renderInterface)
   {
      renderInterface->onShapeInstanceChanged.notify(this, &CollisionComponent::targetShapeChanged);
      mOwnerRenderInterface = renderInterface;
      prepCollision();
   }

   PhysicsComponentInterface *physicsInterface = dynamic_cast<PhysicsComponentInterface*>(comp);
   if (physicsInterface)
   {
      if (mPhysicsRep)
         SAFE_DELETE(mPhysicsRep);

      prepCollision();
   }
}
示例#7
0
void CollisionComponent::onComponentAdd()
{
   Parent::onComponentAdd();

   RenderComponentInterface *renderInterface = mOwner->getComponent<RenderComponentInterface>();
   if (renderInterface)
   {
      renderInterface->onShapeInstanceChanged.notify(this, &CollisionComponent::targetShapeChanged);
      mOwnerRenderInterface = renderInterface;
   }

   //physicsInterface
   PhysicsComponentInterface *physicsInterface = mOwner->getComponent<PhysicsComponentInterface>();
   if (!physicsInterface)
   {
      mPhysicsRep = PHYSICSMGR->createBody();
   }

   prepCollision();
}
示例#8
0
void CollisionComponent::unpackUpdate(NetConnection *con, BitStream *stream)
{
   Parent::unpackUpdate(con, stream);

   if (stream->readFlag()) // UpdateMask
   {
      U32 collisionType = CollisionMesh;

      stream->read(&collisionType);

      // Handle it if we have changed CollisionType's
      if ((MeshType)collisionType != mCollisionType)
      {
         mCollisionType = (MeshType)collisionType;

         prepCollision();
      }

      char readBuffer[1024];

      stream->readString(readBuffer);
      colisionMeshPrefix = StringTable->insert(readBuffer);
   }
}
示例#9
0
void CollisionComponent::targetShapeChanged(RenderComponentInterface* instanceInterface)
{
   prepCollision();
}