本文整理汇总了C++中LLBBox::agentToLocalBasis方法的典型用法代码示例。如果您正苦于以下问题:C++ LLBBox::agentToLocalBasis方法的具体用法?C++ LLBBox::agentToLocalBasis怎么用?C++ LLBBox::agentToLocalBasis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLBBox
的用法示例。
在下文中一共展示了LLBBox::agentToLocalBasis方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getBBoxAspectRatio
// This function calculates the aspect ratio and the world aligned components of a selection bounding box.
F32 LLViewerMediaFocus::getBBoxAspectRatio(const LLBBox& bbox, const LLVector3& normal, F32* height, F32* width, F32* depth)
{
// Convert the selection normal and an up vector to local coordinate space of the bbox
LLVector3 local_normal = bbox.agentToLocalBasis(normal);
LLVector3 z_vec = bbox.agentToLocalBasis(LLVector3(0.0f, 0.0f, 1.0f));
LLVector3 comp1(0.f,0.f,0.f);
LLVector3 comp2(0.f,0.f,0.f);
LLVector3 bbox_max = bbox.getExtentLocal();
F32 dot1 = 0.f;
F32 dot2 = 0.f;
lldebugs << "bounding box local size = " << bbox_max << ", local_normal = " << local_normal << llendl;
// The largest component of the localized normal vector is the depth component
// meaning that the other two are the legs of the rectangle.
local_normal.abs();
// Using temporary variables for these makes the logic a bit more readable.
bool XgtY = (local_normal.mV[VX] > local_normal.mV[VY]);
bool XgtZ = (local_normal.mV[VX] > local_normal.mV[VZ]);
bool YgtZ = (local_normal.mV[VY] > local_normal.mV[VZ]);
if(XgtY && XgtZ)
{
lldebugs << "x component of normal is longest, using y and z" << llendl;
comp1.mV[VY] = bbox_max.mV[VY];
comp2.mV[VZ] = bbox_max.mV[VZ];
*depth = bbox_max.mV[VX];
}
else if(!XgtY && YgtZ)
{
lldebugs << "y component of normal is longest, using x and z" << llendl;
comp1.mV[VX] = bbox_max.mV[VX];
comp2.mV[VZ] = bbox_max.mV[VZ];
*depth = bbox_max.mV[VY];
}
else
{
lldebugs << "z component of normal is longest, using x and y" << llendl;
comp1.mV[VX] = bbox_max.mV[VX];
comp2.mV[VY] = bbox_max.mV[VY];
*depth = bbox_max.mV[VZ];
}
// The height is the vector closest to vertical in the bbox coordinate space (highest dot product value)
dot1 = comp1 * z_vec;
dot2 = comp2 * z_vec;
if(fabs(dot1) > fabs(dot2))
{
*height = comp1.length();
*width = comp2.length();
lldebugs << "comp1 = " << comp1 << ", height = " << *height << llendl;
lldebugs << "comp2 = " << comp2 << ", width = " << *width << llendl;
}
else
{
*height = comp2.length();
*width = comp1.length();
lldebugs << "comp2 = " << comp2 << ", height = " << *height << llendl;
lldebugs << "comp1 = " << comp1 << ", width = " << *width << llendl;
}
lldebugs << "returning " << (*width / *height) << llendl;
// Return the aspect ratio.
return *width / *height;
}
示例2: getBBoxAspectRatio
// This function calculates the aspect ratio and the world aligned components of a selection bounding box.
F32 LLViewerMediaFocus::getBBoxAspectRatio(const LLBBox& bbox, const LLVector3& normal, F32* height, F32* width, F32* depth)
{
// Convert the selection normal and an up vector to local coordinate space of the bbox
LLVector3 local_normal = bbox.agentToLocalBasis(normal);
LLVector3 z_vec = bbox.agentToLocalBasis(LLVector3(0.0f, 0.0f, 1.0f));
LLVector3 comp1(0.f,0.f,0.f);
LLVector3 comp2(0.f,0.f,0.f);
LLVector3 bbox_max = bbox.getExtentLocal();
F32 dot1 = 0.f;
F32 dot2 = 0.f;
// The largest component of the localized normal vector is the depth component
// meaning that the other two are the legs of the rectangle.
local_normal.abs();
if(local_normal.mV[VX] > local_normal.mV[VY])
{
if(local_normal.mV[VX] > local_normal.mV[VZ])
{
// Use the y and z comps
comp1.mV[VY] = bbox_max.mV[VY];
comp2.mV[VZ] = bbox_max.mV[VZ];
*depth = bbox_max.mV[VX];
}
else
{
// Use the x and y comps
comp1.mV[VY] = bbox_max.mV[VY];
comp2.mV[VZ] = bbox_max.mV[VZ];
*depth = bbox_max.mV[VZ];
}
}
else if(local_normal.mV[VY] > local_normal.mV[VZ])
{
// Use the x and z comps
comp1.mV[VX] = bbox_max.mV[VX];
comp2.mV[VZ] = bbox_max.mV[VZ];
*depth = bbox_max.mV[VY];
}
else
{
// Use the x and y comps
comp1.mV[VY] = bbox_max.mV[VY];
comp2.mV[VZ] = bbox_max.mV[VZ];
*depth = bbox_max.mV[VX];
}
// The height is the vector closest to vertical in the bbox coordinate space (highest dot product value)
dot1 = comp1 * z_vec;
dot2 = comp2 * z_vec;
if(fabs(dot1) > fabs(dot2))
{
*height = comp1.length();
*width = comp2.length();
}
else
{
*height = comp2.length();
*width = comp1.length();
}
// Return the aspect ratio.
return *width / *height;
}