Пример #1
0
    public Segment(QuadTreePlanet planet, int resolution, float radius, Vector3 upDir)
    {
        // Creates a new instance of the meshData ready for molding
        meshData = new MeshData(resolution, GetComponent <MeshRenderer>(), GetComponent <MeshCollider>(), GetComponent <MeshFilter>(), upDir, transform, planet.noiseSettings);

        this.radius     = radius;
        this.resolution = resolution;

        this.planet = planet;
    }
Пример #2
0
 public void RemoveAllOf(QuadTreePlanet planet)
 {
     StopCoroutine(splitter);
     foreach (Segment s in Splittees)
     {
         if (s.planet == planet)
         {
             Splittees.Remove(s);
         }
     }
     foreach (Segment s in NextLoop)
     {
         if (s.planet == planet)
         {
             Splittees.Remove(s);
         }
     }
     splitter = StartCoroutine(SplitUp());
 }
Пример #3
0
    public void MakeSegment(QuadTreePlanet planet, int resolution, float radius, Vector3 upDir, int lod, Vector3 offset, Place place)
    {
        // Creates a new instance of the meshData ready for molding
        meshData = new MeshData(resolution, GetComponent <MeshRenderer>(), GetComponent <MeshCollider>(), GetComponent <MeshFilter>(), upDir, transform, planet.noiseSettings);
        // Generates Mesh
        meshData.Generate();
        // Offset Mesh To Right Position

        meshData.Offset(offset);
        meshData.Normalise();
        //Refenrce to know its plcase for prelaoding
        this.place = place;

        // Scakes the mesh to be size of radius
        meshData.Noise();
        if (lod > 1)
        {
            meshData.Scale(Vector3.one * (radius / Mathf.Pow(2, lod)));
            meshData.Scale(Vector3.one * Mathf.Pow(2, lod));
        }
        else
        {
            meshData.Scale(Vector3.one * radius);
        }



        this.upDir = upDir;

        //Temp Material
        meshData.SetMaterial(new Material(Shader.Find("Standard")));
        // Recalculate normals, set meshFilter/renderer etc...
        meshData.RefreshMesh();

        //meshData.SaveMesh();
        // Set this segments local variables
        this.radius     = radius;
        this.resolution = resolution;
        this.planet     = planet;
        this.lodLevel   = lod;
        this.offset     = offset;
    }