Ejemplo n.º 1
0
        // TODO: push this data in through the constructor, probably in a QuadMeshDefintion class, and make
        // this method private.  Except that would do real work in construction.  Hmmm.
        public void Initialize(double planetRadius, DoubleVector3 planeNormalVector, DoubleVector3 uVector, DoubleVector3 vVector, QuadNodeExtents extents, int level)
        {
            _planetRadius = planetRadius;
            _extents      = extents;

            // TODO: get this from the QuadNode instead
            _locationRelativeToPlanet = (planeNormalVector) + (uVector * (_extents.North + (_extents.Width / 2.0))) + (vVector * (_extents.West + (_extents.Width / 2.0)));
            _locationRelativeToPlanet = _locationRelativeToPlanet.ProjectUnitPlaneToUnitSphere() * _planetRadius;

            // TODO: cover this in specs
            _boundingBox.Min = new Vector3(float.MaxValue);
            _boundingBox.Max = new Vector3(float.MinValue);

            GenerateIndices();
            var heightmap = _generator.GenerateHeightmapSamples(new HeightmapDefinition()
            {
                GridSize          = _gridSize,
                Stride            = extents.Width / (_gridSize - 1),
                PlaneNormalVector = planeNormalVector,
                UVector           = uVector,
                VVector           = vVector,
                Extents           = _extents,
                QuadLevel         = level,
                PlanetRadius      = planetRadius
            });
            var vertices = GenerateMeshVertices(heightmap);

            CollectHeightmapSamples(heightmap);

            _renderer.Initialize(vertices, _indices, _boundingBox);
        }
Ejemplo n.º 2
0
        // TODO: push this data in through the constructor, probably in a QuadMeshDefintion class, and make
        // this method private.  Except that would do real work in construction.  Hmmm.
        public void Initialize(double planetRadius, DoubleVector3 planeNormalVector, DoubleVector3 uVector, DoubleVector3 vVector, QuadNodeExtents extents, int level)
        {
            _planetRadius      = planetRadius;
            _planeNormalVector = planeNormalVector;
            _uVector           = uVector;
            _vVector           = vVector;
            _extents           = extents;
            _level             = level;

            // TODO: get this from the QuadNode instead
            _locationRelativeToPlanet = (_planeNormalVector) + (_uVector * (_extents.North + (_extents.Width / 2.0))) + (_vVector * (_extents.West + (_extents.Width / 2.0)));
            _locationRelativeToPlanet = _locationRelativeToPlanet.ProjectUnitPlaneToUnitSphere() * _planetRadius;

            _meshStride = _extents.Width / (_gridSize - 1);

            // TODO: cover this in specs
            _boundingBox.Min = new Vector3(float.MaxValue);
            _boundingBox.Max = new Vector3(float.MinValue);

            GenerateIndices();
            GenerateMeshVertices();
            CollectMeshSamples();

            _renderer.Initialize(_vertices, _indices, _boundingBox);

            TrimUnneededMemory();
        }
Ejemplo n.º 3
0
        // TODO: push this data in through the constructor, probably in a QuadNodeDefintion class, and make
        // this method private.  Except that would do real work in construction.  Hmmm.
        public void Initialize(double planetRadius, DoubleVector3 planeNormalVector, DoubleVector3 uVector, DoubleVector3 vVector, QuadNodeExtents extents, int level)
        {
            _planetRadius      = planetRadius;
            _planeNormalVector = planeNormalVector;
            _uVector           = uVector;
            _vVector           = vVector;
            _extents           = extents;
            Level = level;

            _locationRelativeToPlanet = (_planeNormalVector) + (_uVector * (_extents.North + (_extents.Width / 2.0))) + (_vVector * (_extents.West + (_extents.Width / 2.0)));
            _locationRelativeToPlanet = _locationRelativeToPlanet.ProjectUnitPlaneToUnitSphere() * _planetRadius;

            _mesh.Initialize(planetRadius, planeNormalVector, uVector, vVector, extents, level);

            Interlocked.Increment(ref _statistics.NumberOfQuadNodes);
            Interlocked.Increment(ref _statistics.NumberOfQuadNodesAtLevel[Level]);
        }