本文整理汇总了C++中LLVector3::magVec方法的典型用法代码示例。如果您正苦于以下问题:C++ LLVector3::magVec方法的具体用法?C++ LLVector3::magVec怎么用?C++ LLVector3::magVec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLVector3
的用法示例。
在下文中一共展示了LLVector3::magVec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: heightInPixels
// return height of a sphere of given radius, located at center, in pixels
F32 LLCamera::heightInPixels(const LLVector3 ¢er, F32 radius ) const
{
if (radius == 0.f) return 0.f;
// If height initialized
if (mViewHeightInPixels > -1)
{
// Convert sphere to coord system with 0,0,0 at camera
LLVector3 vec = center - mOrigin;
// Compute distance to sphere
F32 dist = vec.magVec();
// Calculate angle of whole object
F32 angle = 2.0f * (F32) atan2(radius, dist);
// Calculate fraction of field of view
F32 fraction_of_fov = angle / mView;
// Compute number of pixels tall, based on vertical field of view
return (fraction_of_fov * mViewHeightInPixels);
}
else
{
// return invalid height
return -1.0f;
}
}
示例2: visibleDistance
// If pos is visible, return the distance from pos to the camera.
// Use fudge distance to scale rad against top/bot/left/right planes
// Otherwise, return -distance
F32 LLCamera::visibleDistance(const LLVector3 &pos, F32 rad, F32 fudgedist, U32 planemask) const
{
if (mFixedDistance > 0)
{
return mFixedDistance;
}
LLVector3 dvec = pos - mOrigin;
// Check visibility
F32 dist = dvec.magVec();
if (dist > rad)
{
F32 dp,tdist;
dp = dvec * mXAxis;
if (dp < -rad)
return -dist;
rad *= fudgedist;
LLVector3 tvec(pos);
for (int p=0; p<PLANE_NUM; p++)
{
if (!(planemask & (1<<p)))
continue;
tdist = -(mWorldPlanes[p].dist(tvec));
if (tdist > rad)
return -dist;
}
}
return dist;
}
示例3: updateDistance
void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
{
if (LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD)
{
llwarns << "Attempted to update distance for non-world camera." << llendl;
return;
}
//switch LOD with the spatial group to avoid artifacts
//LLSpatialGroup* sg = getSpatialGroup();
LLVector3 pos;
//if (!sg || sg->changeLOD())
{
LLVOVolume* volume = getVOVolume();
if (volume)
{
if (getSpatialGroup())
{
pos.set(getPositionGroup().getF32ptr());
}
else
{
pos = getPositionAgent();
}
if (isState(LLDrawable::HAS_ALPHA))
{
for (S32 i = 0; i < getNumFaces(); i++)
{
LLFace* facep = getFace(i);
if (force_update || facep->getPoolType() == LLDrawPool::POOL_ALPHA)
{
LLVector4a box;
box.setSub(facep->mExtents[1], facep->mExtents[0]);
box.mul(0.25f);
LLVector3 v = (facep->mCenterLocal-camera.getOrigin());
const LLVector3& at = camera.getAtAxis();
for (U32 j = 0; j < 3; j++)
{
v.mV[j] -= box[j] * at.mV[j];
}
facep->mDistance = v * camera.getAtAxis();
}
}
}
}
else
{
pos = LLVector3(getPositionGroup().getF32ptr());
}
pos -= camera.getOrigin();
mDistanceWRTCamera = llround(pos.magVec(), 0.01f);
mVObjp->updateLOD();
}
}
示例4: updateSpatialExtents
void LLSpatialBridge::updateSpatialExtents()
{
LLSpatialGroup* root = (LLSpatialGroup*) mOctree->getListener(0);
{
LLFastTimer ftm(LLFastTimer::FTM_CULL_REBOUND);
root->rebound();
}
LLXformMatrix* mat = mDrawable->getXform();
LLVector3 offset = root->mBounds[0];
LLVector3 size = root->mBounds[1];
LLVector3 center = LLVector3(0,0,0) * mat->getWorldMatrix();
LLQuaternion rotation = LLQuaternion(mat->getWorldMatrix());
offset *= rotation;
center += offset;
LLVector3 v[4];
//get 4 corners of bounding box
v[0] = (size * rotation);
v[1] = (LLVector3(-size.mV[0], -size.mV[1], size.mV[2]) * rotation);
v[2] = (LLVector3(size.mV[0], -size.mV[1], -size.mV[2]) * rotation);
v[3] = (LLVector3(-size.mV[0], size.mV[1], -size.mV[2]) * rotation);
LLVector3& newMin = mExtents[0];
LLVector3& newMax = mExtents[1];
newMin = newMax = center;
for (U32 i = 0; i < 4; i++)
{
for (U32 j = 0; j < 3; j++)
{
F32 delta = fabsf(v[i].mV[j]);
F32 min = center.mV[j] - delta;
F32 max = center.mV[j] + delta;
if (min < newMin.mV[j])
{
newMin.mV[j] = min;
}
if (max > newMax.mV[j])
{
newMax.mV[j] = max;
}
}
}
LLVector3 diagonal = newMax - newMin;
mRadius = diagonal.magVec() * 0.5f;
mPositionGroup.setVec((newMin + newMax) * 0.5f);
updateBinRadius();
}
示例5: updateCameraDistanceRegion
void LLSurfacePatch::updateCameraDistanceRegion(const LLVector3 &pos_region)
{
if (LLPipeline::sDynamicLOD)
{
LLVector3 dv = pos_region;
dv -= mCenterRegion;
mVisInfo.mDistance = llmax(0.f, (F32)(dv.magVec() - mRadius))/
llmax(LLVOSurfacePatch::sLODFactor, 0.1f);
}
else
{
mVisInfo.mDistance = 0.f;
}
}
示例6: updateBehindnessConstraint
//-------------------------------------------------------------------------------------
BOOL LLFollowCam::updateBehindnessConstraint(LLVector3 focus, LLVector3& cam_position)
{
BOOL constraint_active = FALSE;
// only apply this stuff if the behindness angle is something other than opened up all the way
if ( mBehindnessMaxAngle < FOLLOW_CAM_MAX_BEHINDNESS_ANGLE - FOLLOW_CAM_BEHINDNESS_EPSILON )
{
//--------------------------------------------------------------
// horizontalized vector from focus to camera
//--------------------------------------------------------------
LLVector3 horizontalVectorFromFocusToCamera;
horizontalVectorFromFocusToCamera.setVec(cam_position - focus);
horizontalVectorFromFocusToCamera.mV[ VZ ] = 0.0f;
F32 cameraZ = cam_position.mV[ VZ ];
//--------------------------------------------------------------
// distance of horizontalized vector
//--------------------------------------------------------------
F32 horizontalDistance = horizontalVectorFromFocusToCamera.magVec();
//--------------------------------------------------------------------------------------------------
// calculate horizontalized back vector of the subject and scale by horizontalDistance
//--------------------------------------------------------------------------------------------------
LLVector3 horizontalSubjectBack( -1.0f, 0.0f, 0.0f );
horizontalSubjectBack *= mSubjectRotation;
horizontalSubjectBack.mV[ VZ ] = 0.0f;
horizontalSubjectBack.normVec(); // because horizontalizing might make it shorter than 1
horizontalSubjectBack *= horizontalDistance;
//--------------------------------------------------------------------------------------------------
// find the angle (in degrees) between these vectors
//--------------------------------------------------------------------------------------------------
F32 cameraOffsetAngle = 0.f;
LLVector3 cameraOffsetRotationAxis;
LLQuaternion camera_offset_rotation;
camera_offset_rotation.shortestArc(horizontalSubjectBack, horizontalVectorFromFocusToCamera);
camera_offset_rotation.getAngleAxis(&cameraOffsetAngle, cameraOffsetRotationAxis);
cameraOffsetAngle *= RAD_TO_DEG;
if ( cameraOffsetAngle > mBehindnessMaxAngle )
{
F32 fraction = ((cameraOffsetAngle - mBehindnessMaxAngle) / cameraOffsetAngle) * LLCriticalDamp::getInterpolant(mBehindnessLag);
cam_position = focus + horizontalSubjectBack * (slerp(fraction, camera_offset_rotation, LLQuaternion::DEFAULT));
cam_position.mV[VZ] = cameraZ; // clamp z value back to what it was before we started messing with it
constraint_active = TRUE;
}
}
return constraint_active;
}
示例7: updateDistance
void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
{
//switch LOD with the spatial group to avoid artifacts
//LLSpatialGroup* sg = getSpatialGroup();
LLVector3 pos;
//if (!sg || sg->changeLOD())
{
LLVOVolume* volume = getVOVolume();
if (volume)
{
volume->updateRelativeXform();
pos = volume->getRelativeXform().getTranslation();
if (isStatic())
{
pos += volume->getRegion()->getOriginAgent();
}
if (isState(LLDrawable::HAS_ALPHA))
{
for (S32 i = 0; i < getNumFaces(); i++)
{
LLFace* facep = getFace(i);
if (facep->getPoolType() == LLDrawPool::POOL_ALPHA)
{
LLVector3 box = (facep->mExtents[1] - facep->mExtents[0]) * 0.25f;
LLVector3 v = (facep->mCenterLocal-camera.getOrigin());
const LLVector3& at = camera.getAtAxis();
for (U32 j = 0; j < 3; j++)
{
v.mV[j] -= box.mV[j] * at.mV[j];
}
facep->mDistance = v * camera.getAtAxis();
}
}
}
}
else
{
pos = LLVector3(getPositionGroup());
}
pos -= camera.getOrigin();
mDistanceWRTCamera = llround(pos.magVec(), 0.01f);
mVObjp->updateLOD();
}
}
示例8: lineSegmentIntersect
BOOL LLVOTree::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, BOOL pick_transparent, S32 *face_hitp,
LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal)
{
if (!lineSegmentBoundingBox(start, end))
{
return FALSE;
}
const LLVector4a* exta = mDrawable->getSpatialExtents();
//VECTORIZE THIS
LLVector3 ext[2];
ext[0].set(exta[0].getF32ptr());
ext[1].set(exta[1].getF32ptr());
LLVector3 center = (ext[1]+ext[0])*0.5f;
LLVector3 size = (ext[1]-ext[0]);
LLQuaternion quat = getRotation();
center -= LLVector3(0,0,size.magVec() * 0.25f)*quat;
size.scaleVec(LLVector3(0.25f, 0.25f, 1.f));
size.mV[0] = llmin(size.mV[0], 1.f);
size.mV[1] = llmin(size.mV[1], 1.f);
LLVector3 pos, norm;
if (linesegment_tetrahedron(start, end, center, size, quat, pos, norm))
{
if (intersection)
{
*intersection = pos;
}
if (normal)
{
*normal = norm;
}
return TRUE;
}
return FALSE;
}
示例9: mapWindVecToGain
F64 LLAudioEngine::mapWindVecToGain(LLVector3 wind_vec)
{
F64 gain = 0.0;
gain = wind_vec.magVec();
if (gain)
{
if (gain > 20)
{
gain = 20;
}
gain = gain/20.0;
}
return (gain);
}
示例10: visibleHorizDistance
// Like visibleDistance, except uses mHorizPlanes[], which are left and right
// planes perpindicular to (0,0,1) in world space
F32 LLCamera::visibleHorizDistance(const LLVector3 &pos, F32 rad, F32 fudgedist, U32 planemask) const
{
if (mFixedDistance > 0)
{
return mFixedDistance;
}
LLVector3 dvec = pos - mOrigin;
// Check visibility
F32 dist = dvec.magVec();
if (dist > rad)
{
rad *= fudgedist;
LLVector3 tvec(pos);
for (int p=0; p<HORIZ_PLANE_NUM; p++)
{
if (!(planemask & (1<<p)))
continue;
F32 tdist = -(mHorizPlanes[p].dist(tvec));
if (tdist > rad)
return -dist;
}
}
return dist;
}
示例11: updateText
//.........这里部分代码省略.........
LLStringUtil::format_map_t args;
args["[AMOUNT]"] = llformat("%d", nodep->mSaleInfo.getSalePrice());
line.append(LLTrans::getString("TooltipForSaleL$", args));
suppressObjectHoverDisplay = FALSE; // Show tip
}
else
{
// Nothing if not for sale
// line.append("Not for sale");
}
}
else
{
LLStringUtil::format_map_t args;
args["[MESSAGE]"] = LLTrans::getString("RetrievingData");
line.append(LLTrans::getString("TooltipForSaleMsg", args));
}
mText.push_back(line);
}
line.clear();
S32 prim_count = LLSelectMgr::getInstance()->getHoverObjects()->getObjectCount();
line.append(llformat("Prims: %d", prim_count));
mText.push_back(line);
line.clear();
line.append("Position: ");
LLViewerRegion *region = gAgent.getRegion();
LLVector3 position = region->getPosRegionFromGlobal(hit_object->getPositionGlobal());//regionp->getOriginAgent();
LLVector3 mypos = region->getPosRegionFromGlobal(gAgent.getPositionGlobal());
LLVector3 delta = position - mypos;
F32 distance = (F32)delta.magVec();
line.append(llformat("<%.02f,%.02f,%.02f>",position.mV[0],position.mV[1],position.mV[2]));
mText.push_back(line);
line.clear();
line.append(llformat("Distance: %.02fm",distance));
mText.push_back(line);
// If the hover tip shouldn't be shown, delete all the object text
if (suppressObjectHoverDisplay)
{
mText.clear();
}
}
}
else if ( mHoverLandGlobal != LLVector3d::zero )
{
//
// Do not show hover for land unless prefs are set to allow it.
//
if (!gSavedSettings.getBOOL("ShowLandHoverTip")) return;
// Didn't hit an object, but since we have a land point we
// must be hovering over land.
LLParcel* hover_parcel = LLViewerParcelMgr::getInstance()->getHoverParcel();
LLUUID owner;
S32 width = 0;
S32 height = 0;
if ( hover_parcel )
{
示例12: if
//-----------------------------------------------------------------------------
// solve()
//-----------------------------------------------------------------------------
void LLJointSolverRP3::solve()
{
// llinfos << llendl;
// llinfos << "LLJointSolverRP3::solve()" << llendl;
//-------------------------------------------------------------------------
// setup joints in their base rotations
//-------------------------------------------------------------------------
mJointA->setRotation( mJointABaseRotation );
mJointB->setRotation( mJointBBaseRotation );
//-------------------------------------------------------------------------
// get joint positions in world space
//-------------------------------------------------------------------------
LLVector3 aPos = mJointA->getWorldPosition();
LLVector3 bPos = mJointB->getWorldPosition();
LLVector3 cPos = mJointC->getWorldPosition();
LLVector3 gPos = mJointGoal->getWorldPosition();
// llinfos << "bPosLocal = " << mJointB->getPosition() << llendl;
// llinfos << "cPosLocal = " << mJointC->getPosition() << llendl;
// llinfos << "bRotLocal = " << mJointB->getRotation() << llendl;
// llinfos << "cRotLocal = " << mJointC->getRotation() << llendl;
// llinfos << "aPos : " << aPos << llendl;
// llinfos << "bPos : " << bPos << llendl;
// llinfos << "cPos : " << cPos << llendl;
// llinfos << "gPos : " << gPos << llendl;
//-------------------------------------------------------------------------
// get the poleVector in world space
//-------------------------------------------------------------------------
LLVector3 poleVec = mPoleVector;
if ( mJointA->getParent() )
{
LLVector4a pole_veca;
pole_veca.load3(mPoleVector.mV);
mJointA->getParent()->getWorldMatrix().rotate(pole_veca,pole_veca);
poleVec.set(pole_veca.getF32ptr());
}
//-------------------------------------------------------------------------
// compute the following:
// vector from A to B
// vector from B to C
// vector from A to C
// vector from A to G (goal)
//-------------------------------------------------------------------------
LLVector3 abVec = bPos - aPos;
LLVector3 bcVec = cPos - bPos;
LLVector3 acVec = cPos - aPos;
LLVector3 agVec = gPos - aPos;
// llinfos << "abVec : " << abVec << llendl;
// llinfos << "bcVec : " << bcVec << llendl;
// llinfos << "acVec : " << acVec << llendl;
// llinfos << "agVec : " << agVec << llendl;
//-------------------------------------------------------------------------
// compute needed lengths of those vectors
//-------------------------------------------------------------------------
F32 abLen = abVec.magVec();
F32 bcLen = bcVec.magVec();
F32 agLen = agVec.magVec();
// llinfos << "abLen : " << abLen << llendl;
// llinfos << "bcLen : " << bcLen << llendl;
// llinfos << "agLen : " << agLen << llendl;
//-------------------------------------------------------------------------
// compute component vector of (A->B) orthogonal to (A->C)
//-------------------------------------------------------------------------
LLVector3 abacCompOrthoVec = abVec - acVec * ((abVec * acVec)/(acVec * acVec));
// llinfos << "abacCompOrthoVec : " << abacCompOrthoVec << llendl;
//-------------------------------------------------------------------------
// compute the normal of the original ABC plane (and store for later)
//-------------------------------------------------------------------------
LLVector3 abcNorm;
if (!mbUseBAxis)
{
if( are_parallel(abVec, bcVec, 0.001f) )
{
// the current solution is maxed out, so we use the axis that is
// orthogonal to both poleVec and A->B
if ( are_parallel(poleVec, abVec, 0.001f) )
{
// ACK! the problem is singular
if ( are_parallel(poleVec, agVec, 0.001f) )
{
// the solutions is also singular
return;
}
else
{
abcNorm = poleVec % agVec;
//.........这里部分代码省略.........
示例13: postBuild
//.........这里部分代码省略.........
{
// generate unique id for this motion
mTransactionID.generate();
mMotionID = mTransactionID.makeAssetID(gAgent.getSecureSessionID());
mAnimPreview = new LLPreviewAnimation(256, 256);
// motion will be returned, but it will be in a load-pending state, as this is a new motion
// this motion will not request an asset transfer until next update, so we have a chance to
// load the keyframe data locally
motionp = (LLKeyframeMotion*)mAnimPreview->getDummyAvatar()->createMotion(mMotionID);
// create data buffer for keyframe initialization
S32 buffer_size = loaderp->getOutputSize();
U8* buffer = new U8[buffer_size];
LLDataPackerBinaryBuffer dp(buffer, buffer_size);
// pass animation data through memory buffer
loaderp->serialize(dp);
dp.reset();
BOOL success = motionp && motionp->deserialize(dp);
delete []buffer;
if (success)
{
setAnimCallbacks() ;
const LLBBoxLocal &pelvis_bbox = motionp->getPelvisBBox();
LLVector3 temp = pelvis_bbox.getCenter();
// only consider XY?
//temp.mV[VZ] = 0.f;
F32 pelvis_offset = temp.magVec();
temp = pelvis_bbox.getExtent();
//temp.mV[VZ] = 0.f;
F32 pelvis_max_displacement = pelvis_offset + (temp.magVec() * 0.5f) + 1.f;
F32 camera_zoom = LLViewerCamera::getInstance()->getDefaultFOV() / (2.f * atan(pelvis_max_displacement / PREVIEW_CAMERA_DISTANCE));
mAnimPreview->setZoom(camera_zoom);
motionp->setName(childGetValue("name_form").asString());
mAnimPreview->getDummyAvatar()->startMotion(mMotionID);
childSetMinValue("playback_slider", 0.0);
childSetMaxValue("playback_slider", 1.0);
childSetValue("loop_check", LLSD(motionp->getLoop()));
childSetValue("loop_in_point", LLSD(motionp->getLoopIn() / motionp->getDuration() * 100.f));
childSetValue("loop_out_point", LLSD(motionp->getLoopOut() / motionp->getDuration() * 100.f));
childSetValue("priority", LLSD((F32)motionp->getPriority()));
childSetValue("hand_pose_combo", LLHandMotion::getHandPoseName(motionp->getHandPose()));
childSetValue("ease_in_time", LLSD(motionp->getEaseInDuration()));
childSetValue("ease_out_time", LLSD(motionp->getEaseOutDuration()));
setEnabled(TRUE);
std::string seconds_string;
seconds_string = llformat(" - %.2f seconds", motionp->getDuration());
setTitle(mFilename + std::string(seconds_string));
}
else
{
delete mAnimPreview;
mAnimPreview = NULL;
mMotionID.setNull();
childSetValue("bad_animation_text", getString("failed_to_initialize"));
}
}
else
{
if ( loaderp )
{
if (loaderp->getDuration() > MAX_ANIM_DURATION)
{
LLUIString out_str = getString("anim_too_long");
out_str.setArg("[LENGTH]", llformat("%.1f", loaderp->getDuration()));
out_str.setArg("[MAX_LENGTH]", llformat("%.1f", MAX_ANIM_DURATION));
childSetValue("bad_animation_text", out_str.getString());
}
else
{
LLUIString out_str = getString("failed_file_read");
out_str.setArg("[STATUS]", loaderp->getStatus()); // *TODO:Translate
childSetValue("bad_animation_text", out_str.getString());
}
}
//setEnabled(FALSE);
mMotionID.setNull();
mAnimPreview = NULL;
}
refresh();
delete loaderp;
return TRUE;
}
示例14: llmax
S32 LLGlobalEconomy::calculateLightRent(const LLVector3& object_size) const
{
F32 intensity_mod = llmax(object_size.magVec(), 1.f);
return (S32)(intensity_mod * getPriceRentLight());
}
示例15: updateText
//.........这里部分代码省略.........
LLStringUtil::format_map_t args;
args["[AMOUNT]"] = llformat("%d", nodep->mSaleInfo.getSalePrice());
line.append(LLTrans::getString("TooltipForSaleL$", args));
suppressObjectHoverDisplay = FALSE; // Show tip
}
else
{
// Nothing if not for sale
// line.append("Not for sale");
}
}
else
{
LLStringUtil::format_map_t args;
args["[MESSAGE]"] = LLTrans::getString("RetrievingData");
retrieving_data = true;
line.append(LLTrans::getString("TooltipForSaleMsg", args));
}
mText.push_back(line);
line.clear();
S32 prim_count = LLSelectMgr::getInstance()->getHoverObjects()->getObjectCount();
line.append(llformat("Prims: %d", prim_count));
mText.push_back(line);
line.clear();
line.append("Position: ");
LLViewerRegion *region = gAgent.getRegion();
LLVector3 position = region->getPosRegionFromGlobal(hit_object->getPositionGlobal());//regionp->getOriginAgent();
LLVector3 mypos = region->getPosRegionFromGlobal(gAgent.getPositionGlobal());
LLVector3 delta = position - mypos;
F32 distance = (F32)delta.magVec();
line.append(llformat("<%.02f,%.02f,%.02f>",position.mV[0],position.mV[1],position.mV[2]));
mText.push_back(line);
line.clear();
line.append(llformat("Distance: %.02fm",distance));
mText.push_back(line);
}
else
{
suppressObjectHoverDisplay = TRUE;
}
// If the hover tip shouldn't be shown, delete all the object text
if (suppressObjectHoverDisplay)
{
mText.clear();
}
}
}
}
else if ( mHoverLandGlobal != LLVector3d::zero )
{
//
// Do not show hover for land unless prefs are set to allow it.
//
if (!gSavedSettings.getBOOL("ShowLandHoverTip")) return;
// Didn't hit an object, but since we have a land point we
// must be hovering over land.
LLParcel* hover_parcel = LLViewerParcelMgr::getInstance()->getHoverParcel();
LLUUID owner;