本文整理汇总了C++中SbViewVolume::ortho方法的典型用法代码示例。如果您正苦于以下问题:C++ SbViewVolume::ortho方法的具体用法?C++ SbViewVolume::ortho怎么用?C++ SbViewVolume::ortho使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SbViewVolume
的用法示例。
在下文中一共展示了SbViewVolume::ortho方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Doc in superclass.
SbViewVolume
SoOrthographicCamera::getViewVolume(float useaspectratio) const
{
SbViewVolume volume;
if (useaspectratio == 0.0f) useaspectratio = this->aspectRatio.getValue();
float halfheight = this->height.getValue() * 0.5f;
float halfwidth = halfheight * useaspectratio;
volume.ortho(-halfwidth, halfwidth,
-halfheight, halfheight,
this->nearDistance.getValue(), this->farDistance.getValue());
volume.rotateCamera(this->orientation.getValue());
volume.translateCamera(this->position.getValue());
return volume;
}
示例2: GLUWrapper
// doc from superclass.
void
SoNurbsProfile::getVertices(SoState * state, int32_t & numvertices,
SbVec2f * & vertices)
{
// FIXME: optimize by detecting when the previously calculated
// vertices can be returned. pederb, 20000922
int32_t numpoints;
float * points;
int floatspervec;
int32_t numknots;
float * knotvector;
this->getTrimCurve(state, numpoints, points, floatspervec, numknots, knotvector);
if (numpoints == 0 || numknots == 0) {
numvertices = 0;
vertices = NULL;
return;
}
SbList <float> * coordListNurbsProfile =
so_nurbsprofile_get_coordlist(FALSE);
SbList <float> * nurbsProfileTempList =
so_nurbsprofile_get_coordlist(TRUE);
nurbsProfileTempList->truncate(0);
for (int i = 0; i < numpoints; i++) {
nurbsProfileTempList->append(points[i*floatspervec]);
nurbsProfileTempList->append(points[i*floatspervec+1]);
if (GLUWrapper()->available &&
GLUWrapper()->versionMatchesAtLeast(1, 3, 0)) {
nurbsProfileTempList->append(0.0f); // gluNurbs needs 3D coordinates
}
}
if (GLUWrapper()->available &&
GLUWrapper()->versionMatchesAtLeast(1, 3, 0)) {
// we will write into this array in the GLU callback
coordListNurbsProfile->truncate(0);
if (this->nurbsrenderer == NULL) {
this->nurbsrenderer = GLUWrapper()->gluNewNurbsRenderer();
GLUWrapper()->gluNurbsCallback(this->nurbsrenderer, (GLenum) GLU_NURBS_VERTEX,
(gluNurbsCallback_cb_t)nurbsprofile_tess_vertex);
GLUWrapper()->gluNurbsProperty(this->nurbsrenderer, (GLenum) GLU_NURBS_MODE, GLU_NURBS_TESSELLATOR);
GLUWrapper()->gluNurbsProperty(this->nurbsrenderer, (GLenum) GLU_AUTO_LOAD_MATRIX, FALSE);
GLUWrapper()->gluNurbsProperty(this->nurbsrenderer, (GLenum) GLU_DISPLAY_MODE, GLU_POINT);
GLUWrapper()->gluNurbsProperty(this->nurbsrenderer, (GLenum) GLU_SAMPLING_METHOD, GLU_DOMAIN_DISTANCE);
}
// this looks pretty good
float cmplx = SoComplexityElement::get(state);
cmplx += 1.0f;
cmplx = cmplx * cmplx * cmplx;
GLUWrapper()->gluNurbsProperty(this->nurbsrenderer, (GLenum) GLU_U_STEP, float(numpoints)*cmplx);
// these values are not important as we're not using screen-space
// complexity (yet)
SbMatrix modelmatrix = SbMatrix::identity();
SbMatrix affine, proj;
SbViewVolume vv;
vv.ortho(0.0f, 1.0f,
0.0f, 1.0f,
-1.0f, 1.0f);
vv.getMatrices(affine, proj);
GLint viewport[4];
viewport[0] = 0;
viewport[1] = 0;
viewport[2] = 256;
viewport[3] = 256;
GLUWrapper()->gluLoadSamplingMatrices(this->nurbsrenderer,
modelmatrix[0],
proj[0],
viewport);
// generate curve
GLUWrapper()->gluBeginCurve(this->nurbsrenderer);
GLUWrapper()->gluNurbsCurve(this->nurbsrenderer,
numknots,
(float*)knotvector,
3,
(float*)nurbsProfileTempList->getArrayPtr(),
numknots - numpoints,
GL_MAP1_VERTEX_3);
GLUWrapper()->gluEndCurve(this->nurbsrenderer);
// when we get here, the GLU callback should have added the
// points to the list
numvertices = coordListNurbsProfile->getLength() / 2;
vertices = (SbVec2f*) coordListNurbsProfile->getArrayPtr();
}
else {
// just send the control points when GLU v1.3 is not available
numvertices = numpoints;
vertices = (SbVec2f*) nurbsProfileTempList->getArrayPtr();
}
}
示例3: GLRender
/**
* Renders the label.
*/
void SoTextLabel::GLRender(SoGLRenderAction *action)
{
if (!this->shouldGLRender(action)) return;
// only draw text without background
if (!this->background.getValue()) {
inherited::GLRender(action);
return;
}
SoState * state = action->getState();
state->push();
SoLazyElement::setLightModel(state, SoLazyElement::BASE_COLOR);
SbBox3f box;
SbVec3f center;
this->computeBBox(action, box, center);
if (!SoCullElement::cullTest(state, box, TRUE)) {
SoMaterialBundle mb(action);
mb.sendFirst();
const SbMatrix & mat = SoModelMatrixElement::get(state);
//const SbViewVolume & vv = SoViewVolumeElement::get(state);
const SbMatrix & projmatrix = (mat * SoViewingMatrixElement::get(state) *
SoProjectionMatrixElement::get(state));
const SbViewportRegion & vp = SoViewportRegionElement::get(state);
SbVec2s vpsize = vp.getViewportSizePixels();
// font stuff
//float space = this->spacing.getValue();
//float fontsize = SoFontSizeElement::get(state);
SbName fontname = SoFontNameElement::get(state);
int lines = this->string.getNum();
// get left bottom corner of the label
SbVec3f nilpoint(0.0f, 0.0f, 0.0f);
projmatrix.multVecMatrix(nilpoint, nilpoint);
nilpoint[0] = (nilpoint[0] + 1.0f) * 0.5f * vpsize[0];
nilpoint[1] = (nilpoint[1] + 1.0f) * 0.5f * vpsize[1];
#if 1
// Unfortunately, the size of the label is stored in the pimpl class of
// SoText2 which cannot be accessed directly. However, there is a trick
// to get the required information: set model, viewing and projection
// matrix to the identity matrix and also view volume to some default
// values. SoText2::computeBBox() then calls SoText2P::getQuad which
// returns the sizes in form of the bounding box. These values can be
// reverse-engineered to get width and height.
state->push();
SoModelMatrixElement::set(state,this,SbMatrix::identity());
SoViewingMatrixElement::set(state,this,SbMatrix::identity());
SoProjectionMatrixElement::set(state,this,SbMatrix::identity());
SbViewVolume vv;
vv.ortho(-1,1,-1,1,-1,1);
SoViewVolumeElement::set(state,this,vv);
SbBox3f box;
SbVec3f center;
this->computeBBox(action, box, center);
state->pop();
float xmin,ymin,zmin,xmax,ymax,zmax;
box.getBounds(xmin,ymin,zmin,xmax,ymax,zmax);
SbVec3f v0(xmin,ymax,zmax);
SbVec3f v1(xmax,ymax,zmax);
SbVec3f v2(xmax,ymin,zmax);
SbVec3f v3(xmin,ymin,zmax);
vv.projectToScreen(v0,v0);
vv.projectToScreen(v1,v1);
vv.projectToScreen(v2,v2);
vv.projectToScreen(v3,v3);
float width,height;
width = (v1[0]-v0[0])*vpsize[0];
height = (v1[1]-v3[1])*vpsize[1];
switch (this->justification.getValue()) {
case SoText2::RIGHT:
nilpoint[0] -= width;
break;
case SoText2::CENTER:
nilpoint[0] -= 0.5f*width;
break;
default:
break;
}
if (lines > 1) {
nilpoint[1] -= (float(lines-1)/(float)lines*height);
}
#else
// Unfortunately, the required size (in pixels) is stored in a non-accessible way
// in the subclass SoText2. Thus, we try to get a satisfactory solution with Qt
// methods.
// The font name is of the form "family:style". If 'style' is given it can be
// 'Bold', 'Italic' or 'Bold Italic'.
QFont font;
//.........这里部分代码省略.........