Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: Rasturizer/Rasturizer.cpp
- Revision:
- 20:3ca430241df0
- Parent:
- 19:ec4cb22accb0
- Child:
- 21:6b5d2d75e083
--- a/Rasturizer/Rasturizer.cpp Mon Apr 01 14:43:18 2019 +0000
+++ b/Rasturizer/Rasturizer.cpp Mon Apr 01 17:11:40 2019 +0000
@@ -4,16 +4,11 @@
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Rasturizer::Rasturizer(){
+ for(int i = 0; i < 6; i++){
+ selectionCube.getFace(i).setVisible(true);
+ }
+}
- /*float tempPoints[4][3] = {{43, 2.5, 30}, {43, 2.5, 200}, {43, -2.5, 200}, {43, -2.5, 30}};
- for(int vertex = 0; vertex < 8; vertex++){
- for(int axis = 0; axis < 3; axis++){
- edgePoints[vertex][axis] = tempPoints[vertex][axis];
- }
- }
- edge.setVerticies(edgePoints);
- edge.setVisible(true);*/
-}
void Rasturizer::init(){
lcd.init();
@@ -33,12 +28,7 @@
21-rint(angle*50),
84,
21+rint(angle*50),
- 1);/*
- for( int i = 0; i<4; i++){
- edgePoints[i][0] -= angle*50;
- }
- edge.setVerticies(edgePoints);
- drawFace(edge, angle);*/
+ 1);
}
void Rasturizer::drawFace(Face face, float angle){
@@ -96,6 +86,20 @@
1);
}
}
+void Rasturizer::drawAllFaces(Face faceArray[], int noOfCubes, float angle){
+ for (int f = 0; f< (noOfCubes*6)-1; f++){
+ for (int f2 = 0; f2< (noOfCubes*6)-f-1; f2++){
+ if(faceArray[f2].getAvgZ() < faceArray[f2+1].getAvgZ()){
+ Face temp = faceArray[f2+1];
+ faceArray[f2+1] = faceArray[f2];
+ faceArray[f2] = temp;
+ }
+ }
+ }
+ for (int f = 0; f< noOfCubes*6 ; f++){
+ drawFace(faceArray[f], angle/15);
+ }
+}
bool Rasturizer::checkOnScreen(float (&points)[4][3]){
if (points[0][2] < 10 || points[1][2] < 10 || points[2][2] < 10 || points[3][2] < 10){
@@ -123,6 +127,7 @@
}
void Rasturizer::drawDeathScreen(bool selection){
+ Face faces[6];
int x;
int y;
int z;
@@ -146,8 +151,9 @@
lcd.printString("Menu",35,4);
selectionCube.translate(x, y, z);
for(int i = 0; i < 6; i++){
- drawFace(selectionCube.getFace(i), 0);
+ faces[i] = selectionCube.getFace(i);
}
+ drawAllFaces(faces, 1, 0);
selectionCube.rotateX(0.1);
selectionCube.rotateY(0.05);
selectionCube.rotateZ(-0.08);
@@ -155,6 +161,7 @@
}
void Rasturizer::drawHomeScreen(int selection){
+ Face faces[6];
int x;
int y;
int z;
@@ -190,8 +197,9 @@
selectionCube.translate(x, y, z);
for(int i = 0; i < 6; i++){
- drawFace(selectionCube.getFace(i), 0);
+ faces[i] = selectionCube.getFace(i);
}
+ drawAllFaces(faces, 1, 0);
selectionCube.rotateX(-0.1);
selectionCube.rotateY(-0.05);
selectionCube.rotateZ(0.08);