예제 #1
0
        IndexPosition ShiftIPos(IndexPosition ipos, CubeSide normal)
        {
            switch (normal)
            {
            case CubeSide.Back:
                ipos.Z++; break;

            case CubeSide.Bottom:
                ipos.Y--; break;

            case CubeSide.Front:
                ipos.Z--; break;

            case CubeSide.Left:
                ipos.X--; break;

            case CubeSide.Right:
                ipos.X++; break;

            case CubeSide.Top:
                ipos.Y++; break;
            }

            return(ipos);
        }
예제 #2
0
        } //END GetLoadedBool

        //-----------------------------//
        private void SetLoadedBool( CameraType cameraType, CubeSide cubeSide, bool loaded )
        //-----------------------------//
        {

            if( cameraType == CameraType.Left )
            {
                if( cubeSide == CubeSide.front )
                {
                    bool_Left_front_loaded = loaded;
                }
                else if( cubeSide == CubeSide.back )
                {
                    bool_Left_back_loaded = loaded;
                }
                else if( cubeSide == CubeSide.left )
                {
                    bool_Left_left_loaded = loaded;
                }
                else if( cubeSide == CubeSide.right )
                {
                    bool_Left_right_loaded = loaded;
                }
                else if( cubeSide == CubeSide.top )
                {
                    bool_Left_top_loaded = loaded;
                }
                else if( cubeSide == CubeSide.bottom )
                {
                    bool_Left_bottom_loaded = loaded;
                }
            }
            else if( cameraType == CameraType.Right )
            {
                if( cubeSide == CubeSide.front )
                {
                    bool_Right_front_loaded = loaded;
                }
                else if( cubeSide == CubeSide.back )
                {
                    bool_Right_back_loaded = loaded;
                }
                else if( cubeSide == CubeSide.left )
                {
                    bool_Right_left_loaded = loaded;
                }
                else if( cubeSide == CubeSide.right )
                {
                    bool_Right_right_loaded = loaded;
                }
                else if( cubeSide == CubeSide.top )
                {
                    bool_Right_top_loaded = loaded;
                }
                else if( cubeSide == CubeSide.bottom )
                {
                    bool_Right_bottom_loaded = loaded;
                }
            }

        } //END SetLoadedBool
예제 #3
0
 public bool FindSideByPoint(Point point, Scene scene, Matrix parentWorld,
     out CubeCoords coords, out CubeSide side)
 {
     var worldView = view.World * World * parentWorld * scene.View;
     return view.FindSideByPoint(point, scene, worldView, scene.Projection,
         out coords, out side);
 }
예제 #4
0
    private void SetData(CubeSide side, Texture2D txt)
    {
        Color[] pixels = (txt.GetPixels(0, 0, count, count));
        bool[]  data   = new bool[count * count];

        for (int y = 0; y < count; y++)
        {
            for (int x = 0; x < count; x++)
            {
                if (GetWallHight(pixels[x + ((y) * (Count))]) <= 0.5f)
                {
                    data[(y * count) + x] = true;
                }
                else
                {
                    data[(y * count) + x] = false;
                }
            }
        }

        if (sideData.ContainsKey(side))
        {
            sideData[side] = data;
        }
        else
        {
            sideData.Add(side, data);
        }

        if (onDataSet != null)
        {
            onDataSet();
        }
    }
예제 #5
0
    public Vector2 PosToCoord(CubeSide side, Vector3 pos)
    {
        Vector2 ret = Vector2.zero;
        Vector3 p   = GetGridCoords(pos, true);

        switch (side)
        {
        case CubeSide.bottom:
            ret = new Vector2(p.x, p.z);
            break;

        case CubeSide.left:
            ret = new Vector2(p.z, p.y);
            break;

        case CubeSide.front:
            ret = new Vector2(p.x, p.y);
            break;

        case CubeSide.top:
            ret = new Vector2(p.x, p.z);
            break;

        case CubeSide.right:
            ret = new Vector2(p.z, p.y);
            break;

        case CubeSide.back:
            ret = new Vector2(p.x, p.y);
            break;
        }

        return(ret);
    }
예제 #6
0
        } //END SetStreamingAssetsLoadedTexture


        //-----------------------------//
        private void SetLoadedTextureScaleAndSettings( CameraType cameraType, CubeSide cubeSide, TextureFormat format, bool useMipmap, int scaleX, int scaleY )
        //-----------------------------//
        {

            if( cameraType == CameraType.Left )
            {
                if( cubeSide == CubeSide.front )
                {
                    texture_Left_front = new Texture2D( scaleX, scaleY, format, useMipmap ); //, format, useMipmap );
                }
                else if( cubeSide == CubeSide.back )
                {
                    texture_Left_back = new Texture2D( scaleX, scaleY, format, useMipmap );
                }
                else if( cubeSide == CubeSide.left )
                {
                    texture_Left_left = new Texture2D( scaleX, scaleY, format, useMipmap );
                }
                else if( cubeSide == CubeSide.right )
                {
                    texture_Left_right = new Texture2D( scaleX, scaleY, format, useMipmap );
                }
                else if( cubeSide == CubeSide.top )
                {
                    texture_Left_top = new Texture2D( scaleX, scaleY, format, useMipmap );
                }
                else if( cubeSide == CubeSide.bottom )
                {
                    texture_Left_bottom = new Texture2D( scaleX, scaleY, format, useMipmap );
                }
            }
            else if( cameraType == CameraType.Right )
            {
                if( cubeSide == CubeSide.front )
                {
                    texture_Right_front = new Texture2D( scaleX, scaleY, format, useMipmap );
                }
                else if( cubeSide == CubeSide.back )
                {
                    texture_Right_back = new Texture2D( scaleX, scaleY, format, useMipmap );
                }
                else if( cubeSide == CubeSide.left )
                {
                    texture_Right_left = new Texture2D( scaleX, scaleY, format, useMipmap );
                }
                else if( cubeSide == CubeSide.right )
                {
                    texture_Right_right = new Texture2D( scaleX, scaleY, format, useMipmap );
                }
                else if( cubeSide == CubeSide.top )
                {
                    texture_Right_top = new Texture2D( scaleX, scaleY, format, useMipmap );
                }
                else if( cubeSide == CubeSide.bottom )
                {
                    texture_Right_bottom = new Texture2D( scaleX, scaleY, format, useMipmap );
                }
            }

        } //END SetLoadedTextureScale
예제 #7
0
 private bool LightCanAffectFace(BlockSpacePosition samplePosition, BlockSpacePosition lightPosition,
                                 CubeSide sampleSide)
 {
     if (sampleSide == CubeSide.Bottom)
     {
         return(lightPosition.y < samplePosition.y);
     }
     else if (sampleSide == CubeSide.Top)
     {
         return(lightPosition.y > samplePosition.y);
     }
     else if (sampleSide == CubeSide.West)
     {
         return(lightPosition.x < samplePosition.x);
     }
     else if (sampleSide == CubeSide.East)
     {
         return(lightPosition.x > samplePosition.x);
     }
     else if (sampleSide == CubeSide.North)
     {
         return(lightPosition.z < samplePosition.z);
     }
     else if (sampleSide == CubeSide.South)
     {
         return(lightPosition.z > samplePosition.z);
     }
     return(false);
 }
예제 #8
0
        } //END SetLoadedTextureScale


        //-----------------------------//
        private void SetLoadedTextureWrapMode( CameraType cameraType, CubeSide cubeSide, TextureWrapMode wrapMode )
        //-----------------------------//
        {

            if( cameraType == CameraType.Left )
            {
                if( cubeSide == CubeSide.front )
                {
                    texture_Left_front.wrapMode = wrapMode;
                }
                else if( cubeSide == CubeSide.back )
                {
                    texture_Left_back.wrapMode = wrapMode;
                }
                else if( cubeSide == CubeSide.left )
                {
                    texture_Left_left.wrapMode = wrapMode;
                }
                else if( cubeSide == CubeSide.right )
                {
                    texture_Left_right.wrapMode = wrapMode;
                }
                else if( cubeSide == CubeSide.top )
                {
                    texture_Left_top.wrapMode = wrapMode;
                }
                else if( cubeSide == CubeSide.bottom )
                {
                    texture_Left_bottom.wrapMode = wrapMode;
                }
            }
            else if( cameraType == CameraType.Right )
            {
                if( cubeSide == CubeSide.front )
                {
                    texture_Right_front.wrapMode = wrapMode;
                }
                else if( cubeSide == CubeSide.back )
                {
                    texture_Right_back.wrapMode = wrapMode;
                }
                else if( cubeSide == CubeSide.left )
                {
                    texture_Right_left.wrapMode = wrapMode;
                }
                else if( cubeSide == CubeSide.right )
                {
                    texture_Right_right.wrapMode = wrapMode;
                }
                else if( cubeSide == CubeSide.top )
                {
                    texture_Right_top.wrapMode = wrapMode;
                }
                else if( cubeSide == CubeSide.bottom )
                {
                    texture_Right_bottom.wrapMode = wrapMode;
                }
            }

        } //END SetLoadedTextureWrapMode
예제 #9
0
        /// <summary>
        /// Rotates the colors only on the surface of the side.
        /// </summary>
        private void RotateFace(CubeSide side, Rotation rotation)
        {
            var faceToRotate = GetFaceColors(side);
            var newFace      = new Color[3, 3];

            if (rotation == Rotation.Cw)
            {
                for (int i = 2; i >= 0; i--)
                {
                    for (int i2 = 0; i2 < 3; i2++)
                    {
                        newFace[i2, 2 - i] = faceToRotate[i, i2];
                    }
                }
            }
            else
            {
                for (int i = 2; i >= 0; i--)
                {
                    for (int i2 = 0; i2 < 3; i2++)
                    {
                        newFace[2 - i, i2] = faceToRotate[i2, i];
                    }
                }
            }

            SetSide(side, newFace);
        }
예제 #10
0
    //Возвращает цвет стороны, противоположный указанному
    private CubeSide GetOppositeSide(CubeSide side)
    {
        switch (side)
        {
        case CubeSide.White:
            return(CubeSide.Yellow);

        case CubeSide.Yellow:
            return(CubeSide.White);

        case CubeSide.Blue:
            return(CubeSide.Red);

        case CubeSide.Red:
            return(CubeSide.Blue);

        case CubeSide.Green:
            return(CubeSide.Orange);

        case CubeSide.Orange:
            return(CubeSide.Green);

        default:
            return(CubeSide.White);
        }
    }
예제 #11
0
        private static void SetCubeSide(ref SmallCube cube, CubeSide side, int value)
        {
            if (cube == null)
                cube = new SmallCube();

            cube[side] = value;
        }
예제 #12
0
        public ColorTag PrepareChange(CubeSide cubeSide)
        {
            _preparedCubeSide = cubeSide;
            _changesPrepared  = true;

            return(this);
        }
예제 #13
0
    public Texture GetTextureFromCubeSide(CubeSide side)
    {
        switch (side)
        {
        case CubeSide.bottom: {
            return(bottomMap);
        }

        case CubeSide.top: {
            return(topMap);
        }

        case CubeSide.front: {
            return(frontMap);
        }

        case CubeSide.back: {
            return(backMap);
        }

        case CubeSide.left: {
            return(leftMap);
        }

        case CubeSide.right: {
            return(rightMap);
        }
        }
        return(null);
    }
예제 #14
0
        public static Vector3 CubeSideToSurfaceNormal(CubeSide side)
        {
            if (side == CubeSide.Left)
            {
                return(-Vector3.UnitX);
            }
            if (side == CubeSide.Right)
            {
                return(Vector3.UnitX);
            }
            if (side == CubeSide.Top)
            {
                return(Vector3.UnitY);
            }
            if (side == CubeSide.Bottom)
            {
                return(-Vector3.UnitY);
            }
            if (side == CubeSide.Back)
            {
                return(Vector3.UnitZ);
            }
            if (side == CubeSide.Front)
            {
                return(-Vector3.UnitZ);
            }

            return(Vector3.Zero);
        }
예제 #15
0
 /// <summary>
 /// Runs a raytrace for a collision.
 /// </summary>
 /// <returns><c>true</c> if there was a collision</returns>
 /// <param name="origin">Point for the raytrace to start at.</param>
 /// <param name="endpoint">Point for the raytrace to end at.</param>
 /// <param name="endpointSide">Which side of the endpoint to target.</param>
 /// <param name="ignoreStartAndEnd">
 /// Whether to ignore blocks that are actually within the start and end point. You can enable this if you
 /// actually only care about what is between two blocks, but not the blocks themselves.
 /// </param>
 /// <param name="reverseScan">If set to <c>true</c>, it will scan from the endpoint towards the origin.</param>
 public static bool RaytraceCollision(BlockSpacePosition origin, BlockSpacePosition endpoint,
                                      CubeSide endpointSide,
                                      bool ignoreStartAndEnd,
                                      bool reverseScan)
 {
     return(Instance().RaytraceCollision(origin, endpoint, endpointSide, ignoreStartAndEnd, reverseScan));
 }
예제 #16
0
 private void Start()
 {
     _northSide = new CubeSide(@"C:\Users\Lisa\Documents\PlaceTreeRings\NewYOutput", NorthMat);
     _southSide = new CubeSide(@"C:\Users\Lisa\Documents\PlaceTreeRings\NewYOutput", SouthMat);
     _eastSide  = new CubeSide(@"C:\Users\Lisa\Documents\PlaceTreeRings\NewXOutput", EastMat);
     _westSide  = new CubeSide(@"C:\Users\Lisa\Documents\PlaceTreeRings\NewXOutput", WestMat);
 }
예제 #17
0
        public void Update(float deltaTime)
        {
            UI.Update(deltaTime);

            if (Model != null)
            {
                Ray           MouseRay = Camera.Active.MouseRay;
                IndexPosition blockNormalOffsetIndex = IndexPosition.Zero;
                IndexPosition MouseIndexPos          = IndexPosition.Zero;
                CubeSide      ModelSide     = CubeSide.Bottom;
                Vector3       normal        = Vector3.Zero;
                bool          intersections = false;
                Color         voxelColor    = new Color(236, 157, 196);

                if (intersections = Model.RayIntersects(MouseRay, out MouseIndexPos, out ModelSide))
                {
                    normal = Maths.CubeSideToSurfaceNormal(ModelSide);
                    blockNormalOffsetIndex = new IndexPosition(
                        MouseIndexPos.X + (int)normal.X,
                        MouseIndexPos.Y + (int)normal.Y,
                        MouseIndexPos.Z + (int)normal.Z);
                }
                if (Model.IsBlockCoordInRange(MouseIndexPos) && intersections)
                {
                    if (Input.GetMouseButtonDown(MouseButton.Left))
                    {
                        Model.ChangeBlock(blockNormalOffsetIndex, new Block(1,
                                                                            voxelColor.R, voxelColor.G, voxelColor.B));
                    }
                }
            }
        }
예제 #18
0
    private void ReadSpawnsForSide(CubeSide side, Texture t)
    {
        Color[] pixels = ((Texture2D)t).GetPixels(0, 0, GridSystem.System.Count, GridSystem.System.Count);
        for (int y = 0; y < GridSystem.System.Count; y++)
        {
            for (int x = 0; x < GridSystem.System.Count; x++)
            {
                if (GridSystem.System.GetWallHight(pixels[(y * GridSystem.System.Count) + x]) >= 0.5f)
                {
                    if (!spawnpositions.ContainsKey(side))
                    {
                        List <Vector2> tmp = new List <Vector2>();
                        tmp.Add(new Vector2(x, y));
                        spawnpositions.Add(side, tmp);
                    }
                    else
                    {
                        spawnpositions[side].Add(new Vector2(x, y));
                    }
                    //MonoBehaviour.print("s: " + side.ToString() + ", " + new Vector2(x, y));
                }
            }
        }

        MonoBehaviour.print("(item)side: " + side + ", count: " + spawnpositions[side].Count);

        spawnedBerries.Add(side, new List <bool>());
        for (int i = 0; i < spawnpositions[side].Count; i++)
        {
            spawnedBerries[side].Add(false);
        }
    }
예제 #19
0
    protected Transform GetSpawnPoint()
    {
        List <Transform> tempSpawnPoints = new List <Transform>();

        for (int i = 0; i < m_SpawnPoints.Count; i++)
        {
            Transform spawnTransform = m_SpawnPoints [i].transform;
            Vector3   checkLocation  = spawnTransform.position + 1.3f * spawnTransform.up;
            CubeSide  spawnCubeSide  = m_SpawnPoints [i].GetComponent <TDSpawnPointSide> ().m_CubeSide;
            CubeSide  playerCubeSide = Camera.main.GetComponent <TDCameraControl> ().m_CubeSide;

            if (!Physics.CheckBox(checkLocation, m_CheckBoxSize, spawnTransform.rotation) && spawnCubeSide != playerCubeSide)
            {
                tempSpawnPoints.Add(m_SpawnPoints [i]);
            }
        }

        if (tempSpawnPoints.Count > 0)
        {
            int spawnRandom = Random.Range(0, tempSpawnPoints.Count);
            return(tempSpawnPoints [spawnRandom]);
        }
        else
        {
            return(null);
        }
    }
예제 #20
0
        public override void Update(EditorWorldRaycastResult intersection, float deltaTime)
        {
            if (intersection.HitTerrain)
            {
                TerrainRaycastResult terrainIntersection = intersection.TerrainResult;

                if (!TerrainEditor.IsSelecting)
                {
                    lastNonSelectingNormal = terrainIntersection.IntersectionCubeSide.Value;
                }

                if (TerrainEditor.IsSelecting && Input.GetMouseButtonUp(MouseButton.Left))
                {
                    ApplyActionToSelection(TerrainEditor.SelectionBox,
                                           (chunk, blockPos) =>
                    {
                        Block block = Block.CUSTOM;
                        Color color = TerrainEditor.BlockColor;
                        block.R     = color.R;
                        block.G     = color.G;
                        block.B     = color.B;

                        TerrainEditor.SetBlock(chunk, block, blockPos);
                    });
                }
            }
        }
예제 #21
0
    public Vector2 GetRandomBerry(CubeSide side)
    {
        Vector2 ret = Vector2.zero;

        if (spawnpositions.ContainsKey(side))
        {
            int wantedIndex = Random.Range(0, Random.Range(0, spawnpositions[side].Count));
            if (spawnpositions.ContainsKey(side) && spawnedBerries.ContainsKey(side))
            {
                for (int i = 0; i < spawnpositions[side].Count; i++)
                {
                    try {
                        ret = spawnpositions[side][Random.Range(0, spawnpositions[side].Count - 1)];
                        if (i == wantedIndex && spawnedBerries[side][i])
                        {
                            break;
                        }
                    }
                    catch { }
                }
            }
            else
            {
                return(Vector2.zero);
            }
            return(ret);
        }
        else
        {
            return(Vector2.zero);
        }
    }
예제 #22
0
        } //END DestroyDuplicateInstance

        //-------------------------------//
        public void BeginLoadingTexture( CameraType cameraType, CubeSide cubeSide, ImageType imageType )
        //-------------------------------//
        {

            SetLoadedBool( cameraType, cubeSide, false );

            //if( showDebug ) { Debug.Log( "ImageFactory.cs BeginLoadingTexture() ( " + cameraType + ", " + cubeSide + ", " + imageType + " )" ); }

            if( XRSkyboxManager.instance.loadFrom == XRSkyboxManager.LoadFrom.DictionaryTexture )
            {
                SetDictionaryLoadedTexture( cameraType, cubeSide, imageType );
            }
            else if( XRSkyboxManager.instance.loadFrom == XRSkyboxManager.LoadFrom.ResourcesTexture )
            {
                SetTextureFromResourcesTexture( cameraType, cubeSide, imageType );
            }
            else if( XRSkyboxManager.instance.loadFrom == XRSkyboxManager.LoadFrom.ResourcesBytes )
            {
                StartCoroutine( SetTextureFromResourcesBytes( cameraType, cubeSide, imageType ) );
            }
            else if( XRSkyboxManager.instance.loadFrom == XRSkyboxManager.LoadFrom.StreamingAssetsBytes )
            {
                StartCoroutine( SetTextureFromStreamingAssetsBytes( cameraType, cubeSide, imageType ) );
            }

        } //END BeginLoadingTexture
예제 #23
0
파일: IOMap.cs 프로젝트: NeatWolf/PiTUNG
        public IOMap SetSide(CubeSide side, SideType what, float ox, float oy, string description)
        {
            Sides.Add(new IO(side, what, ox, oy, description));
            Changed?.Invoke(this, EventArgs.Empty);

            return(this);
        }
예제 #24
0
        private bool GetBottom(Transform cubeBase, out CubeSide onFloor)
        {
            var bottom = Vector3.up * -1;

            if (bottom == cubeBase.forward)
            {
                onFloor = CubeSide.Front;
            }
            else if (bottom == cubeBase.forward * -1)
            {
                onFloor = CubeSide.Back;
            }
            else if (bottom == cubeBase.up)
            {
                onFloor = CubeSide.Up;
            }
            else if (bottom == cubeBase.up * -1)
            {
                onFloor = CubeSide.Down;
            }
            else if (bottom == cubeBase.right)
            {
                onFloor = CubeSide.Right;
            }
            else if (bottom == cubeBase.right * -1)
            {
                onFloor = CubeSide.Left;
            }
            else
            {
                onFloor = CubeSide.Down;
                return(false);
            }
            return(true);
        }
예제 #25
0
    public Vector3 GetPlaneNormal(CubeSide side, NormalSide towards = NormalSide.inside)
    {
        switch (side)
        {
        case CubeSide.bottom: {
            return(-(transform.TransformPoint(0, 0, 0) - transform.TransformPoint(0, Count, 0)).normalized);
        }

        case CubeSide.top: {
            return((transform.TransformPoint(0, 0, 0) - transform.TransformPoint(0, Count, 0)).normalized);
        }

        case CubeSide.left: {
            return(-(transform.TransformPoint(0, 0, 0) - transform.TransformPoint(Count, 0, 0)).normalized);
        }

        case CubeSide.right: {
            return((transform.TransformPoint(0, 0, 0) - transform.TransformPoint(Count, 0, 0)).normalized);
        }

        case CubeSide.front: {
            return((transform.TransformPoint(0, 0, 0) - transform.TransformPoint(0, 0, Count)).normalized);
        }

        case CubeSide.back: {
            return(-(transform.TransformPoint(0, 0, 0) - transform.TransformPoint(0, 0, Count)).normalized);
        }
        }
        return(Vector3.zero);
    }
예제 #26
0
        public static Vector3 GetNormalFromSide(CubeSide side)
        {
            switch (side)
            {
            case CubeSide.Left:
                return(Vector3.Left);

            case CubeSide.Right:
                return(Vector3.Right);

            case CubeSide.Up:
                return(Vector3.Up);

            case CubeSide.Down:
                return(Vector3.Down);

            case CubeSide.Front:
                return(Vector3.Backward);

            case CubeSide.Back:
                return(Vector3.Forward);

            default:
                throw new ArgumentException("Invalid side value.", "side");
            }
        }
예제 #27
0
        public virtual BlockTextureSlot GetTextureSlot(CubeSide side, bool blockAbove, bool blockBelow, byte lightValue)
        {
            BlockTextureSlot slot;

            slot.x = textureSlot.x;
            slot.y = textureSlot.y;
            return(slot);
        }
예제 #28
0
 public void ExecChanges()
 {
     if (_changesPrepared)
     {
         CubeSide         = _preparedCubeSide;
         _changesPrepared = false;
     }
 }
 public void SetRotation(CubeSide cubeSide)
 {
     if (inRotation == false)
     {
         inRotation = true;
         _rotation  = cubeSide;
     }
 }
예제 #30
0
파일: IOMap.cs 프로젝트: NeatWolf/PiTUNG
 public IO(CubeSide side, SideType type, float xOffset, float yOffset, string description)
 {
     this.Side        = side;
     this.Type        = type;
     this.XOffset     = xOffset;
     this.YOffset     = yOffset;
     this.Description = description;
 }
예제 #31
0
 public Cube(CubeSide side1, CubeSide side2, CubeSide side3, CubeSide side4, CubeSide side5, CubeSide side6)
 {
     this._side1 = side1;
     this._side2 = side2;
     this._side3 = side3;
     this._side4 = side4;
     this._side5 = side5;
     this._side6 = side6;
 }
예제 #32
0
        public void Rotate(Orientation orientation)
        {
            switch (orientation)
            {
                case Orientation.North:

                    CubeSide tempSide = _side1;
                    _side1 = _side2;
                    _side2 = _side3;
                    _side3 = _side4;
                    _side4 = tempSide;

                    break;

                case Orientation.East:
                    CubeSide eastTempSide = _side1;
                    _side1 = _side5;
                    _side5 = _side3;
                    _side3 = _side6;
                    _side6 = eastTempSide;
                    break;

                case Orientation.South:

                    CubeSide southTempSide = _side1;
                    _side1 = _side4;
                    _side4 = _side3;
                    _side3 = _side2;
                    _side2 = southTempSide;

                    break;

                case Orientation.West:
                    CubeSide westTemp = _side1;
                    _side1 = _side5;
                    _side5 = _side3;
                    _side3 = _side6;
                    _side6 = westTemp;
                    break;
            }
        }
            public void Link( CubeSide left, CubeSide top, CubeSide right, CubeSide bottom )
            {
                int res = m_Resolution;
                for ( int col = 0; col < res; ++col )
                {
                //	TerrainPatch.LinkTopAndBottomPatches( top[ col, res - 1 ], this[ col, 0 ] );
                //	TerrainPatch.LinkTopAndBottomPatches( this[ col, res - 1 ], bottom[ res - ( col + 1 ), res - 1 ] );

                //	TerrainPatch.LinkLeftAndRightPatches( left[ res - 1, col ], this[ 0, col ] );
                //	TerrainPatch.LinkLeftAndRightPatches( this[ 0, col ], right[ res - 1, col ] );
                }
            }
        public PlanetTerrainRenderer( )
        {
            IEffect effect = ( IEffect )AssetManager.Instance.Load( "Effects/Planets/terrestrialPlanetTerrain.cgfx" );
            TechniqueSelector selector = new TechniqueSelector( effect, "DefaultTechnique" );

            m_PlanetTerrainTechnique = selector;

            float hDim = 1;
            Point3[] cubePoints = new Point3[]
                {
                    new Point3( -hDim, -hDim, -hDim ),
                    new Point3( +hDim, -hDim, -hDim ),
                    new Point3( +hDim, +hDim, -hDim ),
                    new Point3( -hDim, +hDim, -hDim ),

                    new Point3( -hDim, -hDim, +hDim ),
                    new Point3( +hDim, -hDim, +hDim ),
                    new Point3( +hDim, +hDim, +hDim ),
                    new Point3( -hDim, +hDim, +hDim ),
                };
            int res = 3;
            int defaultLodLevel = 0;
            CubeSide[] sides = new CubeSide[ ]
                {
                    new CubeSide( res, cubePoints[ 0 ], cubePoints[ 1 ], cubePoints[ 3 ], defaultLodLevel, true ),	//	-z
                    new CubeSide( res, cubePoints[ 7 ], cubePoints[ 6 ], cubePoints[ 4 ], defaultLodLevel, true ),	//	+z
                    new CubeSide( res, cubePoints[ 4 ], cubePoints[ 5 ], cubePoints[ 0 ], defaultLodLevel, true ),	//	+y
                    new CubeSide( res, cubePoints[ 6 ], cubePoints[ 7 ], cubePoints[ 2 ], defaultLodLevel, true ),	//	-y
                    new CubeSide( res, cubePoints[ 0 ], cubePoints[ 3 ], cubePoints[ 4 ], defaultLodLevel, true ),	//	-x
                    new CubeSide( res, cubePoints[ 5 ], cubePoints[ 6 ], cubePoints[ 1 ], defaultLodLevel, true )		//	+x
                };

            foreach ( CubeSide side in sides )
            {
                side.PreBuild( m_Builder );
                foreach ( TerrainPatch patch in side.TerrainPatches )
                {
                    m_Patches.Add( patch );
                }
            }

            //	Arrange patches in a spiral, with the centre patch on side -y at position 0
            //int ringSize = 1;
            //CubeSide bottomSide = sides[ 3 ];
            //for ( int offsetFromCentre = 0; offsetFromCentre < res; ++offsetFromCentre )
            //{
            //    if ( offsetFromCentre == 0 )
            //    {
            //        continue;
            //    }
            //    int start = ( res / 2 ) - offsetFromCentre;

            //    ringSize += 2;
            //}

            //int[] cubeSides = new int[]
            //    {
            //        0, 1, 3,	//	-z
            //        7, 6, 4,	//	+z
            //        4, 5, 0,	//	+y
            //        6, 7, 2,	//	-y
            //        0, 3, 4,	//	-x
            //        5, 6, 1		//	+x
            //    };
            //int[] sideConnections = new int[]
            //    {
            //    //	Left	Top		Right	Bottom
            //        4,		2,		5,		3,		//	Side 0 (-z)
            //    //	0,		0,		0,		0,		//	Side 1 (+z)
            //    //	0,		0,		0,		0,		//	Side 2 (+y)
            //    //	0,		0,		0,		0,		//	Side 3 (-y)
            //    //	0,		0,		0,		0,		//	Side 4 (-x)
            //    //	0,		0,		0,		0,		//	Side 5 (+x)
            //    };

            //	for ( int side = 0; side < cubeSides.Length / 3; ++side )
            //for ( int side = 0; side < 1; ++side )
            //{
            //    CubeSide leftSide	= sides[ sideConnections[ side * 4 ] ];
            //    CubeSide topSide	= sides[ sideConnections[ side * 4 + 1 ] ];
            //    CubeSide rightSide	= sides[ sideConnections[ side * 4 + 2 ] ];
            //    CubeSide bottomSide	= sides[ sideConnections[ side * 4 + 3 ] ];

            //    sides[ side ].Link( leftSide, topSide, rightSide, bottomSide );
            //}

            foreach ( CubeSide side in sides )
            {
                side.Build( m_Builder );
            }

            m_PatchRenderState = Graphics.Factory.CreateRenderState( );
            m_PatchRenderState.DepthTest = true;
            m_PatchRenderState.DepthWrite = true;
            m_PatchRenderState.CullBackFaces = true;
            m_PatchRenderState.FaceRenderMode = PolygonRenderMode.Lines;
        }