void S9FbxDrawer::drawClusters(shared_ptr<FbxDrawable> pDrawable) { glPushMatrix(); shared_ptr<FbxMesh> pMesh = pDrawable->meshes[0]; glMultMatrixf(pMesh->offset); Sphere tsphere; tsphere.setCenter(Vec3f(0,0,0)); int idx =0; for (vector<shared_ptr<FbxCluster> >::iterator it = pMesh->clusters.begin(); it != pMesh->clusters.end(); it++) { shared_ptr<FbxCluster> pCluster = *it; if (pCluster->mCentre != Vec3f::zero()) { Vec3f dv = pCluster->mMax; float d = dv.distance(pCluster->mMin); tsphere.setRadius(d / 2.0); // TODO - with the max and min its not great. Bounding box maybe better glPushMatrix(); glTranslated(pCluster->mCentre.x, pCluster->mCentre.y, pCluster->mCentre.z); gl::draw(tsphere); glPopMatrix(); } idx++; } glPopMatrix(); }
void rayMarcherApp::setup() { CameraPersp cam; mStartEyePoint = Vec3f( 15, 21, 27.5 ) * 0.65f; cam.lookAt( mStartEyePoint, Vec3f::zero(), Vec3f::yAxis() ); cam.setCenterOfInterest( mStartEyePoint.distance( Vec3f::zero() ) ); mMayaCam.setCurrentCam( cam ); }
void MindField::Update() { mTime += 0.01f; //camera update Vec3f pos = mCamera.getEyePoint(); Vec3f newPos = pos.lerp(mLerper, mNextCamPoint); mCamera.setEyePoint(newPos); mCamera.setCenterOfInterestPoint(Vec3f(0,0,0)); mLerper = mLerper + 0.0000001* getFrameRate(); float camBound = 8.0; float d = newPos.length(); float maxLength = Vec3f(camBound, camBound, camBound).length(); float t = d / maxLength; mBlurView = lerp(0.9,1.5, t); if(mLerper >= 1.0) { mLerper = 0.0; mNextCamPoint = Vec3f(randFloat(-camBound,camBound), randFloat(-camBound,camBound), randFloat(-camBound,camBound)); } if(pos.distance(mNextCamPoint) < 5) { mLerper = 0.0; mNextCamPoint = Vec3f(randFloat(-camBound, camBound), randFloat(-camBound,camBound), randFloat(-camBound,camBound)); } // end camera update for(int i = 0; i < mNeurons.size(); i++) { Neuron* n = mNeurons[i]; n->Update(); int bx = floor( (n->pos.x + abs(kXLow) ) / kBXDiv); int by = floor( (n->pos.y + abs(kYLow) ) / kBYDiv); int bz = floor( (n->pos.z + abs(kZLow)) / kBZDiv); theMindField.mBins[bx][by][bz].push_back(i); } for( list<Axon*>::iterator p = mAxons.begin(); p != mAxons.end(); ++p ) { (*p)->Update(); } UpdateAxons(); ClearBins(); }
void Cubes::Update() { cubeTimer += 0.1f; Vec3f pos = cubesCamera.getEyePoint(); Vec3f newPos = pos.lerp(mLerper, mNextCamPoint); cubesCamera.setEyePoint(newPos); cubesCamera.setCenterOfInterestPoint(Vec3f(0,0,0)); mLerper = mLerper + 0.0000001* getFrameRate(); if(mLerper >= 1.0) { mLerper = 0.0; mNextCamPoint = Vec3f(randFloat(-10,10), randFloat(-10,10), randFloat(-10,10)); } if(pos.distance(mNextCamPoint) < 5) { mLerper = 0.0; mNextCamPoint = Vec3f(randFloat(-10,10), randFloat(-10,10), randFloat(-10,10)); } }
void ChargesApp::update() { mFps = getAverageFps(); // Update device if ( mLeap && mLeap->isConnected() ) { mLeap->update(); } vector< int32_t > currentFingersIds; for ( const std::pair< int32_t, LeapSdk::Hand > hand : mHands ) { const LeapSdk::FingerMap &fingers = hand.second.getFingers(); for ( const auto &fkv : fingers ) { int32_t id = fkv.first; const LeapSdk::Finger &finger = fkv.second; currentFingersIds.push_back( id ); // new finger? if ( mActiveFingers.find( id ) == mActiveFingers.end() ) { mActiveFingers[ id ] = mTimestamp; mEffectCharge.addCursor( id, 0.f, 0.f, 1.f ); // init with (0, 0), will be updated below } // update finger const LeapSdk::ScreenMap &screens = mLeap->getScreens(); if ( screens.begin() != screens.end() ) { mActiveFingers[ id ] = mTimestamp; const LeapSdk::Screen &screen = screens.begin()->second; Vec3f normPos; screen.intersects( finger, normPos, true, 1.5f ); // normalized screen coordinates with 1.5 clamp ratio Vec2f fingertip = normPos.xy() * Vec2f( mFbo.getSize() ); Vec3f screenPos; screen.intersects( finger, screenPos, false, 1.5f ); // screen coordinates with 1.5 clamp ratio float d = screenPos.distance( finger.getPosition() ); const float dMin = 50.f; const float dMax = 500.f; const float sMin = 1.f; const float sMax = 100.f; d = math< float >::clamp( d, dMin, dMax ); float strength = lmap( d, dMin, dMax, sMax, sMin ); mEffectCharge.updateCursor( id, fingertip.x, fingertip.y, strength ); } } } // erase disappeared fingers int64_t disappearThr = mFingerDisapperanceThreshold * 1000000; for ( auto it = mActiveFingers.begin(); it != mActiveFingers.end(); ) { int32_t id = it->first; if ( find( currentFingersIds.begin(), currentFingersIds.end(), id ) == currentFingersIds.end() ) { // seen earlier than the threshold? if ( mTimestamp - it->second > disappearThr ) { mEffectCharge.removeCursor( id ); it = mActiveFingers.erase( it ); } else { it++; } } else { it++; } } }