本文整理汇总了C++中mhwrender::MRenderer类的典型用法代码示例。如果您正苦于以下问题:C++ MRenderer类的具体用法?C++ MRenderer怎么用?C++ MRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bindTexture
// #### updateRegistry
//
// Evaluates dirty flags and updates the effect registry if any
// attributes have changed that require the shader to be rebuilt
//
void
OpenSubdivShader::updateRegistry()
{
/* If adaptive flag has changed, update the effectRegistry accordingly */
if (_adaptiveDirty) {
g_effectRegistry.setIsAdaptive(_adaptive);
_adaptiveDirty = false;
}
MHWRender::MRenderer *theRenderer = MHWRender::MRenderer::theRenderer();
_theTextureManager = theRenderer->getTextureManager();
/* If diffuse texture has changed, update the effectRegistry accordingly */
if (_diffuseMapDirty) {
GLuint diffMapId = bindTexture( _diffuseMapFile, DIFF_TEXTURE_UNIT );
g_effectRegistry.setDiffuseId(diffMapId);
_diffuseMapDirty = false;
}
/* If shader source has changed, update the effectRegistry accordingly */
if (_shaderSourceDirty) {
if ( _shaderSource.empty() ) {
if ( g_effectRegistry.getShaderSource() != defaultShaderSource ) {
g_effectRegistry.setShaderSource(defaultShaderSource);
}
} else {
if ( g_effectRegistry.getShaderSource() != _shaderSource ) {
g_effectRegistry.setShaderSource(_shaderSource);
}
}
_shaderSourceDirty = false;
}
}
示例2: setup
//
// Update override for the current frame.
//
// Make sure we have a proper set of operations. If so then update
// shaders and light pruning information.
//
MStatus viewRenderOverrideShadows::setup(const MString& destination)
{
// Firewall checks
MHWRender::MRenderer* renderer = MHWRender::MRenderer::theRenderer();
if (!renderer) return MStatus::kFailure;
const MHWRender::MShaderManager* shaderMgr = renderer->getShaderManager();
if (!shaderMgr) return MStatus::kFailure;
// Update render operations
//
MStatus status = updateRenderOperations();
if (status != MStatus::kSuccess)
return status;
// Update shaders
status = updateShaders( shaderMgr );
if (status != MStatus::kSuccess)
return status;
// Update light list
status = updateLightList();
return status;
}
示例3: initializePlugin
MStatus initializePlugin(MObject obj)
{
MStatus status = MStatus::kSuccess;
MFnPlugin plugin(obj, PLUGIN_COMPANY, "1.0", "Any");
status = MGlobal::startErrorLogging("c:/Temp/myLog.txt");
if (!initialised)
{
Core::initClassFactorySingleton(new Maya::MayaClassFactory());
Core::startup();
dag = new Maya::DAG();
dag->createGraph();
MHWRender::MRenderer* renderer = MHWRender::MRenderer::theRenderer(false);
if (renderer)
{
rendererOverride = new Maya::RenderOverride();
status = renderer->registerOverride(rendererOverride);
}
else
{
status = MStatus::kFailure;
}
initialised = true;
}
return status;
}
示例4: uninitializePlugin
MStatus uninitializePlugin(MObject obj)
{
if (dag != NULL)
{
delete dag;
dag = NULL;
}
Core::shutdown();
MStatus status;
MFnPlugin plugin(obj);
// Degister and delete override
//
if (rendererOverride)
{
MHWRender::MRenderer* renderer = MHWRender::MRenderer::theRenderer();
if (renderer)
{
status = renderer->deregisterOverride(rendererOverride);
}
delete rendererOverride;
rendererOverride = NULL;
}
initialised = false;
return MStatus::kSuccess;
}
示例5: initializePlugin
/*!
Register an override and associated command
*/
MStatus initializePlugin( MObject obj )
{
MStatus status;
MFnPlugin plugin( obj, PLUGIN_COMPANY, "1.0", "Any");
// Create and register an override.
if (!viewRenderOverrideInstance)
{
// my_viewRenderOverride is the unique identifier string
// for this override
MHWRender::MRenderer* renderer = MHWRender::MRenderer::theRenderer(false);
if (renderer)
{
viewRenderOverrideInstance = new viewRenderOverride( "my_viewRenderOverride" );
status = renderer->registerOverride(viewRenderOverrideInstance);
}
}
if (!status)
{
status.perror("registerOverride");
}
return status;
}
示例6: MPxSurfaceShadingNodeOverride
LightMaterialOverride::LightMaterialOverride(const MObject& obj)
: MPxSurfaceShadingNodeOverride(obj)
{
MHWRender::MRenderer* theRenderer = MHWRender::MRenderer::theRenderer();
if (theRenderer)
{
MHWRender::MFragmentManager* fragmentMgr = theRenderer->getFragmentManager();
if (fragmentMgr)
{
for (uint i = 0; i < MayaTo::getWorldPtr()->shaderSearchPath.length(); i++)
fragmentMgr->addFragmentPath(MayaTo::getWorldPtr()->shaderSearchPath[i]);
MString fragment = "CoronaLight";
bool fragAdded = fragmentMgr->hasFragment(fragment);
if (!fragAdded)
{
fragAdded = (fragment == fragmentMgr->addShadeFragmentFromFile(fragment + ".xml", false));
if (fragAdded)
{
MGlobal::displayInfo(MString("Successfully loaded fragment ") + fragment + ".xml");
}
else{
MGlobal::displayInfo(MString("Could not load fragment ") + fragment + ".xml");
}
}
}
}
}
示例7:
void dx11ShaderOverride::terminateKey(MHWRender::MDrawContext& context, const MString& /*key*/)
{
if (fShaderNode) {
MHWRender::MRenderer* theRenderer = MHWRender::MRenderer::theRenderer();
if (theRenderer)
{
dx11ShaderDX11Device* dxDevice = (dx11ShaderDX11Device*)theRenderer->GPUDeviceHandle();
if (dxDevice)
{
ID3D11DeviceContext* dxContext = NULL;
dxDevice->GetImmediateContext(&dxContext);
if (dxContext)
{
fShaderNode->restoreStates(dxContext, fStates);
dxContext->VSSetShader(NULL, NULL, 0);
dxContext->PSSetShader(NULL, NULL, 0);
dxContext->GSSetShader(NULL, NULL, 0);
dxContext->HSSetShader(NULL, NULL, 0);
dxContext->DSSetShader(NULL, NULL, 0);
dxContext->Release();
}
}
}
}
}
示例8: uninitializePlugin
/*
When uninitializing the plugin, make sure to deregister the
override and then delete the instance which is being kept here.
Also remove the command used to set options on the override
*/
MStatus uninitializePlugin( MObject obj)
{
MStatus status;
MFnPlugin plugin( obj );
// Degister and delete override
//
if (viewRenderOverrideInstance)
{
MHWRender::MRenderer* renderer = MHWRender::MRenderer::theRenderer();
if (renderer)
{
status = renderer->deregisterOverride(viewRenderOverrideInstance);
}
delete viewRenderOverrideInstance;
viewRenderOverrideInstance = NULL;
}
if (!status)
{
status.perror("deregisterOverride");
}
return status;
}
示例9: 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 () ;
}
}
示例10: MPxShadingNodeOverride
CheckerNodeOverride::CheckerNodeOverride(const MObject& obj)
: MPxShadingNodeOverride(obj)
, fFragmentName("")
{
// Fragments are defined in separate XML files, add the checker node
// directory to the search path and load from the files.
static const MString sFragmentName("checkerNodePluginFragment");
static const MString sFragmentOutputName("checkerNodePluginFragmentOutput");
static const MString sFragmentGraphName("checkerNodePluginGraph");
MHWRender::MRenderer* theRenderer = MHWRender::MRenderer::theRenderer();
if (theRenderer)
{
MHWRender::MFragmentManager* fragmentMgr =
theRenderer->getFragmentManager();
if (fragmentMgr)
{
// Add search path (once only)
static bool sAdded = false;
if (!sAdded)
{
MString location;
if( ! MGlobal::executeCommand(MString("getModulePath -moduleName \"devkit\""), location, false) ) {
location = MString(getenv("MAYA_LOCATION")) + MString("/devkit");
}
location += "/plug-ins/checkerShader";
fragmentMgr->addFragmentPath(location);
sAdded = true;
}
// Add fragments if needed
bool fragAdded = fragmentMgr->hasFragment(sFragmentName);
bool structAdded = fragmentMgr->hasFragment(sFragmentOutputName);
bool graphAdded = fragmentMgr->hasFragment(sFragmentGraphName);
if (!fragAdded)
{
fragAdded = (sFragmentName == fragmentMgr->addShadeFragmentFromFile(sFragmentName + ".xml", false));
}
if (!structAdded)
{
structAdded = (sFragmentOutputName == fragmentMgr->addShadeFragmentFromFile(sFragmentOutputName + ".xml", false));
}
if (!graphAdded)
{
graphAdded = (sFragmentGraphName == fragmentMgr->addFragmentGraphFromFile(sFragmentGraphName + ".xml"));
}
// If we have them all, use the final graph for the override
if (fragAdded && structAdded && graphAdded)
{
fFragmentName = sFragmentGraphName;
}
}
}
}
示例11: 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();
}
}
示例12: setup
// Override setup and cleanup for this override
//
MStatus ViewRenderOverride::setup(const MString & destination)
{
MHWRender::MRenderer *theRenderer = MHWRender::MRenderer::theRenderer();
unsigned int width, height;
theRenderer->outputTargetSize(width, height);
MString panelName;
panelName.set(destination.asChar());
for (int i = 0; i < renderOperations.size(); i++)
{
PluginTestOperationBase* base = dynamic_cast<PluginTestOperationBase*>(renderOperations[i]);
base->panelName = panelName;
}
return MStatus::kSuccess;
}
示例13: initializePlugin
MStatus initializePlugin(MObject obj)
{
MStatus status;
MFnPlugin plugin(obj, PLUGIN_COMPANY, "1.0", "Any");
// ************************ MAYA-25818 PART 1 of 2 *************************
// Workaround for avoiding dirtying the scene until there's a way to
// register overrides without causing dirty.
bool sceneDirty = true; // assume true since that's the safest
try
{
// is the scene currently dirty?
MCommandResult sceneDirtyResult(&status);
if (status != MStatus::kSuccess) throw std::exception();
status = MGlobal::executeCommand("file -query -modified", sceneDirtyResult);
if (status != MStatus::kSuccess) throw std::exception();
int commandResult;
status = sceneDirtyResult.getResult(commandResult);
if (status != MStatus::kSuccess) throw std::exception();
sceneDirty = commandResult != 0;
}
catch (std::exception&)
{
// if we got here, assume the scene is dirty
sceneDirty = true;
}
// ************************ MAYA-25818 PART 1 of 2 *********************
MHWRender::MRenderer* renderer = MHWRender::MRenderer::theRenderer();
if (renderer)
{
if (!viewImageBlitOverride::RenderOverride::sViewImageBlitOverrideInstance)
{
viewImageBlitOverride::RenderOverride::sViewImageBlitOverrideInstance = new viewImageBlitOverride::RenderOverride("my_viewImageBlitOverride");
renderer->registerOverride(viewImageBlitOverride::RenderOverride::sViewImageBlitOverrideInstance);
}
}
// ************************ MAYA-25818 PART 2 of 2 *************************
// If the scene was previously unmodified, return it to that state since
// we haven't done anything that needs to be saved.
if (sceneDirty == false)
{
MGlobal::executeCommand("file -modified 0");
}
// ************************ END MAYA-25818 PART 2 of 2 *********************
return status;
}
示例14:
// Background color override. We get the current colors from the
// renderer and use them
//
MHWRender::MClearOperation &
simpleViewRenderSceneRender::clearOperation()
{
MHWRender::MRenderer* renderer = MHWRender::MRenderer::theRenderer();
bool gradient = renderer->useGradient();
MColor color1 = renderer->clearColor();
MColor color2 = renderer->clearColor2();
float c1[4] = { color1[0], color1[1], color1[2], 1.0f };
float c2[4] = { color2[0], color2[1], color2[2], 1.0f };
mClearOperation.setClearColor( c1 );
mClearOperation.setClearColor2( c2 );
mClearOperation.setClearGradient( gradient);
return mClearOperation;
}
示例15: initializePlugin
MStatus initializePlugin(MObject obj)
{
MStatus status;
MFnPlugin plugin(obj, PLUGIN_COMPANY, "1.0", "Any");
MHWRender::MRenderer* renderer = MHWRender::MRenderer::theRenderer();
if (renderer)
{
if (!viewRenderOverrideShadowsInstance)
{
viewRenderOverrideShadowsInstance = new viewRenderOverrideShadows("my_viewRenderOverrideShadows");
renderer->registerOverride(viewRenderOverrideShadowsInstance);
}
}
return status;
}