Esempio n. 1
0
 // called when this character is being destroyed and the resources should be released
 public void Destroy()
 {
     _scene.TaintedObject(delegate()
     {
         BulletSimAPI.DestroyObject(_scene.WorldID, _localID);
     });
 }
Esempio n. 2
0
        public void Destroy()
        {
#if (!ISWIN)
            _scene.TaintedObject(delegate()
            {
                BulletSimAPI.DestroyObject(_scene.WorldID, _localID);
            });
#else
            _scene.TaintedObject(() => BulletSimAPI.DestroyObject(_scene.WorldID, _localID));
#endif
        }
Esempio n. 3
0
        public BSCharacter(uint localID, UUID avID, String avName, BSScene parent_scene, Vector3 pos,
                           Quaternion rotation, Vector3 size, bool isFlying)
        {
            _localID     = localID;
            _avID        = avID;
            _avName      = avName;
            _scene       = parent_scene;
            _position    = pos;
            _orientation = rotation;
            _size        = size;
            _orientation = Quaternion.Identity;
            _velocity    = Vector3.Zero;
            _buoyancy    = 0f; // characters return a buoyancy of zero
            _scale       = new Vector3(1f, 1f, 1f);
            float AVvolume =
                (float)(Math.PI * Math.Pow(_scene.Params.avatarCapsuleRadius, 2) * _scene.Params.avatarCapsuleHeight);

            _density    = _scene.Params.avatarDensity;
            _mass       = _density * AVvolume;
            _isPhysical = true;

            ShapeData shapeData = new ShapeData
            {
                ID          = _localID,
                Type        = ShapeData.PhysicsShapeType.SHAPE_AVATAR,
                Position    = _position,
                Rotation    = _orientation,
                Velocity    = _velocity,
                Scale       = _scale,
                Mass        = _mass,
                Buoyancy    = isFlying ? 1f : 0f,
                Static      = ShapeData.numericFalse,
                Friction    = _scene.Params.avatarFriction,
                Restitution = _scene.Params.defaultRestitution
            };

            // do actual create at taint time
#if (!ISWIN)
            _scene.TaintedObject(delegate()
            {
                BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData);
            });
#else
            _scene.TaintedObject(() => BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData));
#endif

            return;
        }
Esempio n. 4
0
        public BSCharacter(uint localID, String avName, BSScene parent_scene, Vector3 pos, Vector3 size, bool isFlying)
        {
            _localID     = localID;
            _avName      = avName;
            _scene       = parent_scene;
            _position    = pos;
            _size        = size;
            _flying      = isFlying;
            _orientation = Quaternion.Identity;
            _velocity    = Vector3.Zero;
            _buoyancy    = isFlying ? 1f : 0f;
            _scale       = new Vector3(1f, 1f, 1f);
            _density     = _scene.Params.avatarDensity;
            ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale

            ShapeData shapeData = new ShapeData();

            shapeData.ID          = _localID;
            shapeData.Type        = ShapeData.PhysicsShapeType.SHAPE_AVATAR;
            shapeData.Position    = _position;
            shapeData.Rotation    = _orientation;
            shapeData.Velocity    = _velocity;
            shapeData.Scale       = _scale;
            shapeData.Mass        = _mass;
            shapeData.Buoyancy    = _buoyancy;
            shapeData.Static      = ShapeData.numericFalse;
            shapeData.Friction    = _scene.Params.avatarFriction;
            shapeData.Restitution = _scene.Params.defaultRestitution;

            // do actual create at taint time
            _scene.TaintedObject(delegate()
            {
                BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData);
            });

            return;
        }
Esempio n. 5
0
    public BSCharacter(uint localID, String avName, BSScene parent_scene, Vector3 pos, Vector3 size, bool isFlying)
    {
        _localID = localID;
        _avName = avName;
        _scene = parent_scene;
        _position = pos;
        _size = size;
        _flying = isFlying;
        _orientation = Quaternion.Identity;
        _velocity = Vector3.Zero;
        _buoyancy = isFlying ? 1f : 0f;
        _scale = new Vector3(1f, 1f, 1f);
        _density = _scene.Params.avatarDensity;
        ComputeAvatarVolumeAndMass();   // set _avatarVolume and _mass based on capsule size, _density and _scale

        ShapeData shapeData = new ShapeData();
        shapeData.ID = _localID;
        shapeData.Type = ShapeData.PhysicsShapeType.SHAPE_AVATAR;
        shapeData.Position = _position;
        shapeData.Rotation = _orientation;
        shapeData.Velocity = _velocity;
        shapeData.Scale = _scale;
        shapeData.Mass = _mass;
        shapeData.Buoyancy = _buoyancy;
        shapeData.Static = ShapeData.numericFalse;
        shapeData.Friction = _scene.Params.avatarFriction;
        shapeData.Restitution = _scene.Params.defaultRestitution;

        // do actual create at taint time
        _scene.TaintedObject(delegate()
        {
            BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData);
        });
            
        return;
    }
Esempio n. 6
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();
     });
 }
Esempio n. 7
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();
     });
 }
Esempio n. 8
0
 public override void Destroy()
 {
     _scene.TaintedObject(() => BulletSimAPI.DestroyObject(_scene.WorldID, _localID));
 }
Esempio n. 9
0
        public BSCharacter(uint localID, UUID avID, String avName, BSScene parent_scene, Vector3 pos,
                           Quaternion rotation, Vector3 size, bool isFlying)
        {
            _localID = localID;
            _avID = avID;
            _avName = avName;
            _scene = parent_scene;
            _position = pos;
            _orientation = rotation;
            _size = size;
            _orientation = Quaternion.Identity;
            _velocity = Vector3.Zero;
            _scale = new Vector3(1f, 1f, 1f);
            float AVvolume =
                (float) (Math.PI*Math.Pow(_scene.Params.avatarCapsuleRadius, 2)*_scene.Params.avatarCapsuleHeight);
            _density = _scene.Params.avatarDensity;
            _mass = _density*AVvolume;
            _isPhysical = true;

            ShapeData shapeData = new ShapeData
                                      {
                                          ID = _localID,
                                          Type = ShapeData.PhysicsShapeType.SHAPE_AVATAR,
                                          Position = _position,
                                          Rotation = _orientation,
                                          Velocity = _velocity,
                                          Scale = _scale,
                                          Mass = _mass,
                                          Buoyancy = isFlying ? 1f : 0f,
                                          Static = ShapeData.numericFalse,
                                          Friction = _scene.Params.avatarFriction,
                                          Restitution = _scene.Params.defaultRestitution
                                      };

            // do actual create at taint time
            _scene.TaintedObject(() => BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData));

            return;
        }