本文整理汇总了C++中SbViewVolume::getMatrices方法的典型用法代码示例。如果您正苦于以下问题:C++ SbViewVolume::getMatrices方法的具体用法?C++ SbViewVolume::getMatrices怎么用?C++ SbViewVolume::getMatrices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SbViewVolume
的用法示例。
在下文中一共展示了SbViewVolume::getMatrices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
SoXipMarkerSet::GLRender( SoGLRenderAction* action )
{
if (mCoord && mFaceSet && mScale && mTranslation && mRotation)
{
float pointSize = SoPointSizeElement::get(action->getState());
SbViewportRegion vp = SoViewportRegionElement::get(action->getState());
SbViewVolume vVol = SoViewVolumeElement::get(action->getState());
// world to pixel scale
float scaleFactorY = pointSize * vVol.getHeight() / (float) vp.getViewportSizePixels()[1];
float scaleFactorX = pointSize * vVol.getWidth() / (float) vp.getViewportSizePixels()[0];
mScale->scaleFactor.setValue(0.5f * scaleFactorX, 0.5f * scaleFactorY, 1);
// world to screen rotation
SbMatrix affine, proj;
vVol.getMatrices(affine, proj);
SbVec3f t, s;
SbRotation rot, so;
affine.inverse().getTransform(t, rot, s, so);
mRotation->rotation.setValue(rot);
// number of coordinates
const SoCoordinateElement *ce = (const SoCoordinateElement *) SoCoordinateElement::getInstance(action->getState());
int numPts = 0;
if (ce)
{
numPts = ce->getNum();
}
SbXipMarkerShapes::getVertices(marker.getValue(), mCoord->point);
SbXipMarkerShapes::getNumVertices(marker.getValue(), mFaceSet->numVertices);
for (int i = 0; i < numPts; i++)
{
mTranslation->translation.setValue(ce->get3(i));
action->getState()->push();
action->traverse(mTranslation);
action->traverse(mRotation);
action->traverse(mScale);
action->traverse(mCoord);
action->traverse(mFaceSet);
action->getState()->pop();
}
}
}
示例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();
}
}