예제 #1
0
파일: Flip.cs 프로젝트: Benedani/MCGalaxy
        static CopyState Rotate(CopyState state, CopyState flipped, int[] m)
        {
            byte[] blocks = state.Blocks, extBlocks = state.ExtBlocks;
            for (int i = 0; i < blocks.Length; i++)
            {
                ushort x, y, z;
                state.GetCoords(i, out x, out y, out z);
                flipped.Set(blocks[i], extBlocks[i],
                            Rotate(m[0], x, y, z, state),
                            Rotate(m[1], x, y, z, state),
                            Rotate(m[2], x, y, z, state));
            }

            int oX = state.OriginX - state.X, oY = state.OriginY - state.Y, oZ = state.OriginZ - state.Z;

            flipped.OriginX = state.X + Rotate(m[0], oX, oY, oZ, state);
            flipped.OriginY = state.Y + Rotate(m[1], oX, oY, oZ, state);
            flipped.OriginZ = state.Z + Rotate(m[2], oX, oY, oZ, state);

            // Offset is relative to Origin
            oX += state.Offset.X; oY += state.Offset.Y; oZ += state.Offset.Z;
            flipped.Offset.X = state.X + Rotate(m[0], oX, oY, oZ, state) - flipped.OriginX;
            flipped.Offset.Y = state.Y + Rotate(m[1], oX, oY, oZ, state) - flipped.OriginY;
            flipped.Offset.Z = state.Z + Rotate(m[2], oX, oY, oZ, state) - flipped.OriginZ;
            return(flipped);
        }
예제 #2
0
        static CopyState Rotate(CopyState state, CopyState flipped, int[] m, BlockID[] transform)
        {
            int volume = state.Volume;

            for (int i = 0; i < volume; i++)
            {
                ushort x, y, z;
                state.GetCoords(i, out x, out y, out z);
                BlockID block = transform[state.Get(i)];

                flipped.Set(block,
                            Rotate(m[0], x, y, z, state),
                            Rotate(m[1], x, y, z, state),
                            Rotate(m[2], x, y, z, state));
            }

            int oX = state.OriginX - state.X, oY = state.OriginY - state.Y, oZ = state.OriginZ - state.Z;

            flipped.OriginX = state.X + Rotate(m[0], oX, oY, oZ, state);
            flipped.OriginY = state.Y + Rotate(m[1], oX, oY, oZ, state);
            flipped.OriginZ = state.Z + Rotate(m[2], oX, oY, oZ, state);

            // Offset is relative to Origin
            oX += state.Offset.X; oY += state.Offset.Y; oZ += state.Offset.Z;
            flipped.Offset.X = state.X + Rotate(m[0], oX, oY, oZ, state) - flipped.OriginX;
            flipped.Offset.Y = state.Y + Rotate(m[1], oX, oY, oZ, state) - flipped.OriginY;
            flipped.Offset.Z = state.Z + Rotate(m[2], oX, oY, oZ, state) - flipped.OriginZ;
            return(flipped);
        }
예제 #3
0
		CopyState RotateX(CopyState state) {
			CopyState newState = new CopyState(state.X, state.Y, state.Z,
			                                   state.Width, state.Length, state.Height);
			byte[] blocks = state.Blocks, extBlocks = state.ExtBlocks;
			int newMaxY = newState.Height - 1;
			
			for (int i = 0; i < blocks.Length; i++) {
				ushort x, y, z;
				state.GetCoords(i, out x, out y, out z);
				newState.Set(x, newMaxY - z, y, blocks[i], extBlocks[i]);
			}
			newState.SetOrigin(state.OriginX, state.OriginY, state.OriginZ);
			return newState;
		}