Example #1
0
        /// <summary>
        /// Retourne des informations concernant la géographie de la cellule.
        /// </summary>
        /// <returns></returns>
        public Generation.ChunkGeography GetGeography()
        {
            Generation.ChunkGeography chunk = new Generation.ChunkGeography();
            float xMin = GridPosition.X;
            float yMin = GridPosition.Y;
            float xMax = xMin + Scale;
            float yMax = yMin + Scale;

            // Phi selon X
            chunk.PhiMin = xMin * (float)Math.PI * 2;
            chunk.PhiMax = xMax * (float)Math.PI * 2;

            // Theta selon Y
            chunk.ThetaMin = yMin * (float)Math.PI;
            chunk.ThetaMax = yMax * (float)Math.PI;

            return(chunk);
        }
Example #2
0
        /// <summary>
        /// Indique si cette cellule doit se diviser.
        /// </summary>
        /// <returns></returns>
        bool ShouldDivide()
        {
            if (EXPAND_ALL || m_depth < 3)
            {
                return(m_depth < MaxDepth);
            }

            // Condition nécessaire.
            bool depthOK = m_depth < MaxDepth;

            Generation.ChunkGeography chunk = GetGeography();
            Util.SphericalCoords      playerPlanetCoords = Util.SphericalCoords.FromCartesian(Scene.Instance.Camera.Position - PlanetPosition);
            Vector2 player = new Vector2(playerPlanetCoords.Theta, playerPlanetCoords.Phi);

            float factor = 1.005f + Math.Max(0, 8 - m_depth) * 0.007f;
            bool  thetaOK = player.X <chunk.ThetaMax *factor && player.X> chunk.ThetaMin / factor;
            bool  phiOK = player.Y <chunk.PhiMax *factor && player.Y> chunk.PhiMin / factor;
            bool  radiusOK = Math.Abs(playerPlanetCoords.Radius - PlanetRadius) < 1 + (MaxDepth - m_depth) * 1.5f; //playerPlanetCoords.Radius > PlanetRadius * 0.9f && playerPlanetCoords.Radius < PlanetRadius * 5;

            return(depthOK && (thetaOK && phiOK) && radiusOK);
        }
Example #3
0
        /// <summary>
        /// Indique si cette cellule doit se rétracter.
        /// </summary>
        /// <returns></returns>
        bool ShouldRetract()
        {
            if (EXPAND_ALL || Depth < 3)
            {
                return(false);
            }

            Generation.ChunkGeography chunk = GetGeography();
            Util.SphericalCoords      playerPlanetCoords = Util.SphericalCoords.FromCartesian(Scene.Instance.Camera.Position - PlanetPosition);
            Vector2 player = new Vector2(playerPlanetCoords.Theta, playerPlanetCoords.Phi);

            float factor = 1.3f + Math.Max(0, 5 - m_depth) * 0.100f;;
            bool  thetaOK = player.X <chunk.ThetaMax *factor && player.X> chunk.ThetaMin / factor;
            bool  phiOK = player.Y <chunk.PhiMax *factor && player.Y> chunk.PhiMin / factor;
            bool  radiusOK = Math.Abs(playerPlanetCoords.Radius - PlanetRadius) < 1 + (MaxDepth - m_depth) * 2.0f;

            return(!thetaOK || !phiOK || !radiusOK);

            /*float distance = ComputePlayerDistance();
             * float diagLength = Vector2.Distance(Util.MathHelper.ReduceXY(Bounds.Minimum), Util.MathHelper.ReduceXY(Bounds.Maximum));*/
            // return distance > diagLength * RETRACT_FACTOR && !m_isRetracting && !m_isExpanding;
        }
Example #4
0
        /// <summary>
        /// Retourne des informations concernant la géographie de la cellule.
        /// </summary>
        /// <returns></returns>
        public Generation.ChunkGeography GetGeography()
        {
            Generation.ChunkGeography chunk = new Generation.ChunkGeography();
            float xMin = GridPosition.X;
            float yMin = GridPosition.Y;
            float xMax = xMin + Scale;
            float yMax = yMin + Scale;

            // Phi selon X
            chunk.PhiMin = xMin * (float)Math.PI * 2;
            chunk.PhiMax = xMax * (float)Math.PI * 2;

            // Theta selon Y
            chunk.ThetaMin = yMin * (float)Math.PI;
            chunk.ThetaMax = yMax * (float)Math.PI;

            return chunk;
        }