本文整理汇总了C++中ogre::SceneManager::createBillboardSet方法的典型用法代码示例。如果您正苦于以下问题:C++ SceneManager::createBillboardSet方法的具体用法?C++ SceneManager::createBillboardSet怎么用?C++ SceneManager::createBillboardSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SceneManager
的用法示例。
在下文中一共展示了SceneManager::createBillboardSet方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShowMessage
void EC_ChatBubble::ShowMessage(const QString &msg)
{
if (renderer_.expired())
return;
Ogre::SceneManager *scene = renderer_.lock()->GetSceneManager();
assert(scene);
if (!scene)
return;
Scene::Entity *entity = GetParentEntity();
assert(entity);
if (!entity)
return;
OgreRenderer::EC_OgrePlaceable *node = entity->GetComponent<OgreRenderer::EC_OgrePlaceable>().get();
if (!node)
return;
Ogre::SceneNode *sceneNode = node->GetSceneNode();
assert(sceneNode);
if (!sceneNode)
return;
// Create billboard if it doesn't exist.
if (!billboardSet_ && !billboard_)
{
billboardSet_ = scene->createBillboardSet(renderer_.lock()->GetUniqueObjectName(), 1);
assert(billboardSet_);
std::string newName = std::string("material") + renderer_.lock()->GetUniqueObjectName();
Ogre::MaterialPtr material = OgreRenderer::CloneMaterial("UnlitTexturedSoftAlpha", newName);
billboardSet_->setMaterialName(newName);
billboard_ = billboardSet_->createBillboard(Ogre::Vector3(0, 0, 1.5f));
assert(billboard_);
billboard_->setDimensions(2, 1);
sceneNode->attachObject(billboardSet_);
}
if (msg.isNull() || msg.isEmpty())
return;
messages_.push_back(msg);
// Set timer for removing the message
int timeToShow = 0;
const int minTime = 4000;
if (msg.length() * 400 < minTime)
timeToShow = minTime;
else
timeToShow = msg.length() * 400;
QTimer::singleShot(timeToShow, this, SLOT(RemoveLastMessage()));
Refresh();
}
示例2: ShowMessage
void EC_HoveringText::ShowMessage(const QString &text)
{
if (!ViewEnabled())
return;
if (world_.expired())
return;
OgreWorldPtr world = world_.lock();
Ogre::SceneManager *scene = world->OgreSceneManager();
assert(scene);
if (!scene)
return;
Entity* entity = ParentEntity();
assert(entity);
if (!entity)
return;
EC_Placeable *node = entity->GetComponent<EC_Placeable>().get();
if (!node)
return;
Ogre::SceneNode *sceneNode = node->GetSceneNode();
assert(sceneNode);
if (!sceneNode)
return;
// Create billboard if it doesn't exist.
if (!billboardSet_)
{
billboardSet_ = scene->createBillboardSet(world->GetUniqueObjectName("EC_HoveringText"), 1);
assert(billboardSet_);
billboardSet_->Ogre::MovableObject::setUserAny(Ogre::Any(static_cast<IComponent *>(this)));
billboardSet_->Ogre::Renderable::setUserAny(Ogre::Any(static_cast<IComponent *>(this)));
sceneNode->attachObject(billboardSet_);
}
if (billboardSet_ && !billboard_)
{
billboard_ = billboardSet_->createBillboard(Ogre::Vector3(0, 0, 0.7f));
SetBillboardSize(width.Get(), height.Get());
SetPosition(position.Get());
}
Redraw();
}
示例3: initialize
/**
* @inheritDoc
*/
Error ImageGraphicObject::initialize(void) {
ASSERT(!m_bInitialized);
std::string image = IMAGE_BASE_PATH + m_image;
/*m_sourceImage = IMG_Load(image.c_str());
m_displayImage = SDL_ConvertSurface(m_sourceImage, m_sourceImage->format, m_sourceImage->flags);*/
Ogre::SceneNode* rootNode = static_cast<GraphicScene*>(m_pSystemScene)->getRootNode();
Ogre::SceneManager* sceneManager = static_cast<GraphicScene*>(m_pSystemScene)->getSceneManager();
Ogre::SceneNode* myNode = static_cast<Ogre::SceneNode*>(rootNode->createChild());
Ogre::BillboardSet* mySet = sceneManager->createBillboardSet("mySet");
Ogre::Billboard* myBillboard = mySet->createBillboard(Ogre::Vector3(0, 0, 0));
myBillboard->setDimensions(100, 100);
myNode->attachObject(mySet);
m_bInitialized = true;
return Errors::Success;
}
示例4: Update
void EC_ChatBubble::Update()
{
if (renderer_.expired())
return;
Ogre::SceneManager *scene = renderer_.lock()->GetSceneManager();
assert(scene);
if (!scene)
return;
Scene::Entity *entity = GetParentEntity();
// assert(entity);
if (!entity)
return;
EC_Placeable *node = entity->GetComponent<EC_Placeable>().get();
if (!node)
return;
Ogre::SceneNode *sceneNode = node->GetSceneNode();
assert(sceneNode);
if (!sceneNode)
return;
// Create billboard if it doesn't exist.
if (!billboardSet_ && !billboard_)
{
// Create billboardset and billboard
billboardSet_ = scene->createBillboardSet(renderer_.lock()->GetUniqueObjectName("EC_ChatBubble"), 1);
assert(billboardSet_);
billboard_ = billboardSet_->createBillboard(Ogre::Vector3(0, 0, default_z_pos_));
assert(billboard_);
billboardSet_->setDefaultDimensions(2, 1);
sceneNode->attachObject(billboardSet_);
// Create material
materialName_ = renderer_.lock()->GetUniqueObjectName("EC_ChatBubble_Material");
Ogre::MaterialPtr material = OgreRenderer::CloneMaterial("UnlitTexturedSoftAlpha", materialName_);
billboardSet_->setMaterialName(materialName_);
// Create texture
texture_name_ = renderer_.lock()->GetUniqueObjectName("EC_ChatBubble_Texture");
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual(
texture_name_, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D, 1, 1, 0, Ogre::PF_A8R8G8B8,
Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
// Set texture to material
if (texture.isNull())
texture_name_ = "";
else
OgreRenderer::SetTextureUnitOnMaterial(material, texture_name_);
}
else
{
// Billboard already exists, remove it from the old and attach it to a new scene node.
LogInfo("Trying to detach chat bubble billboard from its old node and attach to a new node. This feature is not tested.");
Ogre::SceneNode *oldNode = billboardSet_->getParentSceneNode();
oldNode->detachObject(billboardSet_);
sceneNode->attachObject(billboardSet_);
}
}
示例5: main
int main(int argc, char* argv[])
{
std::unique_ptr<ExecutionArgs> exArgs(new ExecutionArgs());
if (!processCommandLineArgs(argc, argv, *exArgs)) {
return -1;
} else if (exArgs->helpPrompt) {
std::cout << "Usage: sts [--help] || [--config]" << std::endl;
std::cout << "Options:" << std::endl;
std::cout << "\t --help - print this message;" << std::endl;
std::cout << "\t --config - show config dialog." << std::endl;
std::cout << std::endl;
return 0;
}
try {
Ogre::String lConfigFileName = "ogre.cfg";
Ogre::String lPluginsFileName = "plugins.cfg";
Ogre::String lLogFileName = "Ogre_STS.log";
std::unique_ptr<Ogre::Root> lRoot(new Ogre::Root(lPluginsFileName, lConfigFileName, lLogFileName));
if (exArgs->showConfigDialog) {
if (!lRoot->showConfigDialog()) {
return 0;
}
}
Ogre::String lWindowTitle = "STS";
Ogre::String lCustomCapacities = "";
/* Check for the valid ogre.cfg */
bool lCreateAWindowAutomatically = lRoot->restoreConfig();
if (!lCreateAWindowAutomatically) {
initSomeRenderSystem(lRoot);
}
Ogre::RenderWindow* lWindow = lRoot->initialise(lCreateAWindowAutomatically, lWindowTitle, lCustomCapacities);
if (!lWindow) {
/* ogre.cfg is not available - start with hardcoded parameters */
unsigned int lSizeX = 800;
unsigned int lSizeY = 600;
bool lFullscreen = false;
Ogre::NameValuePairList lParams;
lParams["FSAA"] = "0";
lParams["vsync"] = "true";
lWindow = lRoot->createRenderWindow(lWindowTitle, lSizeX, lSizeY, lFullscreen, &lParams);
}
/* Create a scene manager */
Ogre::SceneManager* lScene = lRoot->createSceneManager(Ogre::ST_GENERIC, "SceneManager");
Ogre::SceneNode* lRootSceneNode = lScene->getRootSceneNode();
/* Create camera */
Ogre::Camera* lCamera = lScene->createCamera("MyCamera");
/* Create viewport (camera <-> window) */
Ogre::Viewport* vp = lWindow->addViewport(lCamera);
vp->setAutoUpdated(true);
vp->setBackgroundColour(Ogre::ColourValue(1, 0, 1));
lCamera->setAspectRatio(float(vp->getActualWidth()) / vp->getActualHeight());
lCamera->setPosition(Ogre::Vector3(0, 100, -1));
lCamera->lookAt(Ogre::Vector3(0, 0, 0));
/* Set clipping*/
lCamera->setNearClipDistance(1.5f);
lCamera->setFarClipDistance(3000.0f);
/* Lighting */
Ogre::Light* lLight = lScene->createLight("MainLight");
lLight->setPosition(Ogre::Vector3(0, 100, 0));
/* Resource manager */
Ogre::String lRcGroupName = "Main group";
initResourceMainGroup(lRcGroupName);
/* Load model */
Ogre::Entity* lShipEntity = lScene->createEntity("airship.mesh");
lShipEntity->setCastShadows(false);
Ogre::SceneNode* lShipNode = lRootSceneNode->createChildSceneNode();
lShipNode->attachObject(lShipEntity);
lShipNode->setScale(Ogre::Vector3(3.15f, 3.15f, 3.15f));
/* Starship start point */
Ogre::Vector3 razorSP(0, -200, -100);
lShipNode->setPosition(razorSP);
/* Sprite billboard */
Ogre::SceneNode* lSpriteNode = lRootSceneNode->createChildSceneNode();
Ogre::BillboardSet* lBillboardSet = lScene->createBillboardSet();
lBillboardSet->setMaterialName("enemy_01", lRcGroupName);
lBillboardSet->setTextureStacksAndSlices(1, 4);
Ogre::Billboard* lSpriteBillboard = lBillboardSet->createBillboard(Ogre::Vector3(0, 0, 0));
lSpriteBillboard->setDimensions(48.0f / 2.0f, 58.0f / 2.0f);
lSpriteBillboard->setTexcoordIndex(1);
lSpriteNode->attachObject(lBillboardSet);
//.........这里部分代码省略.........