Ejemplo n.º 1
0
    Vector3 ApplyElevation(Vector3 worldCoordinates, bool updateWheelEfficiency)
    {
        var x = worldCoordinates.x * 0.25f + m_planetGenerator.m_textureMapWidth * 0.5f - 0.5f;
        var y = worldCoordinates.z * 0.25f + m_planetGenerator.m_textureMapHeight * 0.5f - 0.5f;

        var groundElevation = m_planetGenerator.GetBicubicSmoothedElevation(x, y) * m_elevationScale;
        var waterElevation  = m_planetGenerator.m_waterElevation * m_elevationScale;
        var floatElevation  = waterElevation - m_floatDepth;

        worldCoordinates.y = Mathf.Max(floatElevation, groundElevation);

        if (updateWheelEfficiency)
        {
            m_wheelEfficiency   = Mathf.Clamp((worldCoordinates.y - floatElevation) / m_floatDepth, 0.0f, 1.0f);
            m_waterEffectAmount = Mathf.Pow(1.0f - m_wheelEfficiency, 2.0f);
            m_wheelEfficiency   = m_wheelEfficiency * 0.5f + 0.5f;
        }

        return(worldCoordinates);
    }
Ejemplo n.º 2
0
    public Vector3 ApplyElevation(Vector3 worldCoordinates, bool updateWheelEfficiency)
    {
        if (m_planetGenerator != null)
        {
            Tools.WorldToMapCoordinates(worldCoordinates, out var mapX, out var mapY, m_planetGenerator.m_textureMapWidth, m_planetGenerator.m_textureMapHeight);

            var groundElevation = m_planetGenerator.GetBicubicSmoothedElevation(mapX, mapY) * m_terrainGrid.m_elevationScale;
            var waterElevation  = m_planetGenerator.m_waterElevation * m_terrainGrid.m_elevationScale;

            worldCoordinates.y = Mathf.Max(waterElevation, groundElevation);
        }
        else
        {
            worldCoordinates.y = 0.0f;
        }

        return(worldCoordinates);
    }
Ejemplo n.º 3
0
    Vector3 GetVertexPosition(int i, float xScale, float yScale, float xOffset, float yOffset)
    {
        var vertex = m_vertices[i];

        var x = (vertex.x + m_gridOffset) / m_gridSize * xScale + xOffset;
        var z = (vertex.z + m_gridOffset) / m_gridSize * yScale + yOffset;

        x *= m_planetGenerator.m_textureMapWidth;
        z *= m_planetGenerator.m_textureMapHeight;

        var elevation = m_planetGenerator.GetBicubicSmoothedElevation(x, z);

        if (elevation < m_planetGenerator.m_waterElevation)
        {
            elevation = m_planetGenerator.m_waterElevation;
        }

        return(new Vector3(vertex.x, elevation * m_elevationScale, vertex.z));
    }