Skip to main content

Hidden Surface Removal

Look at the scratch code "RotatingSolidCube.cpp" and study it carefully
#include 
#include 
#include 
#include  

typedef struct{float x;float y;}Point2D;

float dx = 200, dy = 200, dz = 200;

GLfloat n[6][3];  /* Normals for the 6 faces of a cube. */

/* Vertex indices for the 6 faces of a cube. */ 
GLint faces[6][4] = { //traversed in counterclockwise direction as seen from outside
 {0, 1, 2, 3}, {3, 2, 6, 7}, {7, 6, 5, 4},
 {4, 5, 1, 0}, {5, 6, 2, 1}, {7, 4, 0, 3}  
};

GLfloat v[8][3];  /* Will be filled in with X,Y,Z vertexes. */

void init(void)
{
 /* Setup cube vertex data. */
        v[0][0] =100; v[0][1] = 100; v[0][2] = 300; 
        v[1][0] =300; v[1][1] = 100; v[1][2] = 300;
        v[2][0] =300; v[2][1] = 300; v[2][2] = 300;
        v[3][0] =100; v[3][1] = 300; v[3][2] = 300;
        v[4][0] =100; v[4][1] = 100; v[4][2] = 100;
        v[5][0] =300; v[5][1] = 100; v[5][2] = 100;
        v[6][0] =300; v[6][1] = 300; v[6][2] = 100;
        v[7][0] =100; v[7][1] = 300; v[7][2] = 100;

}

Point2D Project_ortho(float x, float y, float z){
 Point2D p0;
 p0.x = x ;
 p0.y = y ;
 return p0;
}

void update_normals(){      //updating the normal vectors 
 for (int f=0; f<6 -="" -dx="" ......="" 0.0f="" 0="" 1.0f="" 180.0="" 3.14="" 600="" 6="" 800="" 8="" amp="" ang="" angle="" argc="" argv="" break="" case="" char="" complete="" cos="" default:="" deg_x="" deg_y="" drawbox="" dx="" dy="" dz="" exit="" f="" faces="" float="" font="" for="" gl_projection="" glbegin="" glclear="" glclearcolor="" glcolor3f="" glend="" glflush="" glloadidentity="" glmatrixmode="" gluortho2d="" glut_key_down:="" glut_key_left:="" glut_key_right:="" glut_key_up:="" glutcreatewindow="" glutdisplayfunc="" glutinit="" glutinitwindowposition="" glutinitwindowsize="" glutkeyboardfunc="" glutmainloop="" glutpostredisplay="" glutspecialfunc="" glvertex2f="" glviewport="" i="" if="" in="" init="" int="" key="" keyboard="" main="" mydisplay="" n="" p0.x="" p0.y="" p0="Project_ortho(v[" p1.x="" p1.y="" p1="Project_ortho(v[" p2.x="" p2.y="" p2="Project_ortho(v[" p3.x="" p3.y="" p3="Project_ortho(v[" point2d="" portion="" prisms="" q="" radians="" return="" rotatebox_x="" rotatebox_y="" rotatex="" rotatey="" sin="" special="" switch="" this="" translate="" tx="*x," ty="*y," tz="" unsigned="" v="" void="" x="" y="" z="-tx">

Implement the back-face removal method to display the solid cube with the following vertices.
And the answer is given here

Comments

Popular posts from this blog

Scan Conversion(Circle) - Midpoint Algorithm

Assignment 05. Use the mid-point circle technique to derive the necessary equations to scan convert the following circular sector (i.e., points from  27 0 o  to 315 o ) .  Implement your method and u se the circle's symmetric property to draw complete circles.   The file is available here ( ScanConvertCirclemidpoint.cpp ) Play with it. You will understand..

Raising cryptography’s standards

Calculating encryption schemes’ theoretical security guarantees eases comparison, improvement. Most modern cryptographic schemes rely on computational complexity for their security. In principle, they can be cracked, but that would take a prohibitively long time, even with enormous computational resources. There is, however, another notion of security — information-theoretic security — which means that even an adversary with unbounded computational power could extract no useful information from an encrypted message. Cryptographic schemes that promise information-theoretical security have been devised, but they’re far too complicated to be practical. In a series of papers presented at the Allerton Conference on Communication, Control, and Computing, researchers at MIT and Maynooth University in Ireland have shown that existing, practical cryptographic schemes come with their own information-theoretic guarantees: Some of the data they encode can’t be extracted, even by a ...

TrashCoders

As I'm forming a Club "TrashCoders" after our Summer Holidays (May 2nd week), and going to share the knowledge I have, I created a new blog to upload all of the works we do in the Club. Hope you guys have some ideas and/or tips. Trash Coders  Happy Holidays..