Exemplo n.º 1
0
        public static GameObject CreateOcean(GameObject sphere, SphereProperties sphereProps, OceanProperties oceanProps)
        {
            GameObject oceanObj = SphereGenerator.GenPrimitive (sphereProps);
            MeshRenderer r = oceanObj.AddComponent<MeshRenderer>();
            r.material = oceanProps.material;
            r.material.mainTexture = oceanProps.texture;
            r.material.mainTextureScale = oceanProps.textureScale;
            oceanObj.transform.position = sphere.transform.position;
            oceanObj.transform.localScale = oceanProps.scale;

            return oceanObj;
        }
Exemplo n.º 2
0
        public static Planet GeneratePlanet(string planetName, PlanetProperties planetProps, OceanProperties oceanProps = null)
        {
            SphereProperties sp = PlanetGen.defaultLandSphereProps.shallowClone();
            sp.radius = planetProps.radius;

            GameObject sphere = SphereGenerator.GenPrimitive (sp);
            Planet planet = sphere.AddComponent<Planet>();
            planet.SetLand (sphere);
            planet.SetName (planetName);

            if (oceanProps != null) {
                SphereProperties osp = PlanetGen.defaultOceanSphereProps.shallowClone();
                osp.radius = planetProps.radius;
                GameObject ocean = PlanetGen.CreateOcean (sphere, osp, oceanProps);
                planet.SetOcean (ocean);
            }

            PlanetGen.ApplyMaterial(sphere, planetProps);
            if (planetProps.applySubdivide) {
                SphereGenerator.Subdivide (sphere, planetProps.landSubTexture, 1);
            }
            if (planetProps.applyHeightmap) {
                SphereGenerator.ApplyHeightMap(sphere, planetProps.heightScaleFactor, planetProps.landHeightTexture);
            }

            return planet;
        }