本文整理汇总了C++中MDrawRequest::token方法的典型用法代码示例。如果您正苦于以下问题:C++ MDrawRequest::token方法的具体用法?C++ MDrawRequest::token怎么用?C++ MDrawRequest::token使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDrawRequest
的用法示例。
在下文中一共展示了MDrawRequest::token方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
/* override */
void apiSimpleShapeUI::draw( const MDrawRequest & request, M3dView & view ) const
//
// Description:
//
// Main (OpenGL) draw routine
//
// Arguments:
//
// request - request to be drawn
// view - view to draw into
//
{
// Get the token from the draw request.
// The token specifies what needs to be drawn.
//
int token = request.token();
switch( token )
{
case kDrawWireframe :
case kDrawWireframeOnShaded :
case kDrawVertices :
drawVertices( request, view );
break;
case kDrawSmoothShaded :
break; // Not implemented, left as exercise
case kDrawFlatShaded : // Not implemented, left as exercise
break;
}
}
示例2: draw
void BaseShapeUI::draw( const MDrawRequest & request, M3dView & view ) const {
if (s_drawData.failure)
return;
MStatus status;
view.beginGL();
if (!s_drawData.initialized)
initializeDraw();
BaseShape *shape = (BaseShape *) surfaceShape();
Model::Base base(MFnDagNode(shape->thisMObject()).parent(0, &status));
if (!status) {
status.perror("MFnDagNode::parent");
return;
}
//MDagPath path = request.multiPath();
MMaterial material = request.material();
MColor color, borderColor;
if (!(status = material.getDiffuse(color))) {
status.perror("MMaterial::getDiffuse");
return;
}
bool wireframe = (M3dView::DisplayStyle) request.token() == M3dView::kWireFrame;
if (wireframe) {
glPushAttrib(GL_POLYGON_BIT);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
glUseProgram(s_drawData.program);
switch (request.displayStatus())
{
case M3dView::kLead :
borderColor = view.colorAtIndex( LEAD_COLOR);
//glUniform1f(s_drawData.border_uniform, 1.0f);
s_drawData.updateBorderUniform(1.0f);
//glUniform3f(s_drawData.borderColor_uniform, borderColor.r, borderColor.g, borderColor.b);
s_drawData.updateBorderColorUniform(borderColor.r, borderColor.g, borderColor.b);
break;
case M3dView::kActive :
borderColor = view.colorAtIndex( ACTIVE_COLOR);
//glUniform1f(s_drawData.border_uniform, 1.0f);
s_drawData.updateBorderUniform(1.0f);
//glUniform3f(s_drawData.borderColor_uniform, borderColor.r, borderColor.g, borderColor.b);
s_drawData.updateBorderColorUniform(borderColor.r, borderColor.g, borderColor.b);
break;
case M3dView::kActiveAffected :
borderColor = view.colorAtIndex( ACTIVE_AFFECTED_COLOR);
//glUniform1f(s_drawData.border_uniform, 0.0f);
s_drawData.updateBorderUniform(0.0f);
break;
case M3dView::kDormant :
borderColor = view.colorAtIndex( DORMANT_COLOR, M3dView::kDormantColors);
//glUniform1f(s_drawData.border_uniform, 0.0f);
s_drawData.updateBorderUniform(0.0f);
break;
case M3dView::kHilite :
borderColor = view.colorAtIndex( HILITE_COLOR);
//glUniform1f(s_drawData.border_uniform, 1.0f);
s_drawData.updateBorderUniform(1.0f);
//glUniform3f(s_drawData.borderColor_uniform, borderColor.r, borderColor.g, borderColor.b);
s_drawData.updateBorderColorUniform(borderColor.r, borderColor.g, borderColor.b);
break;
}
//glUniform3f(s_drawData.color_uniform, color.r, color.g, color.b);
s_drawData.updateColorUniform(color.r, color.g, color.b);
glCallList(s_drawData.display_list);
if (wireframe)
glPopAttrib();
view.endGL();
}
示例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: 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();
}