void Ship::update(float dt) { for (int i = 0; i < m_impulses.size(); ++i) { BodyDescription descr; descr.transform = m_body->getTransform(); descr.type = BodyType::Dynamic; descr.linearMomentum = m_body->getLinearMomentum(); descr.angularMomentum = m_body->getAngularMomentum(); ////// //descr.linearMomentum = vec3(0, 0, 0); //descr.angularMomentum = vec3(0, 0, 0); Ship* newShip = createShip(m_world, m_entities, descr, vec3(0,0,1)); setShip(m_impulses[i].brick, newShip, g_tick++); newShip->getBody()->applyImpulse(m_impulses[i].impulse); newShip->getBody()->applyAngularImpulse(m_impulses[i].angular); newShip->calcBase(); } calcBase(); m_impulses.clear(); }
void ofApp::setup() { // Load and compile shaders horizontalBlurShader.load("blur.vert", "blurX.frag"); if (!horizontalBlurShader.linkProgram()) { std::cerr << "Shaders not set up correctly!" << std::endl; } verticalBlurShader.load("blur.vert", "blurY.frag"); if (!verticalBlurShader.linkProgram()) { std::cerr << "Shaders not set up correctly!" << std::endl; } // Create new framebuffers sceneBuffer.allocate(windowWidth, windowHeight, GL_RGBA); firstPassBuffer.allocate(windowWidth, windowHeight, GL_RGBA); secondPassBuffer.allocate(windowWidth, windowHeight, GL_RGBA); if (!sceneBuffer.checkStatus() || !firstPassBuffer.checkStatus() || !secondPassBuffer.isAllocated()) { std::cerr << "Framebuffers not set up correctly!" << std::endl; } // Load font font.loadFont("Tahoma.ttf", 18, true, true); // Create ship. ship = createShip(); modelPosition = ofVec3f(windowWidth / 2.f, windowHeight / 2.f + 200, 0.f); keyUp = keyDown = keyLeft = keyRight = false; }
/** * Processes the user input file and creates a ship for each entry. * * @param fr File pointer to specified input file * @param head Pointer to pointer of list containing each ship on map * @param t Pointer to time_t containing simulator clock */ void processInput(FILE *fr, ship** head, time_t *t){ char line[80]; //Get the date. if((fgets(line, 80, fr) != NULL)){ struct tm timestamp; sscanf(line, "%d %d %d %d %d %d", ×tamp.tm_mday, ×tamp.tm_mon, ×tamp.tm_year, ×tamp.tm_hour, ×tamp.tm_min, ×tamp.tm_sec); timestamp.tm_year -= 1900; timestamp.tm_isdst = -1; *t = mktime(×tamp); } //Process ship entries. while(fgets(line, 80, fr) != NULL){ if(strcmp(line, "++++++++\n") != 0){ insertShip(head, createShip(line)); } } fclose(fr); }
int main(int argc, char * argv[]) { /* parte OpenGL */ glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE |GLUT_RGBA | GLUT_DEPTH); glutReshapeFunc(reshape); glutInitWindowSize(1200, 768); glViewport(0,0,1200, 760); glutCreateWindow("EP-River Raid"); sh = createShip(createPosition(0., .4, 10.)); /*if (sh->position == NULL) { printf("blal"); return 0; }*/ glClearColor(1,1,1,1); glutDisplayFunc(display); glutMainLoop(); return 0; }