FFTTracer::FFTTracer(){ fft_size = ((testApp*)ofGetAppPtr())->fft_size; magnitude = new float[fft_size]; for (int i = 0; i < fft_size; i++) { ofVec3f p = ofVec3f(0, 0, 0); pos.push_back(p); ofVec3f v = ofVec3f(0, 0, 0); vel.push_back(v); Tracker *t = new Tracker; t->setup(); t->setTrackerLength(10); trackers.push_back(t); } //ばねパラメータ /* stiffness = 1.0; damping = 0.9; mass = 100.0; */ stiffness = 2.0; damping = 0.92; mass = 200; //((testApp*)ofGetAppPtr())->cam.setPosition(0, 0, -200); //((testApp*)ofGetAppPtr())->cam.lookAt(ofVec3f(0,0,0)); //camStart = ofPoint(0,0,-200); //camEnd = camStart; resetCam(); }
void display(void) { /* printf ("xv: %.4f, yv: %.4f, xpos: %.4f, ypos: %.4f\n",xd,yd,x_position,y_position); */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /*Reset Camera*/ resetCam(); /*Rotate, move and display object*/ glODEMultMatrixd(pos,R1); glCallList(sphere); /*Reset Camera*/ resetCam(); /*Rotate, move and display object*/ glODEMultMatrixd(pos2,R2); glCallList(sphere); /*Reset Camera*/ resetCam(); /*Rotate, move and display object*/ glCallList(tfloor); glCallList(suzanne); }
/********************************************* per-frame logic goes here **********************************************/ void App::updateMain(){ //Get the mouse pointer pos in screen space SDL_GetMouseState(&iMouseX, &iMouseY); //Throw away any bad frames if(fTimeScale == infinity || fTimeScale == 0.0f){ return; } float fCamSpeed = fTimeScale * 10.0f; float fDragScale = 0.05f; if (!this->bGlobalDisableKeyMovement) { //Right button means we reset rotation and such //NOTE: I did have this as 'both left and right at once', which seemed //to make more sense, but it doesn't work great on systems that map this //to middle-mouse if(mouseDown(3)){ resetCam(); } //Rotation for the wall /* float camTime = fUptime * 0.1f; float fRotateSpeed = fCamSpeed; fRot[1] += fRotateSpeed; fRot[0] = (sinf(camTime) * 5); fCameraY = cosf(camTime) * 5; fZoom = (sinf(camTime) * 15) + 27; */ //LOG("%f, %f\n", fRot[1], fZoom); //fZoom = -10; //Keyboard rotation if(keyDown(SDLK_RSHIFT) || keyDown(SDLK_LSHIFT)){ fCamSpeed *= 10; } if(keyDown(SDLK_LEFT)) fRot[1] -= fCamSpeed; if(keyDown(SDLK_RIGHT)) fRot[1] += fCamSpeed; if(keyDown(SDLK_UP)) fRot[0] -= fCamSpeed; if(keyDown(SDLK_DOWN)) fRot[0] += fCamSpeed; if(keyDown(SDLK_w)) { fCameraZ -= fCamSpeed; //fRot[0] = 0.0; fRot[1] = 0.0; fRot[2] = 0.0; fLookZ -= fCamSpeed; } if(keyDown(SDLK_s)) { fCameraZ += fCamSpeed; //fRot[0] = 0.0; fRot[1] = 0.0; fRot[2] = 0.0; fLookZ += fCamSpeed; } if(keyDown(SDLK_a)) { fCameraX -= fCamSpeed; fLookX -= fCamSpeed; } if(keyDown(SDLK_d)) { fCameraX += fCamSpeed; fLookX += fCamSpeed; } if(keyDown(SDLK_SPACE)) resetCam(); //If we're actively dragging with the mouse if(bDrag){ //Figure out the drag vectors and stuff Vector2 drag = getMouse(); Vector2 diff = (dragStart - drag) * fDragScale; //Left mouse button means we modify the rotation if(mouseDown(1)){ fRot[1] -= diff.x; fRot[0] -= diff.y; } //Middle mouse means we modify the zoom else if(mouseDown(2)){ fZoom += diff.y; } dragVel = diff; dragStart = getMouse(); }else{ //fRot[1] -= dragVel.x; //fRot[0] -= dragVel.y; } } updateSocket(); //Hack! The shader system doesn't really play nice with the banner, so //we disable it here. if(!isConnected()){ if(ps()->getType() <= PARTICLE_SYSTEM_POINTSPRITES) generateTestData(); else fGUITimeout = 1.0f; } mParticleSystem->update(); }