本文整理汇总了C++中ogre::MaterialPtr::getTechnique方法的典型用法代码示例。如果您正苦于以下问题:C++ MaterialPtr::getTechnique方法的具体用法?C++ MaterialPtr::getTechnique怎么用?C++ MaterialPtr::getTechnique使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::MaterialPtr
的用法示例。
在下文中一共展示了MaterialPtr::getTechnique方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createBrowser
void SalamancerApplication::createBrowser(){
Ogre::TexturePtr renderTexture = Ogre::TextureManager::getSingleton().createManual(
"texture",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D, mWindow->getWidth(), mWindow->getHeight(), 0, Ogre::PF_A8R8G8B8, Ogre::TU_WRITE_ONLY);
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingletonPtr()->create("BrowserMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
material->getTechnique(0)->getPass(0)->setCullingMode(Ogre::CULL_CLOCKWISE); // print both sides of the polygones
material->getTechnique(0)->getPass(0)->createTextureUnitState("texture");
material->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_ALPHA);
material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
Ogre::Overlay *overlay = Ogre::OverlayManager::getSingletonPtr()->create("BrowserOverlay");
Ogre::OverlayContainer* panel = static_cast<OverlayContainer*>(Ogre::OverlayManager::getSingletonPtr()->createOverlayElement("Panel", "BrowserPanel"));
panel->setPosition(0.0, 0.0);
panel->setDimensions(1.0, 1.0);
panel->setMaterialName("BrowserMaterial");
overlay->add2D(panel);
overlay->show();
this->windowInfo.SetAsWindowless(0, true);
this->clientHandler = new ClientHandler(renderTexture, this->mRoot->getAutoCreatedWindow(), mMouse, this->mCamera, this->mSceneMgr, this->world, this->context);
browserSettings.web_security = STATE_DISABLED;
this->browser = CefBrowserHost::CreateBrowserSync(windowInfo, this->clientHandler.get(),
"file:///home/nathan/Projects/salamancer/dist/bin/hud/index.html",
browserSettings,
NULL);
this->clientHandler->SetBrowser(this->browser);
mRoot->addFrameListener(this->clientHandler.get());
}
示例2: createMaterial
Ogre::MaterialPtr AssetLoader::createMaterial(Ogre::String name, int index, aiMaterial* mat)
{
Ogre::MaterialManager* omatMgr = Ogre::MaterialManager::getSingletonPtr();
std::ostringstream matname;
matname << name.data() << "_mat";
matname.widen(4);
matname.fill('0');
matname << index;
Ogre::String matName = matname.str();
Ogre::ResourceManager::ResourceCreateOrRetrieveResult status = omatMgr->createOrRetrieve(matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
Ogre::MaterialPtr omat = status.first;
aiColor4D clr(1.0, 1.0, 1.0, 1.0);
aiGetMaterialColor(mat, AI_MATKEY_COLOR_DIFFUSE, &clr);
omat->getTechnique(0)->getPass(0)->setDiffuse(clr.r, clr.g, clr.b, clr.a);
aiGetMaterialColor(mat, AI_MATKEY_COLOR_SPECULAR, &clr);
omat->getTechnique(0)->getPass(0)->setSpecular(clr.r, clr.g, clr.b, clr.a);
aiGetMaterialColor(mat, AI_MATKEY_COLOR_AMBIENT, &clr);
omat->getTechnique(0)->getPass(0)->setAmbient(clr.r, clr.g, clr.b);
aiGetMaterialColor(mat, AI_MATKEY_COLOR_EMISSIVE, &clr);
omat->getTechnique(0)->getPass(0)->setSelfIllumination(clr.r, clr.g, clr.b);
omat->getTechnique(0)->getPass(0)->setShadingMode(Ogre::SO_GOURAUD);
omat->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
omat->getTechnique(0)->getPass(0)->setLightingEnabled(true);
omat->getTechnique(0)->getPass(0)->setDepthCheckEnabled(true);
//omat->getTechnique(0)->getPass(0)->setVertexColourTracking(Ogre::TVC_DIFFUSE);
aiString path;
aiReturn res = mat->GetTexture(aiTextureType_DIFFUSE, 0, &path);
if (res == AI_SUCCESS) {
Ogre::TextureUnitState* stateBase = omat->getTechnique(0)->getPass(0)->createTextureUnitState();
stateBase->setColourOperation(Ogre::LBO_MODULATE);
stateBase->setTextureName(path.data);
}
return omat;
}
示例3: notifyMaterialRender
void GodRaysListener::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
if(pass_id !=1
&& pass_id !=2
&& pass_id !=3
)
{
return ;
}
// this is the camera you're using
#ifndef ROAD_EDITOR
Ogre::Camera *cam = mApp->mSplitMgr->mCameras.front();
#else
Ogre::Camera *cam = mApp->mCamera;
#endif
//update the sun position
Ogre::Light* sun =((App*)mApp)->sun;
Ogre::GpuProgramParametersSharedPtr params= mat->getTechnique(0)->getPass(0)->getVertexProgramParameters();
Ogre::GpuProgramParametersSharedPtr fparams= mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters();
//disable god rays when the sun is not facing us
float enable=0.0f;
if(sun != NULL)
{
Ogre::Vector3 sunPosition = sun->getDirection() *100;
Ogre::Vector3 worldViewPosition = cam->getViewMatrix() * sunPosition;
Ogre::Vector3 hcsPosition = cam->getProjectionMatrix() * worldViewPosition;
float unclampedLuminance = abs(hcsPosition.x)+abs(hcsPosition.y);
clamp(hcsPosition);
Ogre::Vector2 sunScreenSpacePosition = Ogre::Vector2(0.5f + (0.5f * hcsPosition.x), 0.5f + (0.5f * -hcsPosition.y));
SunScreenSpacePosition = Ogre::Vector4 ( sunScreenSpacePosition.x, sunScreenSpacePosition.y, 0, 1 );
enable = (1.0f / ((unclampedLuminance > 1.0f) ? unclampedLuminance : 1.0f)) * (hcsPosition.z < 1 ? 0.0f : 1.0f);
}
params->setNamedConstant("lightPosition", SunScreenSpacePosition);
fparams->setNamedConstant("enableEffect", enable);
}
示例4: createPortalMaterials
//----------------------------------------------------------------------------------------
void PortalOutlineRenderable::createPortalMaterials(void)
{
Ogre::ColourValue colour = Ogre::ColourValue(0,1,0);//
Ogre::String matname = "PortalOutlineMaterial";
Ogre::ResourceManager::ResourceCreateOrRetrieveResult result = Ogre::MaterialManager::getSingleton().createOrRetrieve(matname, "General");
if(result.second)
{
Ogre::MaterialPtr freePortalMaterial = result.first;
freePortalMaterial->setReceiveShadows(false);
freePortalMaterial->getTechnique(0)->setLightingEnabled(true);
freePortalMaterial->getTechnique(0)->getPass(0)->setDiffuse(colour);
freePortalMaterial->getTechnique(0)->getPass(0)->setAmbient(colour);
freePortalMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(colour);
}
colour = Ogre::ColourValue(1,1,0);//Yellow
matname = "PortalOutlineMaterialConnected";
result = Ogre::MaterialManager::getSingleton().createOrRetrieve(matname, "General");
if(result.second)
{
Ogre::MaterialPtr connectedPortalMaterial = result.first;
connectedPortalMaterial->setReceiveShadows(false);
connectedPortalMaterial->getTechnique(0)->setLightingEnabled(true);
connectedPortalMaterial->getTechnique(0)->getPass(0)->setDiffuse(colour);
connectedPortalMaterial->getTechnique(0)->getPass(0)->setAmbient(colour);
connectedPortalMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(colour);
}
colour = Ogre::ColourValue(1,0,0);//Red
matname = "PortalOutlineMaterialLinked";
result = Ogre::MaterialManager::getSingleton().createOrRetrieve(matname, "General");
if(result.second)
{
Ogre::MaterialPtr linkedPortalMaterial = result.first;
linkedPortalMaterial->setReceiveShadows(false);
linkedPortalMaterial->getTechnique(0)->setLightingEnabled(true);
linkedPortalMaterial->getTechnique(0)->getPass(0)->setDiffuse(colour);
linkedPortalMaterial->getTechnique(0)->getPass(0)->setAmbient(colour);
linkedPortalMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(colour);
}
}
示例5: buildDepthShadowMaterial
//-------------------------------------------------------------------------------
Ogre::MaterialPtr CSceneManagerEditor::buildDepthShadowMaterial(Ogre::MaterialPtr cpyMat)
{
if(mShadowsTechnique->get() >= (int)Ogre::SHADOWTYPE_TEXTURE_ADDITIVE && mShadowsTechnique->get() <= (int)Ogre::SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED)
{
Ogre::String matName = "DepthShadows/" + cpyMat->getName();
Ogre::MaterialPtr ret = Ogre::MaterialManager::getSingleton().getByName(matName);
if (ret.isNull())
{
ret = cpyMat->clone(matName);
Ogre::Technique *t = ret->getTechnique(0);
t->setShadowCasterMaterial("Ogre/shadow/depth/caster");
Ogre::Pass *p = t->getPass(0);
p->setVertexProgram("Ogre/shadow/receiver/depth/pssm3/vp");
p->setFragmentProgram("Ogre/shadow/receiver/depth/pssm3/fp");
Ogre::TextureUnitState *tu = p->createTextureUnitState();
tu->setName("shadow0");
tu->setContentType(Ogre::TextureUnitState::CONTENT_SHADOW);
tu->setTextureAddressingMode(Ogre::TextureUnitState::TAM_BORDER);
tu->setTextureBorderColour(Ogre::ColourValue(1,1,1,1));
tu = p->createTextureUnitState();
tu->setName("shadow1");
tu->setContentType(Ogre::TextureUnitState::CONTENT_SHADOW);
tu->setTextureAddressingMode(Ogre::TextureUnitState::TAM_BORDER);
tu->setTextureBorderColour(Ogre::ColourValue(1,1,1,1));
tu = p->createTextureUnitState();
tu->setName("shadow2");
tu->setContentType(Ogre::TextureUnitState::CONTENT_SHADOW);
tu->setTextureAddressingMode(Ogre::TextureUnitState::TAM_BORDER);
tu->setTextureBorderColour(Ogre::ColourValue(1,1,1,1));
Ogre::Vector4 splitPoints;
const Ogre::PSSMShadowCameraSetup::SplitPointList& splitPointList =
static_cast<Ogre::PSSMShadowCameraSetup*>(mPSSMSetup.get())->getSplitPoints();
for (int i = 0; i < 3; ++i)
{
splitPoints[i] = splitPointList[i];
}
p->getFragmentProgramParameters()->setNamedConstant("pssmSplitPoints", splitPoints);
}
return ret;
}
else
return cpyMat;
}
示例6:
static void
SubEntity_tintColour(
SubEntity* self,
const String& groupName,
const String& materialName,
const Ogre::ColourValue& colour
) {
Ogre::MaterialPtr baseMaterial = Ogre::MaterialManager::getSingleton().getByName(materialName);
Ogre::MaterialPtr materialPtr = baseMaterial->clone(groupName);
materialPtr->compile();
Ogre::TextureUnitState* ptus = materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0);
ptus->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_TEXTURE, colour);
self->setMaterial(materialPtr);
}
示例7: Action
CreateObjectAction::CreateObjectAction(SceneManipulator* sceneManipulator)
: Action(sceneManipulator)
, mDirty(true)
, mObject()
, mHasPosition(false)
, mRangeSphereEntity(NULL)
, mRangeSphereNode(NULL)
{
// create a entity for indicate the range of a point light
mRangeSphereNode = getIndicatorRootSceneNode()->createChildSceneNode();
Ogre::MeshPtr sphereMesh = Fairy::createCommonSphere("PointLightRangeSphere", 100, 16, 16);
Ogre::MaterialPtr material = Fairy::createPureColourMaterial(Ogre::ColourValue(0, 1, 0, 0.75));
material->getTechnique(0)->getPass(0)->setPolygonMode(Ogre::PM_WIREFRAME);
material->getTechnique(0)->getPass(0)->setCullingMode(Ogre::CULL_NONE);
mRangeSphereEntity = getSceneManager()->createEntity("CreateLightRangeSphere", sphereMesh->getName());
mRangeSphereEntity->setMaterialName(material->getName());
mRangeSphereNode->attachObject(mRangeSphereEntity);
mRangeSphereNode->setVisible(false);
}
示例8: createScene
void SplashScreenState::createScene()
{
// creation image splash screen
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("SplashScreen", "General");
material->getTechnique(0)->getPass(0)->createTextureUnitState("splash_screen.jpg");
material->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
// creation rect
Ogre::Rectangle2D *rect = new Ogre::Rectangle2D(true);
rect->setCorners(-1.0, 1.0, 1.0, -1.0);
rect->setMaterial("SplashScreen");
// priorité chargement
rect->setRenderQueueGroup(Ogre::RenderQueueGroupID::RENDER_QUEUE_BACKGROUND);
// stay visible
Ogre::AxisAlignedBox aabInf;
aabInf.setInfinite();
rect->setBoundingBox(aabInf);
//
Ogre::SceneNode* node = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("SplashScreen");
node->attachObject(rect);
m_pSceneMgr->setAmbientLight(Ogre::ColourValue(1, 1, 1));
}
示例9: SetTextures
void EC_SkyBox::SetTextures()
{
if (!ViewEnabled())
return;
AssetReferenceList lst = textureRefs.Get();
std::vector<std::string> texture_names;
texture_names.reserve(6);
for(int i = 0; i < lst.Size() && i <= 6; ++i)
texture_names.push_back(lst[i].ref.toStdString());
Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(materialRef.Get().ref.toStdString().c_str());
if (!materialPtr.isNull() && texture_names.size() == 6)
materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setCubicTextureName(&texture_names[0], false);
//skyMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureScale(1, -1);
else if(!materialPtr.isNull() )
for(int i = 0; i < texture_names.size(); ++i)
materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setFrameTextureName(Ogre::String(texture_names[i].c_str()), i);
DisableSky();
CreateSky();
}
示例10: createOgreColorTexture
//create Color texture
void KinectDevice::createOgreColorTexture(const std::string colorTextureName, const std::string materialName)
{
if(!colorTextureName.empty())
{
mColorTexture = TextureManager::getSingleton().createManual(
colorTextureName,
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_2D,
KINECT_DEPTH_WIDTH,
KINECT_DEPTH_HEIGHT,
0,
PF_R8G8B8,
TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
}
if(!materialName.empty())
{
//Create Material
Ogre::MaterialPtr material = MaterialManager::getSingleton().create(materialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
material->getTechnique(0)->getPass(0)->createTextureUnitState(colorTextureName);
material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureRotate(Ogre::Degree(180));
}
}
示例11: createOgreUserTexture
//create User texture
void KinectDevice::createOgreUserTexture(const std::string UserTextureName, const std::string materialName)
{
if(!UserTextureName.empty())
{
mUserTexture = TextureManager::getSingleton().createManual(
UserTextureName, // name
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_2D, // type
KINECT_DEPTH_WIDTH, KINECT_DEPTH_HEIGHT,// width & height
0, // number of mipmaps
PF_BYTE_BGRA, // pixel format
TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
}
if(!materialName.empty())
{
// Create a material using the texture
Ogre::MaterialPtr material = MaterialManager::getSingleton().create(
materialName, // name
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
material->getTechnique(0)->getPass(0)->createTextureUnitState(UserTextureName);
material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureRotate(Ogre::Degree(180));
//material->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_ALPHA);
}
}
示例12: CEGUIWindow
CEGUIVideoPlayer::CEGUIVideoPlayer(
std::string name,
int width,
int height
) : CEGUIWindow("Thrive/Image",name)
{
Ogre::MaterialPtr videoMaterial = Ogre::MaterialManager::getSingleton().create(
"VideoMaterial"+name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
m_videoMaterialPass = videoMaterial->getTechnique( 0 )->getPass( 0 );
m_videoPlayer = std::unique_ptr<Video::VideoPlayer>(new Video::VideoPlayer());
//m_videoPlayer->setAudioFactory(new FFMPEGAudioFactory()); Don't know what I need to do to make audio work
m_videoImage = static_cast<CEGUI::BitmapImage*>(&CEGUI::ImageManager::getSingleton().create("BitmapImage", "ThriveGeneric/VideoImage"));
m_window->setWidth(CEGUI::UDim(0,width));
m_window->setHeight(CEGUI::UDim(0,height));
}
示例13: shoot
void MainApplication::shoot()
{
Ogre::String number2 = Ogre::StringConverter::toString(shotCounter + 1);
shots.push_back("manual1_node" + number2);
/*
Ogre::Entity* ogreHead = mSceneMgr -> createEntity("ogrehead.mesh");
Ogre::SceneNode *headNode = mSceneMgr -> getRootSceneNode() -> createChildSceneNode("manual1_node" + number2);
Ogre::Vector3 pos1(mSceneMgr-> getSceneNode("NinjaNode")->getPosition());
headNode -> setPosition(pos1);
headNode -> attachObject(ogreHead);
*/
Ogre::ManualObject* myManualObject = mSceneMgr->createManualObject("manual1" + number2);
Ogre::SceneNode* myManualObjectNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("manual1_node" + number2);
// NOTE: The second parameter to the create method is the resource group the material will be added to.
// If the group you name does not exist (in your resources.cfg file) the library will assert() and your program will crash
Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("manual1Material","General");
myManualObjectMaterial->setReceiveShadows(false);
myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true);
myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(0,0,1,0);
myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(0,0,1);
myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(0,0,1);
//myManualObjectMaterial->dispose(); // dispose pointer, not the material
Ogre::Vector3 pos1(mSceneMgr-> getSceneNode("NinjaNode")->getPosition());//Get position of player
myManualObject->begin("manual1Material", Ogre::RenderOperation::OT_LINE_LIST);
myManualObject->position(pos1.x + 20, pos1.y, pos1.z);
myManualObject->position(pos1.x + 50, pos1.y, pos1.z);
// etc
myManualObject->end();
myManualObjectNode->attachObject(myManualObject);
shotCounter++;
}
示例14: createScene
void IntroState::createScene()
{
MaterialPtr material = MaterialManager::getSingleton().create("Background", "General");
material->getTechnique(0)->getPass(0)->createTextureUnitState("rockwall.tga");
material->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
//Ustvarimo 2D kvadrat, ki prekrije celonti ekrat
Rectangle2D* rect = new Rectangle2D(true);
rect->setCorners(-1.0, 1.0, 1.0, -1.0);
rect->setMaterial("Background");
//najprej renderiramo ozadje potem pa vse ostalo
rect->setRenderQueueGroup(RENDER_QUEUE_BACKGROUND);
rect->setBoundingBox(AxisAlignedBox(-100000.0*Ogre::Vector3::UNIT_SCALE, 100000.0*Ogre::Vector3::UNIT_SCALE));
// pripnemo teksturo na ozadje
SceneNode* node = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("Background");
node->attachObject(rect);
Ogre::MaterialPtr mat;
Ogre::TextureUnitState* tex;
Ogre::String materialName="Background";
if (!Ogre::MaterialManager::getSingleton().resourceExists(materialName))
{
throw("Error, material doesn't exist!");
}
//tukaj prilepimo film na prej ustvarjeno teksturo
mat=Ogre::MaterialManager::getSingleton().getByName(materialName);
tex=mat->getTechnique(0)->getPass(0)->getTextureUnitState(0);
tex->setTextureName(dshowMovieTextureSystem->getMovieTexture()->getName());
mTitleLabel->setCaption("Intro");
mTitleLabel->show();
mTitleLabel2->setCaption("Press ESC to Exit Game!");
mTitleLabel2->show();
mTitleLabel3->setCaption("Press Space to skip!");
mTitleLabel3->show();
}
示例15: ChangeShaderColour
void StereoController::ChangeShaderColour(qreal r, qreal g, qreal b,const Ogre::String& name)
{
try
{
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName("Stereo/Anaglyph");
Ogre::Pass* pass = mat->getTechnique(0)->getPass(0);
Ogre::GpuProgramParametersSharedPtr param = pass->getFragmentProgramParameters();
Ogre::ColourValue colour(r,g,b,1);
param->setNamedConstant(name, colour);
}
catch (Ogre::Exception &e)
{
LogWarning("StereoController: Failed to set Anaglyph shader constant.");
LogWarning(e.what());
}
}