public bool y_plane(double plane, double xp, double yp, Bitmap bm, int j, int i, bool tick) { //Find the y coordnate t for the given plane double ycoord = (plane - camera[1]) / (((-1.0) * camera[1]) + yp); double xcoord = (camera[0] * (1.0 - ycoord)) + (xp * ycoord); double zcoord = (camera[2] * (1.0 - ycoord)); double[] xplanes = null; int k = 0; if (plane == 5.0) { //Top face of the black keys if (((xcoord >= 2.75 && xcoord <= 3.25) || (xcoord >= 3.75 && xcoord <= 4.25) || (xcoord >= 5.75 && xcoord <= 6.25) || (xcoord >= 6.75 && xcoord <= 7.25) || (xcoord >= 7.75 && xcoord <= 8.25)) && (zcoord >= 2.0 && zcoord <= 5.0)) { //Populate the array for the black keys here if (xcoord >= 2.75 && xcoord <= 3.25) { if (!tick) { pixelsForKeys[8, count[8]] = new Pixel(j, i); count[8]++; } } else if (xcoord >= 3.75 && xcoord <= 4.25) { if (!tick) { pixelsForKeys[9, count[9]] = new Pixel(j, i); count[9]++; } } else if (xcoord >= 5.75 && xcoord <= 6.25) { if (!tick) { pixelsForKeys[10, count[10]] = new Pixel(j, i); count[10]++; } } else if (xcoord >= 6.75 && xcoord <= 7.25) { if (!tick) { pixelsForKeys[11, count[11]] = new Pixel(j, i); count[11]++; } } else if (xcoord >= 7.75 && xcoord <= 8.25) { if (!tick) { pixelsForKeys[12, count[12]] = new Pixel(j, i); count[12]++; } } bm.SetPixel(j, i, Color.FromArgb(255, 61, 61, 61)); return(true); } else { //Check the z plane, it is given in the first conditional if (z_plane(2.0, xp, yp, bm, j, i, tick)) { return(true); } //In the x direction, there is a list of x planes to choose from, so this will be the same as the main loop here bool xFind = false; //Start middle, go left, then go right xplanes = new double[10] { 5.75, 4.25, 3.75, 3.25, 2.75, 6.25, 6.75, 7.25, 7.75, 8.25 }; while (k < xplanes.Length && xFind == false) { xFind |= x_plane(xplanes[k], xp, yp, bm, j, i, tick); k++; } //If the plane is found; if (xFind) { return(true); } } } else if (plane == 4.0) { //Top face of the keys if ((xcoord <= 10.0 && xcoord >= 2.0) && (zcoord >= 1.0 && zcoord <= 5.0)) { double floorX = Math.Floor(xcoord); //Populate the array for the pixels used in the animation\ if (!tick) { pixelsForKeys[(int)(floorX - 2), count[(int)(floorX - 2)]] = new Pixel(j, i); count[(int)(floorX - 2)]++; } double ceilX = Math.Ceiling(xcoord); //Add the dividing lines here if ((xcoord <= floorX + 0.05) || (xcoord >= ceilX - 0.05)) { bm.SetPixel(j, i, Color.Black); } else { bm.SetPixel(j, i, Color.White); } return(true); } else if (((xcoord >= 1.0 && xcoord <= 2.0) || (xcoord <= 11.0 && xcoord >= 10.0)) && (zcoord >= 0.75 && zcoord <= 5.0)) { //This is the side panel of the keys bm.SetPixel(j, i, Color.FromArgb(255, 120, 80, 39)); return(true); } else { //Front face of keys if (z_plane(1.0, xp, yp, bm, j, i, tick)) { return(true); } bool xFind = false; //Left to Right xplanes = new double[2] { 2.0, 10.0 }; while (k < xplanes.Length && xFind == false) { xFind |= x_plane(xplanes[k], xp, yp, bm, j, i, tick); k++; } if (xFind) { return(true); } } } else if (plane == 2.0) { //Connecting keys to front panel if ((xcoord >= 2.0 && xcoord <= 10.0) && (zcoord >= 0.75 && zcoord <= 1.0)) { bm.SetPixel(j, i, Color.FromArgb(255, 63, 42, 20)); return(true); } else { if (z_plane(0.75, xp, yp, bm, j, i, tick)) { return(true); } } } else if (plane == 1.0) { //floor of piano if ((xcoord <= 11.0 && xcoord >= 1.0) && (zcoord >= 0.75 && zcoord <= 5.0)) { bm.SetPixel(j, i, Color.OrangeRed); return(true); } else { if (z_plane(0.75, xp, yp, bm, j, i, tick)) { return(true); } } } return(false); }
public bool x_plane(double plane, double xp, double yp, Bitmap bm, int j, int i, bool tick) { //Determine the xcoordinate t for the specific plane given by the parameter double xcoord = (plane - camera[0]) / (((-1.0) * camera[0]) + xp); double ycoord = (camera[1] * (1.0 - xcoord)) + (yp * xcoord); double zcoord = (camera[2] * (1.0 - xcoord)); //What if we start middle //Go left //Then Go right, //that ensures that no matter the angle the correct plane is hit first //We will need to order the checks from middle, left, and right //Black Keys sides //as long as the order is taken care of in the array, this should work if (plane >= 2.75 && plane <= 8.25) { if ((ycoord >= 4.0 && ycoord <= 5.0) && (zcoord >= 2.0 && zcoord <= 5.0)) { //Populate the array associated with the specific keys here if (!tick) { if (plane == 3.25) { pixelsForKeys[8, count[8]] = new Pixel(j, i); count[8]++; blackSides[0] = 3.25; } if (plane == 4.25) { pixelsForKeys[9, count[9]] = new Pixel(j, i); count[9]++; blackSides[1] = 4.25; } if (plane == 6.25 || plane == 5.75) { pixelsForKeys[10, count[10]] = new Pixel(j, i); count[10]++; blackSides[2] = 6.25; } if (plane == 6.75) { pixelsForKeys[11, count[11]] = new Pixel(j, i); count[11]++; blackSides[3] = 6.75; } if (plane == 7.75) { pixelsForKeys[12, count[12]] = new Pixel(j, i); count[12]++; blackSides[4] = 7.75; } } bm.SetPixel(j, i, Color.FromArgb(255, 41, 41, 41)); return(true); } } //This will be the side panels between the front panel and the border, so it will be close to the keys if (plane == 2.0 || plane == 10.0) { if ((ycoord <= 4.0 && ycoord >= 2.0) && (zcoord >= 0.75 && zcoord <= 5.0)) { bm.SetPixel(j, i, Color.FromArgb(255, 63, 42, 20)); return(true); } } return(false); }
public bool z_plane(double plane, double xp, double yp, Bitmap bm, int j, int i, bool tick) { //Find the z coordinate t for the given plane double zcoord = 1.0 - (plane / camera[2]); double xcoord = (camera[0] * (1.0 - zcoord)) + (xp * zcoord); //X double ycoord = (camera[1] * (1.0 - zcoord)) + (yp * zcoord); //Y if (plane == 0.75) { //Two Front Panels if (((xcoord >= 1.0 && xcoord <= 2.0) || (xcoord <= 11.0 && xcoord >= 10.0)) && (ycoord >= 1.0 && ycoord <= 4.0)) { bm.SetPixel(j, i, Color.FromArgb(255, 82, 54, 27)); return(true); } //Front facing panel if ((xcoord >= 2.0 && xcoord <= 10.0) && (ycoord >= 1.0 && ycoord <= 2.0)) { bm.SetPixel(j, i, Color.FromArgb(255, 82, 54, 27)); return(true); } } else if (plane == 1.0) { //These are the fronts of the white keys if ((xcoord <= 10.0 && xcoord >= 2.0) && (ycoord <= 4.0 && ycoord >= 2.0)) { double floorX = Math.Floor(xcoord); //Populate the array for the pixels used in the animation if (!tick) { pixelsForKeys[(int)(floorX - 2), count[(int)(floorX - 2)]] = new Pixel(j, i); count[(int)(floorX - 2)]++; } double ceilX = Math.Ceiling(xcoord); //Create the division in the keys if ((xcoord <= floorX + 0.03) || (xcoord >= ceilX - 0.03)) { bm.SetPixel(j, i, Color.Black); } else { bm.SetPixel(j, i, Color.WhiteSmoke); } return(true); } } else if (plane == 2.0) { //These are the fronts of the black keys if (((xcoord >= 2.75 && xcoord <= 3.25) || (xcoord >= 3.75 && xcoord <= 4.25) || (xcoord >= 5.75 && xcoord <= 6.25) || (xcoord >= 6.75 && xcoord <= 7.25) || (xcoord >= 7.75 && xcoord <= 8.25)) && (ycoord >= 4.0 && ycoord <= 5.0)) { //Populate the proper array for the black keys here if (xcoord >= 2.75 && xcoord <= 3.25) { if (!tick) { pixelsForKeys[8, count[8]] = new Pixel(j, i); count[8]++; } } else if (xcoord >= 3.75 && xcoord <= 4.25) { if (!tick) { pixelsForKeys[9, count[9]] = new Pixel(j, i); count[9]++; } } else if (xcoord >= 5.75 && xcoord <= 6.25) { if (!tick) { pixelsForKeys[10, count[10]] = new Pixel(j, i); count[10]++; } } else if (xcoord >= 6.75 && xcoord <= 7.25) { if (!tick) { pixelsForKeys[11, count[11]] = new Pixel(j, i); count[11]++; } } else if (xcoord >= 7.75 && xcoord <= 8.25) { if (!tick) { pixelsForKeys[12, count[12]] = new Pixel(j, i); count[12]++; } } bm.SetPixel(j, i, Color.Black); return(true); } } return(false); }