Exemplo n.º 1
0
        //Update the current chunk
        public void UpdateChunk()
        {
            if (!hasGenerated)
            {
                GenerateChunk();
            }

            if (hasData)
            {
                //GET LOD INDEX HERE!

                //Fetch the mesh or request it if not found
                if (lodIndex != previousLodIndex)
                {
                    LodData lodMesh = lodMeshes[lodIndex];
                    if (lodMesh.hasMesh)
                    {
                        previousLodIndex            = lodIndex;
                        meshFilter.mesh             = lodMesh.mesh;
                        meshCollider.sharedMesh     = lodMesh.mesh;
                        meshRenderer.sharedMaterial = planet.graphicalSettings.planetMaterial;
                    }
                    else if (!lodMesh.hasRequestedMesh)
                    {
                        lodMesh.RequestMesh(this);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public Chunk(Planet planet, Face face, int u, int v)
        {
            this.planet          = planet;
            this.face            = face;
            this.faceCoord       = new IUV(face.index, u, v);
            this.planetGenerator = planet.PlanetGenerator;

            CalculateCentre(planet.faceResolution, planet.radius);

            //Add lod levels based on planet presets
            lodMeshes = new LodData[planet.detailLevels.Length];
            for (int i = 0; i < planet.detailLevels.Length; i++)
            {
                lodMeshes[i] = new LodData(planet.detailLevels[i].lod, UpdateChunk, planetGenerator);
            }

            //Debug.Log("Chunk [" + iuv.x + "," + iuv.y + "," + iuv.z + "] has been constructed");
        }