本文整理汇总了C++中ogre::Technique::createPass方法的典型用法代码示例。如果您正苦于以下问题:C++ Technique::createPass方法的具体用法?C++ Technique::createPass怎么用?C++ Technique::createPass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Technique
的用法示例。
在下文中一共展示了Technique::createPass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mCudaRoot
GPUSurfFeatureDetector::GPUSurfFeatureDetector(Ogre::Cuda::Root* root, int nbOctave, int nbFeatureMax)
: mCudaRoot(root)
{
mOgreIsAllocated = false;
mCudaIsAllocated = false;
mWidth = 0;
mHeight = 0;
mNbFeatureMax = nbFeatureMax;
mNbOctave = nbOctave;
mThreshold = 0.003f;
mNbFeatureFound = 0;
mGPGPURoot = new Ogre::GPGPU::Root;
mWebcamTexture = Ogre::TextureManager::getSingleton().createManual("WebcamVideoTexture", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 640, 480, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);
//Create Webcam Material
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("WebcamVideoMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::Technique *technique = material->createTechnique();
technique->createPass();
material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
material->getTechnique(0)->getPass(0)->createTextureUnitState("WebcamVideoTexture");
}
示例2: updateSelectedVersion
//--------------------------------------------------------------------------------
void MaterialUtil::updateSelectedVersion(const MaterialPtr& _material)
{
String name = _material->getName();
String selName = getSelectedVersionName(name);
MaterialPtr material, selectedMaterial;
if(selName == name)
{
name = getUnselectedVersionName(selName);
selectedMaterial = _material;
material = MaterialManager::getSingleton().getByName(name);
}
else
{
material = _material;
selectedMaterial = MaterialManager::getSingleton().getByName(selName);
}
if(!material.isNull() && !selectedMaterial.isNull())
{
material->copyDetailsTo(selectedMaterial);
Ogre::Technique* technique = selectedMaterial->getBestTechnique();
Pass* pass0 = technique->getPass(0);
Pass* passNew = technique->createPass();
passNew->setDiffuse(1, 1, 1, 1);
passNew->setPolygonMode(Ogre::PM_WIREFRAME);
if(pass0->getNumTextureUnitStates() != 0)
{
Ogre::TextureUnitState* tu = pass0->getTextureUnitState(0);
tu->setColourOperationEx(Ogre::LBX_MODULATE,
Ogre::LBS_TEXTURE, Ogre::LBS_MANUAL,
ColourValue::White, ColourValue(1, 0.6f, 0.6f, 1));
}
}
}
示例3: compileMaterial
bool Simple::compileMaterial(Ogre::MaterialPtr material)
{
material->removeAllTechniques();
Ogre::Technique* technique = material->createTechnique();
for (SurfaceLayerStore::const_iterator I = mTerrainPageSurfaces.begin(); I != mTerrainPageSurfaces.end(); ++I) {
const TerrainPageSurfaceLayer* surfaceLayer = I->second;
if (I == mTerrainPageSurfaces.begin()) {
Ogre::Pass* pass = technique->createPass();
pass->setLightingEnabled(false);
//add the first layer of the terrain, no alpha or anything
Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState();
textureUnitState->setTextureScale(1.0f / surfaceLayer->getScale(), 1.0f / surfaceLayer->getScale());
textureUnitState->setTextureName(surfaceLayer->getDiffuseTextureName());
textureUnitState->setTextureCoordSet(0);
} else {
if (surfaceLayer->intersects(*mGeometry)) {
addPassToTechnique(*mGeometry, technique, surfaceLayer);
}
}
}
if (mTerrainPageShadow) {
addShadow(technique, mTerrainPageShadow, material);
}
material->load();
if (material->getNumSupportedTechniques() == 0) {
S_LOG_WARNING("The material '" << material->getName() << "' has no supported techniques. The reason for this is: \n" << material->getUnsupportedTechniquesExplanation());
return false;
}
return true;
}
示例4: compileMaterial
bool Simple::compileMaterial(Ogre::MaterialPtr material, std::set<std::string>& managedTextures) const
{
material->removeAllTechniques();
Ogre::Technique* technique = material->createTechnique();
if (!mTerrainPageSurfaces.empty()) {
//First add a base pass
auto surfaceLayer = mTerrainPageSurfaces.begin()->second;
Ogre::Pass* pass = technique->createPass();
pass->setLightingEnabled(false);
Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState();
textureUnitState->setTextureScale(1.0f / surfaceLayer->getScale(), 1.0f / surfaceLayer->getScale());
textureUnitState->setTextureName(surfaceLayer->getDiffuseTextureName());
textureUnitState->setTextureCoordSet(0);
for (auto& layer : mLayers) {
addPassToTechnique(*mGeometry, technique, layer, managedTextures);
}
}
if (mTerrainPageShadow) {
addShadow(technique, mTerrainPageShadow, material, managedTextures);
}
// addLightingPass(technique, managedTextures);
material->load();
if (material->getNumSupportedTechniques() == 0) {
S_LOG_WARNING("The material '" << material->getName() << "' has no supported techniques. The reason for this is: \n" << material->getUnsupportedTechniquesExplanation());
return false;
}
return true;
}
示例5: initAR
bool OgreARAppLogic::initAR()
{
//INIT Realidad aumentada
if ( !userInit(this) ) return false; // user defined function to init AR
if(mWidth==0 || mHeight==0 || mBuffer==0) {
std::cout << "Image size or buffer not defined in user-defined init function" << std::endl;
return false;
}
// create background texture
mPixelBox = Ogre::PixelBox(mWidth, mHeight, 1, Ogre::PF_R8G8B8, mBuffer);
// Create Texture
mTexture = Ogre::TextureManager::getSingleton().createManual(
"CameraTexture",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D,
mWidth,
mHeight,
0,
Ogre::PF_R8G8B8,
Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
//Create Camera Material
MaterialPtr material = MaterialManager::getSingleton().create("CameraMaterial", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::Technique *technique = material->createTechnique();
technique->createPass();
material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
material->getTechnique(0)->getPass(0)->createTextureUnitState("CameraTexture");
return true;
}
示例6: forceCreateFirstTexture
//-----------------------------------------------------------------------
Ogre::TextureUnitState* MaterialTab::forceCreateFirstTexture(const Ogre::String textureName)
{
// Ignore some materials because they result in a crash while unloading
wxString materialName = mMaterialListBox->GetStringSelection();
if (materialName == wxT("DefaultSettings"))
return 0;
Ogre::Technique* technique = 0;
Ogre::TextureUnitState* texture = 0;
Ogre::Pass* pass = getFirstPass();
if (pass)
{
// There is a pass, check for textures or create one
if (pass->getNumTextureUnitStates() > 0)
{
pass->removeAllTextureUnitStates();
}
texture = pass->createTextureUnitState(textureName);
}
else
{
// There is no pass
wxString materialName = mMaterialListBox->GetStringSelection();
Ogre::String name = wx2ogre(materialName);
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(name);
if (!material.isNull())
{
material->load();
if (material->getNumTechniques() > 0)
{
technique = material->getBestTechnique(); // Get the best technique
pass = technique->createPass();
texture = pass->createTextureUnitState(textureName);
}
else
{
// There is no technique, no pass and no textureunitstate
technique = material->createTechnique();
pass = technique->createPass();
texture = pass->createTextureUnitState(textureName);
}
}
}
return texture;
}
示例7: handleSchemeNotFound
Ogre::Technique* GBufferSchemeHandler::handleSchemeNotFound(unsigned short schemeIndex,
const Ogre::String& schemeName, Ogre::Material* originalMaterial, unsigned short lodIndex,
const Ogre::Renderable* rend)
{
Ogre::MaterialManager& matMgr = Ogre::MaterialManager::getSingleton();
Ogre::String curSchemeName = matMgr.getActiveScheme();
matMgr.setActiveScheme(Ogre::MaterialManager::DEFAULT_SCHEME_NAME);
Ogre::Technique* originalTechnique = originalMaterial->getBestTechnique(lodIndex, rend);
matMgr.setActiveScheme(curSchemeName);
Ogre::Technique* gBufferTech = originalMaterial->createTechnique();
gBufferTech->removeAllPasses();
gBufferTech->setSchemeName(schemeName);
Ogre::Technique* noGBufferTech = originalMaterial->createTechnique();
noGBufferTech->removeAllPasses();
noGBufferTech->setSchemeName("NoGBuffer");
for (unsigned short i=0; i<originalTechnique->getNumPasses(); i++)
{
Ogre::Pass* originalPass = originalTechnique->getPass(i);
PassProperties props = inspectPass(originalPass, lodIndex, rend);
if (!props.isDeferred)
{
//Just copy the technique so it gets rendered regularly
Ogre::Pass* clonePass = noGBufferTech->createPass();
*clonePass = *originalPass;
continue;
}
Ogre::Pass* newPass = gBufferTech->createPass();
MaterialGenerator::Perm perm = getPermutation(props);
const Ogre::MaterialPtr& templateMat = mMaterialGenerator.getMaterial(perm);
//We assume that the GBuffer technique contains only one pass. But its true.
*newPass = *(templateMat->getTechnique(0)->getPass(0));
fillPass(newPass, originalPass, props);
}
return gBufferTech;
}
示例8: initTracking
void OgreAppLogic::initTracking(int width, int height)
{
mWebcamBufferL8 = new unsigned char[width*height];
mTrackingSystem->init(width, height);
//Create Webcam Material
MaterialPtr material = MaterialManager::getSingleton().create("WebcamMaterial", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::Technique *technique = material->createTechnique();
technique->createPass();
material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
material->getTechnique(0)->getPass(0)->createTextureUnitState(colorTextureName);
}
示例9: OnNewPass
void MaterialEditor::OnNewPass(wxCommandEvent &e)
{
if(mMaterial.isNull())
return;
Ogre::Technique* pTechinque = m_MaterialTree->getSelecteTechnique();
if(pTechinque)
{
Ogre::Pass* pPass = pTechinque->createPass();
m_Frame->GetEffectObjectProperty()->InitMaterialEditor(mMaterial,mMaterialName);
m_MaterialTree->DeleteAllItems();
m_MaterialTree->AddMaterialToTree(mMaterial,mMaterialName);
m_MaterialTree->SelectePassItem(pPass);
}
}
示例10: onNewMessage
void MeshResourceMarker::onNewMessage(const MarkerConstPtr& old_message, const MarkerConstPtr& new_message)
{
ROS_ASSERT(new_message->type == visualization_msgs::Marker::MESH_RESOURCE);
// flag indicating if the mesh material color needs to be updated
bool update_color = false;
scene_node_->setVisible(false);
if (!entity_ ||
old_message->mesh_resource != new_message->mesh_resource ||
old_message->mesh_use_embedded_materials != new_message->mesh_use_embedded_materials)
{
reset();
if (new_message->mesh_resource.empty())
{
return;
}
if (loadMeshFromResource(new_message->mesh_resource).isNull())
{
std::stringstream ss;
ss << "Mesh resource marker [" << getStringID() << "] could not load [" << new_message->mesh_resource << "]";
if (owner_)
{
owner_->setMarkerStatus(getID(), StatusProperty::Error, ss.str());
}
ROS_DEBUG("%s", ss.str().c_str());
return;
}
static uint32_t count = 0;
std::stringstream ss;
ss << "mesh_resource_marker_" << count++;
std::string id = ss.str();
entity_ = context_->getSceneManager()->createEntity(id, new_message->mesh_resource);
scene_node_->attachObject(entity_);
// create a default material for any sub-entities which don't have their own.
ss << "Material";
Ogre::MaterialPtr default_material = Ogre::MaterialManager::getSingleton().create(ss.str(), ROS_PACKAGE_NAME);
default_material->setReceiveShadows(false);
default_material->getTechnique(0)->setLightingEnabled(true);
default_material->getTechnique(0)->setAmbient(0.5, 0.5, 0.5);
materials_.insert(default_material);
if (new_message->mesh_use_embedded_materials)
{
// make clones of all embedded materials so selection works correctly
S_MaterialPtr materials = getMaterials();
S_MaterialPtr::iterator it;
for (it = materials.begin(); it != materials.end(); it++)
{
if ((*it)->getName() != "BaseWhiteNoLighting")
{
Ogre::MaterialPtr new_material = (*it)->clone(id + (*it)->getName());
materials_.insert(new_material);
}
}
// make sub-entities use cloned materials
for (uint32_t i = 0; i < entity_->getNumSubEntities(); ++i)
{
std::string mat_name = entity_->getSubEntity(i)->getMaterialName();
if (mat_name != "BaseWhiteNoLighting")
{
entity_->getSubEntity(i)->setMaterialName(id + mat_name);
}
else
{
// BaseWhiteNoLighting is the default material Ogre uses
// when it sees a mesh with no material. Here we replace
// that with our default_material which gets colored with
// new_message->color.
entity_->getSubEntity(i)->setMaterial(default_material);
}
}
}
else
{
entity_->setMaterial(default_material);
}
// add a pass to every material to perform the color tinting
S_MaterialPtr::iterator material_it;
for (material_it = materials_.begin(); material_it != materials_.end(); material_it++)
{
Ogre::Technique* technique = (*material_it)->getTechnique(0);
color_tint_passes_.push_back(technique->createPass());
}
// always update color on resource change
update_color = true;
handler_.reset(new MarkerSelectionHandler(this, MarkerID(new_message->ns, new_message->id), context_));
handler_->addTrackedObject(entity_);
}
else
//.........这里部分代码省略.........
示例11: create
Ogre::MaterialPtr MaterialGenerator::create(bool renderCompositeMap, bool displayCompositeMap)
{
assert(!renderCompositeMap || !displayCompositeMap);
static int count = 0;
std::stringstream name;
name << "terrain/mat" << count++;
if (!mShaders)
{
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create(name.str(),
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::Technique* technique = mat->getTechnique(0);
technique->removeAllPasses();
if (displayCompositeMap)
{
Ogre::Pass* pass = technique->createPass();
pass->setVertexColourTracking(Ogre::TVC_AMBIENT|Ogre::TVC_DIFFUSE);
pass->createTextureUnitState(mCompositeMap)->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
}
else
{
assert(mLayerList.size() == mBlendmapList.size()+1);
std::vector<Ogre::TexturePtr>::iterator blend = mBlendmapList.begin();
for (std::vector<LayerInfo>::iterator layer = mLayerList.begin(); layer != mLayerList.end(); ++layer)
{
Ogre::Pass* pass = technique->createPass();
pass->setLightingEnabled(false);
pass->setVertexColourTracking(Ogre::TVC_NONE);
// TODO: How to handle fog?
pass->setFog(true, Ogre::FOG_NONE);
bool first = (layer == mLayerList.begin());
Ogre::TextureUnitState* tus;
if (!first)
{
pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
pass->setDepthFunction(Ogre::CMPF_EQUAL);
tus = pass->createTextureUnitState((*blend)->getName());
tus->setAlphaOperation(Ogre::LBX_BLEND_TEXTURE_ALPHA,
Ogre::LBS_TEXTURE,
Ogre::LBS_TEXTURE);
tus->setColourOperationEx(Ogre::LBX_BLEND_DIFFUSE_ALPHA,
Ogre::LBS_TEXTURE,
Ogre::LBS_TEXTURE);
tus->setIsAlpha(true);
tus->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
float scale = (16/(16.f+1.f));
tus->setTextureScale(1.f/scale,1.f/scale);
}
// Add the actual layer texture on top of the alpha map.
tus = pass->createTextureUnitState(layer->mDiffuseMap);
if (!first)
tus->setColourOperationEx(Ogre::LBX_BLEND_DIFFUSE_ALPHA,
Ogre::LBS_TEXTURE,
Ogre::LBS_CURRENT);
tus->setTextureScale(1/16.f,1/16.f);
if (!first)
++blend;
}
if (!renderCompositeMap)
{
Ogre::Pass* lightingPass = technique->createPass();
lightingPass->setSceneBlending(Ogre::SBT_MODULATE);
lightingPass->setVertexColourTracking(Ogre::TVC_AMBIENT|Ogre::TVC_DIFFUSE);
lightingPass->setFog(true, Ogre::FOG_NONE);
}
}
return mat;
}
#if TERRAIN_USE_SHADER
else
{
sh::MaterialInstance* material = sh::Factory::getInstance().createMaterialInstance (name.str());
material->setProperty ("allow_fixed_function", sh::makeProperty<sh::BooleanValue>(new sh::BooleanValue(false)));
if (displayCompositeMap)
{
sh::MaterialInstancePass* p = material->createPass ();
p->setProperty ("vertex_program", sh::makeProperty<sh::StringValue>(new sh::StringValue("terrain_vertex")));
p->setProperty ("fragment_program", sh::makeProperty<sh::StringValue>(new sh::StringValue("terrain_fragment")));
p->mShaderProperties.setProperty ("is_first_pass", sh::makeProperty(new sh::BooleanValue(true)));
p->mShaderProperties.setProperty ("render_composite_map", sh::makeProperty(new sh::BooleanValue(false)));
p->mShaderProperties.setProperty ("display_composite_map", sh::makeProperty(new sh::BooleanValue(true)));
p->mShaderProperties.setProperty ("num_layers", sh::makeProperty (new sh::StringValue("0")));
p->mShaderProperties.setProperty ("num_blendmaps", sh::makeProperty (new sh::StringValue("0")));
p->mShaderProperties.setProperty ("normal_map_enabled", sh::makeProperty (new sh::BooleanValue(false)));
p->mShaderProperties.setProperty ("parallax_enabled", sh::makeProperty (new sh::BooleanValue(false)));
p->mShaderProperties.setProperty ("normal_maps",
//.........这里部分代码省略.........
示例12: createActions
//.........这里部分代码省略.........
mNodeEditor->addNode(mMaterialNode);
}
}
//****************************************************************************/
void EditorDockWidget::doTechniqueHToolbarAction(void)
{
// Add a technique node
Magus::QtNodeTechnique* techniqueNode = new Magus::QtNodeTechnique(NODE_TITLE_TECHNIQUE);
mNodeEditor->addNode(techniqueNode);
}
//****************************************************************************/
void EditorDockWidget::doPassHToolbarAction(void)
{
// Add a pass node
Magus::QtNodePass* passNode = new Magus::QtNodePass(NODE_TITLE_PASS);
mNodeEditor->addNode(passNode);
}
//****************************************************************************/
void EditorDockWidget::doTextureHToolbarAction(void)
{
// Add a texture unit node
Magus::QtNodeTextureUnit* textureUnitNode = new Magus::QtNodeTextureUnit(NODE_TITLE_TEXTURE_UNIT);
mNodeEditor->addNode(textureUnitNode);
}
//****************************************************************************/
void EditorDockWidget::doCogHToolbarAction(void)
{
if (!mMaterialNode)
return;
if (mMaterialNode->getMaterialName().isEmpty())
return;
// ---------------------------------------- Create a material ----------------------------------------
Ogre::LogManager* logManager = Ogre::LogManager::getSingletonPtr();
Ogre::MaterialManager* materialManager = Ogre::MaterialManager::getSingletonPtr();
Ogre::String materialName = mMaterialNode->getMaterialName().toStdString(); // Convert to std format
logManager->logMessage("SME: create Ogre material: " + materialName);
Ogre::MaterialPtr material = materialManager->create(materialName, "General");
// Remark: Sceneblending is done for each pass individually, although it is defined on material level
// ---------------------------------------- Add the technique ----------------------------------------
Magus::QtNode* node = mMaterialNode->getNodeConnectedToPort(PORT_TECHNIQUE_OUT);
if (!node)
{
logManager->logMessage("SME: No technique node available");
return;
}
Magus::QtNodeTechnique* techniqueNode = static_cast<Magus::QtNodeTechnique*>(node);
material->removeAllTechniques();
Ogre::Technique* technique = material->createTechnique();
technique->removeAllPasses();
logManager->logMessage("SME: Technique created" + Ogre::StringConverter::toString(material->getNumTechniques()));
// ---------------------------------------- Add the passes ----------------------------------------
Magus::QtNodePass* passNode;
Magus::QtNodeTextureUnit* textureUnitNode;
Ogre::Pass* pass;
Ogre::TextureUnitState* textureUnit;
for (unsigned int i = 1; i < 5; ++i)
{
node = techniqueNode->getNodeConnectedToPort(PORT_PASS_OUT, i); // node with the same name
if (node)
{
passNode = static_cast<Magus::QtNodePass*>(node);
pass = technique->createPass();
pass->removeAllTextureUnitStates();
logManager->logMessage("SME: Pass on port nr. " + Ogre::StringConverter::toString(i) + " created");
propagatePassNodeData(passNode, pass);
// ---------------------------------------- Add the texture units ----------------------------------------
for (unsigned int j = 1; j < 9; ++j)
{
node = passNode->getNodeConnectedToPort(PORT_TEXTURE_OUT, j);
if (node)
{
logManager->logMessage("SME: Texture unit on port nr. " +
Ogre::StringConverter::toString(j) +
" of Pass port nr. " +
Ogre::StringConverter::toString(i) +
" created");
textureUnitNode = static_cast<Magus::QtNodeTextureUnit*>(node);
textureUnit = pass->createTextureUnitState();
propagateTextureUnitNodeData(textureUnitNode, textureUnit);
}
}
}
}
// Assign the material to the ogrehead
material->compile();
material->load();
mParent->getOgreManager()->getOgreWidget(1)->mEntity->setMaterial(material);
}
示例13: markerCallback
//.........这里部分代码省略.........
{
case visualization_msgs::Marker::CUBE_LIST:
tAM->publishStatus(Gadget::OKAY, "Successfully added cube list marker");
break;
case visualization_msgs::Marker::SPHERE_LIST:
tAM->publishStatus(Gadget::OKAY, "Successfully added sphere list marker");
break;
}
}
}
break;
case visualization_msgs::Marker::POINTS:
{
unsigned int i;
unsigned int N;
if (renew)
{
tAM->subGraphicNode = tAM->graphicNode->createChildSceneNode();
if (marker.points.size() > 0)
{
string materialName = name + "PointMat";
tAM->material = Ogre::MaterialManager::getSingleton().create(materialName.c_str(),
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
tAM->material->setPointSize(marker.scale.x);
Ogre::Technique* pT = tAM->material->getTechnique( 0 );
if( NULL == pT ) pT = tAM->material->createTechnique();
Ogre::Pass* pP = pT->getPass( 0 );
if( NULL == pP ) pP = pT->createPass();
// set parameters
pP->setVertexColourTracking(Ogre::TVC_AMBIENT);
pP->setLightingEnabled(false);
//pP->setDepthCheckEnabled(true);
//pP->setDepthWriteEnabled(false);
//pP->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
tAM->manual = tAM->scene->createManualObject(tAM->name + "_manual");
tAM->subGraphicNode->attachObject(tAM->manual);
tAM->manual->setDynamic(true);
tAM->manual->estimateVertexCount(1000);
tAM->manual->begin(materialName.c_str(), Ogre::RenderOperation::OT_POINT_LIST);
}
else
{
tAM->publishStatus(Gadget::WARNING, "No data in message");
}
}
else
{
if (marker.points.size() > 0)
{
tAM->material->setPointSize(marker.scale.x);
tAM->manual->beginUpdate(0);
}
else
{
tAM->publishStatus(Gadget::WARNING, "No data in message");
}
示例14: initOgreAR
int initOgreAR(aruco::CameraParameters camParams, unsigned char* buffer, std::string resourcePath)
{
/// INIT OGRE FUNCTIONS
#ifdef _WIN32
root = new Ogre::Root(resourcePath + "plugins_win.cfg", resourcePath + "ogre_win.cfg");
#elif __x86_64__ || __ppc64__
root = new Ogre::Root(resourcePath + "plugins_x64.cfg", resourcePath + "ogre.cfg");
#else
root = new Ogre::Root(resourcePath + "plugins.cfg", resourcePath + "ogre.cfg");
#endif
if (!root->showConfigDialog()) return -1;
Ogre::SceneManager* smgr = root->createSceneManager(Ogre::ST_GENERIC);
/// CREATE WINDOW, CAMERA AND VIEWPORT
Ogre::RenderWindow* window = root->initialise(true);
Ogre::Camera *camera;
Ogre::SceneNode* cameraNode;
camera = smgr->createCamera("camera");
camera->setNearClipDistance(0.01f);
camera->setFarClipDistance(10.0f);
camera->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
camera->setPosition(0, 0, 0);
camera->lookAt(0, 0, 1);
double pMatrix[16];
camParams.OgreGetProjectionMatrix(camParams.CamSize,camParams.CamSize, pMatrix, 0.05,10, false);
Ogre::Matrix4 PM(pMatrix[0], pMatrix[1], pMatrix[2] , pMatrix[3],
pMatrix[4], pMatrix[5], pMatrix[6] , pMatrix[7],
pMatrix[8], pMatrix[9], pMatrix[10], pMatrix[11],
pMatrix[12], pMatrix[13], pMatrix[14], pMatrix[15]);
camera->setCustomProjectionMatrix(true, PM);
camera->setCustomViewMatrix(true, Ogre::Matrix4::IDENTITY);
window->addViewport(camera);
cameraNode = smgr->getRootSceneNode()->createChildSceneNode("cameraNode");
cameraNode->attachObject(camera);
/// CREATE BACKGROUND FROM CAMERA IMAGE
int width = camParams.CamSize.width;
int height = camParams.CamSize.height;
// create background camera image
mPixelBox = Ogre::PixelBox(width, height, 1, Ogre::PF_R8G8B8, buffer);
// Create Texture
mTexture = Ogre::TextureManager::getSingleton().createManual("CameraTexture",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D,width,height,0,Ogre::PF_R8G8B8,Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
//Create Camera Material
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("CameraMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::Technique *technique = material->createTechnique();
technique->createPass();
material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
material->getTechnique(0)->getPass(0)->createTextureUnitState("CameraTexture");
Ogre::Rectangle2D* rect = new Ogre::Rectangle2D(true);
rect->setCorners(-1.0, 1.0, 1.0, -1.0);
rect->setMaterial("CameraMaterial");
// Render the background before everything else
rect->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND);
// Hacky, but we need to set the bounding box to something big, use infinite AAB to always stay visible
Ogre::AxisAlignedBox aabInf;
aabInf.setInfinite();
rect->setBoundingBox(aabInf);
// Attach background to the scene
Ogre::SceneNode* node = smgr->getRootSceneNode()->createChildSceneNode("Background");
node->attachObject(rect);
/// CREATE SIMPLE OGRE SCENE
// add sinbad.mesh
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(resourcePath + "Sinbad.zip", "Zip", "Popular");
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
for(int i=0; i<MAX_MARKERS; i++) {
Ogre::String entityName = "Marker_" + Ogre::StringConverter::toString(i);
Ogre::Entity* ogreEntity = smgr->createEntity(entityName, "Sinbad.mesh");
Ogre::Real offset = ogreEntity->getBoundingBox().getHalfSize().y;
ogreNode[i] = smgr->getRootSceneNode()->createChildSceneNode();
// add entity to a child node to correct position (this way, entity axis is on feet of sinbad)
Ogre::SceneNode *ogreNodeChild = ogreNode[i]->createChildSceneNode();
ogreNodeChild->attachObject(ogreEntity);
// Sinbad is placed along Y axis, we need to rotate to put it along Z axis so it stands up over the marker
// first rotate along X axis, then add offset in Z dir so it is over the marker and not in the middle of it
ogreNodeChild->rotate(Ogre::Vector3(1,0,0), Ogre::Radian(Ogre::Degree(90)));
ogreNodeChild->translate(0,0,offset,Ogre::Node::TS_PARENT);
// mesh is too big, rescale!
const float scale = 0.006675f;
ogreNode[i]->setScale(scale, scale, scale);
// Init animation
ogreEntity->getSkeleton()->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);
if(i==0)
{
baseAnim[i] = ogreEntity->getAnimationState("HandsClosed");
topAnim[i] = ogreEntity->getAnimationState("HandsRelaxed");
}
else if(i==1)
{
//.........这里部分代码省略.........
示例15: logic_error
Camera::Camera(Event::Lane& lane,
GameHandle cameraHandle,
Ogre::SceneNode* camNode,
Ogre::RenderTarget* renderTarget,
u32 width,
u32 height,
const v3& position,
const qv4& orientation,
GameHandle parent) :
mSubLane(lane.createSubLane()),
mCameraNode(camNode),
mRenderTarget(renderTarget),
mHandle(cameraHandle),
mNodeCreated(false),
mRenderTargetCreated(false)
{
Ogre::SceneManager* sceneMgr = Ogre::Root::getSingleton().getSceneManager(BFG_SCENEMANAGER);
if (mCameraNode == NULL) // Create SceneNode
{
if (sceneMgr->hasSceneNode(stringify(mHandle)))
{
mCameraNode = sceneMgr->getSceneNode(stringify(mHandle));
}
else
{
mCameraNode = sceneMgr->getRootSceneNode()->createChildSceneNode(stringify(mHandle));
mNodeCreated = true;
}
}
mCameraNode->setOrientation(toOgre(orientation));
mCameraNode->setPosition(toOgre(position));
v3 target = toBFG(mCameraNode->getOrientation().zAxis());
norm(target);
Ogre::Camera* cam;
cam = sceneMgr->createCamera(stringify(mHandle));
cam->setFOVy(Ogre::Degree(60.0f));
cam->setNearClipDistance(0.1f);
cam->setFarClipDistance(250000.0f);
cam->lookAt(toOgre(target)*10);
mCameraNode->attachObject(cam);
infolog << "Camera: " << stringify(mHandle) << " created.";
if (mRenderTarget == NULL)
{
// Create renderToTexture RenderTarget
if (width == 0 || height == 0)
{
throw std::logic_error("Too few information to create a render target.");
}
cam->setAspectRatio((f32)width / (f32)height);
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual
(
stringify(mHandle),
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D,
width,
height,
0,
Ogre::PF_R8G8B8,
Ogre::TU_RENDERTARGET
);
mRenderTarget = texture->getBuffer()->getRenderTarget();
prepareRenderTarget();
mRenderTarget->addViewport(cam);
mRenderTarget->getViewport(0)->setClearEveryFrame(true);
mRenderTarget->getViewport(0)->setBackgroundColour(Ogre::ColourValue::Black);
mRenderTarget->getViewport(0)->setOverlaysEnabled(false);
Ogre::MaterialPtr mat =
Ogre::MaterialManager::getSingleton().getByName(stringify(mHandle));
if (mat.isNull())
{
mat = Ogre::MaterialManager::getSingleton().create(
stringify(mHandle),
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
}
Ogre::Technique* tech = mat->getTechnique(0);
if (!tech)
{
tech = mat->createTechnique();
}
Ogre::Pass* pass = tech->getPass(0);
if (!pass)
{
pass = tech->createPass();
}
pass->setLightingEnabled(false);
if (pass->getNumTextureUnitStates() > 0)
//.........这里部分代码省略.........