예제 #1
0
        public OdeCharacter(uint localID, String avName, ODEScene parent_scene, Vector3 pos, Vector3 pSize, float pfeetOffset, float density, float walk_divisor, float rundivisor)
        {
            m_uuid = UUID.Random();
            m_localID = localID;

            timeStep = parent_scene.ODE_STEPSIZE;
            invtimeStep = 1 / timeStep;

            if (pos.IsFinite())
            {
                if (pos.Z > 99999f)
                {
                    pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
                }
                if (pos.Z < -100f) // shouldn't this be 0 ?
                {
                    pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
                }
                _position = pos;
            }
            else
            {
                _position = new Vector3(((float)_parent_scene.WorldExtents.X * 0.5f), ((float)_parent_scene.WorldExtents.Y * 0.5f), parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f);
                m_log.Warn("[PHYSICS]: Got NaN Position on Character Create");
            }

            _parent_scene = parent_scene;


            m_size.X = pSize.X;
            m_size.Y = pSize.Y;
            m_size.Z = pSize.Z;

            if(m_size.X <0.01f)
                m_size.X = 0.01f;
            if(m_size.Y <0.01f)
                m_size.Y = 0.01f;
            if(m_size.Z <0.01f)
                m_size.Z = 0.01f;

            m_feetOffset = pfeetOffset;
            m_orientation = Quaternion.Identity;
            m_orientation2D = Quaternion.Identity;
            m_density = density;

            // force lower density for testing
            m_density = 3.0f;

            mu = parent_scene.AvatarFriction;

            walkDivisor = walk_divisor;
            runDivisor = rundivisor;

            m_mass = m_density * m_size.X * m_size.Y * m_size.Z; ; // sure we have a default           

            PID_D = basePID_D * m_mass * invtimeStep;
            PID_P = basePID_P * m_mass * invtimeStep;

            m_isPhysical = false; // current status: no ODE information exists

            Name = avName;

            AddChange(changes.Add, null);
        }