Beispiel #1
0
 public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
                    OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
 {
     // m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID);
     _localID = localID;
     _avName = primName;
     _scene = parent_scene;
     _position = pos;
     _size = size;
     _scale = new OMV.Vector3(1f, 1f, 1f);   // the scale will be set by CreateGeom depending on object type
     _orientation = rotation;
     _buoyancy = 1f;
     _velocity = OMV.Vector3.Zero;
     _rotationalVelocity = OMV.Vector3.Zero;
     _angularVelocity = OMV.Vector3.Zero;
     _hullKey = 0;
     _meshKey = 0;
     _pbs = pbs;
     _isPhysical = pisPhysical;
     _isVolumeDetect = false;
     _subscribedEventsMs = 0;
     _friction = _scene.Params.defaultFriction; // TODO: compute based on object material
     _density = _scene.Params.defaultDensity; // TODO: compute based on object material
     _restitution = _scene.Params.defaultRestitution;
     _parentPrim = null;     // not a child or a parent
     _vehicle = new BSDynamics(this);    // add vehicleness
     _childrenPrims = new List<BSPrim>();
     if (_isPhysical)
         _mass = CalculateMass();
     else
         _mass = 0f;
     // do the actual object creation at taint time
     _scene.TaintedObject(delegate()
     {
         RecreateGeomAndObject();
     });
 }
 // Find and return a handle to the current vehicle actor.
 // Return 'null' if there is no vehicle actor.
 public BSDynamics GetVehicleActor(bool createIfNone)
 {
     BSDynamics ret = null;
     BSActor actor;
     if (PhysicalActors.TryGetActor(VehicleActorName, out actor))
     {
         ret = actor as BSDynamics;
     }
     else
     {
         if (createIfNone)
         {
             ret = new BSDynamics(PhysScene, this, VehicleActorName);
             PhysicalActors.Add(ret.ActorName, ret);
         }
     }
     return ret;
 }
Beispiel #3
0
 public BSPrim(ISceneChildEntity entity, bool isPhysical, BSScene parent_scene)
 {
     _parent_entity = entity;
     // m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID);
     _localID = _parent_entity.LocalId;
     _avName = _parent_entity.Name;
     _scene = parent_scene;
     _position = _parent_entity.AbsolutePosition;
     _size = _parent_entity.Scale;
     _scale = new OMV.Vector3(1f, 1f, 1f);   // the scale will be set by CreateGeom depending on object type
     _orientation = _parent_entity.Rotation;
     _buoyancy = 1f;
     _velocity = OMV.Vector3.Zero;
     _rotationalVelocity = OMV.Vector3.Zero;
     _angularVelocity = OMV.Vector3.Zero;
     _hullKey = 0;
     _pbs = _parent_entity.Shape;
     _isPhysical = isPhysical;
     _isVolumeDetect = _parent_entity.VolumeDetectActive;
     _subscribedEventsMs = 0;
     _parentPrim = null;
     _vehicle = new BSDynamics(this);
     _childrenPrims = new List<BSPrim>();
     if (_isPhysical)
         _mass = CalculateMass();
     else
         _mass = 0f;
     // do the actual object creation at taint time
     _scene.TaintedObject(delegate()
     {
         RecreateGeomAndObject();
     });
 }
Beispiel #4
0
    public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
                       OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
            : base(parent_scene, localID, primName, "BSPrim")
    {
        // m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID);
        _physicsActorType = (int)ActorTypes.Prim;
        _position = pos;
        _size = size;
        Scale = size;   // prims are the size the user wants them to be (different for BSCharactes).
        _orientation = rotation;
        _buoyancy = 0f;
        RawVelocity = OMV.Vector3.Zero;
        _rotationalVelocity = OMV.Vector3.Zero;
        BaseShape = pbs;
        _isPhysical = pisPhysical;
        _isVolumeDetect = false;

        // We keep a handle to the vehicle actor so we can set vehicle parameters later.
        VehicleActor = new BSDynamics(PhysScene, this, VehicleActorName);
        PhysicalActors.Add(VehicleActorName, VehicleActor);

        _mass = CalculateMass();

        // DetailLog("{0},BSPrim.constructor,call", LocalID);
        // do the actual object creation at taint time
        PhysScene.TaintedObject("BSPrim.create", delegate()
        {
            // Make sure the object is being created with some sanity.
            ExtremeSanityCheck(true /* inTaintTime */);

            CreateGeomAndObject(true);

            CurrentCollisionFlags = PhysScene.PE.GetCollisionFlags(PhysBody);
        });
    }
Beispiel #5
0
    public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
                       OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
    {
        // m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID);
        base.BaseInitialize(parent_scene, localID, primName, "BSPrim");
        _physicsActorType = (int)ActorTypes.Prim;
        _position = pos;
        _size = size;
        Scale = new OMV.Vector3(1f, 1f, 1f);   // the scale will be set by CreateGeom depending on object type
        _orientation = rotation;
        _buoyancy = 1f;
        _velocity = OMV.Vector3.Zero;
        _rotationalVelocity = OMV.Vector3.Zero;
        BaseShape = pbs;
        _isPhysical = pisPhysical;
        _isVolumeDetect = false;
        _friction = PhysicsScene.Params.defaultFriction;  // TODO: compute based on object material
        _density = PhysicsScene.Params.defaultDensity;    // TODO: compute based on object material
        _restitution = PhysicsScene.Params.defaultRestitution;
        _vehicle = new BSDynamics(PhysicsScene, this);            // add vehicleness
        _mass = CalculateMass();

        // No body or shape yet
        BSBody = new BulletBody(LocalID, IntPtr.Zero);
        BSShape = new BulletShape(IntPtr.Zero);

        DetailLog("{0},BSPrim.constructor,call", LocalID);
        // do the actual object creation at taint time
        PhysicsScene.TaintedObject("BSPrim.create", delegate()
        {
            CreateGeomAndObject(true);

            CurrentCollisionFlags = BulletSimAPI.GetCollisionFlags2(BSBody.ptr);
        });
    }
Beispiel #6
0
    public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
                       OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
            : base(parent_scene, localID, primName, "BSPrim")
    {
        // m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID);
        _physicsActorType = (int)ActorTypes.Prim;
        _position = pos;
        _size = size;
        Scale = size;   // prims are the size the user wants them to be (different for BSCharactes).
        _orientation = rotation;
        _buoyancy = 0f;
        _velocity = OMV.Vector3.Zero;
        _rotationalVelocity = OMV.Vector3.Zero;
        BaseShape = pbs;
        _isPhysical = pisPhysical;
        _isVolumeDetect = false;

        // Someday set default attributes based on the material but, for now, we don't know the prim material yet.
        // MaterialAttributes primMat = BSMaterials.GetAttributes(Material, pisPhysical);
        _density = PhysicsScene.Params.defaultDensity;
        _friction = PhysicsScene.Params.defaultFriction;
        _restitution = PhysicsScene.Params.defaultRestitution;

        _vehicle = new BSDynamics(PhysicsScene, this);            // add vehicleness

        _mass = CalculateMass();

        // Cause linkset variables to be initialized (like mass)
        Linkset.Refresh(this);

        DetailLog("{0},BSPrim.constructor,call", LocalID);
        // do the actual object creation at taint time
        PhysicsScene.TaintedObject("BSPrim.create", delegate()
        {
            CreateGeomAndObject(true);

            CurrentCollisionFlags = PhysicsScene.PE.GetCollisionFlags(PhysBody);
        });
    }