예제 #1
0
void EtherformData::packData(BitStream* stream)
{
   Parent::packData(stream);

   stream->write(boxSize.x);
   stream->write(boxSize.y);
   stream->write(boxSize.z);

   stream->write(accelerationForce);

   for( S32 i=0; i<NUM_ETHERFORM_LASERTRAILS; i++ )
   {
      if( stream->writeFlag( laserTrailList[i] != NULL ) )
      {
         stream->writeRangedU32( laserTrailList[i]->getId(), DataBlockObjectIdFirst,  DataBlockObjectIdLast );
      }
   }

   for (S32 j = 0; j < MaxJetEmitters; j++)
   {
      if (stream->writeFlag(jetEmitter[j]))
      {
         SimObjectId writtenId = packed ? SimObjectId(jetEmitter[j]) : jetEmitter[j]->getId();
         stream->writeRangedU32(writtenId, DataBlockObjectIdFirst,DataBlockObjectIdLast);
      }
   }
   stream->write(minTrailSpeed);
}
예제 #2
0
//--------------------------------------------------------------------------
void HoverVehicleData::packData(BitStream* stream)
{
    Parent::packData(stream);

    stream->write(dragForce);
    stream->write(vertFactor);
    stream->write(floatingThrustFactor);
    stream->write(mainThrustForce);
    stream->write(reverseThrustForce);
    stream->write(strafeThrustForce);
    stream->write(turboFactor);
    stream->write(stabLenMin);
    stream->write(stabLenMax);
    stream->write(stabSpringConstant);
    stream->write(stabDampingConstant);
    stream->write(gyroDrag);
    stream->write(normalForce);
    stream->write(restorativeForce);
    stream->write(steeringForce);
    stream->write(rollForce);
    stream->write(pitchForce);
    mathWrite(*stream, dustTrailOffset);
    stream->write(triggerTrailHeight);
    stream->write(dustTrailFreqMod);

    for (S32 i = 0; i < MaxSounds; i++)
        if (stream->writeFlag(sound[i]))
            stream->writeRangedU32(packed? SimObjectId((uintptr_t)sound[i]):
                                   sound[i]->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);

    for (S32 j = 0; j < MaxJetEmitters; j++)
    {
        if (stream->writeFlag(jetEmitter[j]))
        {
            SimObjectId writtenId = packed ? SimObjectId((uintptr_t)jetEmitter[j]) : jetEmitter[j]->getId();
            stream->writeRangedU32(writtenId, DataBlockObjectIdFirst,DataBlockObjectIdLast);
        }
    }

    if (stream->writeFlag( dustTrailEmitter ))
    {
        stream->writeRangedU32( dustTrailEmitter->getId(), DataBlockObjectIdFirst,  DataBlockObjectIdLast );
    }
    stream->write(floatingGravMag);
    stream->write(brakingForce);
    stream->write(brakingActivationSpeed);
}
예제 #3
0
bool HoverVehicleData::preload(bool server, String &errorStr)
{
    if (Parent::preload(server, errorStr) == false)
        return false;

    if (dragForce <= 0.01f) {
        Con::warnf("HoverVehicleData::preload: dragForce must be at least 0.01");
        dragForce = 0.01f;
    }
    if (vertFactor < 0.0f || vertFactor > 1.0f) {
        Con::warnf("HoverVehicleData::preload: vert factor must be [0, 1]");
        vertFactor = vertFactor < 0.0f ? 0.0f : 1.0f;
    }
    if (floatingThrustFactor < 0.0f || floatingThrustFactor > 1.0f) {
        Con::warnf("HoverVehicleData::preload: floatingThrustFactor must be [0, 1]");
        floatingThrustFactor = floatingThrustFactor < 0.0f ? 0.0f : 1.0f;
    }

    maxThrustSpeed = (mainThrustForce + strafeThrustForce) / dragForce;

    massCenter = Point3F(0, 0, 0);

    // Resolve objects transmitted from server
    if (!server) {
        for (S32 i = 0; i < MaxSounds; i++)
            if (sound[i])
                Sim::findObject(SimObjectId((uintptr_t)sound[i]),sound[i]);
        for (S32 j = 0; j < MaxJetEmitters; j++)
            if (jetEmitter[j])
                Sim::findObject(SimObjectId((uintptr_t)jetEmitter[j]),jetEmitter[j]);
    }

    if( !dustTrailEmitter && dustTrailID != 0 )
    {
        if( !Sim::findObject( dustTrailID, dustTrailEmitter ) )
        {
            Con::errorf( ConsoleLogEntry::General, "HoverVehicleData::preload Invalid packet, bad datablockId(dustTrailEmitter): 0x%x", dustTrailID );
        }
    }
    // Resolve jet nodes
    for (S32 j = 0; j < MaxJetNodes; j++)
        jetNode[j] = mShape->findNode(sJetNode[j]);

    return true;
}
예제 #4
0
bool FlyingVehicleData::preload(bool server, String &errorStr)
{
   if (!Parent::preload(server, errorStr))
      return false;

   TSShapeInstance* si = new TSShapeInstance(mShape, false);

   // Resolve objects transmitted from server
   if (!server) {
      for (S32 i = 0; i < MaxSounds; i++)
         if (sound[i])
            Sim::findObject(SimObjectId(sound[i]),sound[i]);

      for (S32 j = 0; j < MaxJetEmitters; j++)
         if (jetEmitter[j])
            Sim::findObject(SimObjectId(jetEmitter[j]),jetEmitter[j]);
   }

   // Extract collision planes from shape collision detail level
   if (collisionDetails[0] != -1)
   {
      MatrixF imat(1);
      PlaneExtractorPolyList polyList;
      polyList.mPlaneList = &rigidBody.mPlaneList;
      polyList.setTransform(&imat, Point3F(1,1,1));
      si->animate(collisionDetails[0]);
      si->buildPolyList(&polyList,collisionDetails[0]);
   }

   // Resolve jet nodes
   for (S32 j = 0; j < MaxJetNodes; j++)
      jetNode[j] = mShape->findNode(sJetNode[j]);

   //
   maxSpeed = maneuveringForce / minDrag;

   delete si;
   return true;
}
예제 #5
0
void FlyingVehicleData::packData(BitStream* stream)
{
   Parent::packData(stream);

   for (S32 i = 0; i < MaxSounds; i++)
   {
      if (stream->writeFlag(sound[i]))
      {
         SimObjectId writtenId = packed ? SimObjectId(sound[i]) : sound[i]->getId();
         stream->writeRangedU32(writtenId, DataBlockObjectIdFirst, DataBlockObjectIdLast);
      }
   }

   for (S32 j = 0; j < MaxJetEmitters; j++)
   {
      if (stream->writeFlag(jetEmitter[j]))
      {
         SimObjectId writtenId = packed ? SimObjectId(jetEmitter[j]) : jetEmitter[j]->getId();
         stream->writeRangedU32(writtenId, DataBlockObjectIdFirst,DataBlockObjectIdLast);
      }
   }

   stream->write(maneuveringForce);
   stream->write(horizontalSurfaceForce);
   stream->write(verticalSurfaceForce);
   stream->write(autoInputDamping);
   stream->write(steeringForce);
   stream->write(steeringRollForce);
   stream->write(rollForce);
   stream->write(autoAngularForce);
   stream->write(rotationalDrag);
   stream->write(autoLinearForce);
   stream->write(maxAutoSpeed);
   stream->write(hoverHeight);
   stream->write(createHoverHeight);
   stream->write(minTrailSpeed);
   stream->write(vertThrustMultiple);
}
예제 #6
0
bool afxT3DLightBaseData::preload(bool server, String &errorStr)
{
  if (!Parent::preload(server, errorStr))
    return false;

  // Resolve objects transmitted from server
  if (!server)
  {
    if (do_id_convert)
    {
      SimObjectId anim_id = SimObjectId((uintptr_t)mAnimationData);
      if (anim_id != 0)
      {
        // try to convert id to pointer
        if (!Sim::findObject(anim_id, mAnimationData))
        {
          Con::errorf(ConsoleLogEntry::General,
            "afxT3DLightBaseData::preload() -- bad datablockId: 0x%x (animationType)",
            anim_id);
        }
      }
      SimObjectId flare_id = SimObjectId((uintptr_t)mFlareData);
      if (flare_id != 0)
      {
        // try to convert id to pointer
        if (!Sim::findObject(flare_id, mFlareData))
        {
          Con::errorf(ConsoleLogEntry::General,
            "afxT3DLightBaseData::preload() -- bad datablockId: 0x%x (flareType)",
            flare_id);
        }
      }
      do_id_convert = false;
    }
  }

  return true;
}
예제 #7
0
void DebrisData::packData(BitStream* stream)
{
   Parent::packData(stream);

   stream->write(elasticity);
   stream->write(friction);
   stream->write(numBounces);
   stream->write(bounceVariance);
   stream->write(minSpinSpeed);
   stream->write(maxSpinSpeed);
   stream->write(explodeOnMaxBounce);
   stream->write(staticOnMaxBounce);
   stream->write(snapOnMaxBounce);
   stream->write(lifetime);
   stream->write(lifetimeVariance);
   stream->write(velocity);
   stream->write(velocityVariance);
   stream->write(fade);
   stream->write(useRadiusMass);
   stream->write(baseRadius);
   stream->write(gravModifier);
   stream->write(terminalVelocity);
   stream->write(ignoreWater);

   stream->writeString( textureName );
   stream->writeString( shapeName );

   for( S32 i=0; i<DDC_NUM_EMITTERS; i++ )
   {
      if( stream->writeFlag( emitterList[i] != NULL ) )
      {
         stream->writeRangedU32( emitterList[i]->getId(), DataBlockObjectIdFirst,  DataBlockObjectIdLast );
      }
   }

   if( stream->writeFlag( explosion ) )
   {
      stream->writeRangedU32(packed? SimObjectId((uintptr_t)explosion):
         explosion->getId(),DataBlockObjectIdFirst,DataBlockObjectIdLast);
   }

}
예제 #8
0
bool DebrisData::onAdd()
{
   if(!Parent::onAdd())
      return false;

   for( S32 i=0; i<DDC_NUM_EMITTERS; i++ )
   {
      if( !emitterList[i] && emitterIDList[i] != 0 )
      {
         if( Sim::findObject( emitterIDList[i], emitterList[i] ) == false)
         {
            Con::errorf( ConsoleLogEntry::General, "DebrisData::onAdd: Invalid packet, bad datablockId(emitter): 0x%x", emitterIDList[i]);
         }
      }
   }

   if (!explosion && explosionId != 0)
   {
      if (!Sim::findObject( SimObjectId( explosionId ), explosion ))
            Con::errorf( ConsoleLogEntry::General, "DebrisData::onAdd: Invalid packet, bad datablockId(particle emitter): 0x%x", explosionId);
   }

   // validate data

   if( velocityVariance > velocity )
   {
      Con::warnf(ConsoleLogEntry::General, "DebrisData(%s)::onAdd: velocityVariance invalid", getName());
      velocityVariance = velocity;
   }
   if( friction < -10.0f || friction > 10.0f )
   {
      Con::warnf(ConsoleLogEntry::General, "DebrisData(%s)::onAdd: friction invalid", getName());
      friction = 0.2f;
   }
   if( elasticity < -10.0f || elasticity > 10.0f )
   {
      Con::warnf(ConsoleLogEntry::General, "DebrisData(%s)::onAdd: elasticity invalid", getName());
      elasticity = 0.2f;
   }
   if( lifetime < 0.0f || lifetime > 1000.0f )
   {
      Con::warnf(ConsoleLogEntry::General, "DebrisData(%s)::onAdd: lifetime invalid", getName());
      lifetime = 3.0f;
   }
   if( lifetimeVariance < 0.0f || lifetimeVariance > lifetime )
   {
      Con::warnf(ConsoleLogEntry::General, "DebrisData(%s)::onAdd: lifetimeVariance invalid", getName());
      lifetimeVariance = 0.0f;
   }
   if( numBounces < 0 || numBounces > 10000 )
   {
      Con::warnf(ConsoleLogEntry::General, "DebrisData(%s)::onAdd: numBounces invalid", getName());
      numBounces = 3;
   }
   if( bounceVariance < 0 || bounceVariance > numBounces )
   {
      Con::warnf(ConsoleLogEntry::General, "DebrisData(%s)::onAdd: bounceVariance invalid", getName());
      bounceVariance = 0;
   }
   if( minSpinSpeed < -10000.0f || minSpinSpeed > 10000.0f || minSpinSpeed > maxSpinSpeed )
   {
      Con::warnf(ConsoleLogEntry::General, "DebrisData(%s)::onAdd: minSpinSpeed invalid", getName());
      minSpinSpeed = maxSpinSpeed - 1.0f;
   }
   if( maxSpinSpeed < -10000.0f || maxSpinSpeed > 10000.0f )
   {
      Con::warnf(ConsoleLogEntry::General, "DebrisData(%s)::onAdd: maxSpinSpeed invalid", getName());
      maxSpinSpeed = 0.0f;
   }

   return true;
}