void mouse_event(int button, int state, int x, int y) { glClear(GL_COLOR_BUFFER_BIT); light.draw(); r.clearZbuffer(); switch(button) { case GLUT_LEFT_BUTTON: { for(unsigned int i=0;i<o.face_size;i++) { o.vertices[i] =SCH*o.vertices[i]; } o.draw(Color(0.3,0.2,0.3)); break; } case GLUT_RIGHT_BUTTON: { for(unsigned int i=0;i<o.face_size;i++) { o.vertices[i] =SCL*o.vertices[i]; } o.draw(Color(0.3,0.2,0.3)); break; } } glFlush(); glutSwapBuffers(); }
// draw callback // Purposes: // - Load the navigation matrix to reflect frame's navigation // - Use OpenGL to generate computer graphics. void draw(arMasterSlaveFramework& framework) { // Load the navigation matrix. framework.loadNavMatrix(); // Generate graphics. if(selectionMode == 2) { renderPrimitive(-2.5f); // draws square with quadrants drawObjects(-2.5f); // draw the mini versions } vector<arInteractable*>::iterator i; for(i=objects.begin(); i != objects.end(); ++i) { Object* oby = ((Object*)(*i)); oby->draw(); } // Draw the effectors. rightHand.draw(); leftHand.draw(); }
bool Object::draw() { bool drawn = false; glMatrixMode(GL_MODELVIEW); glPushMatrix(); glTranslatef(transform_.translation_.x(), transform_.translation_.y(), transform_.translation_.z()); glRotatef(transform_.rotation_deg_.z(), 0, 0, 1); // ZYX Euler angles glRotatef(transform_.rotation_deg_.y(), 0, 1, 0); glRotatef(transform_.rotation_deg_.x(), 1, 0, 0); // Draw this: drawn = drawVertices(); // Draw children: for (list<Object*>::iterator it = children_.begin(); it != children_.end(); ++it) { Object* obj = dynamic_cast<Object*>(*it); if (obj != NULL) { drawn = obj->draw() | drawn; } } glMatrixMode(GL_MODELVIEW); glPopMatrix(); return drawn; }
void display() { float fov = RADIANS(70.0); float aspect = (float)W_WIDTH / (float)W_HEIGHT; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); projection = glm::perspective(fov, aspect, 0.1f, 100.0f); camera.viewMatrix(view); lightPos = glm::vec4(1, 0, 1, 0); lightDiff = glm::vec4(0.8, 0.8, 0.8, 1); lightSpec = glm::vec4(1, 1, 1, 0); glUniformMatrix4fv(uProjection, 1, GL_FALSE, &projection[0][0]); glUniformMatrix4fv(uView, 1, GL_FALSE, &view[0][0]); glUniform4fv(uLightPos, 1, &lightPos[0]); glUniform4fv(uLightDiff, 1, &lightDiff[0]); glUniform4fv(uLightSpec, 1, &lightSpec[0]); glUniform3fv(uCameraPosition, 1, &(camera.position)[0]); obj.rotation[2] = (float)timer / 5000.0; obj.draw(programID, projection * view, uModel); glutSwapBuffers(); }
void World::draw(SDL_Surface *dest, Player *player, int clip_x, int clip_y, int clip_w, int clip_h) { // Draw background SDL_Rect rect; rect.x = clip_x; rect.y = clip_y; rect.w = clip_w; rect.h = clip_h; SDL_FillRect(dest, &rect, m_bg_color); int num_layers = m_map->get_num_layers(); if (num_layers > 0) { m_map->draw_layer(dest, clip_x, clip_y, clip_w, clip_h, 0); } // Draw objects for (std::list<Object*>::iterator it = m_objects.begin(); it != m_objects.end(); ++it) { Object *object = *it; object->draw(dest, m_map, clip_x, clip_y, clip_w, clip_h); } player->draw(dest, m_map, clip_x, clip_y, clip_w, clip_h); if (num_layers > 1) { m_map->draw_layer(dest, clip_x, clip_y, clip_w, clip_h, 1); } }
void rotatee() { for(unsigned int i=0;i<rem.face_size;i++) { rem.vertices[i] =NN*RR*MM*rem.vertices[i]; } for(unsigned int i=0;i<boom.face_size;i++) { boom.vertices[i] =NN*RR*MM*boom.vertices[i]; } for(unsigned int i=0;i<hook.face_size;i++) { hook.vertices[i] =NN*RR*MM*hook.vertices[i]; } o.draw(Color(0.3,0.2,0.3)); rem.draw(Color(1.0,1.2,0.1)); boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); }
void draw_shape(void *ptr, void *s) { long int stamp = (long int)s; cpShape *shape = (cpShape*)ptr; Object *o = (Object*)shape->data; if (o->draw(stamp)) // if true it was drawn, happens only once per Object { if (!o->inBounds()) delete o; } }
void GraphicsRunner::update() { // Clear the graphics window with a slight gray background window_.clear(BACKGROUND_COLOR); // Move and draw all objects while removing ones that need deletion for (auto i = objects_.begin(); i != objects_.end(); ++i) { Object* object = *i; // If the object needs to be deleted if (object->delete_) { // First check to see this object is a brick if (Brick* brick = dynamic_cast<Brick*>(object)) { // And if it is, apply any special properties the brick might have. This function also decrements either // numBricks_ or numSpecialBricks_ depending on the brick's type handleSpecialBrick(brick); } // Free the memory delete object; // Erase the object from the containing vector. The iterator now points at the next object. i = objects_.erase(i); // Decrement the iterator since it will be incremented in the for loop. // Note! If i == objects_.begin() then this will cause undefined behavior. The first object should never // be deleted! --i; continue; } // Move and draw object->draw(window_); if (status_ == '\0') object->move(); } // Draw the game text for (Text text : text_) window_.draw(text); // Update the level timer if the game isn't paused if (status_ == '\0') text_[2].setString(getTimeStringFromSeconds(difftime(time(0), timerStart_) - secondsPaused_)); // Finally display all the objects on the screen. window_.display(); // And check the status of the game for the next frame checkStatus(); }
void Window::display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); float time = glutGet(GLUT_ELAPSED_TIME); for(ObjectList::const_iterator iter = objects.begin(), endIter = objects.end(); iter != endIter; ++iter) { Object *object = *iter; object->draw(); } glutSwapBuffers(); glFlush(); }
void display(void) { // for hiden suface removel, clear color,depth buffer glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //enable the depth test when displaying. glEnable(GL_DEPTH_TEST); //clear the matrix here //setProjectionMatrix(1,1); glLoadIdentity (); //set up light, eye, lookat gluLookAt(0.f,3.5f,6.f+z,0.f,1.f,0.f+z,0.f,1.f,0.f); glMatrixMode(GL_MODELVIEW); glPushMatrix(); //incase I want to add anything... //glMatrixMode(GL_MODELVIEW); // define & setup material here GLfloat ambient[] = {.1,0.1,0.1,1.0}; GLfloat diffuse[] = {1.0, 1.0, 1.0, 1.0}; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, diffuse); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 120.0); glRotatef(anglex+xd,1,0,0); glRotatef(angley+yd,0,1,0); //draw computes the texture coordinates and renders the teapot... teapot.draw(shader_program); glPopMatrix(); //glDisable(GL_TEXTURE_2D); //glDisable(GL_TEXTURE_GEN_S); //glDisable(GL_TEXTURE_GEN_T); //glEnable(GL_TEXTURE_GEN_R); //glTexGeni(GL_R,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR); glutSwapBuffers(); glFlush (); glutPostRedisplay(); }
void Scene::render() { float aspectRatio = (float)glutGet(GLUT_WINDOW_WIDTH) / (float)glutGet(GLUT_WINDOW_HEIGHT); Transform::setOrthographicProjection(-4, 4, -4 / aspectRatio, 4 / aspectRatio, 1, 1000.0f); //Transform::setPerspectiveProjection(70, (float)glutGet(GLUT_WINDOW_WIDTH), (float)glutGet(GLUT_WINDOW_HEIGHT), 0.1f, 1000.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); for (unsigned int i = 0; i < objects.size(); i++) { Object *o = objects.at(i); if (o) o->draw(); } }
int main() { ALLEGRO_DISPLAY *display = NULL; ALLEGRO_EVENT_QUEUE *event_queue = NULL; ALLEGRO_TIMER *timer = NULL; if(!al_init()){ cout << "failed to initialize allegro!" << endl; return -1; } if(!al_install_audio()){ cout << "failed to initialize audio!" << endl; return -1; } if(!al_init_acodec_addon()){ cout << "failed to initialize audio codecs!" << endl; return -1; }; al_init_primitives_addon(); al_init_image_addon(); al_install_keyboard(); srand(time(NULL)); ALLEGRO_BITMAP *mnuNew_game = al_load_bitmap("Images\\Menu\\mnuNewGame.png"); if(!mnuNew_game) { cout << "couldn't load image!" << endl; } ALLEGRO_BITMAP *mnuExit = al_load_bitmap("Images\\Menu\\mnuExit.png"); ALLEGRO_BITMAP *mnuOptions = al_load_bitmap("Images\\Menu\\mnuOptions.png"); ALLEGRO_BITMAP *mnuNew_gameS = al_load_bitmap("Images\\Menu\\mnuNewGameS.png"); ALLEGRO_BITMAP *mnuExitS = al_load_bitmap("Images\\Menu\\mnuExitS.png"); ALLEGRO_BITMAP *mnuOptionsS = al_load_bitmap("Images\\Menu\\mnuOptionsS.png"); ALLEGRO_BITMAP *help1 = al_load_bitmap("Images\\Help\\Help1.png"); ALLEGRO_BITMAP *gameStart1 = al_load_bitmap("Images\\Help\\count1.png"); ALLEGRO_BITMAP *gameStart2 = al_load_bitmap("Images\\Help\\count2.png"); ALLEGRO_BITMAP *gameStart3 = al_load_bitmap("Images\\Help\\count3.png"); ALLEGRO_BITMAP *gameStart4 = al_load_bitmap("Images\\Help\\count4.png"); ALLEGRO_BITMAP *bitmap = NULL; ALLEGRO_BITMAP *bitmap2 = NULL; bitmap = al_create_bitmap(200,600); bitmap2 = al_create_bitmap(200,600); al_set_target_bitmap(bitmap); al_clear_to_color(al_map_rgb(0,0,0)); al_set_target_bitmap(bitmap2); al_clear_to_color(al_map_rgb(0,0,0)); if (!al_reserve_samples(20)) { cout << "failed to reserve samples!\n" << endl; return -1; } bool redraw = false; bool doexit = false; bool initMenu = true; bool dogame = false; bool key[8] = {false, false, false, false, false, false, false, false}; Object *spaceship; spaceship = new Object(); M_Object *shots; shots = NULL; M_Object *enemies; enemies = NULL; Sound_Effects Sounds; int menuSelection = 1; int contador = 0; int count_pressed = 0; int enem_mov_flag = 0; display = al_create_display(Width,Height); timer = al_create_timer(1.0/FPS); event_queue = al_create_event_queue(); al_register_event_source(event_queue, al_get_display_event_source(display)); al_register_event_source(event_queue, al_get_timer_event_source(timer)); al_register_event_source(event_queue, al_get_keyboard_event_source()); // Pintando o background e desenhando o bitmap// al_set_target_bitmap(al_get_backbuffer(display)); al_clear_to_color(al_map_rgb(100,100,100)); // Flip display trás o background desenhado para a tela// al_flip_display(); al_start_timer(timer); while(!doexit) { ALLEGRO_EVENT ev; al_wait_for_event(event_queue, &ev); ///-/////////////////////////////////////////////////////////////////////-/// ///------------------------------ MENU LOOP ------------------------------/// ///-/////////////////////////////////////////////////////////////////////-/// if(initMenu && !dogame) { if(ev.type == ALLEGRO_EVENT_TIMER) { if(key[KEY_UP] || key[KEY_DOWN]) { count_pressed++; if((count_pressed == FPS/6) && key[KEY_UP]) { menuSelection = (menuSelection-1) + 3*(1 - 7%menuSelection); count_pressed = 0; } if((count_pressed == FPS/6) && key[KEY_DOWN]) { menuSelection = (1 - (menuSelection+1)/4)*menuSelection +1; count_pressed = 0; } } if(!key[KEY_UP] && !key[KEY_DOWN]) { count_pressed = 0; } redraw = true; } else if(ev.type == ALLEGRO_EVENT_KEY_DOWN) { switch(ev.keyboard.keycode) { case ALLEGRO_KEY_UP: key[KEY_UP] = true; menuSelection = (menuSelection-1) + 3*(1 - 7%menuSelection); break; case ALLEGRO_KEY_DOWN: key[KEY_DOWN] = true; menuSelection = (1 - (menuSelection+1)/4)*menuSelection +1; break; case ALLEGRO_KEY_LEFT: break; case ALLEGRO_KEY_RIGHT: break; case ALLEGRO_KEY_ENTER: if(menuSelection == 1) { cout << "loading."; spaceship->set_obj(Width/2 - 60, Height - 120, 300, 100); spaceship->select_image("Images\\Ship\\"); for( int i = 0; i < 10; i++) { enemies = enemies->create_each(enemies, 250 + (i*45), 50, 60, 3, true, 45); enemies->select_image("Images\\Enemies\\"); enemies = enemies->create_each(enemies, 250 + (i*45), 100, 60, 3, true, 45); enemies->select_image("Images\\Enemies\\"); enemies = enemies->create_each(enemies, 250 + (i*45), 150, 60, 3, true, 45); enemies->select_image("Images\\Enemies\\"); } al_set_target_bitmap(al_get_backbuffer(display)); al_clear_to_color(al_map_rgb(100,100,100)); cout << "."; al_draw_bitmap( bitmap, 0, 0, 0); al_draw_bitmap( bitmap2, 800, 0, 0); spaceship->draw(); Draw_Multi(enemies); al_flip_display(); cout << "." << endl; Sounds.load_music(); al_rest(0.2); cout << "done!" << endl; initMenu = false; dogame = true; Sounds.play_music(); } if(menuSelection == 3) { doexit = true; } break; case ALLEGRO_KEY_Z: break; } } else if(ev.type == ALLEGRO_EVENT_KEY_UP) { switch(ev.keyboard.keycode) { case ALLEGRO_KEY_UP: key[KEY_UP] = false; break; case ALLEGRO_KEY_DOWN: key[KEY_DOWN] = false; break; case ALLEGRO_KEY_LEFT: break; case ALLEGRO_KEY_RIGHT: break; case ALLEGRO_KEY_ESCAPE: doexit = true; break; } } else if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { break; } if(redraw && al_is_event_queue_empty(event_queue)) { redraw = false; al_set_target_bitmap(al_get_backbuffer(display)); al_clear_to_color(al_map_rgb(100,100,100)); if( menuSelection == 1) { al_draw_bitmap(mnuNew_gameS, 410, 300, 0); al_draw_bitmap(mnuOptions, 430, 340, 0); al_draw_bitmap(mnuExit, 476, 380, 0); } if( menuSelection == 2) { al_draw_bitmap(mnuNew_game, 410, 300, 0); al_draw_bitmap(mnuOptionsS, 430, 340, 0); al_draw_bitmap(mnuExit, 476, 380, 0); } if( menuSelection == 3) { al_draw_bitmap(mnuNew_game, 410, 300, 0); al_draw_bitmap(mnuOptions, 430, 340, 0); al_draw_bitmap(mnuExitS, 476, 380, 0); } al_flip_display(); } } ///-/////////////////////////////////////////////////////////////////////-/// ///------------------------------ GAME LOOP ------------------------------/// ///-/////////////////////////////////////////////////////////////////////-/// if(dogame && !initMenu) { if(ev.type == ALLEGRO_EVENT_TIMER) { if(contador > 195) { if(key[KEY_LEFT] && spaceship->positionX >= 185) { spaceship->movement(180); } if(key[KEY_RIGHT] && spaceship->positionX <= 695) { spaceship->movement(0); } Object_Collision(shots, enemies); shots = shots->Clean_list(shots, false); Update_Objects(shots, 1); enemies = enemies->Clean_list(enemies, false); Enemies_movement(enemies, enem_mov_flag); Update_Objects(enemies, enem_mov_flag); } if(contador < 200) { contador ++; } redraw = true; } else if(ev.type == ALLEGRO_EVENT_KEY_DOWN) { switch(ev.keyboard.keycode) { case ALLEGRO_KEY_UP: break; case ALLEGRO_KEY_DOWN: break; case ALLEGRO_KEY_LEFT: key[KEY_LEFT] = true; break; case ALLEGRO_KEY_RIGHT: key[KEY_RIGHT] = true; break; case ALLEGRO_KEY_Z: key[KEY_Z] = true; shots = shots->create_each(shots, spaceship->positionX + 50, spaceship->positionY, 300, 2, false, 20); shots->select_image("Images\\Shots\\G1\\"); Sounds.load_sound( shots); break; case ALLEGRO_KEY_X: key[KEY_X] = true; shots = shots->create_each(shots, spaceship->positionX + 50, spaceship->positionY, 300, 1, false, 20); shots->select_image("Images\\Shots\\G1\\"); Sounds.load_sound( shots); break; case ALLEGRO_KEY_C: key[KEY_C] = true; shots = shots->create_each(shots, spaceship->positionX + 50, spaceship->positionY, 300, 0, false, 20); shots->select_image("Images\\Shots\\G1\\"); Sounds.load_sound( shots); break; case ALLEGRO_KEY_SPACE: break; } } else if(ev.type == ALLEGRO_EVENT_KEY_UP) { switch(ev.keyboard.keycode) { case ALLEGRO_KEY_UP: break; case ALLEGRO_KEY_DOWN: break; case ALLEGRO_KEY_LEFT: key[KEY_LEFT] = false; break; case ALLEGRO_KEY_RIGHT: key[KEY_RIGHT] = false; break; case ALLEGRO_KEY_ESCAPE: shots = shots->Clean_list(shots, true); enemies = enemies->Clean_list(enemies, true); Sounds.stop_music(); dogame = false; initMenu = true; break; case ALLEGRO_KEY_Z: key[KEY_Z] = false; break; } } else if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { shots = shots->Clean_list(shots, true); enemies = enemies->Clean_list(enemies, true); break; } if(redraw && al_is_event_queue_empty(event_queue)) { redraw = false; al_set_target_bitmap(al_get_backbuffer(display)); al_clear_to_color(al_map_rgb(100,100,100)); al_draw_bitmap( bitmap, 0, 0, 0); al_draw_bitmap( bitmap2, 800, 0, 0); al_draw_bitmap( help1, 0, 100, 0); if(contador < 60) { al_draw_bitmap( gameStart1, 150, 100, 0); } else if(contador < 120) { al_draw_bitmap( gameStart2, 150, 100, 0); } else if(contador < 180) { al_draw_bitmap( gameStart3, 150, 100, 0); } else if(contador < 200) { al_draw_bitmap( gameStart4, 400, 100, 0); } spaceship->draw(); Draw_Multi(enemies); Draw_Multi(shots); al_flip_display(); } } } al_destroy_bitmap(mnuExit); al_destroy_bitmap(mnuExitS); al_destroy_bitmap(mnuNew_game); al_destroy_bitmap(mnuNew_gameS); al_destroy_bitmap(mnuOptions); al_destroy_bitmap(mnuOptionsS); al_destroy_timer(timer); al_destroy_display(display); al_destroy_event_queue(event_queue); return 0; }
void ColoredCubeApp::drawScene() { D3DApp::drawScene(); //Step through animation frame animationTimeElapsed += mTimer.getGameTime() - animationTimePrev; animationTimePrev = mTimer.getGameTime(); if(animationTimeElapsed > 0.0666f) { animationTimeElapsed = 0.0f; frameOfAnimation++; if(frameOfAnimation > fireFrameCount-1) { frameOfAnimation = 0; } } // Restore default states, input layout and primitive topology // because mFont->DrawText changes them. Note that we can // restore the default states by passing null. md3dDevice->OMSetDepthStencilState(0, 0); float blendFactors[] = {0.0f, 0.0f, 0.0f, 0.0f}; md3dDevice->OMSetBlendState(0, blendFactors, 0xffffffff); md3dDevice->IASetInputLayout(mVertexLayout); md3dDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST); // Set per frame constants mfxEyePosVar->SetRawValue(&mCameraPos, 0, sizeof(D3DXVECTOR3)); mfxLightVar->SetRawValue(&mLights[0], 0, sizeof(Light)); mfxLightVar2->SetRawValue(&mLights[1], 0, sizeof(Light)); mfxCubeMapVR->SetResource(mCubeMapRV); // set constants mWVP = mView*mProj; mfxWVPVar->SetMatrix((float*)&mWVP); //set gWVP in color.fx to mWVP mTree.setEyePos(mCameraPos); mTree.setLights(mLights, 2); mTree.draw(mView, mProj); mObjBox.setEyePos(mCameraPos); mObjBox.setLights(mLights, 2); mObjBox.draw(mView, mProj); D3D10_TECHNIQUE_DESC techDesc; mTech->GetDesc( &techDesc ); for(UINT p = 0; p < techDesc.Passes; ++p) { ID3D10EffectPass* pass = mTech->GetPassByIndex( p ); //zero is always used in D3D10 D3DXMATRIX texMtx; mWVP = mBoxWorld*mView*mProj; mfxWVPVar->SetMatrix((float*)&mWVP); mfxWorldVar->SetMatrix((float*)&mBoxWorld); mfxDiffuseMapVar->SetResource(mCrateMapRV); //mfxDiffuseMapVar->SetResource(mFireAnimationMapRVs[frameOfAnimation]); mfxSpecularMapVar->SetResource(mSpecularMapRV); mfxNormalMapVR->SetResource(mDefaultNormalMapRV); mfxReflectEnabledVar->SetBool(false); D3DXMatrixIdentity(&texMtx); mfxTexMtxVar->SetMatrix((float*)&texMtx); pass->Apply(0); mBox.draw(); mWVP = mPlaneWorld*mView*mProj; mfxWVPVar->SetMatrix((float*)&mWVP); mfxWorldVar->SetMatrix((float*)&mPlaneWorld); mfxDiffuseMapVar->SetResource(mGrassMapRV); mfxNormalMapVR->SetResource(mBrickNormalMapRV); mfxReflectEnabledVar->SetBool(true); D3DXMATRIX s; D3DXMatrixScaling(&s, 5.0f, 5.0f, 1.0f); texMtx = s; D3DXMatrixIdentity(&texMtx); mfxTexMtxVar->SetMatrix((float*)&texMtx); pass->Apply(0); mPlane.draw(); } mSky.draw(mWVP); // We specify DT_NOCLIP, so we do not care about width/height of the rect. RECT R = {5, 5, 0, 0}; md3dDevice->RSSetState(0); mFont->DrawText(0, mFrameStats.c_str(), -1, &R, DT_NOCLIP, BLACK); mSwapChain->Present(0, 0); }
int main( int argc, char* argv[] ) { VideoCapture cap; TermCriteria termcrit(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,20,0.03); Size winSize(10,10); bool needToInit =true; bool nightMode = false; bool reSift=true; if( argc == 1 || (argc == 2 && strlen(argv[1]) == 1 && isdigit(argv[1][0]))) cap.open(argc == 2 ? argv[1][0] - '0' : 0); else if( argc == 2 ) cap.open(argv[1]); if( !cap.isOpened() ) { cout << "Could not initialize capturing...\n"; return 0; } Mat gray, prevGray, image; vector<Point2f> points[2]; VideoWriter wri; siftCorner cornerFinder; if(!cornerFinder.Init("track.config")) { cout<<"Can not Init cornerFinder"<<endl; return 0; } const string backGroundFilename="background.jpg"; const float alpha=0.85; Mat backGround; backGround=imread(backGroundFilename,CV_LOAD_IMAGE_GRAYSCALE); backGroundModel bgModel; bgModel.Init(alpha,backGround); namedWindow("Track",1); const int step=1; reSiftValidate validator; Tracker *tracker=NULL; Object curObj; tracker=new LKTracker; //validator.init(); // DECLARE_TIMING(myTimer); START_TIMING(myTimer); DECLARE_TIMING(siftTimer); for(;;) { Mat frame; for(int ii(0);ii<step;++ii) cap >> frame; if( frame.empty() ) break; frame.copyTo(image); cvtColor(image, gray, CV_BGR2GRAY); if( nightMode ) image = Scalar::all(0); medianBlur(gray,gray,3); bgModel.renewModel(gray); if( needToInit ) { char fileNameBuffer[30]; time_t rawtime; struct tm * timeinfo; time ( &rawtime ); timeinfo = localtime ( &rawtime ); sprintf(fileNameBuffer ,"output/%d_%d_%d_%d_%d_%d.avi" ,timeinfo->tm_year+1900,timeinfo->tm_mon,timeinfo->tm_mday,timeinfo->tm_hour,timeinfo->tm_min,timeinfo->tm_sec); wri.open(fileNameBuffer,CV_FOURCC('X','V','I','D'),50,image.size(),true); if(!wri.isOpened()) { cout<<"can not init the writer"<<endl; return 0; } needToInit = false; tracker->Init(gray); } if(reSift) { START_TIMING(siftTimer); cout<<"reSift"<<endl; Mat Mask; bgModel.substractModel(gray,Mask); reSift=false; cornerFinder.goodFeatures(gray,curObj,Mask); cout<<"reSift Done"<<endl; STOP_TIMING(siftTimer); tracker->setObject(curObj); } else { tracker->Process(gray); curObj=tracker->getObject(); curObj.draw(image); reSift=!validator.validate(curObj); } imshow("Track", image); wri<<image; char c; c=(char)waitKey(2); if( c == 27 ) break; switch( c ) { case 'r': case 'c': case 'R': case 'C': points[1].clear(); reSift=true; cout<<"reSift Type four"<<endl; break; case 'n': nightMode = !nightMode; break; case ' ': waitKey(-1); break; default: ; } std::swap(points[1], points[0]); swap(prevGray, gray); } STOP_TIMING(myTimer); printf("Execution time: %f ms.\n", GET_TIMING(myTimer)); printf("sift Execution time: %f ms.\n", GET_TIMING(siftTimer)); printf("sift average Execution time: %f ms.\n", GET_AVERAGE_TIMING(siftTimer)); if(!tracker) delete tracker; return 0; }
int main(int argc, char** args) { GLFWwindow* window = setup(); //------------------------------------------ //-------- View-Projection settings -------- //------------------------------------------ glm::vec3 cameraPos = glm::vec3(5.0f, 1.0f, 0.0f); glm::mat4 Projection = glm::perspective(glm::radians(45.0f), 800.0f/600.0f, 0.01f, 20.0f); glm::mat4 View = glm::lookAt(cameraPos, //Position glm::vec3(0.0f, 0.0f, 0.0f), //Look direction glm::vec3(0.0f, 1.0f, 0.0f) ); //Up //Pre-multiply projection and view glm::mat4 vpMatrix = Projection * View; //--------------------------- //-------- Lighting --------- //--------------------------- PointLight p[2]; p[0].pos = glm::vec3(0.0f, 0.0f, +3.0f); p[0].intensity = 2.0f; p[0].falloff = 1.0f; p[1].pos = glm::vec3(0.0f, 0.0f, -3.0f); p[1].intensity = 2.0f; p[1].falloff = 1.0f; glm::vec3 p0 = glm::vec3(0.0f, 0.0f, +3.0f); glm::vec3 p1 = glm::vec3(0.0f, +4.0f, 0.0f); float angle = 0.0f; //---------------------------------- //-------- Geometry setting -------- //---------------------------------- if(argc != 3) { std::cout<<"Wrong input! Usage: "<<std::endl<<std::endl; std::cout<<" ./render path/to/file.obj gouraud|flat"<<std::endl<<std::endl; return 0; } std::string filepath(args[1]); std::string shading(args[2]); Object obj; obj.load(filepath, std::string("./shaders/") + shading); obj.setViewProjection(&vpMatrix); do { //Clear screen -> this function also clears stencil and depth buffer glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); //Rotate lights glm::mat4 rot1 = glm::rotate(glm::mat4(1.0f), angle, glm::vec3(0.0f, 1.0f, 0.0f)); glm::mat4 rot2 = glm::rotate(glm::mat4(1.0f), angle, glm::vec3(0.0f, 0.0f, 1.0f)); p[0].pos = glm::vec3( rot1 * glm::vec4(p0, 1.0f) ); p[1].pos = glm::vec3( rot2 * glm::vec4(p1, 1.0f) ); angle += 0.05f; if(angle >= 6.28) angle = 0.0f; obj.draw(cameraPos, p, 2); //Swap buffer and query events glfwSwapBuffers(window); glfwPollEvents(); } while(glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS && !glfwWindowShouldClose(window)); //Drop GLFW device glfwTerminate(); return 0; }
void special_keyboard(int key,int ,int) { glClear(GL_COLOR_BUFFER_BIT); r.clearZbuffer(); DrawTriangle(x_y_zCoordinate(-450,0,3000),Color(1,1,0),x_y_zCoordinate(-600,-350,-1000), Color(0,1,0),x_y_zCoordinate(600,-350,-1000),Color(0,1,1)); DrawTriangle(x_y_zCoordinate(-450,0,3000),Color(1,1,0),x_y_zCoordinate(600,0,-1000), Color(0,1,0),x_y_zCoordinate(600,-350,-1000),Color(0,1,1)); light.draw(); switch (key) { case GLUT_KEY_DOWN: { for(unsigned int i=0;i<o.face_size;i++) { o.vertices[i] =DOWN*o.vertices[i]; } for(unsigned int i=0;i<rem.face_size;i++) { rem.vertices[i] =DOWN*rem.vertices[i]; } for(unsigned int i=0;i<boom.face_size;i++) { boom.vertices[i] =DOWN*boom.vertices[i]; } for(unsigned int i=0;i<hook.face_size;i++) { hook.vertices[i] =DOWN*hook.vertices[i]; } o.draw(Color(0.3,0.2,0.3)); rem.draw(Color(1.0,1.2,0.1)); boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); break; } case GLUT_KEY_UP: { for(unsigned int i=0;i<o.face_size;i++) { o.vertices[i] =UP*o.vertices[i]; } for(unsigned int i=0;i<rem.face_size;i++) { rem.vertices[i] =UP*rem.vertices[i]; } for(unsigned int i=0;i<boom.face_size;i++) { boom.vertices[i] =UP*boom.vertices[i]; } for(unsigned int i=0;i<hook.face_size;i++) { hook.vertices[i] =UP*hook.vertices[i]; } o.draw(Color(0.3,0.2,0.3)); rem.draw(Color(1.0,1.2,0.1)); boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); break; } case GLUT_KEY_RIGHT: { for(unsigned int i=0;i<o.face_size;i++) { o.vertices[i] =T*o.vertices[i]; } for(unsigned int i=0;i<rem.face_size;i++) { rem.vertices[i] =T*rem.vertices[i]; } for(unsigned int i=0;i<boom.face_size;i++) { boom.vertices[i] =T*boom.vertices[i]; } for(unsigned int i=0;i<hook.face_size;i++) { hook.vertices[i] =T*hook.vertices[i]; } cout<<"rotation\n"; RR.display(); cout<<"NNpaxadi\n"; NN.display(); cout<<"agadi\n"; MM.display(); RR = RR*T; MM = MM*T; NN = NN*T; o.draw(Color(0.3,0.2,0.3)); rem.draw(Color(1.0,1.2,0.1)); boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); break; } case GLUT_KEY_LEFT: { for(unsigned int i=0;i<o.face_size;i++) { o.vertices[i] =T2*o.vertices[i]; } for(unsigned int i=0;i<rem.face_size;i++) { rem.vertices[i] =T2*rem.vertices[i]; } for(unsigned int i=0;i<boom.face_size;i++) { boom.vertices[i] =T2*boom.vertices[i]; } for(unsigned int i=0;i<hook.face_size;i++) { hook.vertices[i] =T2*hook.vertices[i]; } o.draw(Color(0.3,0.2,0.3)); rem.draw(Color(1.0,1.2,0.1)); boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); break; } case GLUT_KEY_F1: { } default: o.draw(Color(0.3,0.2,0.3)); rem.draw(Color(1.0,1.2,0.1)); boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); break; } glFlush(); glutSwapBuffers(); }
void keyboard_event(unsigned char key,int x,int y) { glClear(GL_COLOR_BUFFER_BIT); r.clearZbuffer(); x+=0;y+=0; DrawTriangle(x_y_zCoordinate(-450,0,3000),Color(1,1,0),x_y_zCoordinate(-600,-350,-1000), Color(0,1,0),x_y_zCoordinate(600,-350,-1000),Color(0,1,1)); DrawTriangle(x_y_zCoordinate(-450,0,3000),Color(1,1,0),x_y_zCoordinate(600,0,-1000), Color(0,1,0),x_y_zCoordinate(600,-350,-1000),Color(0,1,1)); light.draw(); for(unsigned int i=0;i<hook.face_size;i++){ if ((hook.vertices[i].x > ligh.x -10 && hook.vertices[i].x < ligh.x +10) && (hook.vertices[i].y > ligh.y -10 && hook.vertices[i].y < ligh.y +10)&& (hook.vertices[i].z > ligh.z -10 && hook.vertices[i].z < ligh.z +10)) { set = true; }} //c1.create(); switch(key) { case 'o': { for(unsigned int i=0;i<hook.face_size;i++) { hook.vertices[i] =TTTT*hook.vertices[i]; } o.draw(Color(0.3,0.2,0.3)); rem.draw(Color(1.0,1.2,0.1)); boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); break; } case'i': { if(set==true){ for(unsigned int i=0;i<light.Total_Points;i++) { light.Vertices[i]=LLLL*light.Vertices[i]; }} for(unsigned int i=0;i<hook.face_size;i++) { hook.vertices[i] =LLLL*hook.vertices[i]; } o.draw(Color(0.3,0.2,0.3)); rem.draw(Color(1.0,1.2,0.1)); boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); break; } case 'q': { /* for(unsigned int i=0;i<sph.Total_Points;i++) { sph.Vertices[i] = IN*sph.Vertices[i]; } //drawLine(-600,0,600,0); //drawLine(0,350,0,-350); sph.draw();*/ for(unsigned int i=0;i<o.face_size;i++) { o.vertices[i] =IN*o.vertices[i]; } o.draw(Color(0.3,0.2,0.3)); rem.draw(Color(1.0,1.2,0.1)); boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); break; } case 'e': { /*for(unsigned int i=0;i<sph.Total_Points;i++) { sph.Vertices[i] = OUT*sph.Vertices[i]; } //drawLine(-600,0,600,0); //drawLine(0,350,0,-350); sph.draw();*/ for(unsigned int i=0;i<o.face_size;i++) { o.vertices[i] =OUT*o.vertices[i]; } break; } case 'x': { /*for(int i=0;i<sph.Total_Points;i++) { sph.Vertices[i] = XR*sph.Vertices[i]; } sph.draw();*/ for(unsigned int i=0;i<o.face_size;i++) { o.vertices[i] =XR*o.vertices[i]; } for(unsigned int i=0;i<rem.face_size;i++) { rem.vertices[i] =XR*rem.vertices[i]; } for(unsigned int i=0;i<boom.face_size;i++) { boom.vertices[i] =XR*boom.vertices[i]; } for(unsigned int i=0;i<hook.face_size;i++) { hook.vertices[i] =XR*hook.vertices[i]; } o.draw(Color(0.3,0.2,0.3)); rem.draw(Color(1.0,1.2,0.1)); boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); cout<<"\nx"; break; } case 'y': { /* for(int i=0;i<sph.Total_Points;i++) { sph.Vertices[i] = YR*sph.Vertices[i]; } sph.draw();*/ for(unsigned int i=0;i<o.face_size;i++) { o.vertices[i] =YR*o.vertices[i]; } for(unsigned int i=0;i<rem.face_size;i++) { rem.vertices[i] =YR*rem.vertices[i]; } for(unsigned int i=0;i<boom.face_size;i++) { boom.vertices[i] =YR*boom.vertices[i]; } for(unsigned int i=0;i<hook.face_size;i++) { hook.vertices[i] =YR*hook.vertices[i]; } o.draw(Color(0.3,0.2,0.3)); rem.draw(Color(1.0,1.2,0.1)); boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); cout<<"\ny"; break; } case 'z': { /* for(int i=0;i<sph.Total_Points;i++) { sph.Vertices[i] = ZR*sph.Vertices[i]; } sph.draw();*/ for(unsigned int i=0;i<o.face_size;i++) { o.vertices[i] =ZR*o.vertices[i]; } o.draw(Color(0.3,0.2,0.3)); rem.draw(Color(1.0,1.2,0.1)); boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); cout<<"\nz"; break; } case 'l': { //for(int i=0;i<sph.Total_Points;i++) //{ // sph.Vertices[i] = SCL*sph.Vertices[i]; //} //sph.draw(); for(unsigned int i=0;i<o.face_size;i++) { o.vertices[i] =SCL*o.vertices[i]; } for(unsigned int i=0;i<rem.face_size;i++) { rem.vertices[i] =SCL*rem.vertices[i]; } for(unsigned int i=0;i<boom.face_size;i++) { boom.vertices[i] =SCL*boom.vertices[i]; } for(unsigned int i=0;i<hook.face_size;i++) { hook.vertices[i] =SCL*hook.vertices[i]; } o.draw(Color(0.3,0.2,0.3)); rem.draw(Color(1.0,1.2,0.1)); boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); o.draw(Color(0.3,0.2,0.3)); rem.draw(Color(1.0,1.2,0.1)); boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); cout<<"\nl"; break; } case 'h': { /*for(int i=0;i<sph.Total_Points;i++) { sph.Vertices[i] = SCH*sph.Vertices[i]; } sph.draw();*/ for(unsigned int i=0;i<o.face_size;i++) { o.vertices[i] =SCH*o.vertices[i]; } for(unsigned int i=0;i<rem.face_size;i++) { rem.vertices[i] =SCH*rem.vertices[i]; } for(unsigned int i=0;i<boom.face_size;i++) { boom.vertices[i] =SCH*boom.vertices[i]; } for(unsigned int i=0;i<hook.face_size;i++) { hook.vertices[i] =SCH*hook.vertices[i]; } //o.draw(Color(0.3,0.2,0.3)); //rem.draw(Color(1.0,1.2,0.1)); //boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); cout<<"\nh"; break; } case 'm': { /*for(unsigned int i=0;i<sph.Total_Points;i++) { sph.Vertices[i] = RR*sph.Vertices[i]; } sph.draw();*/ for(unsigned int i=0;i<rem.face_size;i++) { rem.vertices[i] =NN*RR*MM*rem.vertices[i]; } for(unsigned int i=0;i<boom.face_size;i++) { boom.vertices[i] =NN*RR*MM*boom.vertices[i]; } for(unsigned int i=0;i<=hook.face_size;i++) { hook.vertices[i] =NN*RR*MM*hook.vertices[i]; } o.draw(Color(0.3,0.2,0.3)); rem.draw(Color(1.0,1.2,0.1)); boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); break; } case 'c': { break; } case 'p': { x_y_zCoordinate cc111(-600,-310,10),cc222(-512,310,10),cc333(0,280,10); x_y_zCoordinate cc11(0,0,0),cc22(480,0,0),cc33(0,350,0); x_y_zCoordinate cc1(0,0,10),cc2(340,0,10),cc3(0,340,10); Color c1(1,0,0),c2(0,1,0),c3(0,0,1); DrawTriangle(cc1,c3,cc2,c3,cc3,c3); DrawTriangle(cc11,c1,cc22,c1,cc33,c1); DrawTriangle(cc111,c2,cc222,c2,cc333,c2); //DrawTriangle(); break; } case 'b': { o.draw(Color(0.3,0.2,0.3)); rem.draw(Color(1.0,1.2,0.1)); boom.draw(Color(0.8,0.9,1)); hook.draw(Color(0.1,0,1)); setPixel(0,0,Color(1,0,0)); break; } default: //drawLine(-600,0,600,0); //drawLine(0,350,0,-350); exit(-1);//terminate the program break; // do nothing } glFlush(); glutSwapBuffers(); }
int main() { // SFML window that will host our OpenGL magic sf::Window window(sf::VideoMode(1920, 1080), "OpenGL", sf::Style::Default, sf::ContextSettings(32)); window.setVerticalSyncEnabled(true); window.setMouseCursorVisible(false); sf::View view; sf::Mouse::setPosition(sf::Vector2i(window.getSize().x / 2, window.getSize().y / 2), window); glewInit(); Player player; programInit(shaderMap, modelMap, textureMap, normalMap); initPresetSystem(shaderMap, modelMap, textureMap, normalMap, presetMap); Editor editor(modelMap, shaderMap, textureMap, normalMap, presetMap); GLInit(); // ---------------------- MODELS ------------------------------- Model sphereModel, unitSquareModel; generateSphere(&sphereModel, 50); sphereModel.upload(); myLoadObj("Models/unitSquare.obj", &unitSquareModel); unitSquareModel.upload(); loadNoise(); // Add terrain information to earth cv::Mat earthBumpMap = cv::imread("Textures/earthBumpMap.jpg"); earthBumpMap.convertTo(earthBumpMap, CV_32F); int height = earthBumpMap.rows; int width = earthBumpMap.cols; std::cout << "Dims: " << height << ", " << width << std::endl; std::cout << "Dims: " << *earthBumpMap.row(height-1).col(5).ptr<float>() << std::endl; // ---------------------- OBJECTS ------------------------------- // Initiation of all objects in the program // ShaderParameters = (ambientCoeff, diffuseCoeff, specularCoeff, specularExponent) cv::Vec4f standardShaderParameters(0.2f, 0.5f, 0.8f, 10); Object squareNormalMap, squareSpecularityMap; GLuint earthNormalMap, earthSpecularityMap, earthTextureDay, earthTextureNight; GLuint normalMapShader, specularityMapShader; shaderInit(&phongNoTex, "Shaders/phongNoTex.vert", "Shaders/phongNoTex.frag"); shaderInit(&normalMapShader, "Shaders/normalMap.vert", "Shaders/normalMap.frag"); shaderInit(&specularityMapShader, "Shaders/specularityMap.vert", "Shaders/specularityMap.frag"); LoadTGATextureSimple("Textures/earthTextureDay.tga", &earthTextureDay); LoadTGATextureSimple("Textures/earthTextureNight.tga", &earthTextureNight); LoadTGATextureSimple("Textures/earthNormalMap.tga", &earthNormalMap); LoadTGATextureSimple("Textures/earthSpecularityMap.tga", &earthSpecularityMap); //squareNormalMap.init(&unitSquareModel, phongNoTex, standardShaderParameters, 0, 0, 0, earthNormalMap); squareNormalMap.init(&unitSquareModel, normalMapShader, standardShaderParameters, 0, 0, 0, earthNormalMap); squareSpecularityMap.init(&unitSquareModel, specularityMapShader, standardShaderParameters, earthTextureDay, earthTextureNight, earthSpecularityMap, earthNormalMap); squareNormalMap.set(cv::Vec3f(100,0,0), cv::Vec3f(50,50,100), cv::Vec3f(0, pi/2, -pi/2), cv::Vec3f(0,0,0), 1); squareSpecularityMap.set(cv::Vec3f(100,0,0), cv::Vec3f(50,50,100), cv::Vec3f(0, pi/2, -pi/2), cv::Vec3f(0,0,0), 1); // ---------------------- SKYSPHERE ------------------------------- Object skysphere; GLuint skysphereTexture, skyboxShader; LoadTGATextureSimple("Textures/spaceBox6.tga", &skysphereTexture); shaderInit(&skyboxShader, "Shaders/skybox.vert", "Shaders/skybox.frag"); skysphere.init(&sphereModel, skyboxShader, standardShaderParameters, skysphereTexture); skysphere.set(player.position, cv::Vec3f(1,1,1), cv::Vec3f(0,0,0), cv::Vec3f(0,0,0), 1); int item; // SFML built-in clock sf::Clock clock; states[RUNNING] = true; states[EDITOR] = true; states[STARTUP] = true; /* bool running = true; bool runningEditor = true; bool startup = true; bool selectObject = false; bool cooldown = false; */ Object* currentObject = NULL; Object* playerObject = NULL; while (states[RUNNING]) { dt = clock.getElapsedTime().asSeconds(); if(states[EDITOR]) { window.setVisible(false); if(states[SELECTOBJECT]) { solsystem.getObjects(&allObjects); currentObject = getSelectedObject(&allObjects, &player); allObjects.clear(); } editor.edit(solsystem, states, currentObject); states[STARTUP] = false; sf::Mouse::setPosition(sf::Vector2i(window.getSize().x / 2, window.getSize().y / 2), window); clock.restart(); window.setActive(); states[SELECTOBJECT] = false; currentObject = NULL; states[EDITOR] = false; window.setVisible(true); } else { clock.restart(); if (playerObject != NULL) { std::cout << player.position << std::endl; player.move(playerObject->position); //player.position = playerObject->position; std::cout << playerObject->position << std::endl; } handleEvents(&window, states, &item, playerObject, &player, dt); player.lookAtUpdate(dt); // Plocka ut all planeters positioner std::list<Object*> allObjects; solsystem.getObjects(&allObjects); std::vector<cv::Vec3f> positionVector; std::vector<cv::Vec3f> radiusVector; std::list<Object*>::iterator i = allObjects.begin(); for (i++ ; i != allObjects.end(); ++i) { positionVector.push_back((*i)->position); radiusVector.push_back((*i)->scale); //std::cout << "Scale: " << (*i)->scale << std::endl; } int numberOfPlanets = positionVector.size(); GLfloat* positions = makeArray(positionVector); GLfloat* radius = makeArray(radiusVector); ///////////////////////////////// SKYBOX ///////////////////////////////////////// window.setActive(); //drawSkybox(&player, &skyboxModel, skyboxShader, skyboxTexture); glDisable(GL_DEPTH_TEST); //skybox.set(player.position, cv::Vec3f(5,5,5), cv::Vec3f(0,0,0), cv::Vec3f(0,0,0), 1); //skybox.draw(&player); skysphere.set(player.position, cv::Vec3f(5,5,5), cv::Vec3f(0,0,0), cv::Vec3f(0,0,0), 1); skysphere.draw(&player, 0, dt); glEnable(GL_DEPTH_TEST); ///////////////////////////////// ALX ///////////////////////////////////////// if (states[NORMALMAP]) { squareNormalMap.draw(&player, dt, numberOfPlanets, positions, radius); } if (states[SPECULARITYMAP]) { squareSpecularityMap.draw(&player, dt, numberOfPlanets, positions, radius); } ///////////////////////////////// ALX ///////////////////////////////////////// if(!states[COOLDOWN] && item == 1) { Object* newItem = presetMap["Earth"]->clone(); newItem->set(player.position, cv::Vec3f(0.25,0.25,0.25), cv::Vec3f(0,0,0), 10*player.getLookAtDirection(), 1); solsystem.addItem(newItem); std::cout << 10*normalize(player.position - player.lookAtVector) << std::endl; states[COOLDOWN] = true; } item = 0; if(states[ENABLEGRAVITY] && playerObject == NULL) { playerObject = presetMap["Earth"]->clone(); playerObject->set(player.position, cv::Vec3f(1.25,1.25,1.25), cv::Vec3f(0,0,0), cv::Vec3f(0,0,0), 1); solsystem.addPlayerItem(playerObject); states[ENABLEGRAVITY] = false; } if(states[DISABLEGRAVITY] && playerObject != NULL) { solsystem.removePlayerItem(); playerObject = NULL; states[DISABLEGRAVITY] = false; } solsystem.update(physEngine, dt*0.5); solsystem.draw(&player, accTime); accTime += dt; window.display(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } cv::waitKey(0); } // release resources... glDeleteVertexArrays(1, &sphereModel.VAO); //glDeleteVertexArrays(1, &skyboxModel.VAO); //glDeleteVertexArrays(1, &unitSquareModel.VAO); //glDeleteVertexArrays(1, &groundModel.VAO); return 0; }
void drawAll() { Object *o = this; do o->draw(); while ((o = o->next) != this); }