コード例 #1
0
    public ViewChunk[] View()
    {
        Point observerPoint = space.GetPointFromPosition(observer.position);

        if (view == null || !space.IsPointInRange(observerPoint, previousObserverPoint, updateDistace))
        {
            previousObserverPoint = observerPoint;
            view = GetVisible(observerPoint);
        }
        return(view);
    }
コード例 #2
0
    public Vector3 GetHeightAtPosition(Vector3 targetStartPosition)
    {
        Point   closestPoint  = space.GetPointFromPosition(targetStartPosition);
        float   heightValue   = terrain.GetValue(closestPoint);
        Vector3 surfaceNormal = space.GetNormalFromPosition(targetStartPosition);

        return(closestPoint.GetPosition() + surfaceNormal * heightValue);
    }
コード例 #3
0
    public FixedViewer(ChunkedSpace space, Vector3 origin, float distace, MeshLod?visibleLod = null)
    {
        Point originPoint = space.GetPointFromPosition(origin);

        Chunk[] chunks = space.GetChunksWithin(originPoint, distace);
        view = chunks
               .Select(chunk => new ViewChunk(chunk, visibleLod ?? new MeshLod(0)))
               .ToArray();
    }
コード例 #4
0
    public ViewChunk[] View()
    {
        Point observerPoint = space.GetPointFromPosition(observer.position);
        float altitude      = space.GetDistanceFromSurface(observer.position);

        if (view == null)
        {
            previousObserverPoint    = observerPoint;
            previousObserverAltitude = altitude;
            view = GetVisible(observerPoint);
            return(view);
        }
        bool pointIsOutsideUpdateDistance = !space.IsPointInRange(observerPoint, previousObserverPoint, updateDistace);
        // In this viewer we are also interesed in movement along the space normal
        bool normalDimensionIsOutsideUpdateDistance = Mathf.Abs(altitude - previousObserverAltitude) > updateDistace;

        if (pointIsOutsideUpdateDistance || normalDimensionIsOutsideUpdateDistance)
        {
            previousObserverPoint    = observerPoint;
            previousObserverAltitude = altitude;
            view = GetVisible(observerPoint);
        }
        return(view);
    }