当前位置: 首页>>代码示例>>C++>>正文


C++ MDrawRequest::displayStyle方法代码示例

本文整理汇总了C++中MDrawRequest::displayStyle方法的典型用法代码示例。如果您正苦于以下问题:C++ MDrawRequest::displayStyle方法的具体用法?C++ MDrawRequest::displayStyle怎么用?C++ MDrawRequest::displayStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MDrawRequest的用法示例。


在下文中一共展示了MDrawRequest::displayStyle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cleanupLights

// Currently, Maya leaves lights in GL when you reduce the number of active lights in 
// your scene. It fills the GL light space from 0 with the visible lights, so, we simply 
// need to reset the potentially 'old' state of lights after the last one we know to be 
// visible. We'll put it all back as we found it though. For the moment, this assumes 
// Maya is filling GL consecutively, if they stop doing that, we'll need to get the 
// actual light indexes from the view. Its just a bit quicker to assume this, whilst we can.
bool ProceduralHolderUI::cleanupLights( const MDrawRequest &request, M3dView &view, LightingState *s ) const
{
		
	if( !(request.displayStyle()==M3dView::kFlatShaded || request.displayStyle()==M3dView::kGouraudShaded) )
	{
		return false;
	}
	
	M3dView::LightingMode mode;
	view.getLightingMode(mode);
	
	if (mode == M3dView::kLightDefault)
	{
		s->numMayaLights = 1;
	}
	else
	{
		view.getLightCount( s->numMayaLights );
	}
	
	int sGlMaxLights = 0;
	glGetIntegerv( GL_MAX_LIGHTS, &sGlMaxLights );
	s->numGlLights = sGlMaxLights;	

	if( s->numMayaLights >= s->numGlLights || s->numGlLights == 0 )
	{
		return false;
	}		
	
	unsigned int vectorSize = s->numGlLights - s->numMayaLights;
	
	s->diffuses.resize( vectorSize );
	s->specs.resize( vectorSize );
	s->ambients.resize( vectorSize );

	static float s_defaultColor[] = { 0.0, 0.0, 0.0, 1.0 };
	
	GLenum light;
	unsigned int j = 0;
	
	for( unsigned int i = s->numMayaLights; i < s->numGlLights; i++ )
	{		
		light = GL_LIGHT0 + i;
		
		glGetLightfv( light, GL_DIFFUSE, s->diffuses[j].getValue() );
		glLightfv( light, GL_DIFFUSE, s_defaultColor );
			
		glGetLightfv( light, GL_SPECULAR, s->specs[j].getValue() );
		glLightfv( light, GL_SPECULAR, s_defaultColor );
			
		glGetLightfv( light, GL_AMBIENT, s->ambients[j].getValue() );
		glLightfv( light, GL_AMBIENT, s_defaultColor );
		
		j++;
	}
	
	return true;
}
开发者ID:TRiGGER80,项目名称:cortex,代码行数:64,代码来源:ProceduralHolderUI.cpp

示例2: 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();
}
开发者ID:ImageEngine,项目名称:cortex,代码行数:50,代码来源:DrawableHolderUI.cpp

示例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();
}
开发者ID:TRiGGER80,项目名称:cortex,代码行数:78,代码来源:ProceduralHolderUI.cpp

示例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();
}
开发者ID:RotorStudios,项目名称:cortex,代码行数:89,代码来源:SceneShapeUI.cpp


注:本文中的MDrawRequest::displayStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。