本文整理汇总了C++中Vec3f::distance方法的典型用法代码示例。如果您正苦于以下问题:C++ Vec3f::distance方法的具体用法?C++ Vec3f::distance怎么用?C++ Vec3f::distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vec3f
的用法示例。
在下文中一共展示了Vec3f::distance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup
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 );
}
示例2: Update
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();
}
示例3: Update
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));
}
}
示例4: update
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++;
}
}
}