// ONLY GUI DRAWS GO HERE //-------------------------------------------------------------- void ofApp::draw() { // draw our graphics on-screen so we can copy to texture. ofPushMatrix(); ofTranslate(699, 480); drawFbo(); ofPopMatrix(); drawPanels(); // brightness draw ofSetColor(255, 255, 255); ofDrawBitmapString("// PROJECT LUMI //", ofGetWidth()-250, 20); ofDrawBitmapString("Rotate (r) == " + ofToString(fboRotate), ofGetWidth()-250, 40); ofDrawBitmapString("Flip (f) == " + ofToString(fboFlip), ofGetWidth()-250, 60); ofDrawBitmapString("Bright (u/d) == " + ofToString(brightness), ofGetWidth()-250, 80); ofDrawBitmapString("Speed (l/r) == " + ofToString(waveSpeed), ofGetWidth()-250, 100); ofDrawBitmapString("Videos # == " + ofToString(dirVid.size()), ofGetWidth()-250, 120); ofDrawBitmapString("Images # == " + ofToString(dirImg.size()), ofGetWidth()-250, 140); ofDrawBitmapString("GIFs # == " + ofToString(dirGif.size()), ofGetWidth()-250, 160); }
void myInit(void) { /* glGetIntegerv(GL_MAX_CLIP_PLANES, nest); printf("GL_MAX_CLIP_PLANES are %d \n", nest[0]); */ /*%%%%%%%% Initialize Positional Light and Ambient Light %%%%%%%%*/ #if 0 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); #endif #if 0 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glLightfv(GL_LIGHT0, GL_POSITION, lightPos); glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmb); glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiff); glLightfv(GL_LIGHT0, GL_SPECULAR, lightSpec); glEnable(GL_LIGHT0); #endif /*** Initial light position is declared in the display function ***/ glLightfv(GL_LIGHT1, GL_AMBIENT, light1Amb); glLightfv(GL_LIGHT1, GL_DIFFUSE, light1Diff); glLightfv(GL_LIGHT1, GL_SPECULAR, light1Spec); glEnable(GL_LIGHT1); glEnable(GL_LIGHTING); /* glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 0.7);*/ /* glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.04);*/ /* use 0.04 w/ 24 bit color */ glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.07); /* try 0.07 w/ 24 bit color */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ /*########### Initialize Fog ##################*/ /* { GLfloat fog_color[] = {0.5, 0.5, 0.5, 1.0}; GLfloat fog_start[] = {0.0, 0.0, 1.0, 20.0}; glEnable(GL_FOG); glFogi(GL_FOG_MODE, GL_LINEAR); glFogfv(GL_FOG_COLOR, fog_color); glFogf(GL_FOG_DENSITY, 0.35); glFogfv(GL_FOG_START, fog_start); glHint(GL_FOG_HINT, GL_FASTEST); } */ /*##########################################*/ /*....Shadow Matrices For Floor, Left Wall, Back Wall, and Right Wall......*/ /* For light0 */ myShadowMatrix(groundPlane, lightPos, shadowMat_ground); myShadowMatrix(leftPlane, lightPos, shadowMat_left); myShadowMatrix(columnPlane, lightPos, shadowMat_column); myShadowMatrix(backPlane, lightPos, shadowMat_back); myShadowMatrix(rightPlane, lightPos, shadowMat_right); /* For light1 */ myShadowMatrix(groundPlane, light1Pos, shadowMat1_ground); myShadowMatrix(leftPlane, light1Pos, shadowMat1_left); myShadowMatrix(backPlane, light1Pos, shadowMat1_back); myShadowMatrix(rightPlane, light1Pos, shadowMat1_right); /*.......................................................................*/ /*sssssssssssssssss Make Satellite Body and Shadow ssssssssssssssssssssssss*/ glNewList(satellite1, GL_COMPILE); glPushMatrix(); drawSatellite(satellite_diffuse, satellite_ambient, satellite_specular, satellite_shiny); glPopMatrix(); glEndList(); glNewList(satellite2, GL_COMPILE); glPushMatrix(); drawSatellite(shadow_diffuse, shadow_ambient, shadow_specular, shadow_shiny); glPopMatrix(); glEndList(); /*sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss*/ /*ppppppppppppppppppppppppppp Make Solar Panels and Shadows pppppppppppppppppp*/ glNewList(panel1, GL_COMPILE); glPushMatrix(); drawPanels(panel_color, panel_ambient); glPopMatrix(); glEndList(); glNewList(panel2, GL_COMPILE); glPushMatrix(); drawPanels(shadow_diffuse, shadow_ambient); glPopMatrix(); glEndList(); /*pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp*/ /*========= Make Floor ==============*/ glNewList(ground, GL_COMPILE); glPushMatrix(); glPushAttrib(GL_LIGHTING_BIT); glMaterialfv(GL_FRONT, GL_DIFFUSE, floor_color); glMaterialfv(GL_FRONT, GL_AMBIENT, shadow_ambient); glTranslatef(0.0, -1.5, -5.0); glRotatef(-90.0, 1, 0, 0); glScalef(5.0, 5.0, 1.0); drawGround(); /* draw ground */ glPopAttrib(); glPopMatrix(); glEndList(); /*==================================*/ /*@@@@@@@@@@ Make Lamp Post and Lamp @@@@@@@@@@@@*/ glNewList(21, GL_COMPILE); glPushMatrix(); glPushAttrib(GL_LIGHTING_BIT); glMaterialfv(GL_FRONT, GL_AMBIENT, lamp_post_specular); glTranslatef(0.0, -0.1, -5.0); glScalef(0.07, 1.45, 0.07); drawCube(lamp_post_diffuse, lamp_post_ambient); /* draw lamp post */ glPopAttrib(); glPopMatrix(); glPushMatrix(); glTranslatef(0.0, -1.45, -5.0); glScalef(0.3, 0.05, 0.3); drawCube(wall_color, cube_ambient); /* draw lamp post base */ glPopMatrix(); glEndList(); glNewList(22, GL_COMPILE); glPushMatrix(); glPushAttrib(GL_LIGHTING_BIT); glMaterialfv(GL_FRONT, GL_AMBIENT, lamp_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, lamp_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, lamp_specular); glTranslatef(0.0, 1.6, -5.0); glutSolidSphere(0.3, 20.0, 20.0); /* draw lamp */ glPopAttrib(); glPopMatrix(); glEndList(); /*** Lamp post base shadow ***/ glNewList(501, GL_COMPILE); glPushMatrix(); glPushAttrib(GL_LIGHTING_BIT); glMaterialfv(GL_FRONT, GL_AMBIENT, shadow_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, shadow_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, shadow_specular); glMaterialfv(GL_FRONT, GL_SHININESS, shadow_shiny); glTranslatef(0.0, -1.49, -5.0); glRotatef(-90.0, 1.0, 0.0, 0.0); glScalef(0.7, 0.7, 1.0); drawOct(); glPopAttrib(); glPopMatrix(); glEndList(); /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*||||||||||| Make Left Wall |||||||||||||*/ glNewList(left_wall, GL_COMPILE); glPushMatrix(); glPushAttrib(GL_LIGHTING_BIT); glMaterialfv(GL_FRONT, GL_DIFFUSE, wall_color); glMaterialfv(GL_FRONT, GL_AMBIENT, wall_ambient); glTranslatef(0.0, -1.5, 0.0); glTranslatef(0.0, 1.2, 0.0); glTranslatef(0.0, 0.0, -5.0); glTranslatef(-5.0, 0.0, 0.0); glRotatef(90.0, 0, 1, 0); glScalef(4.5, 1.2, 1.0); glNormal3f (0.0, 0.0, 1.0); drawGround(); /* draw left wall */ glPopAttrib(); glPopMatrix(); glEndList(); /*||||||||||||||||||||||||||||||||||||||||*/ /*\\\\\\\\\\\\\ Make Right Wall \\\\\\\\\\\\\\\\\\\*/ glNewList(right_wall, GL_COMPILE); glPushMatrix(); glPushAttrib(GL_LIGHTING_BIT); glMaterialfv(GL_FRONT, GL_DIFFUSE, wall_color); glMaterialfv(GL_FRONT, GL_AMBIENT, wall_ambient); glTranslatef(0.0, -1.5, 0.0); glTranslatef(0.0, 1.2, 0.0); glTranslatef(0.0, 0.0, -5.0); glTranslatef(5.0, 0.0, 0.0); glRotatef(270.0, 0, 1, 0); glScalef(4.5, 1.2, 1.0); glNormal3f (0.0, 0.0, 1.0); drawGround(); /* draw right wall */ glPopAttrib(); glPopMatrix(); glEndList(); /*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ /*[[[[[[[[[[[ Build Columns ]]]]]]]]]]]*/ glPushMatrix(); glNewList(1, GL_COMPILE); glPushMatrix(); glScalef(0.4, 1.4, 0.4); drawCube(column_color, column_ambient); /* draw column1 */ glPopMatrix(); glEndList(); glNewList(2, GL_COMPILE); glPushMatrix(); glTranslatef(0.0, -1.45, 0.0); glScalef(0.5, 0.1, 0.5); drawCube(wall_color, cube_ambient); /* draw base */ glPopMatrix(); glPushMatrix(); glTranslatef(0.0, 1.45, 0.0); glScalef(0.5, 0.1, 0.5); drawCube(wall_color, cube_ambient); /* draw top */ glPopMatrix(); glEndList(); glPopMatrix(); glNewList(column, GL_COMPILE); glPushMatrix(); glCallList(1); glCallList(2); glPopMatrix(); glEndList(); /***** Place columns at front of scene. *****/ glNewList(4, GL_COMPILE); glPushMatrix(); glTranslatef(-5.0, 0.0, -0.5); glCallList(column); glPopMatrix(); glEndList(); glNewList(5, GL_COMPILE); glPushMatrix(); glTranslatef(-1.75, 0.0, -0.5); glCallList(column); glPopMatrix(); glEndList(); glNewList(6, GL_COMPILE); glPushMatrix(); glTranslatef(1.75, 0.0, -0.5); glCallList(column); glPopMatrix(); glEndList(); glNewList(17, GL_COMPILE); glPushMatrix(); glTranslatef(5.0, 0.0, -0.5); glCallList(column); glPopMatrix(); glEndList(); /*** Get the modelview matrix once ***/ glPushMatrix(); glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z); glTranslatef(-mvt_x, -mvt_y, -mvt_z); glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *) four_columnsXform); glPopMatrix(); glNewList(four_columns, GL_COMPILE); glPushMatrix(); glCallList(4); glCallList(5); glCallList(6); glCallList(17); glPopMatrix(); glEndList(); /***** Make two columns for sides of scene *****/ glNewList(two_columns, GL_COMPILE); glPushMatrix(); glRotatef(90.0, 0.0, 1.0, 0.0); glTranslatef(5.0, 0.0, -5.0); glPushMatrix(); glTranslatef(0.0, 0.0, -0.3); glCallList(column); glPopMatrix(); glPushMatrix(); glTranslatef(0.0, 0.0, 10.3); glCallList(column); glPopMatrix(); glPopMatrix(); glEndList(); /*[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]*/ /* .......................Make shadows .........................*/ glPushMatrix(); glNewList(8, GL_COMPILE); glPushMatrix(); glScalef(0.4, 1.4, 0.4); drawCube(shadow_diffuse, shadow_ambient); /* draw column1 */ glPopMatrix(); glEndList(); glNewList(9, GL_COMPILE); glPushMatrix(); glTranslatef(0.0, -1.45, 0.0); glScalef(0.5, 0.1, 0.5); drawCube(shadow_diffuse, shadow_ambient); /* draw base. */ glPopMatrix(); glPushMatrix(); glTranslatef(0.0, 1.45, 0.0); glScalef(0.5, 0.1, 0.5); drawCube(shadow_diffuse, shadow_ambient); /* draw top. */ glPopMatrix(); glEndList(); glPopMatrix(); glNewList(10, GL_COMPILE); glPushMatrix(); glCallList(8); glCallList(9); glPopMatrix(); glEndList(); glNewList(11, GL_COMPILE); glPushMatrix(); glTranslatef(-5.0, 0.0, -0.5); glCallList(10); glPopMatrix(); glEndList(); glNewList(12, GL_COMPILE); glPushMatrix(); glTranslatef(-1.75, 0.0, -0.5); glCallList(10); glPopMatrix(); glEndList(); glNewList(13, GL_COMPILE); glPushMatrix(); glTranslatef(1.75, 0.0, -0.5 ); glCallList(10); glPopMatrix(); glEndList(); glNewList(14, GL_COMPILE); glPushMatrix(); glTranslatef(5.0, 0.0, -0.5 ); glCallList(10); glPopMatrix(); glEndList(); glNewList(15, GL_COMPILE); glPushMatrix(); glCallList(11); glCallList(12); glCallList(13); glCallList(14); glPopMatrix(); glEndList(); glNewList(100, GL_COMPILE); glPushMatrix(); glMultMatrixf((const GLfloat *) shadowMat_ground); glTranslatef(-mvt_x, -mvt_y, -mvt_z); /* correct for modelview matrix */ glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z); glMultMatrixf((const GLfloat *) four_columnsXform); glCallList(15); glPopMatrix(); glEndList(); glNewList(101, GL_COMPILE); glPushMatrix(); glMultMatrixf((const GLfloat *) shadowMat_left); glTranslatef(-mvt_x, -mvt_y, -mvt_z); /* correct for modelview matrix */ glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z); glMultMatrixf((const GLfloat *) four_columnsXform); glCallList(15); glPopMatrix(); glEndList(); glNewList(102, GL_COMPILE); glPushMatrix(); glMultMatrixf((const GLfloat *) shadowMat_back); glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z); glTranslatef(-mvt_x, -mvt_y, -mvt_z); /* correct for modelview matrix */ glMultMatrixf((const GLfloat *) four_columnsXform); glCallList(15); glPopMatrix(); glEndList(); glNewList(103, GL_COMPILE); glPushMatrix(); glMultMatrixf((const GLfloat *) shadowMat_right); glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z); glTranslatef(-mvt_x, -mvt_y, -mvt_z); /* correct for modelview matrix */ glMultMatrixf((const GLfloat *) four_columnsXform); glCallList(15); glPopMatrix(); glEndList(); /* ......................................................*/ }
void display(void) { glPushMatrix(); /* Make sure the matrix stack is cleared at the end of this function. */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); /*@@@@@@ Rotation and Translation of Entire Scene @@@@@*/ if(mvt_x < 0 && mvt_y < 0){ glTranslatef(mvt_x ,mvt_y ,mvt_z ); mvt_x = mvt_x - Tx; mvt_y = mvt_y - Ty; mvt_z = mvt_z - Tz; glRotatef(mvr_d, mvr_x, mvr_y, mvr_z); mvr_d = mvr_d - Rx; } else{ glTranslatef(0.0, 0.0 ,mvt_z); } /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ glPushMatrix(); glLightfv(GL_LIGHT1, GL_POSITION, light1Pos); glPopMatrix(); /*______________________ Draw Floor _______________________*/ glPushMatrix(); glCallList(ground); glPopMatrix(); /*_________________________________________________________*/ /*@@@@@@@@@ Draw Lamp Post amd Lamp @@@@@@@@@@*/ glPushMatrix(); glCallList(21); glPopMatrix(); glPushMatrix(); glCallList(22); glPopMatrix(); glPushMatrix(); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glCallList(501); glDisable(GL_BLEND); glPopMatrix(); /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*||||||||||||||||||| Draw Left Wall ||||||||||||||||||*/ glCallList(left_wall); /*|||||||||||||||||||||||||||||||||||||||||||||||||||||*/ /*\\\\\\\\\\\\\\\\ Draw Right Wall \\\\\\\\\\\\\\*/ glCallList(right_wall); /*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ /*[[[[[[[[[[[[[[[[[[[ Draw Columns ]]]]]]]]]]]]]]]]]]]*/ /***** Place columns at front of scene. *****/ glCallList(four_columns); /***** Place columns at back of scene. *****/ glPushMatrix(); glTranslatef(0.0, 0.0, -9.0); glCallList(four_columns); glPopMatrix(); /***** Place columns at centers of left and right walls. *****/ glCallList(two_columns); /*[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]*/ /*....................... Draw Column Shadows ....................*/ /*glDepthMask(GL_FALSE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ /* shadows on floor */ /* glPushMatrix(); glCallList(100); glPopMatrix();*/ /* shdows on left wall */ /* glPushMatrix(); glCallList(101); glPopMatrix();*/ /* shdows on back wall */ /* glPushMatrix(); glCallList(102); glPopMatrix();*/ /* shdows on right wall */ /* glPushMatrix(); glCallList(103); glPopMatrix();*/ /*glDepthMask(GL_TRUE); glDisable(GL_BLEND);*/ /*................................................................*/ /************************* CUBE ***********************/ glMaterialf(GL_FRONT, GL_SHININESS, 99.0); glMaterialfv(GL_FRONT, GL_SPECULAR, cube_specular); glPushMatrix(); glTranslatef(0.0, 0.0, -5.0); glRotatef((360.0 / (30 * 2)) * tick, 0, 1, 0); glPushMatrix(); glTranslatef(0.0, 0.2, 2.0); /* glTranslatef(0.0, 0.2, 0.0); */ /* glScalef(0.3, 0.3, 0.3); */ glRotatef((360.0 / (30 * 1)) * tick, 1, 0, 0); glRotatef((360.0 / (30 * 2)) * tick, 0, 1, 0); glRotatef((360.0 / (30 * 4)) * tick, 0, 0, 1); glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *) cubeXform); /* drawSatellite(satellite_diffuse, satellite_ambient, satellite_specular, satellite_shiny); */ glCallList(satellite1); glCallList(panel1); /* drawPanels(panel_color, panel_ambient); */ glPopMatrix(); glPopMatrix(); glMaterialf(GL_FRONT, GL_SHININESS, 0.0); glMaterialfv(GL_FRONT, GL_SPECULAR, shadow_specular); /****************************************************/ /*................... CUBE SHADOWS .............................*/ /*glDepthMask(GL_FALSE);*/ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPushMatrix(); glMultMatrixf((const GLfloat *) shadowMat1_ground); glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z); glTranslatef(-mvt_x, -mvt_y, -mvt_z); /* correct for modelview matrix */ glMultMatrixf((const GLfloat *) cubeXform); /* drawSatellite(shadow_diffuse, shadow_ambient, shadow_specular, shadow_shiny); */ /* draw ground shadow */ glCallList(satellite2); glTranslatef(0.0, -.040, 0.0); glCallList(panel2); /* drawPanels(shadow_diffuse, shadow_ambient); */ glPopMatrix(); /* Shadow left wall only if cube is in front of left wall. */ if((tick*6) >= 220 && (tick*6) <= 320) { glPushMatrix(); glMultMatrixf((const GLfloat *) shadowMat1_left); glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z); glTranslatef(-mvt_x, -mvt_y, -mvt_z); /* correct for modelview matrix */ glMultMatrixf((const GLfloat *) cubeXform); drawSatellite(shadow_diffuse, shadow_ambient, shadow_specular, shadow_shiny); /* draw left shadow */ drawPanels(shadow_diffuse, shadow_ambient); glPopMatrix(); } /* Shadow back wall only if cube is in front of back wall. */ if((tick*6) >= 125 && (tick*6) <= 330) { glPushMatrix(); glMultMatrixf((const GLfloat *) shadowMat1_back); glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z); glTranslatef(-mvt_x, -mvt_y, -mvt_z); /* correct for modelview matrix */ glMultMatrixf((const GLfloat *) cubeXform); drawSatellite(shadow_diffuse, shadow_ambient, shadow_specular, shadow_shiny); /* draw back wall shadow */ drawPanels(shadow_diffuse, shadow_ambient); glPopMatrix(); } /* Shadow right wall only if cube is in front of right wall. */ if((tick*6) >= 40 && (tick*6) <= 145) { glPushMatrix(); glMultMatrixf((const GLfloat *) shadowMat1_right); glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z); glTranslatef(-mvt_x, -mvt_y, -mvt_z); /* correct for modelview matrix */ glMultMatrixf((const GLfloat *) cubeXform); drawSatellite(shadow_diffuse, shadow_ambient, shadow_specular, shadow_shiny); /* draw right wall shadow */ drawPanels(shadow_diffuse, shadow_ambient); glPopMatrix(); } /*glDepthMask(GL_TRUE);*/ glDisable(GL_BLEND); /*.........................................................*/ glutSwapBuffers(); checkErrors(); glPopMatrix(); /* Clear the matrix stack */ }