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


C++ MaterialManager::getByName方法代码示例

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


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

示例1: enter

void RenderState::enter()
{
        OgreFramework* framework = OgreFramework::getSingletonPtr();
        
        framework->_viewport->setVisibilityMask(RF_MAIN);
        //framework->_log->logMessage("Entering RenderState...");

        _sceneMgr = framework->_root->createSceneManager(ST_GENERIC, "RenderSceneMgr");
        _sceneMgr->setAmbientLight(Ogre::ColourValue(0.7f, 0.7f, 0.7f));

        _sceneMgr->addRenderQueueListener(framework->_overlaySystem);

        /////////////////// Setup Ray queries (unused)
        _rsq = _sceneMgr->createRayQuery(Ray());
        _rsq->setQueryMask(OGRE_HEAD_MASK);

        ////////////////// Setup Camera
        _camera = _sceneMgr->createCamera("GameCamera");
        _camera->setPosition(Vector3(5, 60, 60));
        _camera->lookAt(Vector3(5, 20, 0));
        _camera->setNearClipDistance(5);

        Real vpWidth  = Real(framework->_viewport->getActualWidth());
        Real vpHeight = Real(framework->_viewport->getActualHeight());
        _camera->setAspectRatio(vpWidth / vpHeight);

        framework->_viewport->setCamera(_camera);
        _currentObject = 0;

        ////////////////// Setup GUI
        buildGUI();

        ////////////////// Setup Scene
        createScene();

        ////////////////// Create render textures
        // PixelFormat format = PF_A8B8G8R8;
        PixelFormat format = PF_FLOAT16_RGBA;
        float rtWidth = vpWidth;
        float rtHeight = vpHeight;
        if (rayPositions.create("rayPos", rtWidth, rtHeight, format, _camera, _sceneMgr)) {
                std::cout << "Error creating ray positions texture\n";
        }

        if (rayDirections.create("rayDir", rtWidth, rtHeight, format, _camera, _sceneMgr)) {
                std::cout << "Error creating ray directions texture\n";
        }

        rayPositions.setupThumbnail(0.74, 0.99, -0.74, -0.99);
        rayPositions.showThumbnail();

        rayDirections.setupThumbnail(0.45, 0.7, -0.74, -0.99);
        rayDirections.showThumbnail();

        ////////////////// Setup parameters for ray materials
        MaterialManager* matMgr = MaterialManager::getSingletonPtr();
        MaterialPtr rayDirMat = matMgr->getByName("BoundingCubesDirections");
        GpuProgramParametersSharedPtr fragParameters;
        fragParameters = 
                rayDirMat->getTechnique(0)->getPass(0)->getFragmentProgramParameters();

        float rt_width_inv = 1.0 / rtWidth;
        float rt_height_inv = 1.0 / rtHeight;
        try {
                fragParameters->setNamedConstant("width_inv", rt_width_inv);
                fragParameters->setNamedConstant("height_inv", rt_height_inv);
        } 
        catch (Exception e) {}

        float width_inv = 1.0 / vpWidth;
        float height_inv = 1.0 / vpHeight;
        fragParameters = 
                breadMat->getTechnique(0)->getPass(0)->getFragmentProgramParameters();
        try {
                fragParameters->setNamedConstant("width_inv", width_inv);
                fragParameters->setNamedConstant("height_inv", height_inv);
        } 
        catch (Exception e) {}

        ////////////////// Setup shadow params
        _sceneMgr->setShadowFarDistance(100);
        _sceneMgr->setShadowTextureCount(2);
        _sceneMgr->setShadowTextureSelfShadow(true);
        _sceneMgr->setShadowCasterRenderBackFaces(false);
        _sceneMgr->setShadowTextureCasterMaterial("DepthShadowmap/Caster/Bread");
        _sceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED);
        _sceneMgr->setShadowTextureConfig( 0, 2048, 2048, PF_FLOAT32_R );

        tableEntity->getSubEntity(0)->getMaterial()->setReceiveShadows(true);
        tableEntity->getSubEntity(0)->setMaterialName("DepthShadowmap/Receiver/Float",
                                                      "General");

        breadEntity->getSubEntity(0)->getMaterial()->setReceiveShadows(true);
        breadEntity->setCastShadows(true);
        
}
开发者ID:rbaravalle,项目名称:breaddemo,代码行数:96,代码来源:RenderState.cpp


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