示例#1
0
文件: Planet.cs 项目: fulcircle/sagan
        public Planet(Sagan.Framework.Camera camera, int radius, int levels=2) : base(name: "SaganPlanet") {

            this._camera = camera;
            this.radius = radius;

            this.levels = levels;

            this._terrainSize = 2 * this.radius;

            // Add a cube to center our local origin around the cube faces we will be adding
            this._planetCube = new SaganCube("PlanetCube");
            this.AddChild(_planetCube);
            this._planetCube.transform.localScale = new Vector3(this._terrainSize, this._terrainSize, this._terrainSize);
            this._planetCube.visible = false;

            // Add our terrain faces to the cube
            // If the faces are splayed out, this is how they would look:
            //   4
            // 0 1 2 3
            //   5
            this.AddFace("Face 0", new Vector3(270, 0, 0), new Vector3(0, 0, -this.radius));
            this.AddFace("Face 1", new Vector3(270, 270, 0), new Vector3(this.radius, 0, 0));
            this.AddFace("Face 2", new Vector3(270, 180, 0), new Vector3(0, 0, this.radius));
            this.AddFace("Face 3", new Vector3(270, 90, 0), new Vector3(-this.radius, 0, 0));
            this.AddFace("Face 4", new Vector3(0, 270, 0), new Vector3(0, this.radius, 0));
            this.AddFace("Face 5", new Vector3(0, 90, 180), new Vector3(0, -this.radius, 0));

        }
示例#2
0
        public Terrain(int terrainSize, int levels, Camera cam) : base(name: "SaganTerrain") {
            this.levels = levels;

            // Add +1 to width and height of heightmap so bilinear interpolation of quad can interpolate extra data point beyond edge of quad
            this.heightMap = new HeightMap(terrainSize + 1);

            this.rootQuad = new Quad(1, terrainSize, terrainSize, this.heightMap);

            this.cam = cam;

        }