public int WhichFace(Face t) { FaceID fid = FaceID.None; foreach (Node n in t.vrts) { int idx = Array.IndexOf <Node>(this.vrts, n); fid |= IdxToID(idx); } if (fid == FaceID.Face0) { return(0); } else if (fid == FaceID.Face1) { return(1); } else if (fid == FaceID.Face2) { return(2); } else if (fid == FaceID.Face3) { return(3); } else { throw new Exception(); } }
public bool areAdjacent(FaceID face1, FaceID face2) { // return whether 2 faces are adjacent return !((face1 == FaceID.Top && face2 == FaceID.Bottom) || (face1 == FaceID.Front && face2 == FaceID.Back) || (face1 == FaceID.Right && face2 == FaceID.Left) || (face1 == FaceID.Bottom && face2 == FaceID.Top) || (face1 == FaceID.Back && face2 == FaceID.Front) || (face1 == FaceID.Left && face2 == FaceID.Right)); }
/// <summary> /// Gets the smiley shop id /// </summary> /// <param name="smiley">The smiley</param> public string GetSmileyId(FaceID smiley) { int id = (int)smiley; if (m_Smilies.ContainsKey(id)) { return(m_Smilies[id]); } return(null); }
/// <summary> /// Checks to see if the player has a smiley /// </summary> /// <param name="smiley">The smiley</param> /// <returns></returns> public bool HasSmiley(FaceID smiley) { string smileyPack = m_ShopInfo.GetSmileyId(smiley); if (smileyPack == null) { return(false); } else if (smileyPack == string.Empty) { return(true); } m_Client.PayVault.Refresh(); return(m_Client.PayVault.Has(smileyPack)); }
/// <summary> /// Sets the friend's status /// </summary> /// <param name="online">Is online</param> /// <param name="smiley">The selected smiley</param> /// <param name="worldId">The World ID</param> /// <param name="worldName">The world name</param> internal void SetOnlineStatus(bool online, FaceID smiley, string worldId, string worldName) { Online = online; Smiley = smiley; if (!string.IsNullOrEmpty(worldId)) { In = new WorldReference(m_LobbyConnection.Client, worldId) { WorldName = worldName }; } else { In = null; } }
public MainWindow() { kinect = new KinectManager(); capture = new DataCapture(); faceId = new FaceID(this); trainingUpdater = new TrainingUpdater(this); results = new Results(); rnd = new Random(); kinect.OnStartTracking += PersonEnter; kinect.OnStopTracking += PersonLeave; KinectRegion.SetKinectRegion(this, kinectRegion); this.DataContext = this; this.KeyDown += new KeyEventHandler(OnButtonKeyDown); this.InitializeComponent(); Mouse.OverrideCursor = Cursors.None; }
public int WhichEdge(GranuleEdge ge) { FaceID fid = FaceID.None; foreach (Node n in ge.vrts) { int idx = Array.IndexOf <Node>(this.vrts, n); fid |= IdxToID(idx); } if (fid == FaceID.Edge0) { return(0); } else if (fid == FaceID.Edge1) { return(1); } else if (fid == FaceID.Edge2) { return(2); } else if (fid == FaceID.Edge3) { return(3); } else if (fid == FaceID.Edge4) { return(4); } else if (fid == FaceID.Edge5) { return(5); } else { throw new Exception(); } }
public void Test_EF_DownloadTemplatesFromDevices() { IList <FaceUser> results = new List <FaceUser>(); IList <string> ipAddresses = new List <string>(); ipAddresses.Add("172.16.0.110"); ipAddresses.Add("172.16.0.111"); ipAddresses.Add("172.16.0.112"); ipAddresses.Add("172.16.0.113"); ipAddresses.Add("172.16.0.114"); var test = new FaceID(); for (int i = 1; i < 150; i++) { foreach (var ipAddress in ipAddresses) { try { var obj = test.DownloadTemplates("1", ipAddress, i.ToString()); results.Add(obj); } catch (Exception ex) { Debug.WriteLine(ex.Message); } } } //Print results Debug.WriteLine("================================="); foreach (var faceUser in results) { Debug.WriteLine(faceUser.ToString()); } Debug.WriteLine("================================="); }
public Move(FaceID f, CubeMove t) { face = f; twist = t; }
public FaceCoord(FaceID f, int i, int j) { face = f; this.i = i; this.j = j; }
private FaceID[,] rotateFace(FaceID[,] face, CubeMove rot) { // rotate all the colours on a face and adjacent squares FaceID[,] newFace = new FaceID[5, 5]; for(int i = 0; i < 5; i++) for(int j = 0; j < 5; j++) // for each piece on the face switch(rot) { case CubeMove.Clockwise: newFace[4 - j, i] = face[i, j]; // if clockwise rotation move all pieces around clockwise break; case CubeMove.Double: newFace[4 - i, 4 - j] = face[i, j]; // if double rotation move them around 180 degrees break; case CubeMove.AntiClockwise: // if anti-clockwise move them around anti-clockwise newFace[j, 4 - i] = face[i, j]; break; } return newFace; }
private void actualMove(FaceID face, CubeMove rot) { FaceID[,] transposed = new FaceID[5, 5]; // create a temporary store for face being moved and adjacent piece colours for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) { FaceCoord coords = transposeFromFront(face, FaceID.Front, i, j); // pull off the colours of the face and put them into the transpose array transposed[i + 1, j + 1] = faceColours[(int) coords.face, coords.i, coords.j]; } for(int i = 0; i < 3; i++) { // pull off the affected colours from the 4 adjacent edges FaceCoord coords = transposeFromFront(face, FaceID.Top, i, 2); transposed[i + 1, 0] = faceColours[(int) coords.face, coords.i, coords.j]; coords = transposeFromFront(face, FaceID.Left, 2, i); transposed[0, i + 1] = faceColours[(int) coords.face, coords.i, coords.j]; coords = transposeFromFront(face, FaceID.Right, 0, i); transposed[4, i + 1] = faceColours[(int) coords.face, coords.i, coords.j]; coords = transposeFromFront(face, FaceID.Bottom, i, 0); transposed[i + 1, 4] = faceColours[(int) coords.face, coords.i, coords.j]; } transposed = rotateFace(transposed, rot); // perform the actual rotation on the colours for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) { // place the newly rotated colours back onto the rotated face FaceCoord coords = transposeFromFront(face, FaceID.Front, i, j); faceColours[(int) coords.face, coords.i, coords.j] = transposed[i + 1, j + 1]; } for(int i = 0; i < 3; i++) { // place the newly rotated colours back onto the adjacent faces FaceCoord coords = transposeFromFront(face, FaceID.Top, i, 2); faceColours[(int) coords.face, coords.i, coords.j] = transposed[i + 1, 0]; coords = transposeFromFront(face, FaceID.Left, 2, i); faceColours[(int) coords.face, coords.i, coords.j] = transposed[0, i + 1]; coords = transposeFromFront(face, FaceID.Right, 0, i); faceColours[(int) coords.face, coords.i, coords.j] = transposed[4, i + 1]; coords = transposeFromFront(face, FaceID.Bottom, i, 0); faceColours[(int) coords.face, coords.i, coords.j] = transposed[i + 1, 4]; } }
public FaceCoord transposeFromFront(FaceID target, FaceCoord coords) { // take a co-ordinate to a colour on a face and convert it for use on another face FaceCoord newCoords = new FaceCoord(coords.face, coords.i, coords.j); switch(target) { // hard-coded changes for each face to change the co-ordinates in the relevant way case FaceID.Top: switch(coords.face) { case FaceID.Front: newCoords.face = FaceID.Top; break; case FaceID.Back: newCoords.face = FaceID.Bottom; newCoords.i = 2 - coords.i; newCoords.j = 2 - coords.j; break; case FaceID.Left: newCoords.i = coords.j; newCoords.j = 2 - coords.i; break; case FaceID.Right: newCoords.i = 2 - coords.j; newCoords.j = coords.i; break; case FaceID.Top: newCoords.face = FaceID.Back; newCoords.i = 2 - coords.i; newCoords.j = 2 - coords.j; break; case FaceID.Bottom: newCoords.face = FaceID.Front; break; } break; case FaceID.Bottom: switch(coords.face) { case FaceID.Front: newCoords.face = FaceID.Bottom; break; case FaceID.Back: newCoords.face = FaceID.Top; newCoords.i = 2 - coords.i; newCoords.j = 2 - coords.j; break; case FaceID.Left: newCoords.i = 2 - coords.j; newCoords.j = coords.i; break; case FaceID.Right: newCoords.i = coords.j; newCoords.j = 2 - coords.i; break; case FaceID.Top: newCoords.face = FaceID.Front; break; case FaceID.Bottom: newCoords.face = FaceID.Back; newCoords.i = 2 - coords.i; newCoords.j = 2 - coords.j; break; } break; case FaceID.Left: switch(coords.face) { case FaceID.Front: newCoords.face = FaceID.Left; break; case FaceID.Back: newCoords.face = FaceID.Right; break; case FaceID.Left: newCoords.face = FaceID.Back; break; case FaceID.Right: newCoords.face = FaceID.Front; break; case FaceID.Top: newCoords.i = 2 - coords.j; newCoords.j = coords.i; break; case FaceID.Bottom: newCoords.i = coords.j; newCoords.j = 2 - coords.i; break; } break; case FaceID.Right: switch(coords.face) { case FaceID.Front: newCoords.face = FaceID.Right; break; case FaceID.Back: newCoords.face = FaceID.Left; break; case FaceID.Left: newCoords.face = FaceID.Front; break; case FaceID.Right: newCoords.face = FaceID.Back; break; case FaceID.Top: newCoords.i = coords.j; newCoords.j = 2 - coords.i; break; case FaceID.Bottom: newCoords.i = 2 - coords.j; newCoords.j = coords.i; break; } break; case FaceID.Front: return coords; case FaceID.Back: switch(coords.face) { case FaceID.Front: newCoords.face = FaceID.Back; break; case FaceID.Back: newCoords.face = FaceID.Front; break; case FaceID.Left: newCoords.face = FaceID.Right; break; case FaceID.Right: newCoords.face = FaceID.Left; break; case FaceID.Top: newCoords.i = 2 - coords.i; newCoords.j = 2 - coords.j; break; case FaceID.Bottom: newCoords.i = 2 - coords.i; newCoords.j = 2 - coords.j; break; } break; } return newCoords; }
public FaceCoord transposeFromFront(FaceID target, FaceID face, int i, int j) { // take a co-ordinate to a colour on a face and convert it for use on another face return transposeFromFront(target, new FaceCoord(face, i, j)); }
protected void update() { // called on every step in idle application time float correction = 1.0F; // initial time correction value if(timer.IsRunning) { timer.Stop(); correction = (float) timer.ElapsedTicks / 3000F; // get the difference in time between this step and the last and create compensation for it } viewMatrix = Matrix.CreateLookAt(new Vector3(0, 0, -7 + zoom), new Vector3(0, 0, 0), new Vector3(0, -1, 0)); // update matrices for new zoom and new viewport if changed projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, GraphicsDevice.Viewport.AspectRatio, 1.0f, 300.0f); if(!paused) { // if not paused update any rotations on the cube if(moveQueue.Count > 0 && delaySoFar == 0 && faceAngle <= 0.0F) { // no move currently being performed so start a new one Move move = moveQueue.Dequeue(); // get the next move delaySoFar = (int) (performDelay / correction); // set up the delay for this move if(animateFaces) { // if animate the faces then set up a slow face rotation verticesChanged[(int) move.face] = true; // invalidate the relevant faces for refreshing for(int i = 0; i < 6; i++) if(areAdjacent(move.face, (FaceID) i)) verticesChanged[i] = true; rotatingBackwards = move.twist == CubeMove.AntiClockwise; // update the current rotation rotatingFace = move.face; faceAngle = rotatePerStep; if(move.twist == CubeMove.Double) rotatingTo = MathHelper.Pi; else rotatingTo = MathHelper.PiOver2; lastMove = move; } else { // faces not animated so perform rotation instantly verticesChanged[(int) move.face] = true; for(int i = 0; i < 6; i++) if(areAdjacent(move.face, (FaceID) i)) verticesChanged[i] = true; cube.performMove(move); updateHighlights(move); lastMove = move; if(moveQueue.Count == 0) // update when sequence has finished onSequenceFinish(); } } if(delaySoFar > 0) delaySoFar--; // update delay between rotations if(faceAngle > 0.0F) { // face currently being rotated so continue it verticesChanged[(int) lastMove.face] = true; // invalidate faces for(int i = 0; i < 6; i++) if(areAdjacent(lastMove.face, (FaceID) i)) verticesChanged[i] = true; faceAngle += rotatePerStep * correction; // update rotation with correction for time differences } if(faceAngle >= rotatingTo) { // if rotation is finished, end it verticesChanged[(int) lastMove.face] = true; // invalidate faces for(int i = 0; i < 6; i++) if(areAdjacent(lastMove.face, (FaceID) i)) verticesChanged[i] = true; faceAngle = 0.0F; // reset face angle, perform latest move on actual cube stored, and update changes in pieces highlighted cube.performMove(lastMove); updateHighlights(lastMove); if(moveQueue.Count == 0) // update when sequence has finished onSequenceFinish(); } } KeyboardState kb = Keyboard.GetState(); // get current user input data MouseState ms = Mouse.GetState(); Point vms = this.PointToClient(new Point(ms.X, ms.Y)); if(ms.LeftButton == ButtonState.Pressed && inBounds(vms) && inBounds(prevMs)) { // if mouse is within control bounds and was in control bounds last step with the mouse button held angleX += (vms.Y - prevMs.Y) * 0.01F / (float) Height * 365F; // update rotations of entire cube angleY += (prevMs.X - vms.X) * 0.01F / (float) Width * 805F * (angleX > MathHelper.PiOver2 || angleX < -MathHelper.PiOver2 ? -1 : 1); } angleX = angleX % (float) (2 * Math.PI); // ensure angleX doesn't exceed -2*pi or 2*pi when not necessary (for above rotation logic) prevKb = kb; // input finished with so update input from last step prevMs = vms; if(!timer.IsRunning) // restart step timer timer.Restart(); }
public VertexPositionColorTexture[] generateFaceVertices(FaceID face) { // generate the 3d vertices for face VertexPositionColorTexture[] vertices = new VertexPositionColorTexture[108]; switch(face) { case FaceID.Top: for(int x = 0; x < 3; x++) for(int z = 0; z < 3; z++) { Color c = cube.colourIDs[(int) cube.faceColours[(int) face, x, z]]; vertices[x * 12 + z * 36 + 0] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, -1.5F, 1.5F - (float) z), c, new Vector2(0, 0)); vertices[x * 12 + z * 36 + 1] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, -1.5F, 0.5F - (float) z), c, new Vector2(1, 1)); vertices[x * 12 + z * 36 + 2] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, -1.5F, 1.5F - (float) z), c, new Vector2(1, 0)); vertices[x * 12 + z * 36 + 3] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, -1.5F, 1.5F - (float) z), c, new Vector2(0, 0)); vertices[x * 12 + z * 36 + 4] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, -1.5F, 0.5F - (float) z), c, new Vector2(0, 1)); vertices[x * 12 + z * 36 + 5] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, -1.5F, 0.5F - (float) z), c, new Vector2(1, 1)); vertices[x * 12 + z * 36 + 6] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, -1.5F, 1.5F - (float) z), Color.Black, Vector2.Zero); vertices[x * 12 + z * 36 + 7] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, -1.5F, 1.5F - (float) z), Color.Black, Vector2.Zero); vertices[x * 12 + z * 36 + 8] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, -1.5F, 0.5F - (float) z), Color.Black, Vector2.Zero); vertices[x * 12 + z * 36 + 9] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, -1.5F, 1.5F - (float) z), Color.Black, Vector2.Zero); vertices[x * 12 + z * 36 + 10] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, -1.5F, 0.5F - (float) z), Color.Black, Vector2.Zero); vertices[x * 12 + z * 36 + 11] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, -1.5F, 0.5F - (float) z), Color.Black, Vector2.Zero); } break; case FaceID.Bottom: for(int x = 0; x < 3; x++) for(int z = 0; z < 3; z++) { Color c = cube.colourIDs[(int) cube.faceColours[(int) face, x, z]]; vertices[x * 12 + z * 36 + 0] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, 1.5F, (float) z - 0.5F), c, new Vector2(0, 0)); vertices[x * 12 + z * 36 + 1] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, 1.5F, (float) z - 0.5F), c, new Vector2(1, 0)); vertices[x * 12 + z * 36 + 2] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, 1.5F, (float) z - 1.5F), c, new Vector2(1, 1)); vertices[x * 12 + z * 36 + 3] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, 1.5F, (float) z - 0.5F), c, new Vector2(0, 0)); vertices[x * 12 + z * 36 + 4] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, 1.5F, (float) z - 1.5F), c, new Vector2(1, 1)); vertices[x * 12 + z * 36 + 5] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, 1.5F, (float) z - 1.5F), c, new Vector2(0, 1)); vertices[x * 12 + z * 36 + 6] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, 1.5F, (float) z - 0.5F), Color.Black, Vector2.Zero); vertices[x * 12 + z * 36 + 7] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, 1.5F, (float) z - 1.5F), Color.Black, Vector2.Zero); vertices[x * 12 + z * 36 + 8] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, 1.5F, (float) z - 0.5F), Color.Black, Vector2.Zero); vertices[x * 12 + z * 36 + 9] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, 1.5F, (float) z - 0.5F), Color.Black, Vector2.Zero); vertices[x * 12 + z * 36 + 10] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, 1.5F, (float) z - 1.5F), Color.Black, Vector2.Zero); vertices[x * 12 + z * 36 + 11] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, 1.5F, (float) z - 1.5F), Color.Black, Vector2.Zero); } break; case FaceID.Front: for(int x = 0; x < 3; x++) for(int y = 0; y < 3; y++) { Color c = cube.colourIDs[(int) cube.faceColours[(int) face, x, y]]; vertices[x * 12 + y * 36 + 0] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, (float) y - 1.5F, -1.5F), c, new Vector2(0, 0)); vertices[x * 12 + y * 36 + 1] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, (float) y - 0.5F, -1.5F), c, new Vector2(1, 1)); vertices[x * 12 + y * 36 + 2] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, (float) y - 1.5F, -1.5F), c, new Vector2(1, 0)); vertices[x * 12 + y * 36 + 3] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, (float) y - 1.5F, -1.5F), c, new Vector2(0, 0)); vertices[x * 12 + y * 36 + 4] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, (float) y - 0.5F, -1.5F), c, new Vector2(0, 1)); vertices[x * 12 + y * 36 + 5] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, (float) y - 0.5F, -1.5F), c, new Vector2(1, 1)); vertices[x * 12 + y * 36 + 6] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, (float) y - 1.5F, -1.5F), Color.Black, Vector2.Zero); vertices[x * 12 + y * 36 + 7] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, (float) y - 1.5F, -1.5F), Color.Black, Vector2.Zero); vertices[x * 12 + y * 36 + 8] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, (float) y - 0.5F, -1.5F), Color.Black, Vector2.Zero); vertices[x * 12 + y * 36 + 9] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, (float) y - 1.5F, -1.5F), Color.Black, Vector2.Zero); vertices[x * 12 + y * 36 + 10] = new VertexPositionColorTexture(new Vector3((float) x - 1.5F, (float) y - 0.5F, -1.5F), Color.Black, Vector2.Zero); vertices[x * 12 + y * 36 + 11] = new VertexPositionColorTexture(new Vector3((float) x - 0.5F, (float) y - 0.5F, -1.5F), Color.Black, Vector2.Zero); } break; case FaceID.Back: for(int x = 0; x < 3; x++) for(int y = 0; y < 3; y++) { Color c = cube.colourIDs[(int) cube.faceColours[(int) face, x, y]]; vertices[x * 12 + y * 36 + 0] = new VertexPositionColorTexture(new Vector3(1.5F - (float) x, (float) y - 1.5F, 1.5F), c, new Vector2(0, 0)); vertices[x * 12 + y * 36 + 1] = new VertexPositionColorTexture(new Vector3(0.5F - (float) x, (float) y - 1.5F, 1.5F), c, new Vector2(1, 0)); vertices[x * 12 + y * 36 + 2] = new VertexPositionColorTexture(new Vector3(0.5F - (float) x, (float) y - 0.5F, 1.5F), c, new Vector2(1, 1)); vertices[x * 12 + y * 36 + 3] = new VertexPositionColorTexture(new Vector3(1.5F - (float) x, (float) y - 1.5F, 1.5F), c, new Vector2(0, 0)); vertices[x * 12 + y * 36 + 4] = new VertexPositionColorTexture(new Vector3(0.5F - (float) x, (float) y - 0.5F, 1.5F), c, new Vector2(1, 1)); vertices[x * 12 + y * 36 + 5] = new VertexPositionColorTexture(new Vector3(1.5F - (float) x, (float) y - 0.5F, 1.5F), c, new Vector2(0, 1)); vertices[x * 12 + y * 36 + 6] = new VertexPositionColorTexture(new Vector3(1.5F - (float) x, (float) y - 1.5F, 1.5F), Color.Black, Vector2.Zero); vertices[x * 12 + y * 36 + 7] = new VertexPositionColorTexture(new Vector3(0.5F - (float) x, (float) y - 0.5F, 1.5F), Color.Black, Vector2.Zero); vertices[x * 12 + y * 36 + 8] = new VertexPositionColorTexture(new Vector3(0.5F - (float) x, (float) y - 1.5F, 1.5F), Color.Black, Vector2.Zero); vertices[x * 12 + y * 36 + 9] = new VertexPositionColorTexture(new Vector3(1.5F - (float) x, (float) y - 1.5F, 1.5F), Color.Black, Vector2.Zero); vertices[x * 12 + y * 36 + 10] = new VertexPositionColorTexture(new Vector3(1.5F - (float) x, (float) y - 0.5F, 1.5F), Color.Black, Vector2.Zero); vertices[x * 12 + y * 36 + 11] = new VertexPositionColorTexture(new Vector3(0.5F - (float) x, (float) y - 0.5F, 1.5F), Color.Black, Vector2.Zero); } break; case FaceID.Left: for(int y = 0; y < 3; y++) for(int z = 0; z < 3; z++) { Color c = cube.colourIDs[(int) cube.faceColours[(int) face, z, y]]; vertices[z * 12 + y * 36 + 0] = new VertexPositionColorTexture(new Vector3(-1.5F, (float) y - 1.5F, 1.5F - (float) z), c, new Vector2(0, 0)); vertices[z * 12 + y * 36 + 1] = new VertexPositionColorTexture(new Vector3(-1.5F, (float) y - 0.5F, 0.5F - (float) z), c, new Vector2(1, 1)); vertices[z * 12 + y * 36 + 2] = new VertexPositionColorTexture(new Vector3(-1.5F, (float) y - 0.5F, 1.5F - (float) z), c, new Vector2(1, 0)); vertices[z * 12 + y * 36 + 3] = new VertexPositionColorTexture(new Vector3(-1.5F, (float) y - 1.5F, 1.5F - (float) z), c, new Vector2(0, 0)); vertices[z * 12 + y * 36 + 4] = new VertexPositionColorTexture(new Vector3(-1.5F, (float) y - 1.5F, 0.5F - (float) z), c, new Vector2(0, 1)); vertices[z * 12 + y * 36 + 5] = new VertexPositionColorTexture(new Vector3(-1.5F, (float) y - 0.5F, 0.5F - (float) z), c, new Vector2(1, 1)); vertices[z * 12 + y * 36 + 6] = new VertexPositionColorTexture(new Vector3(-1.5F, (float) y - 1.5F, 1.5F - (float) z), Color.Black, Vector2.Zero); vertices[z * 12 + y * 36 + 7] = new VertexPositionColorTexture(new Vector3(-1.5F, (float) y - 0.5F, 1.5F - (float) z), Color.Black, Vector2.Zero); vertices[z * 12 + y * 36 + 8] = new VertexPositionColorTexture(new Vector3(-1.5F, (float) y - 0.5F, 0.5F - (float) z), Color.Black, Vector2.Zero); vertices[z * 12 + y * 36 + 9] = new VertexPositionColorTexture(new Vector3(-1.5F, (float) y - 1.5F, 1.5F - (float) z), Color.Black, Vector2.Zero); vertices[z * 12 + y * 36 + 10] = new VertexPositionColorTexture(new Vector3(-1.5F, (float) y - 0.5F, 0.5F - (float) z), Color.Black, Vector2.Zero); vertices[z * 12 + y * 36 + 11] = new VertexPositionColorTexture(new Vector3(-1.5F, (float) y - 1.5F, 0.5F - (float) z), Color.Black, Vector2.Zero); } break; case FaceID.Right: for(int y = 0; y < 3; y++) for(int z = 0; z < 3; z++) { Color c = cube.colourIDs[(int) cube.faceColours[(int) face, z, y]]; vertices[z * 12 + y * 36 + 0] = new VertexPositionColorTexture(new Vector3(1.5F, (float) y - 1.5F, (float) z - 0.5F), c, new Vector2(0, 0)); vertices[z * 12 + y * 36 + 1] = new VertexPositionColorTexture(new Vector3(1.5F, (float) y - 0.5F, (float) z - 0.5F), c, new Vector2(1, 0)); vertices[z * 12 + y * 36 + 2] = new VertexPositionColorTexture(new Vector3(1.5F, (float) y - 0.5F, (float) z - 1.5F), c, new Vector2(1, 1)); vertices[z * 12 + y * 36 + 3] = new VertexPositionColorTexture(new Vector3(1.5F, (float) y - 1.5F, (float) z - 0.5F), c, new Vector2(0, 0)); vertices[z * 12 + y * 36 + 4] = new VertexPositionColorTexture(new Vector3(1.5F, (float) y - 0.5F, (float) z - 1.5F), c, new Vector2(1, 1)); vertices[z * 12 + y * 36 + 5] = new VertexPositionColorTexture(new Vector3(1.5F, (float) y - 1.5F, (float) z - 1.5F), c, new Vector2(0, 1)); vertices[z * 12 + y * 36 + 6] = new VertexPositionColorTexture(new Vector3(1.5F, (float) y - 1.5F, (float) z - 0.5F), Color.Black, Vector2.Zero); vertices[z * 12 + y * 36 + 7] = new VertexPositionColorTexture(new Vector3(1.5F, (float) y - 0.5F, (float) z - 1.5F), Color.Black, Vector2.Zero); vertices[z * 12 + y * 36 + 8] = new VertexPositionColorTexture(new Vector3(1.5F, (float) y - 0.5F, (float) z - 0.5F), Color.Black, Vector2.Zero); vertices[z * 12 + y * 36 + 9] = new VertexPositionColorTexture(new Vector3(1.5F, (float) y - 1.5F, (float) z - 0.5F), Color.Black, Vector2.Zero); vertices[z * 12 + y * 36 + 10] = new VertexPositionColorTexture(new Vector3(1.5F, (float) y - 1.5F, (float) z - 1.5F), Color.Black, Vector2.Zero); vertices[z * 12 + y * 36 + 11] = new VertexPositionColorTexture(new Vector3(1.5F, (float) y - 0.5F, (float) z - 1.5F), Color.Black, Vector2.Zero); } break; } if(faceAngle > 0.0F && face == rotatingFace) { // if a face is being rotated and it is this face then rotate all the vertices by the rotation amount for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) for(int n = 0; n < 12; n++) vertices[i * 12 + j * 36 + n].Position = rotate(face, vertices[i * 12 + j * 36 + n].Position, faceAngle); } else if(faceAngle > 0.0F && areAdjacent(face, rotatingFace)) { // otherwise if a face is being rotated and it's adjacent to this face then rotate the relevant vertices for(int i = 0; i < 3; i++) foreach(FaceCoord coords in new FaceCoord[] { cube.transposeFromFront(rotatingFace, FaceID.Top, i, 2), cube.transposeFromFront(rotatingFace, FaceID.Left, 2, i), cube.transposeFromFront(rotatingFace, FaceID.Right, 0, i), cube.transposeFromFront(rotatingFace, FaceID.Bottom, i, 0) }) { if(coords.face == face) for(int n = 0; n < 12; n++) vertices[coords.i * 12 + coords.j * 36 + n].Position = rotate(rotatingFace, vertices[coords.i * 12 + coords.j * 36 + n].Position, faceAngle); } } return vertices; }
/// <summary> /// Gets the smiley's shop name /// </summary> /// <param name="smiley">The smiley</param> public string GetSmileyPackName(FaceID smiley) { return(m_ShopInfo.GetSmileyId(smiley)); }
public void performMove(FaceID face, CubeMove rot) { // performing move type methods performMove(new Move(face, rot)); }
public void performMove(FaceID face, CubeMove rot) { // perform move stored in FaceID value and CubeMove value actualMove(face, rot); }
/// <summary> /// Changes the connected user's face /// </summary> /// <param name="face">The face id</param> public void ChangeFace(FaceID face) { this.SendMessage(World.WorldKey + "f", (int)face); }
public Vector3 rotate(FaceID face, Vector3 vector, float angle) { // perform rotation on a vector based on angle and the face if(rotatingBackwards) angle = -angle; Vector3 rotated = new Vector3(vector.X, vector.Y, vector.Z); switch(face) { case FaceID.Top: rotated = Vector3.Transform(vector, Matrix.CreateRotationY(angle)); break; case FaceID.Bottom: rotated = Vector3.Transform(vector, Matrix.CreateRotationY(-angle)); break; case FaceID.Front: rotated = Vector3.Transform(vector, Matrix.CreateRotationZ(angle)); break; case FaceID.Back: rotated = Vector3.Transform(vector, Matrix.CreateRotationZ(-angle)); break; case FaceID.Left: rotated = Vector3.Transform(vector, Matrix.CreateRotationX(angle)); break; case FaceID.Right: rotated = Vector3.Transform(vector, Matrix.CreateRotationX(-angle)); break; } return rotated; }