本文整理汇总了C++中mhwrender::MRenderer::drawAPIIsOpenGL方法的典型用法代码示例。如果您正苦于以下问题:C++ MRenderer::drawAPIIsOpenGL方法的具体用法?C++ MRenderer::drawAPIIsOpenGL怎么用?C++ MRenderer::drawAPIIsOpenGL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mhwrender::MRenderer
的用法示例。
在下文中一共展示了MRenderer::drawAPIIsOpenGL方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void ovalLocatorDrawOverride::draw (const MHWRender::MDrawContext &context, const MUserData *data) {
MPointArray vertices =ovalLocator::vertices () ;
// get cached data
float color [3] ={ 0.0f, 1.0f, 0.0f } ;
float multiplier =1.0f ;
const ovalLocatorData *ovalData =dynamic_cast<const ovalLocatorData *>(data) ;
if ( ovalData )
multiplier =ovalData->multiplier ;
// get state data
MStatus status ;
const MMatrix transform =context.getMatrix (MHWRender::MDrawContext::kWorldViewMtx, &status) ;
if ( status !=MStatus::kSuccess )
return ;
const MMatrix projection =context.getMatrix (MHWRender::MDrawContext::kProjectionMtx, &status) ;
if ( status !=MStatus::kSuccess )
return ;
const int displayStyle =context.getDisplayStyle () ;
// get renderer
MHWRender::MRenderer *theRenderer =MHWRender::MRenderer::theRenderer () ;
if ( !theRenderer )
return ;
// GL Draw
if ( theRenderer->drawAPIIsOpenGL () ) {
// set colour
glColor3fv (color) ;
// set world matrix
glMatrixMode (GL_MODELVIEW) ;
glPushMatrix () ;
glLoadMatrixd (transform.matrix [0]) ;
// set projection matrix
glMatrixMode (GL_PROJECTION) ;
glPushMatrix () ;
glLoadMatrixd (projection.matrix [0]) ;
if ( displayStyle & MHWRender::MDrawContext::kGouraudShaded ) {
// See myShadedDraw
glPushAttrib (GL_CURRENT_BIT) ;
glBegin (GL_TRIANGLE_FAN) ;
glVertex3f (0, 0, 0) ;
for ( int i =0 ; i < vertices.length () ; ++i )
glVertex3f (vertices [i].x * multiplier, vertices [i].y * multiplier, vertices [i].z * multiplier) ;
glEnd () ;
glPopAttrib () ;
}
if ( displayStyle & MHWRender::MDrawContext::kWireFrame ) {
// See myWireFrameDraw
glBegin (GL_LINES) ;
for ( int i =0 ; i < vertices.length () - 1 ; ++i ) {
glVertex3f (vertices [i].x * multiplier, vertices [i].y * multiplier, vertices [i].z * multiplier) ;
glVertex3f (vertices [i + 1].x * multiplier, vertices [i + 1].y * multiplier, vertices [i + 1].z * multiplier) ;
}
glEnd () ;
}
glPopMatrix () ;
glMatrixMode (GL_MODELVIEW) ;
glPopMatrix () ;
}
}
示例2: draw
void arrowLocatorOverride::draw(
const MHWRender::MDrawContext& context,
const MUserData* data)
{
MAngle rotationAngle;
float color [3] ={ 0.0f, 1.0f, 0.0f } ;
// data
MStatus status;
MHWRender::MStateManager* stateMgr = context.getStateManager();
const arrowLocatorData* locatorData =
dynamic_cast<const arrowLocatorData*>(data);
if (!stateMgr || !locatorData) return;
if ( locatorData )
rotationAngle = locatorData->rotateAngle;
// matrices
const MMatrix transform =
context.getMatrix(MHWRender::MFrameContext::kWorldViewMtx, &status);
if (status != MStatus::kSuccess) return;
const MMatrix projection =
context.getMatrix(MHWRender::MFrameContext::kProjectionMtx, &status);
if (status != MStatus::kSuccess) return;
// get renderer
MHWRender::MRenderer *theRenderer =MHWRender::MRenderer::theRenderer () ;
if ( !theRenderer )
return ;
if ( theRenderer->drawAPIIsOpenGL () ) {
glPushAttrib(GL_CURRENT_BIT);
glColor4fv(color);
glPushMatrix();
glRotated(-rotationAngle.asDegrees(), 0.0, 1.0, 0.0);
glBegin( GL_LINE_STRIP);
glVertex3f(arrow[0][0],arrow[0][1],arrow[0][2]);
glVertex3f(arrow[1][0],arrow[1][1],arrow[1][2]);
glVertex3f(arrow[2][0],arrow[2][1],arrow[2][2]);
glEnd();
glBegin( GL_LINE_STRIP );
glVertex3f(arrow[2][0],arrow[2][1],arrow[2][2]);
glVertex3f(arrow[3][0],arrow[3][1],arrow[3][2]);
glVertex3f(arrow[0][0],arrow[0][1],arrow[0][2]);
glEnd();
glPopMatrix();
}
}
示例3: viewport
void
UsdMayaGLBatchRenderer::Draw(
const MHWRender::MDrawContext& context,
const MUserData *userData)
{
// VP 2.0 Implementation
//
MHWRender::MRenderer* theRenderer = MHWRender::MRenderer::theRenderer();
if( !theRenderer || !theRenderer->drawAPIIsOpenGL() )
return;
const _BatchDrawUserData* batchData = static_cast<const _BatchDrawUserData*>(userData);
if( !batchData )
return;
MStatus status;
MMatrix projectionMat = context.getMatrix(MHWRender::MDrawContext::kProjectionMtx, &status);
if( batchData->_bounds )
{
MMatrix worldViewMat = context.getMatrix(MHWRender::MDrawContext::kWorldViewMtx, &status);
px_vp20Utils::RenderBoundingBox(*(batchData->_bounds),
*(batchData->_wireframeColor),
worldViewMat,
projectionMat);
}
if( batchData->_drawShape && !_renderQueue.empty() )
{
MMatrix viewMat = context.getMatrix(MHWRender::MDrawContext::kViewMtx, &status);
// Extract camera settings from maya view
int viewX, viewY, viewWidth, viewHeight;
context.getViewportDimensions(viewX, viewY, viewWidth, viewHeight);
GfVec4d viewport(viewX, viewY, viewWidth, viewHeight);
// Only the first call to this will do anything... After that the batch
// queue is cleared.
//
_RenderBatches( &context, viewMat, projectionMat, viewport );
}
}
示例4: modelViewMatrix
void UsdMayaGLHdRenderer::RenderVp2(
const RequestDataArray &requests,
const MHWRender::MDrawContext& context,
UsdImagingGLRenderParams params) const
{
using namespace MHWRender;
MStatus status;
MHWRender::MRenderer* theRenderer = MHWRender::MRenderer::theRenderer();
if (!theRenderer) return;
MHWRender::MStateManager* stateMgr = context.getStateManager();
if (!stateMgr) return;
const int displayStyle = context.getDisplayStyle();
if (displayStyle == 0) return;
if (displayStyle & MDrawContext::kXray) {
// Viewport 2.0 will call draw() twice when drawing transparent objects
// (X-Ray mode). We skip the first draw() call.
const MRasterizerState* rasterState = stateMgr->getRasterizerState();
if (rasterState && rasterState->desc().cullMode == MRasterizerState::kCullFront) {
return;
}
}
if (!theRenderer->drawAPIIsOpenGL()) return;
glPushAttrib(GL_CURRENT_BIT | GL_LIGHTING_BIT);
const MMatrix worldView =
context.getMatrix(MHWRender::MDrawContext::kWorldViewMtx, &status);
GfMatrix4d modelViewMatrix(worldView.matrix);
const MMatrix projection =
context.getMatrix(MHWRender::MDrawContext::kProjectionMtx, &status);
GfMatrix4d projectionMatrix(projection.matrix);
// get root matrix
MMatrix root = context.getMatrix(MHWRender::MDrawContext::kWorldMtx, &status);
GfMatrix4d rootMatrix(root.matrix);
// Extract camera settings from maya view
int viewX, viewY, viewWidth, viewHeight;
context.getViewportDimensions(viewX, viewY, viewWidth, viewHeight);
GfVec4d viewport(viewX, viewY, viewWidth, viewHeight);
M3dView::DisplayStyle viewDisplayStyle = displayStyle & MDrawContext::kWireFrame ?
M3dView::kWireFrame : M3dView::kGouraudShaded;
if(viewDisplayStyle == M3dView::kGouraudShaded)
{
px_vp20Utils::setupLightingGL(context);
glEnable(GL_LIGHTING);
}
_renderer->SetCameraState(modelViewMatrix, projectionMatrix, viewport);
_renderer->SetLightingStateFromOpenGL();
TF_FOR_ALL(it, requests) {
RequestData request = *it;
if(viewDisplayStyle == M3dView::kWireFrame && request.drawRequest.displayStyle() == M3dView::kGouraudShaded) {
request.drawRequest.setDisplayStyle(viewDisplayStyle);
}
switch(request.drawRequest.token()) {
case UsdMayaGLHdRenderer::DRAW_WIREFRAME:
case UsdMayaGLHdRenderer::DRAW_POINTS: {
params.drawMode = request.drawRequest.token() ==
UsdMayaGLHdRenderer::DRAW_WIREFRAME ?
UsdImagingGLDrawMode::DRAW_WIREFRAME :
UsdImagingGLDrawMode::DRAW_POINTS;
params.enableLighting = false;
params.cullStyle = UsdImagingGLCullStyle::CULL_STYLE_NOTHING;
params.overrideColor = request.fWireframeColor;
// Get and render usdPrim
_renderer->Render(_renderedPrim, params);
break;
}
case UsdMayaGLHdRenderer::DRAW_SHADED_FLAT:
case UsdMayaGLHdRenderer::DRAW_SHADED_SMOOTH: {
params.drawMode = ((request.drawRequest.token() ==
UsdMayaGLHdRenderer::DRAW_SHADED_FLAT) ?
UsdImagingGLDrawMode::DRAW_GEOM_FLAT :
UsdImagingGLDrawMode::DRAW_GEOM_SMOOTH);
params.enableLighting = true;
params.cullStyle =
UsdImagingGLCullStyle::CULL_STYLE_BACK_UNLESS_DOUBLE_SIDED;
_renderer->Render(_renderedPrim, params);
//.........这里部分代码省略.........