本文整理汇总了C++中LLBBox::getCenterAgent方法的典型用法代码示例。如果您正苦于以下问题:C++ LLBBox::getCenterAgent方法的具体用法?C++ LLBBox::getCenterAgent怎么用?C++ LLBBox::getCenterAgent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLBBox
的用法示例。
在下文中一共展示了LLBBox::getCenterAgent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bbox_overlap
// only works for our specialized (AABB, position centered) bboxes
BOOL bbox_overlap(LLBBox bbox1, LLBBox bbox2)
{
const F32 FUDGE = 0.001f; // because of SL precision/rounding
LLVector3 delta = bbox1.getCenterAgent() - bbox2.getCenterAgent();
LLVector3 half_extent = (bbox1.getExtentLocal() + bbox2.getExtentLocal()) / 2.0;
return ((fabs(delta.mV[VX]) < half_extent.mV[VX] - FUDGE) &&
(fabs(delta.mV[VY]) < half_extent.mV[VY] - FUDGE) &&
(fabs(delta.mV[VZ]) < half_extent.mV[VZ] - FUDGE));
}
示例2: setup_transforms_bbox
void setup_transforms_bbox(LLBBox bbox)
{
// translate to center
LLVector3 center = bbox.getCenterAgent();
gGL.translatef(center.mV[VX], center.mV[VY], center.mV[VZ]);
// rotate
LLQuaternion rotation = bbox.getRotation();
F32 angle_radians, x, y, z;
rotation.getAngleAxis(&angle_radians, &x, &y, &z);
gGL.flush();
gGL.rotatef(angle_radians * RAD_TO_DEG, x, y, z);
// scale
LLVector3 scale = bbox.getMaxLocal() - bbox.getMinLocal();
gGL.scalef(scale.mV[VX], scale.mV[VY], scale.mV[VZ]);
}
示例3: setup_transforms_bbox
void setup_transforms_bbox(LLBBox bbox)
{
// translate to center
LLVector3 center = bbox.getCenterAgent();
gGL.translatef(center.mV[VX], center.mV[VY], center.mV[VZ]);
// rotate
LLQuaternion rotation = bbox.getRotation();
F32 angle_radians, x, y, z;
rotation.getAngleAxis(&angle_radians, &x, &y, &z);
// gGL has no rotate method (despite having translate and scale) presumably because
// its authors smoke crack. so we hack.
gGL.flush();
glRotatef(angle_radians * RAD_TO_DEG, x, y, z);
// scale
LLVector3 scale = bbox.getMaxLocal() - bbox.getMinLocal();
gGL.scalef(scale.mV[VX], scale.mV[VY], scale.mV[VZ]);
}
示例4: setCameraZoom
// This function selects an ideal viewing distance based on the focused object, pick normal, and padding value
void LLViewerMediaFocus::setCameraZoom(LLViewerObject* object, LLVector3 normal, F32 padding_factor, bool zoom_in_only)
{
if (object)
{
gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE);
LLBBox bbox = object->getBoundingBoxAgent();
LLVector3d center = gAgent.getPosGlobalFromAgent(bbox.getCenterAgent());
F32 height;
F32 width;
F32 depth;
F32 angle_of_view;
F32 distance;
// We need the aspect ratio, and the 3 components of the bbox as height, width, and depth.
F32 aspect_ratio = getBBoxAspectRatio(bbox, normal, &height, &width, &depth);
F32 camera_aspect = LLViewerCamera::getInstance()->getAspect();
lldebugs << "normal = " << normal << ", aspect_ratio = " << aspect_ratio << ", camera_aspect = " << camera_aspect << llendl;
// We will normally use the side of the volume aligned with the short side of the screen (i.e. the height for
// a screen in a landscape aspect ratio), however there is an edge case where the aspect ratio of the object is
// more extreme than the screen. In this case we invert the logic, using the longer component of both the object
// and the screen.
bool invert = (camera_aspect > 1.0f && aspect_ratio > camera_aspect) ||
(camera_aspect < 1.0f && aspect_ratio < camera_aspect);
// To calculate the optimum viewing distance we will need the angle of the shorter side of the view rectangle.
// In portrait mode this is the width, and in landscape it is the height.
// We then calculate the distance based on the corresponding side of the object bbox (width for portrait, height for landscape)
// We will add half the depth of the bounding box, as the distance projection uses the center point of the bbox.
if(camera_aspect < 1.0f || invert)
{
angle_of_view = llmax(0.1f, LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect());
distance = width * 0.5 * padding_factor / tan(angle_of_view * 0.5f );
lldebugs << "using width (" << width << "), angle_of_view = " << angle_of_view << ", distance = " << distance << llendl;
}
else
{
angle_of_view = llmax(0.1f, LLViewerCamera::getInstance()->getView());
distance = height * 0.5 * padding_factor / tan(angle_of_view * 0.5f );
lldebugs << "using height (" << height << "), angle_of_view = " << angle_of_view << ", distance = " << distance << llendl;
}
distance += depth * 0.5;
// Finally animate the camera to this new position and focal point
LLVector3d camera_pos, target_pos;
// The target lookat position is the center of the selection (in global coords)
target_pos = center;
// Target look-from (camera) position is "distance" away from the target along the normal
LLVector3d pickNormal = LLVector3d(normal);
pickNormal.normalize();
camera_pos = target_pos + pickNormal * distance;
if (pickNormal == LLVector3d::z_axis || pickNormal == LLVector3d::z_axis_neg)
{
// If the normal points directly up, the camera will "flip" around.
// We try to avoid this by adjusting the target camera position a
// smidge towards current camera position
// *NOTE: this solution is not perfect. All it attempts to solve is the
// "looking down" problem where the camera flips around when it animates
// to that position. You still are not guaranteed to be looking at the
// media in the correct orientation. What this solution does is it will
// put the camera into position keeping as best it can the current
// orientation with respect to the face. In other words, if before zoom
// the media appears "upside down" from the camera, after zooming it will
// still be upside down, but at least it will not flip.
LLVector3d cur_camera_pos = LLVector3d(gAgentCamera.getCameraPositionGlobal());
LLVector3d delta = (cur_camera_pos - camera_pos);
F64 len = delta.length();
delta.normalize();
// Move 1% of the distance towards original camera location
camera_pos += 0.01 * len * delta;
}
// If we are not allowing zooming out and the old camera position is closer to
// the center then the new intended camera position, don't move camera and return
if (zoom_in_only &&
(dist_vec_squared(gAgentCamera.getCameraPositionGlobal(), target_pos) < dist_vec_squared(camera_pos, target_pos)))
{
return;
}
gAgentCamera.setCameraPosAndFocusGlobal(camera_pos, target_pos, object->getID() );
}
else
{
// If we have no object, focus back on the avatar.
gAgentCamera.setFocusOnAvatar(TRUE, ANIMATE);
}
}
示例5: pickLeftMouseDownCallback
//.........这里部分代码省略.........
return TRUE;
case CLICK_ACTION_OPEN:
if (parent && parent->allowOpen())
{
mClickActionObject = parent;
mLeftClickSelection = LLToolSelect::handleObjectSelection(mPick, FALSE, TRUE, TRUE);
if (LLSelectMgr::getInstance()->selectGetAllValid())
{
// call this right away, since we have all the info we need to continue the action
selectionPropertiesReceived();
}
}
return TRUE;
case CLICK_ACTION_PLAY:
handle_click_action_play();
return TRUE;
case CLICK_ACTION_OPEN_MEDIA:
// mClickActionObject = object;
handle_click_action_open_media(object);
return TRUE;
case CLICK_ACTION_ZOOM:
{
const F32 PADDING_FACTOR = 2.f;
LLViewerObject* object = gObjectList.findObject(mPick.mObjectID);
if (object)
{
gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE);
LLBBox bbox = object->getBoundingBoxAgent() ;
F32 angle_of_view = llmax(0.1f, LLViewerCamera::getInstance()->getAspect() > 1.f ? LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect() : LLViewerCamera::getInstance()->getView());
F32 distance = bbox.getExtentLocal().magVec() * PADDING_FACTOR / atan(angle_of_view);
LLVector3 obj_to_cam = LLViewerCamera::getInstance()->getOrigin() - bbox.getCenterAgent();
obj_to_cam.normVec();
LLVector3d object_center_global = gAgent.getPosGlobalFromAgent(bbox.getCenterAgent());
gAgentCamera.setCameraPosAndFocusGlobal(object_center_global + LLVector3d(obj_to_cam * distance),
object_center_global,
mPick.mObjectID );
}
}
return TRUE;
default:
// nothing
break;
}
}
// put focus back "in world"
gFocusMgr.setKeyboardFocus(NULL);
BOOL touchable = (object && object->flagHandleTouch())
|| (parent && parent->flagHandleTouch());
// Switch to grab tool if physical or triggerable
if (object &&
!object->isAvatar() &&
((object->usePhysics() || (parent && !parent->isAvatar() && parent->usePhysics())) || touchable)
)
{
gGrabTransientTool = this;
LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolGrab::getInstance() );
return LLToolGrab::getInstance()->handleObjectHit( mPick );
}