Exemplo n.º 1
0
        public BSCharacter(
            uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 vel, OMV.Vector3 size, bool isFlying)

            : base(parent_scene, localID, avName, "BSCharacter")
        {
            _physicsActorType = (int)ActorTypes.Agent;
            RawPosition       = pos;

            _flying        = isFlying;
            RawOrientation = OMV.Quaternion.Identity;
            RawVelocity    = vel;
            _buoyancy      = ComputeBuoyancyFromFlying(isFlying);
            Friction       = BSParam.AvatarStandingFriction;
            Density        = BSParam.AvatarDensity;

            // Old versions of ScenePresence passed only the height. If width and/or depth are zero,
            //     replace with the default values.
            _size = size;
            if (_size.X == 0f)
            {
                _size.X = BSParam.AvatarCapsuleDepth;
            }
            if (_size.Y == 0f)
            {
                _size.Y = BSParam.AvatarCapsuleWidth;
            }

            // The dimensions of the physical capsule are kept in the scale.
            // Physics creates a unit capsule which is scaled by the physics engine.
            Scale = ComputeAvatarScale(_size);
            // set _avatarVolume and _mass based on capsule size, _density and Scale
            ComputeAvatarVolumeAndMass();

            DetailLog(
                "{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5},pos={6},vel={7}",
                LocalID, _size, Scale, Density, _avatarVolume, RawMass, pos, vel);

            // do actual creation in taint time
            PhysScene.TaintedObject(LocalID, "BSCharacter.create", delegate()
            {
                DetailLog("{0},BSCharacter.create,taint", LocalID);

                // New body and shape into PhysBody and PhysShape
                PhysScene.Shapes.GetBodyAndShape(true, PhysScene.World, this);

                // The avatar's movement is controlled by this motor that speeds up and slows down
                //    the avatar seeking to reach the motor's target speed.
                // This motor runs as a prestep action for the avatar so it will keep the avatar
                //    standing as well as moving. Destruction of the avatar will destroy the pre-step action.
                m_moveActor = new BSActorAvatarMove(PhysScene, this, AvatarMoveActorName);
                PhysicalActors.Add(AvatarMoveActorName, m_moveActor);

                SetPhysicalProperties();

                IsInitialized = true;
            });
            return;
        }
Exemplo n.º 2
0
        public BSCharacter(
            uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 vel, OMV.Vector3 size, float footOffset, bool isFlying)

            : base(parent_scene, localID, avName, "BSCharacter")
        {
            _physicsActorType = (int)ActorTypes.Agent;
            RawPosition       = pos;

            _flying        = isFlying;
            RawOrientation = OMV.Quaternion.Identity;
            RawVelocity    = vel;
            _buoyancy      = ComputeBuoyancyFromFlying(isFlying);
            Friction       = BSParam.AvatarStandingFriction;
            Density        = BSParam.AvatarDensity;
            _isPhysical    = true;

            _footOffset = footOffset;
            // Adjustments for zero X and Y made in Size()
            // This also computes avatar scale, volume, and mass
            SetAvatarSize(size, footOffset, true /* initializing */);

            DetailLog(
                "{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5},pos={6},vel={7}",
                LocalID, Size, Scale, Density, _avatarVolume, RawMass, pos, vel);

            // do actual creation in taint time
            PhysScene.TaintedObject(LocalID, "BSCharacter.create", delegate()
            {
                DetailLog("{0},BSCharacter.create,taint", LocalID);

                // New body and shape into PhysBody and PhysShape
                PhysScene.Shapes.GetBodyAndShape(true, PhysScene.World, this);

                // The avatar's movement is controlled by this motor that speeds up and slows down
                //    the avatar seeking to reach the motor's target speed.
                // This motor runs as a prestep action for the avatar so it will keep the avatar
                //    standing as well as moving. Destruction of the avatar will destroy the pre-step action.
                m_moveActor = new BSActorAvatarMove(PhysScene, this, AvatarMoveActorName);
                PhysicalActors.Add(AvatarMoveActorName, m_moveActor);

                SetPhysicalProperties();

                IsInitialized = true;
            });
            return;
        }
Exemplo n.º 3
0
    public BSCharacter(
            uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 vel, OMV.Vector3 size, bool isFlying)

            : base(parent_scene, localID, avName, "BSCharacter")
    {
        _physicsActorType = (int)ActorTypes.Agent;
        RawPosition = pos;        

        _flying = isFlying;
        RawOrientation = OMV.Quaternion.Identity;
        RawVelocity = vel;
        _buoyancy = ComputeBuoyancyFromFlying(isFlying);
        Friction = BSParam.AvatarStandingFriction;
        Density = BSParam.AvatarDensity;

        // Old versions of ScenePresence passed only the height. If width and/or depth are zero,
        //     replace with the default values.
        _size = size;
        if (_size.X == 0f) _size.X = BSParam.AvatarCapsuleDepth;
        if (_size.Y == 0f) _size.Y = BSParam.AvatarCapsuleWidth;

        // The dimensions of the physical capsule are kept in the scale.
        // Physics creates a unit capsule which is scaled by the physics engine.
        Scale = ComputeAvatarScale(_size);
        // set _avatarVolume and _mass based on capsule size, _density and Scale
        ComputeAvatarVolumeAndMass();

        DetailLog(
            "{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5},pos={6},vel={7}",
            LocalID, _size, Scale, Density, _avatarVolume, RawMass, pos, vel);

        // do actual creation in taint time
        PhysScene.TaintedObject(LocalID, "BSCharacter.create", delegate()
        {
            DetailLog("{0},BSCharacter.create,taint", LocalID);

            // New body and shape into PhysBody and PhysShape
            PhysScene.Shapes.GetBodyAndShape(true, PhysScene.World, this);

            // The avatar's movement is controlled by this motor that speeds up and slows down
            //    the avatar seeking to reach the motor's target speed.
            // This motor runs as a prestep action for the avatar so it will keep the avatar
            //    standing as well as moving. Destruction of the avatar will destroy the pre-step action.
            m_moveActor = new BSActorAvatarMove(PhysScene, this, AvatarMoveActorName);
            PhysicalActors.Add(AvatarMoveActorName, m_moveActor);

            SetPhysicalProperties();

            IsInitialized = true;
        });
        return;
    }