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

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..

Download your favorite Serials whole season at once

So, we all have our favorite serials. Or someone recently suggested you a serial which is now on it's latest season and you want to look at all those previous seasons. Some may watch it in online There are plenty of sites to watch them online. mywatchseries.to watch-series.com What if you want to download? You can download using IDM while playing online. How to download a whole season? Playing every episode and download? That's possible. But, is there an easy way? Yes. There is! These are the steps to follow. Before going down, download and install the latest IDM. IDM Latest (This is cracked. But, if you like. Support the developers by buying it) Step one Choose the site where you can download all your episodes. for example : http://dl2.mihanpix.com/Serial/ Index of Serial There are plenty of sites like this. To find those, just google "Index of Serials". Googled it Step two Go to the page of which season you want to download...

Scan Conversion(Line) - Bresenham's Algorithm

As the second Assignment we implemented Bresenham's Algorithm. For details visit  here . Assignment 02. 1.   Use the  Bresenham’s method to derive an algorithm to scan convert lines  with slope between 0 o  and -45 o (NOT  0 o  and +45 o ). 2.   Implement your algorithm to rasterize   lines that go from left to right, with slope between 0 o  and -45 o . 3.    Modify your program to scan convert lines with any slope. The file is available here (ScanConvertLine.cpp)