ELEC2645 (2018/19) / Mbed 2 deprecated el17cd

Dependencies:   mbed

Committer:
el17cd
Date:
Fri Apr 05 15:34:28 2019 +0000
Revision:
31:e681177037ef
Child:
32:9c250eda7f3f
Changed Rasturizer.cpp and Rasturizer.h to Renderer.cpp and Renderer.h, documented Renderer class

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el17cd 31:e681177037ef 1 #include "mbed.h"
el17cd 31:e681177037ef 2 #include "N5110.h"
el17cd 31:e681177037ef 3 #ifndef FACE_H
el17cd 31:e681177037ef 4 #define FACE_H
el17cd 31:e681177037ef 5 #include "Face.h"
el17cd 31:e681177037ef 6 #endif
el17cd 31:e681177037ef 7
el17cd 31:e681177037ef 8 #ifndef CUBE_H
el17cd 31:e681177037ef 9 #define CUBE_H
el17cd 31:e681177037ef 10 #include "Cube.h"
el17cd 31:e681177037ef 11 #endif
el17cd 31:e681177037ef 12
el17cd 31:e681177037ef 13 class Renderer {
el17cd 31:e681177037ef 14 private:
el17cd 31:e681177037ef 15 float fov;
el17cd 31:e681177037ef 16 Cube selectionCube;
el17cd 31:e681177037ef 17 public:
el17cd 31:e681177037ef 18 Renderer();
el17cd 31:e681177037ef 19 void init();
el17cd 31:e681177037ef 20 float xTo2D(float x, float z);
el17cd 31:e681177037ef 21 /** @brief Projects the 3D x coordinate to 2D perspective
el17cd 31:e681177037ef 22 *@param The 3d x coordinate as a float
el17cd 31:e681177037ef 23 *@param The 3d z coordinate as a float
el17cd 31:e681177037ef 24 *@returns The 2D perspective fo the x coordinate
el17cd 31:e681177037ef 25 */
el17cd 31:e681177037ef 26 float yTo2D(float y, float z);
el17cd 31:e681177037ef 27 /** @brief Projects the 3D y coordinate to 2D perspective
el17cd 31:e681177037ef 28 *@param The 3d y coordinate as a float
el17cd 31:e681177037ef 29 *@param The 3d z coordinate as a float
el17cd 31:e681177037ef 30 *@returns The 2D perspective of the y coordinate
el17cd 31:e681177037ef 31 */
el17cd 31:e681177037ef 32 void drawHorizon(float angle);
el17cd 31:e681177037ef 33 /** @brief Draws the games horizon line
el17cd 31:e681177037ef 34 *@param The angle of the horizon determined by the joystick position
el17cd 31:e681177037ef 35 */
el17cd 31:e681177037ef 36 void drawFace(Face *face, float angle);
el17cd 31:e681177037ef 37 /** @brief Draw an individual face
el17cd 31:e681177037ef 38 *@param The face object
el17cd 31:e681177037ef 39 *@param The angle of the face object as a float
el17cd 31:e681177037ef 40 */
el17cd 31:e681177037ef 41 void rasterizeFace(float (&points)[4][3], Face *face);
el17cd 31:e681177037ef 42 /** @brief Fill in the face
el17cd 31:e681177037ef 43 *@param The pointer to an array containing the verticies of the face
el17cd 31:e681177037ef 44 *@param The face object
el17cd 31:e681177037ef 45 */
el17cd 31:e681177037ef 46 void drawFillLines(float (&points)[4][3], int diffX2, int stepBottomY, int stepTopX, int stepTopY);
el17cd 31:e681177037ef 47 /** @brief Draw an individual face
el17cd 31:e681177037ef 48 *@param The pointer to an array containing the verticies of the face
el17cd 31:e681177037ef 49 *@param The integer difference between the top horizontal edge x coordinates
el17cd 31:e681177037ef 50 *@param The integer difference between right vertical edge y coordinates
el17cd 31:e681177037ef 51 *@param The integer difference between bottom horizontal edge x coordinates
el17cd 31:e681177037ef 52 *@param The integer difference between left horizontal edge y coordinates
el17cd 31:e681177037ef 53 */
el17cd 31:e681177037ef 54 void drawFaceOutline(float (&points)[4][3]);
el17cd 31:e681177037ef 55 /** @brief Draw the outline of the face
el17cd 31:e681177037ef 56 *@param The pointer to an array containing the verticies of the face
el17cd 31:e681177037ef 57 */
el17cd 31:e681177037ef 58 void drawAllFaces(Face *faceArray, int noOfFaces, float angle);
el17cd 31:e681177037ef 59 /** @brief Draw all faces within a face array
el17cd 31:e681177037ef 60 *@param The pointer to an array of face objects
el17cd 31:e681177037ef 61 *@param The number of faces as an integer
el17cd 31:e681177037ef 62 *@param The angle of the faces as a float
el17cd 31:e681177037ef 63 */
el17cd 31:e681177037ef 64 bool checkOnScreen(float (&Points)[4][3]);
el17cd 31:e681177037ef 65 /** @brief Checks whether any area of the face is on the screen
el17cd 31:e681177037ef 66 *@param The pointer to an array containing the verticies of the face
el17cd 31:e681177037ef 67 */
el17cd 31:e681177037ef 68 void print(const char *text, int x, int y);
el17cd 31:e681177037ef 69 /** @brief Prints a string at a desired location on the screen
el17cd 31:e681177037ef 70 *@param The pointer to an array of characters of the string
el17cd 31:e681177037ef 71 *@param The x coordinate to draw the string as an integer
el17cd 31:e681177037ef 72 *@param The y coordinate to draw the string as an integer
el17cd 31:e681177037ef 73 */
el17cd 31:e681177037ef 74 void printScore(int score, int x, int y);
el17cd 31:e681177037ef 75 /** @brief Prints a score at a desired location on the screen
el17cd 31:e681177037ef 76 *@param The value of the score as an integer
el17cd 31:e681177037ef 77 *@param The x coordinate to draw the score as an integer
el17cd 31:e681177037ef 78 *@param The y coordinate to draw the score as an integer
el17cd 31:e681177037ef 79 */
el17cd 31:e681177037ef 80 void clear();
el17cd 31:e681177037ef 81 /** @brief Clears the display
el17cd 31:e681177037ef 82 */
el17cd 31:e681177037ef 83 void refresh();
el17cd 31:e681177037ef 84 /** @brief Refreshes the display
el17cd 31:e681177037ef 85 */
el17cd 31:e681177037ef 86 void turnOff();
el17cd 31:e681177037ef 87 /** @brief Turns off the display
el17cd 31:e681177037ef 88 */
el17cd 31:e681177037ef 89 void drawDeathScreen(int selection, int highScore);
el17cd 31:e681177037ef 90 /** @brief Draws the screen after the user has collided with a cube
el17cd 31:e681177037ef 91 *@param The selected option as an integer
el17cd 31:e681177037ef 92 *@param The high score as an integer
el17cd 31:e681177037ef 93 */
el17cd 31:e681177037ef 94 void drawDeathButtons();
el17cd 31:e681177037ef 95 /** @brief Draws the death menus buttons
el17cd 31:e681177037ef 96 */
el17cd 31:e681177037ef 97 void drawHomeScreen(int selection);
el17cd 31:e681177037ef 98 /** @brief Draws the games home screen
el17cd 31:e681177037ef 99 *@param The selected option as an integer
el17cd 31:e681177037ef 100 */
el17cd 31:e681177037ef 101 void drawHomeButtons();
el17cd 31:e681177037ef 102 /** @brief Draws the home menus buttons
el17cd 31:e681177037ef 103 */
el17cd 31:e681177037ef 104 void drawSelectionCube(int x, int y, int z, int rotationSpeed);
el17cd 31:e681177037ef 105 /** @brief Draws the cube which indicates the selected button on the menus
el17cd 31:e681177037ef 106 *@param The x coordinate of where to draw the cube as an integer
el17cd 31:e681177037ef 107 *@param The y coordinate of where to draw the cube as an integer
el17cd 31:e681177037ef 108 *@param The z coordinate of where to draw the cube as an integer
el17cd 31:e681177037ef 109 *@param The rotation speed multiplier of the cube as an integer
el17cd 31:e681177037ef 110 */
el17cd 31:e681177037ef 111 void drawHelpScreen1();
el17cd 31:e681177037ef 112 /** @brief Draws the first help screen
el17cd 31:e681177037ef 113 */
el17cd 31:e681177037ef 114 void drawHelpScreen2();
el17cd 31:e681177037ef 115 /** @brief Draws the second help screen
el17cd 31:e681177037ef 116 */
el17cd 31:e681177037ef 117 void drawHelpScreen3();
el17cd 31:e681177037ef 118 /** @brief Draws the third help screen
el17cd 31:e681177037ef 119 */
el17cd 31:e681177037ef 120 void drawHelpScreen4();
el17cd 31:e681177037ef 121 /** @brief Draws the fourth help screen
el17cd 31:e681177037ef 122 */
el17cd 31:e681177037ef 123 };
el17cd 31:e681177037ef 124