示例#1
0
        /// <summary>
        /// Scale region by a constant
        /// </summary>
        /// <param name="f"></param>
        /// <returns></returns>
        public Zone3 scale(float f)
        {
            Zone3 b = new Zone3();

            b.a = this.a * f;
            b.b = this.b * f;
            b.c = this.c * f;
            b.d = this.d * f;
            return(b);
        }
示例#2
0
        public void RenderOn(GameObject go)
        {
            //Create ranges for cubic faces
            float rad         = 1;
            Zone3 topRange    = new Zone3(new Vector3(-rad, rad, rad), new Vector3(rad, rad, rad), new Vector3(rad, rad, -rad), new Vector3(-rad, rad, -rad));
            Zone3 bottomRange = new Zone3(new Vector3(-rad, -rad, -rad), new Vector3(rad, -rad, -rad), new Vector3(rad, -rad, rad), new Vector3(-rad, -rad, rad));

            Zone3 frontRange = new Zone3(new Vector3(rad, rad, rad), new Vector3(-rad, rad, rad), new Vector3(-rad, -rad, rad), new Vector3(rad, -rad, rad));
            Zone3 backRange  = new Zone3(new Vector3(-rad, rad, -rad), new Vector3(rad, rad, -rad), new Vector3(rad, -rad, -rad), new Vector3(-rad, -rad, -rad));

            Zone3 rightRange = new Zone3(new Vector3(rad, rad, -rad), new Vector3(rad, rad, rad), new Vector3(rad, -rad, rad), new Vector3(rad, -rad, -rad));
            Zone3 leftRange  = new Zone3(new Vector3(-rad, rad, rad), new Vector3(-rad, rad, -rad), new Vector3(-rad, -rad, -rad), new Vector3(-rad, -rad, rad));

            if (config.generationService)
            {
                config.generationService.Init();
            }

            UpdateMaterial(go, true);

            this.topFace         = new PlanetFace(PlanetFaceDirection.Top, config.generationService, config.detailService, config.radius, config.highestQualityAtDistance, config.lodDepth, topRange, config.textureService);
            this.topFace.go.name = "Top";
            this.topFace.transform.SetParent(go.transform);
            this.topFace.transform.localPosition = Vector3.zero;

            this.bottomFace         = new PlanetFace(PlanetFaceDirection.Bottom, config.generationService, config.detailService, config.radius, config.highestQualityAtDistance, config.lodDepth, bottomRange, config.textureService);
            this.bottomFace.go.name = "Bottom";
            this.bottomFace.transform.SetParent(go.transform);
            this.bottomFace.transform.localPosition = Vector3.zero;

            this.leftFace         = new PlanetFace(PlanetFaceDirection.Left, config.generationService, config.detailService, config.radius, config.highestQualityAtDistance, config.lodDepth, leftRange, config.textureService);
            this.leftFace.go.name = "Left";
            this.leftFace.transform.SetParent(go.transform);
            this.leftFace.transform.localPosition = Vector3.zero;

            this.rightFace         = new PlanetFace(PlanetFaceDirection.Right, config.generationService, config.detailService, config.radius, config.highestQualityAtDistance, config.lodDepth, rightRange, config.textureService);
            this.rightFace.go.name = "Right";
            this.rightFace.transform.SetParent(go.transform);
            this.rightFace.transform.localPosition = Vector3.zero;

            this.backFace         = new PlanetFace(PlanetFaceDirection.Back, config.generationService, config.detailService, config.radius, config.highestQualityAtDistance, config.lodDepth, backRange, config.textureService);
            this.backFace.go.name = "Back";
            this.backFace.transform.SetParent(go.transform);
            this.backFace.transform.localPosition = Vector3.zero;

            this.frontFace         = new PlanetFace(PlanetFaceDirection.Front, config.generationService, config.detailService, config.radius, config.highestQualityAtDistance, config.lodDepth, frontRange, config.textureService);
            this.frontFace.go.name = "Front";
            this.frontFace.transform.SetParent(go.transform);
            this.frontFace.transform.localPosition = Vector3.zero;
        }
示例#3
0
        /// <summary>
        /// Subdivide this range into 4 quadrants
        /// </summary>
        /// <param name="NE">North east zone</param>
        /// <param name="NW">North west zone</param>
        /// <param name="SE">South east zone</param>
        /// <param name="SW">South west zone</param>
        public void QuadSubdivide(out Zone3 NE, out Zone3 NW, out Zone3 SE, out Zone3 SW)
        {
            //Create 4 subdivided ranges
            Vector3 topl = this.a;
            Vector3 topr = this.b;
            Vector3 btnl = this.d;
            Vector3 btnr = this.c;

            Vector3 tc = Vector3.Lerp(topl, topr, 0.5f);
            Vector3 lm = Vector3.Lerp(topl, btnl, 0.5f);
            Vector3 rm = Vector3.Lerp(topr, btnr, 0.5f);
            Vector3 mc = Vector3.Lerp(lm, rm, 0.5f);
            Vector3 bc = Vector3.Lerp(btnl, btnr, 0.5f);

            NW = new Zone3(topl, tc, mc, lm);
            NE = new Zone3(tc, topr, rm, mc);
            SW = new Zone3(lm, mc, bc, btnl);
            SE = new Zone3(mc, rm, btnr, bc);
        }
示例#4
0
        public PlanetFace(PlanetFaceDirection direction, IMeshService ms, IDetailer ds, float baseRadius, int minDistance, int treeDepth, Zone3 range, ITextureService textureService)
        {
            //Apply params
            this.direction       = direction;
            this.maxResolutionAt = minDistance;
            this.maxDepth        = treeDepth;
            this.textureService  = textureService;
            this.meshService     = ms;
            this.detailService   = ds;
            this.radius          = baseRadius;

            //Create Gameobjects
            go = new GameObject("PlanetFace");

            //Create quadtree
            root = new QuadNode <ChunkData>(range);
            Vector2 topLeft     = new Vector2(0, 1);
            Vector2 topRight    = new Vector2(1, 1);
            Vector2 bottomRight = new Vector2(1, 0);
            Vector2 bottomLeft  = new Vector2(0, 0);

            GenerateChunkdata(
                root,
                //Default zone for root quadnode - covers whole 0:1 range
                new Zone2(
                    topLeft,
                    topRight,
                    bottomRight,
                    bottomLeft
                    )
                );
        }
示例#5
0
 /// <summary>
 /// Create node covering area with value
 /// </summary>
 /// <param name="area"></param>
 /// <param name="value"></param>
 public QuadNode(Zone3 area, T value)
 {
     this.range = area;
     this.value = value;
 }
示例#6
0
 /// <summary>
 /// Create node covering area
 /// </summary>
 /// <param name="area"></param>
 public QuadNode(Zone3 area)
 {
     this.range = area;
 }