本文整理汇总了C++中MDrawRequest::drawData方法的典型用法代码示例。如果您正苦于以下问题:C++ MDrawRequest::drawData方法的具体用法?C++ MDrawRequest::drawData怎么用?C++ MDrawRequest::drawData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDrawRequest
的用法示例。
在下文中一共展示了MDrawRequest::drawData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void DrawableHolderUI::draw( const MDrawRequest &request, M3dView &view ) const
{
MDrawData drawData = request.drawData();
DrawableHolder *drawableHolder = (DrawableHolder *)drawData.geometry();
assert( drawableHolder );
IECoreGL::ConstScenePtr s = drawableHolder->scene();
if( !s )
{
return;
}
view.beginGL();
// maya can sometimes leave an error from it's own code,
// and we don't want that to confuse us in our drawing code.
while( glGetError()!=GL_NO_ERROR )
{
}
// if we're being drawn as part of a selection operation we need
// to make sure there's a name on the name stack, as the IECoreGL::NameStateComponent
// expects to be able to load a name into it (it fails with an invalid operation if
// there's no name slot to load into).
if( view.selectMode() )
{
view.pushName( 0 );
}
try
{
// do the main render
s->render( m_displayStyle.baseState( request.displayStyle() ) );
// do a wireframe render over the top if we're selected and we just did a solid
// draw.
bool selected = request.displayStatus()==M3dView::kActive || request.displayStatus()==M3dView::kLead;
bool solid = request.displayStyle()==M3dView::kFlatShaded || request.displayStyle()==M3dView::kGouraudShaded;
if( selected && solid )
{
s->render( m_displayStyle.baseState( M3dView::kWireFrame ) );
}
}
catch( std::exception &e )
{
IECore::msg( IECore::Msg::Error, "DrawableHolderUI::draw", e.what() );
}
view.endGL();
}
示例2: viewMat
void
UsdMayaGLBatchRenderer::Draw(
const MDrawRequest& request,
M3dView &view )
{
// VP 1.0 Implementation
//
MDrawData drawData = request.drawData();
_BatchDrawUserData* batchData =
static_cast<_BatchDrawUserData*>(drawData.geometry());
if( !batchData )
return;
MMatrix projectionMat;
view.projectionMatrix(projectionMat);
MMatrix modelViewMat;
view.modelViewMatrix(modelViewMat);
if( batchData->_bounds )
{
px_vp20Utils::RenderBoundingBox(*(batchData->_bounds),
*(batchData->_wireframeColor),
modelViewMat,
projectionMat);
}
if( batchData->_drawShape && !_renderQueue.empty() )
{
MMatrix viewMat( request.matrix().inverse() * modelViewMat );
unsigned int viewX, viewY, viewWidth, viewHeight;
view.viewport(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( NULL, viewMat, projectionMat, viewport );
}
// Clean up the _BatchDrawUserData!
delete batchData;
}
示例3: draw
void ProceduralHolderUI::draw( const MDrawRequest &request, M3dView &view ) const
{
MStatus s;
MDrawData drawData = request.drawData();
ProceduralHolder *proceduralHolder = (ProceduralHolder *)drawData.geometry();
assert( proceduralHolder );
view.beginGL();
LightingState lightingState;
bool restoreLightState = cleanupLights( request, view, &lightingState );
// maya can sometimes leave an error from it's own code,
// and we don't want that to confuse us in our drawing code.
while( glGetError()!=GL_NO_ERROR )
{
}
try
{
// draw the bound if asked
if( request.token()==BoundDrawMode )
{
IECoreGL::BoxPrimitive::renderWireframe( IECore::convert<Imath::Box3f>( proceduralHolder->boundingBox() ) );
}
// draw the scene if asked
if( request.token()==SceneDrawMode )
{
resetHilites();
IECoreGL::ConstScenePtr scene = proceduralHolder->scene();
if( scene )
{
IECoreGL::State *displayState = m_displayStyle.baseState( (M3dView::DisplayStyle)request.displayStyle() );
if ( request.component() != MObject::kNullObj )
{
MDoubleArray col;
s = MGlobal::executeCommand( "colorIndex -q 21", col );
assert( s );
IECoreGL::WireframeColorStateComponentPtr hilite = new IECoreGL::WireframeColorStateComponent( Imath::Color4f( col[0], col[1], col[2], 1.0f ) );
MFnSingleIndexedComponent fnComp( request.component(), &s );
assert( s );
int len = fnComp.elementCount( &s );
assert( s );
for ( int j = 0; j < len; j++ )
{
int compId = fnComp.element(j);
assert( proceduralHolder->m_componentToGroupMap.find( compId ) != proceduralHolder->m_componentToGroupMap.end() );
hiliteGroups(
proceduralHolder->m_componentToGroupMap[compId],
hilite,
const_cast<IECoreGL::WireframeColorStateComponent *>( displayState->get< IECoreGL::WireframeColorStateComponent >() )
);
}
}
scene->render( displayState );
}
}
}
catch( const IECoreGL::Exception &e )
{
// much better to catch and report this than to let the application die
IECore::msg( IECore::Msg::Error, "ProceduralHolderUI::draw", boost::format( "IECoreGL Exception : %s" ) % e.what() );
}
if( restoreLightState )
{
restoreLights( &lightingState );
}
view.endGL();
}
示例4: diffuse
/* virtual */
MStatus pnTriangles::bind(const MDrawRequest& request, M3dView& view)
//
// Description:
// This bind demonstrates the usage of internal material
// and texture properties. This shader must be connected
// to the "hardwareShader" attribute of a lambert derived
// shader.
//
{
// Setup the view
view.beginGL();
glPushAttrib( GL_ALL_ATTRIB_BITS );
glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
MColor diffuse(1.0F, 1.0F, 0.0F, 1.0F);
MColor specular(1.0F, 1.0F, 1.0F, 1.0F);
MColor emission(0.0F, 0.0F, 0.0F, 1.0F);
MColor ambient(0.2F, 0.2F, 0.2F, 1.0F);
// Get the diffuse and specular colors
//
float shininess;
bool hasTransparency = false;
MMaterial material = request.material();
fInTexturedMode = material.materialIsTextured();
// Setting this to true will get the default "green" material back
// since it will try and evaluate this shader, which internally
// Maya does not understand -> thus giving the "green" material back
bool useInternalMaterialSetting = false;
if (!useInternalMaterialSetting)
{
material.getEmission( emission );
material.getSpecular( specular );
shininess = 13.0;
}
material.getHasTransparency( hasTransparency );
if (!fInTexturedMode)
{
if (!fTestVertexProgram && !useInternalMaterialSetting)
material.getDiffuse( diffuse );
}
// In textured mode. Diffuse material is always white
// for texture blends
else
{
if (!useInternalMaterialSetting)
diffuse.r = diffuse.g = diffuse.b = diffuse.a = 1.0;
}
// Use a vertex program to set up shading
//
if (fTestVertexProgram)
{
bindVertexProgram(diffuse, specular, emission, ambient);
}
else if (fTestFragmentProgram)
{
bindFragmentProgram();
}
// Don't use a vertex program to set up shading
//
else
{
// Set up the material state
//
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT);
glColor4fv(&ambient.r);
if (fInTexturedMode)
{
glEnable( GL_TEXTURE_2D );
MDrawData drawData = request.drawData();
material.applyTexture( view, drawData );
float scaleS, scaleT, translateS, translateT, rotate;
material.getTextureTransformation(scaleS, scaleT, translateS,
translateT, rotate);
rotate = DEG_TO_RAD(-rotate);
float c = cosf(rotate);
float s = sinf(rotate);
translateS += ((c+s)/2.0F);
translateT += ((c-s)/2.0F);
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity();
if(scaleS != 1.0f || scaleT != 1.0f)
glScalef(1.0f/scaleS, 1.0f/scaleT, 1.0f);
if(translateS != 0.0f || translateT != 0.0f)
glTranslatef(0.5f-translateS, 0.5f-translateT, 0.0f);
//.........这里部分代码省略.........
示例5: drawVertices
void apiSimpleShapeUI::drawVertices( const MDrawRequest & request,
M3dView & view ) const
//
// Description:
//
// Component (vertex) drawing routine
//
// Arguments:
//
// request - request to be drawn
// view - view to draw into
//
{
MDrawData data = request.drawData();
MVectorArray * geom = (MVectorArray*)data.geometry();
view.beginGL();
// Query current state so it can be restored
//
bool lightingWasOn = glIsEnabled( GL_LIGHTING ) ? true : false;
if ( lightingWasOn ) {
glDisable( GL_LIGHTING );
}
float lastPointSize;
glGetFloatv( GL_POINT_SIZE, &lastPointSize );
// Set the point size of the vertices
//
glPointSize( POINT_SIZE );
// If there is a component specified by the draw request
// then loop over comp (using an MFnComponent class) and draw the
// active vertices, otherwise draw all vertices.
//
MObject comp = request.component();
if ( ! comp.isNull() ) {
MFnSingleIndexedComponent fnComponent( comp );
for ( int i=0; i<fnComponent.elementCount(); i++ )
{
int index = fnComponent.element( i );
glBegin( GL_POINTS );
MVector& point = (*geom)[index];
glVertex3f( (float)point[0],
(float)point[1],
(float)point[2] );
glEnd();
char annotation[32];
sprintf( annotation, "%d", index );
view.drawText( annotation, point );
}
}
else {
for ( unsigned int i=0; i<geom->length(); i++ )
{
glBegin( GL_POINTS );
MVector point = (*geom)[ i ];
glVertex3f( (float)point[0], (float)point[1], (float)point[2] );
glEnd();
}
}
// Restore the state
//
if ( lightingWasOn ) {
glEnable( GL_LIGHTING );
}
glPointSize( lastPointSize );
view.endGL();
}
示例6: draw
void SceneShapeUI::draw( const MDrawRequest &request, M3dView &view ) const
{
MStatus s;
MDrawData drawData = request.drawData();
SceneShape *sceneShape = (SceneShape *)drawData.geometry();
assert( sceneShape );
view.beginGL();
M3dView::LightingMode lightingMode;
view.getLightingMode( lightingMode );
LightingState lightingState;
bool restoreLightState = cleanupLights( request, view, &lightingState );
// maya can sometimes leave an error from it's own code,
// and we don't want that to confuse us in our drawing code.
while( glGetError()!=GL_NO_ERROR )
{
}
try
{
// draw the bound if asked
if( request.token()==BoundDrawMode )
{
IECoreGL::BoxPrimitive::renderWireframe( IECore::convert<Imath::Box3f>( sceneShape->boundingBox() ) );
}
// draw the scene if asked
if( request.token()==SceneDrawMode )
{
resetHilites();
IECoreGL::ConstScenePtr scene = sceneShape->glScene();
if( scene )
{
IECoreGL::State *displayState = m_displayStyle.baseState( (M3dView::DisplayStyle)request.displayStyle(), lightingMode );
if ( request.component() != MObject::kNullObj )
{
MDoubleArray col;
s = MGlobal::executeCommand( "colorIndex -q 21", col );
assert( s );
IECoreGL::WireframeColorStateComponentPtr hilite = new IECoreGL::WireframeColorStateComponent( Imath::Color4f( col[0], col[1], col[2], 1.0f ) );
MFnSingleIndexedComponent fnComp( request.component(), &s );
assert( s );
int len = fnComp.elementCount( &s );
assert( s );
std::vector<IECore::InternedString> groupNames;
for ( int j = 0; j < len; j++ )
{
int index = fnComp.element(j);
groupNames.push_back( sceneShape->selectionName( index ) );
}
// Sort by name to make sure we don't unhilite selected items that are further down the hierarchy
std::sort( groupNames.begin(), groupNames.end() );
for ( std::vector<IECore::InternedString>::iterator it = groupNames.begin(); it!= groupNames.end(); ++it)
{
IECoreGL::GroupPtr group = sceneShape->glGroup( *it );
hiliteGroups(
group,
hilite,
const_cast<IECoreGL::WireframeColorStateComponent *>( displayState->get< IECoreGL::WireframeColorStateComponent >() )
);
}
}
scene->render( displayState );
}
}
}
catch( const IECoreGL::Exception &e )
{
// much better to catch and report this than to let the application die
IECore::msg( IECore::Msg::Error, "SceneShapeUI::draw", boost::format( "IECoreGL Exception : %s" ) % e.what() );
}
if( restoreLightState )
{
restoreLights( &lightingState );
}
view.endGL();
}