本文整理汇总了C++中SbViewVolume::getDepth方法的典型用法代码示例。如果您正苦于以下问题:C++ SbViewVolume::getDepth方法的具体用法?C++ SbViewVolume::getDepth怎么用?C++ SbViewVolume::getDepth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SbViewVolume
的用法示例。
在下文中一共展示了SbViewVolume::getDepth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void
SmTextureText2::renderString(const SmTextureFontBundle & bundle,
const SbString * s,
const int numstring,
const SbVec3f & pos,
const SbViewVolume & vv,
const SbViewportRegion & vp,
const SbMatrix & projmatrix,
const SbMatrix & modelmatrix,
const SbMatrix & invmodelmatrix,
const float rotation)
{
// get distance from pos to camera plane
SbVec3f tmp;
modelmatrix.multVecMatrix(pos, tmp);
float dist = -vv.getPlane(0.0f).getDistance(tmp);
if (dist <= vv.getNearDist()) return;
if (dist > (vv.getNearDist() + vv.getDepth())) return;
float maxr = this->maxRange.getValue();
if (maxr > 0.0f && dist > maxr) return;
int i;
SbVec2s vpsize = vp.getViewportSizePixels();
SbVec3f screenpoint;
projmatrix.multVecMatrix(pos, screenpoint);
int xmin = 0;
int ymax = bundle.getAscent();
int ymin = ymax - numstring * (bundle.height() + bundle.getLeading());
ymin += bundle.getLeading();
short h = ymax - ymin;
short halfh = h / 2;
switch (this->verticalJustification.getValue()) {
case SmTextureText2::BOTTOM:
break;
case SmTextureText2::TOP:
ymin -= bundle.getAscent();
ymax -= bundle.getAscent();
break;
case SmTextureText2::VCENTER:
ymin -= halfh;
ymax -= halfh;
break;
default:
assert(0 && "unknown alignment");
break;
}
SbList <int> widthlist;
for (i = 0; i < numstring; i++) {
widthlist.append(bundle.stringWidth(s[i]));
}
for (i = 0; i < numstring; i++) {
int len = s[i].getLength();
if (len == 0) continue;
SbVec2s sp;
if (!get_screenpoint_pixels(screenpoint, vpsize, sp)) continue;
SbVec2s n0 = SbVec2s(sp[0] + xmin,
sp[1] + ymax - (i+1)*bundle.height());
short w = static_cast<short>(widthlist[i]);
short halfw = w / 2;
switch (this->justification.getValue()) {
case SmTextureText2::LEFT:
break;
case SmTextureText2::RIGHT:
n0[0] -= w;
break;
case SmTextureText2::CENTER:
n0[0] -= halfw;
break;
default:
assert(0 && "unknown alignment");
break;
}
if (rotation != 0) {
float x = static_cast<float>(sp[0]);
float y = static_cast<float>(sp[1]);
glPushMatrix();
glTranslatef(x, y, 0);
glRotatef(rotation * static_cast<float>(180 / M_PI), 0, 0, 1);
glTranslatef(-x, -y, 0);
}
bundle.begin();
bundle.renderString(s[i], SbVec3f(n0[0], n0[1], screenpoint[2]));
bundle.end();
if (rotation != 0) glPopMatrix();
}
//.........这里部分代码省略.........
示例2: GLRender
void SoXipCPUMprRender::GLRender(SoGLRenderAction * action)
{
SoState *state = action->getState();
SbViewportRegion vpRegion = SoViewportRegionElement::get(state);
SbVec2s vpSize = vpRegion.getViewportSizePixels();
// Don't do anything if 0 size
if (!vpSize[0] || !vpSize[1])
return;
// Bind texture to available texture stage
if (!mMPRTexId)
glGenTextures(1, &mMPRTexId);
int texUnit = SoXipMultiTextureElement::getFreeUnit(state);
SoXipMultiTextureElement::setUnit(state, texUnit);
SoXipMultiTextureElement::bindTexture(state, GL_TEXTURE_2D, mMPRTexId);
// Check the size against min/max
SbVec2s minmax = minMaxSize.getValue();
int which = (vpSize[0] > vpSize[1]) ? 0 : 1;
float ratio = (float) vpSize[which] / (float) vpSize[1 - which];
// If smallest dim is < min
if (vpSize[1 - which] < minmax[0])
{
// Clamp to min and change biggest dim according to aspect ratio
vpSize[1 - which] = minmax[0];
vpSize[which] = (short) (ratio * vpSize[1 - which]);
}
// If biggest dim is > max
if (vpSize[which] > minmax[1])
{
// Clamp to max and change smallest dim according to aspect ratio
vpSize[which] = minmax[1];
vpSize[1 - which] = (short) (vpSize[which] / ratio);
}
// Ready the buffers
readyBuffers(state);
if (vpSize[0] == 0 || vpSize[1] == 0)
return;
// Check if mpr texture must be resized
if (mMPRSize != vpSize)
{
resizeBuffers(vpSize);
mUpdateFlag |= UPDATE_MPRCACHE;
}
// Exit if unsupported image type
if (mTexInternalFormat == 0 ||
mTexType == 0)
return;
// Check if orientation has changed
SbVec3f corners[4];
SbViewVolume viewVolume = SoViewVolumeElement::get(state);
float dist = viewVolume.getNearDist() + viewVolume.getDepth() * 0.5f;
corners[0] = viewVolume.getPlanePoint(dist, SbVec2f(0, 1));
corners[1] = viewVolume.getPlanePoint(dist, SbVec2f(1, 1));
corners[2] = viewVolume.getPlanePoint(dist, SbVec2f(1, 0));
corners[3] = viewVolume.getPlanePoint(dist, SbVec2f(0, 0));
if (corners[0] != mCorners[0] ||
corners[1] != mCorners[1] ||
corners[2] != mCorners[2] ||
corners[3] != mCorners[3])
{
mCorners[0] = corners[0];
mCorners[1] = corners[1];
mCorners[2] = corners[2];
mCorners[3] = corners[3];
mUpdateFlag |= UPDATE_MPRCACHE;
}
//
if (mUpdateFlag & UPDATE_MPRCACHE)
{
// Compute new cache table and mpr
switch (mVolDataType)
{
case SbXipImage::UNSIGNED_BYTE:
mLutBuf ? computeMPRCacheLUT(this, (unsigned char*)mVolBuf, state) : computeMPRCache(this, (unsigned char*)mVolBuf, state);
break;
case SbXipImage::BYTE:
mLutBuf ? computeMPRCacheLUT(this, (char*)mVolBuf, state) : computeMPRCache(this, (char*)mVolBuf, state);
break;
case SbXipImage::UNSIGNED_SHORT:
mLutBuf ? computeMPRCacheLUT(this, (unsigned short*)mVolBuf, state) : computeMPRCache(this, (unsigned short*)mVolBuf, state);
break;
case SbXipImage::SHORT:
mLutBuf ? computeMPRCacheLUT(this, (short*)mVolBuf, state) : computeMPRCache(this, (short*)mVolBuf, state);
break;
case SbXipImage::UNSIGNED_INT:
mLutBuf ? computeMPRCacheLUT(this, (unsigned int*)mVolBuf, state) : computeMPRCache(this, (unsigned int*)mVolBuf, state);
break;
case SbXipImage::INT:
mLutBuf ? computeMPRCacheLUT(this, (int*)mVolBuf, state) : computeMPRCache(this, (int*)mVolBuf, state);
break;
//.........这里部分代码省略.........