本文整理汇总了C++中LLVector2类的典型用法代码示例。如果您正苦于以下问题:C++ LLVector2类的具体用法?C++ LLVector2怎么用?C++ LLVector2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LLVector2类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: angle_between
F32 angle_between(const LLVector2& a, const LLVector2& b)
{
LLVector2 an = a;
LLVector2 bn = b;
an.normVec();
bn.normVec();
F32 cosine = an * bn;
F32 angle = (cosine >= 1.0f) ? 0.0f :
(cosine <= -1.0f) ? F_PI :
acos(cosine);
return angle;
}
示例2: are_parallel
BOOL are_parallel(const LLVector2 &a, const LLVector2 &b, float epsilon)
{
LLVector2 an = a;
LLVector2 bn = b;
an.normVec();
bn.normVec();
F32 dot = an * bn;
if ( (1.0f - fabs(dot)) < epsilon)
{
return TRUE;
}
return FALSE;
}
示例3: calc_desired_size
F32 calc_desired_size(LLVector3 pos, LLVector2 scale)
{
F32 desired_size = (pos-LLViewerCamera::getInstance()->getOrigin()).magVec();
desired_size /= 4;
return llclamp(desired_size, scale.magVec()*0.5f, PART_SIM_BOX_SIDE*2);
}
示例4: translation
BOOL QToolAlign::findSelectedManipulator(S32 x, S32 y)
{
mHighlightedAxis = -1;
mHighlightedDirection = 0;
LLMatrix4 transform;
if (LLSelectMgr::getInstance()->getSelection()->getSelectType() == SELECT_TYPE_HUD)
{
LLVector4 translation(mBBox.getCenterAgent());
transform.initRotTrans(mBBox.getRotation(), translation);
LLMatrix4 cfr(OGL_TO_CFR_ROTATION);
transform *= cfr;
LLMatrix4 window_scale;
F32 zoom_level = 2.f * gAgentCamera.mHUDCurZoom;
window_scale.initAll(LLVector3(zoom_level / LLViewerCamera::getInstance()->getAspect(), zoom_level, 0.f),
LLQuaternion::DEFAULT,
LLVector3::zero);
transform *= window_scale;
}
else
{
transform.initAll(LLVector3(1.f, 1.f, 1.f), mBBox.getRotation(), mBBox.getCenterAgent());
LLMatrix4 projection_matrix = LLViewerCamera::getInstance()->getProjection();
LLMatrix4 model_matrix = LLViewerCamera::getInstance()->getModelview();
transform *= model_matrix;
transform *= projection_matrix;
}
LLRect world_view_rect = gViewerWindow->getWorldViewRectScaled();
F32 half_width = (F32)world_view_rect.getWidth() / 2.f;
F32 half_height = (F32)world_view_rect.getHeight() / 2.f;
LLVector2 manip2d;
LLVector2 mousePos((F32)x - half_width, (F32)y - half_height);
LLVector2 delta;
LLVector3 bbox_scale = mBBox.getMaxLocal() - mBBox.getMinLocal();
for (S32 axis = VX; axis <= VZ; axis++)
{
for (F32 direction = -1.0; direction <= 1.0; direction += 2.0)
{
LLVector3 axis_vector = LLVector3(0,0,0);
axis_vector.mV[axis] = direction * bbox_scale.mV[axis] / 2.0;
LLVector4 manipulator_center = LLVector4(axis_vector);
LLVector4 screen_center = manipulator_center * transform;
screen_center /= screen_center.mV[VW];
manip2d.setVec(screen_center.mV[VX] * half_width, screen_center.mV[VY] * half_height);
delta = manip2d - mousePos;
if (delta.magVecSquared() < MANIPULATOR_SELECT_SIZE * MANIPULATOR_SELECT_SIZE)
{
mHighlightedAxis = axis;
mHighlightedDirection = direction;
return TRUE;
}
}
}
return FALSE;
}
示例5: llhudnametag_further_away
void LLHUDNameTag::updateAll()
{
// iterate over all text objects, calculate their restoration forces,
// and add them to the visible set if they are on screen and close enough
sVisibleTextObjects.clear();
TextObjectIterator text_it;
for (text_it = sTextObjects.begin(); text_it != sTextObjects.end(); ++text_it)
{
LLHUDNameTag* textp = (*text_it);
textp->mTargetPositionOffset.clearVec();
textp->updateSize();
textp->updateVisibility();
}
// sort back to front for rendering purposes
std::sort(sVisibleTextObjects.begin(), sVisibleTextObjects.end(), llhudnametag_further_away());
// iterate from front to back, and set LOD based on current screen coverage
F32 screen_area = (F32)(gViewerWindow->getWindowWidthScaled() * gViewerWindow->getWindowHeightScaled());
F32 current_screen_area = 0.f;
std::vector<LLPointer<LLHUDNameTag> >::reverse_iterator r_it;
for (r_it = sVisibleTextObjects.rbegin(); r_it != sVisibleTextObjects.rend(); ++r_it)
{
LLHUDNameTag* textp = (*r_it);
if (current_screen_area / screen_area > LOD_2_SCREEN_COVERAGE)
{
textp->setLOD(3);
}
else if (current_screen_area / screen_area > LOD_1_SCREEN_COVERAGE)
{
textp->setLOD(2);
}
else if (current_screen_area / screen_area > LOD_0_SCREEN_COVERAGE)
{
textp->setLOD(1);
}
else
{
textp->setLOD(0);
}
textp->updateSize();
// find on-screen position and initialize collision rectangle
textp->mTargetPositionOffset = textp->updateScreenPos(LLVector2::zero);
current_screen_area += (F32)(textp->mSoftScreenRect.getWidth() * textp->mSoftScreenRect.getHeight());
}
LLTrace::CountStatHandle<>* camera_vel_stat = LLViewerCamera::getVelocityStat();
F32 camera_vel = LLTrace::get_frame_recording().getLastRecording().getPerSec(*camera_vel_stat);
if (camera_vel > MAX_STABLE_CAMERA_VELOCITY)
{
return;
}
VisibleTextObjectIterator src_it;
for (S32 i = 0; i < NUM_OVERLAP_ITERATIONS; i++)
{
for (src_it = sVisibleTextObjects.begin(); src_it != sVisibleTextObjects.end(); ++src_it)
{
LLHUDNameTag* src_textp = (*src_it);
VisibleTextObjectIterator dst_it = src_it;
++dst_it;
for (; dst_it != sVisibleTextObjects.end(); ++dst_it)
{
LLHUDNameTag* dst_textp = (*dst_it);
if (src_textp->mSoftScreenRect.overlaps(dst_textp->mSoftScreenRect))
{
LLRectf intersect_rect = src_textp->mSoftScreenRect;
intersect_rect.intersectWith(dst_textp->mSoftScreenRect);
intersect_rect.stretch(-BUFFER_SIZE * 0.5f);
F32 src_center_x = src_textp->mSoftScreenRect.getCenterX();
F32 src_center_y = src_textp->mSoftScreenRect.getCenterY();
F32 dst_center_x = dst_textp->mSoftScreenRect.getCenterX();
F32 dst_center_y = dst_textp->mSoftScreenRect.getCenterY();
F32 intersect_center_x = intersect_rect.getCenterX();
F32 intersect_center_y = intersect_rect.getCenterY();
LLVector2 force = lerp(LLVector2(dst_center_x - intersect_center_x, dst_center_y - intersect_center_y),
LLVector2(intersect_center_x - src_center_x, intersect_center_y - src_center_y),
0.5f);
force.setVec(dst_center_x - src_center_x, dst_center_y - src_center_y);
force.normVec();
LLVector2 src_force = -1.f * force;
LLVector2 dst_force = force;
LLVector2 force_strength;
F32 src_mult = dst_textp->mMass / (dst_textp->mMass + src_textp->mMass);
F32 dst_mult = 1.f - src_mult;
F32 src_aspect_ratio = src_textp->mSoftScreenRect.getWidth() / src_textp->mSoftScreenRect.getHeight();
F32 dst_aspect_ratio = dst_textp->mSoftScreenRect.getWidth() / dst_textp->mSoftScreenRect.getHeight();
src_force.mV[VY] *= src_aspect_ratio;
src_force.normVec();
dst_force.mV[VY] *= dst_aspect_ratio;
dst_force.normVec();
src_force.mV[VX] *= llmin(intersect_rect.getWidth() * src_mult, intersect_rect.getHeight() * SPRING_STRENGTH);
//.........这里部分代码省略.........