本文整理汇总了C++中ogre::SceneNode::attachObject方法的典型用法代码示例。如果您正苦于以下问题:C++ SceneNode::attachObject方法的具体用法?C++ SceneNode::attachObject怎么用?C++ SceneNode::attachObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SceneNode
的用法示例。
在下文中一共展示了SceneNode::attachObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: allocateCloudsAndNodes
void SparseOccupancyGridArrayDisplay::allocateCloudsAndNodes(const size_t num)
{
if (num > clouds_.size()) { // need to allocate new node and clouds
for (size_t i = clouds_.size(); i < num; i++) {
Ogre::SceneNode* node = scene_node_->createChildSceneNode();
rviz::PointCloud* cloud = new rviz::PointCloud();
cloud->setRenderMode(rviz::PointCloud::RM_TILES);
cloud->setCommonDirection( Ogre::Vector3::UNIT_Z );
cloud->setCommonUpVector( Ogre::Vector3::UNIT_Y );
node->attachObject(cloud);
clouds_.push_back(cloud);
nodes_.push_back(node);
}
}
else if (num < clouds_.size()) // need to destroy
{
for (size_t i = num; i < clouds_.size(); i++) {
nodes_[i]->detachObject(clouds_[i]);
delete clouds_[i];
scene_manager_->destroySceneNode(nodes_[i]);
}
clouds_.resize(num);
nodes_.resize(num);
}
}
示例2: allocateTexts
void FootstepDisplay::allocateTexts(size_t num) {
if (num > texts_.size()) {
// need to allocate
for (size_t i = texts_.size(); i < num; i++) {
// create nodes
Ogre::SceneNode* node = scene_node_->createChildSceneNode();
rviz::MovableText* text
= new rviz::MovableText("not initialized", "Arial", 0.05);
text->setVisible(false);
text->setTextAlignment(rviz::MovableText::H_CENTER,
rviz::MovableText::V_ABOVE);
text->setCaption("hello world");
node->attachObject(text);
texts_.push_back(text);
text_nodes_.push_back(node);
}
}
else if (num < texts_.size()) {
for (size_t i = texts_.size() - 1; i >= num; i--) {
Ogre::SceneNode* node = text_nodes_[i];
node->removeAndDestroyAllChildren();
node->detachAllObjects();
scene_manager_->destroySceneNode(node);
}
text_nodes_.resize(num);
texts_.resize(num);
}
}
示例3: createBox
void createBox(std::string name, dReal x, dReal y, dReal z) {
Ogre::Entity* e;
e=sceneMgr_->createEntity(name.c_str(), "cube.mesh");
Ogre::SceneNode* n;
n=sceneMgr_->getRootSceneNode()->createChildSceneNode(name.c_str());
n->attachObject(e);
n->scale(0.02, 0.02, 0.02);
e->setMaterialName("Car/Subframe");
dBodyID b;
dGeomID g;
dMass m;
static dContact contact=boxContact();
g = World::getSingletonPtr()->addBox(2.0, 2.0, 2.0);
dMassSetBox (&m, 1 ,2.0, 2.0, 2.0);
b=World::getSingletonPtr()->add(g,&m);
dGeomSetData(g,(void*)&contact);
names.push_back(name);//for updating
geoms.push_back(g);
dBodySetPosition (b, x, y, z);
MyTools::byOdeToOgre(b, n);
}
示例4: setEntity
void OgreEntityRenderer::setEntity(Ogre::Entity* entity)
{
mActiveAnimation = nullptr;
Ogre::SceneNode* node = mTexture->getRenderContext()->getSceneNode();
node->detachAllObjects();
if (mEntity) {
if (mMeshListener) {
mEntity->getMesh()->removeListener(mMeshListener);
}
if (mEntity->hasSkeleton()) {
mEntity->getSkeleton()->removeListener(mSkeletonListener);
}
}
mSkeletonDisplay.reset();
if (entity) {
node->attachObject(entity);
mTexture->getRenderContext()->repositionCamera();
if (mAutoShowFull) {
showFull();
}
entity->getMesh()->addListener(mMeshListener);
if (entity->hasSkeleton()) {
entity->getSkeleton()->addListener(mSkeletonListener);
if (mShowSkeleton) {
mSkeletonDisplay.reset(new SkeletonDisplay(*entity));
}
}
}
}
示例5: createBall
void createBall(std::string name, dReal x, dReal y, dReal z) {
Ogre::Entity* e;
e=sceneMgr_->createEntity(name.c_str(), "sphere.mesh");
Ogre::SceneNode* n;
n=sceneMgr_->getRootSceneNode()->createChildSceneNode(name.c_str());
n->attachObject(e);
n->scale(0.03, 0.03, 0.03);
e->setMaterialName("MyOwn/Sphere");
dBodyID b;
dGeomID g;
dMass m;
static dContact contact=ballContact();
g = World::getSingletonPtr()->addSphere(3.0);
dMassSetSphere (&m,1,3.0);
b=World::getSingletonPtr()->add(g,&m);
dGeomSetData(g,(void*)&contact);
names.push_back(name);
geoms.push_back(g);
dBodySetPosition (b, x, y, z);
MyTools::byOdeToOgre(b, n);
}
示例6: createBox
void SelectionHandler::createBox(const std::pair<CollObjectHandle, uint64_t>& handles, const Ogre::AxisAlignedBox& aabb, const std::string& material_name)
{
Ogre::WireBoundingBox* box = 0;
Ogre::SceneNode* node = 0;
M_HandleToBox::iterator it = boxes_.find(handles);
if (it == boxes_.end())
{
Ogre::SceneManager* scene_manager = manager_->getSceneManager();
node = scene_manager->getRootSceneNode()->createChildSceneNode();
box = new Ogre::WireBoundingBox;
bool inserted = boxes_.insert(std::make_pair(handles, std::make_pair(node, box))).second;
ROS_ASSERT(inserted);
}
else
{
node = it->second.first;
box = it->second.second;
}
box->setMaterial(material_name);
box->setupBoundingBox(aabb);
node->detachAllObjects();
node->attachObject(box);
}
示例7: createTerrainLiquid
//-----------------------------------------------------------------------
void TerrainLiquidObject::createTerrainLiquid(void)
{
assert(!mTerrainLiquid);
assert(mProjectionMaterial.isNull());
assert(!mProjectionCamera);
assert(mSystem);
assert(!mMaterialName.empty());
Ogre::SceneNode* parent = mSystem->getBaseSceneNode()->createChildSceneNode();
assert(parent);
mTerrainLiquid = new TerrainLiquid(mSystem, mPosition, mSubdivision, TERRAIN_LIQUID_VERTEX_LIMIT, mDiffuse, mAdjustDepth, mMatSpecular, mShininess);
assert(mTerrainLiquid);
parent->attachObject(mTerrainLiquid);
mTerrainLiquid->setTexcoordScale(mTexcoordScale);
mTerrainLiquid->setTexcoordRotate(Ogre::Radian(mTexcoordRotate));
mTerrainLiquid->setDepthTexLayerSettings(
mDepthTexLayerEnabled,
mDepthTexLayerScale,
mDepthTexLayerAdjust);
_createRenderTexture();
_setReflectPlane();
_prepareProjector();
if (!mProjectionMaterial.isNull())
mTerrainLiquid->setMaterialName(mProjectionMaterial->getName());
else
mTerrainLiquid->setMaterialName(mMaterialName);
}
示例8: OnEditsceneAddentity
void CSceneEditorView::OnEditsceneAddentity()
{
CEntityCreatorDlg EntityCreatorDlg;
if (IDOK == EntityCreatorDlg.DoModal())
{
HTREEITEM Selected = m_SceneManagerDlg->m_SceneTree.GetSelectedItem();
m_SceneManagerDlg->m_SceneTree.InsertItem(EntityCreatorDlg.m_EntityName, Selected);
Ogre::String SceneNodeName = m_SceneManagerDlg->m_SceneTree.GetItemText(Selected);
Ogre::Entity *Entity = m_SceneManager->createEntity(Ogre::String(EntityCreatorDlg.m_EntityName), Ogre::String(EntityCreatorDlg.m_MeshName));
Ogre::SceneNode *SceneNode = m_SceneManager->getSceneNode(SceneNodeName);
SceneNode->attachObject(Entity);
Ogre::AxisAlignedBox Box = Entity->getBoundingBox();
Ogre::Vector3 Center = Box.getCenter();
m_Camera->lookAt(Center);
m_SceneManagerDlg->m_SceneTree.Expand(Selected, TVE_EXPAND);
if (m_Root != NULL)
{
m_Root->renderOneFrame();
}
}
}
开发者ID:southerlies,项目名称:OGRE-3D-1.7-Application-Development-Cookbook-Code,代码行数:26,代码来源:SceneEditorView.cpp
示例9: run
void Game::run()
{
if (!ogreRoot)
return;
if (!ogreRoot->showConfigDialog())
return;
ogreRoot->initialise(true, "OgreWindow");
createWindow();
createSceneManager();
createCamera();
createViewport();
createInput();
setupResourceManager();
Ogre::Entity *ogreHead = sceneManager->createEntity("OgreHead", "T80_obj.mesh");
Ogre::SceneNode *ogreHeadNode = sceneManager->getRootSceneNode()
->createChildSceneNode("Head Node", Ogre::Vector3(-50.0f, 30.0f, 0.0f));
ogreHeadNode->attachObject(ogreHead);
Ogre::Light *directionalLight = sceneManager->createLight("DirectionalLight");
directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
directionalLight->setDiffuseColour(Ogre::ColourValue(.4, 0, 0));
directionalLight->setSpecularColour(Ogre::ColourValue(.4, 0, 0));
directionalLight->setDirection(Ogre::Vector3(0, -1, 1));
ogreRoot->addFrameListener(this);
ogreRoot->startRendering();
}
示例10: createRadiusObject
void NavViewPanel::createRadiusObject()
{
static int count = 0;
std::stringstream ss;
ss << "NavViewRadius" << count++;
radius_object_ = scene_manager_->createManualObject( ss.str() );
Ogre::SceneNode* node = root_node_->createChildSceneNode();
node->attachObject( radius_object_ );
radius_object_->begin( "BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_STRIP );
{
Ogre::ColourValue color( 0.2, 1.0, 0.4 );
for( float f = 0; f < Ogre::Math::TWO_PI; f += 0.5f )
{
radius_object_->position( ROBOT_RADIUS * cos(f), ROBOT_RADIUS * sin(f), 0.0f );
radius_object_->colour(color);
}
radius_object_->position( ROBOT_RADIUS , 0.0f, 0.0f );
radius_object_->colour(color);
radius_object_->position( 0.0f, 0.0f, 0.0f );
radius_object_->colour(color);
}
radius_object_->end();
updateRadiusPosition();
}
示例11:
Shuriken::Shuriken(Ogre::SceneManager* mSceneMgr, Ogre::SceneNode* parentNode, PhysicsEngine* bulletEngine, const Ogre::Vector3& pos, bool isTennis) :
graphicsEngine(mSceneMgr),
positionNode(0),
active(true),
physicsEngine(bulletEngine),
colliding(false),
shooting(false)
{
Ogre::Real ratio = SIZE_REGULAR_SHURIKEN;
if(isTennis){
entShuriken = mSceneMgr->createEntity(Ogre::SceneManager::PT_SPHERE);
entShuriken->setMaterialName("Examples/TennisBall");
ratio = ratio/100;
} else
entShuriken = mSceneMgr->createEntity("Shuriken.mesh");
entShuriken->setCastShadows(true);
positionNode = parentNode->createChildSceneNode(pos);
Ogre::SceneNode* tempNode = positionNode->createChildSceneNode();
tempNode->attachObject(entShuriken);
tempNode->scale(ratio, ratio, ratio);
physicsObject.setToSphere(
SIZE_REGULAR_SHURIKEN,
2,
btQuaternion(0.2f, 0.6f, 0.1f, 1.0f).normalized(),
btVector3(pos.x,pos.y,pos.z)
);
physicsObject.setRestitution(0.99);
physicsObject.setLinearVelocity(btVector3(0,0,0));
physicsObject.setFriction(0.5);
physicsObject.setAngularVelocity(btVector3(0.2f, 0.5f, 0.2f));
physicsEngine->addObject(&physicsObject);
}
示例12: summonEvilBall
void TutorialApplication::summonEvilBall() {
Ogre::Entity* ball = mSceneMgr->createEntity("evilBall");
ball->setMaterialName("Ogre/Skin");
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
node->setPosition(Ogre::Vector3(Ogre::Math::SymmetricRandom() * (AREA_RANGE/2),
Ogre::Math::SymmetricRandom() * (AREA_RANGE/2),
Ogre::Math::SymmetricRandom() * (AREA_RANGE/2)));
node->attachObject(ball);
ShipProject::GameObject* oBall = new ShipProject::GameObject(ball, 2);
oBall->SetupCollision(new btSphereShape(BALL_RADIUS), CollisionGroup::BALLS, CollisionGroup::PLAYER | CollisionGroup::WALLS
| CollisionGroup::BALLS | CollisionGroup::PROJECTILES_PLAYER);
objects_.push_back( oBall );
if (Ogre::Math::UnitRandom() < 0.5) {
oBall->body()->setLinearVelocity( btVector3(Ogre::Math::SymmetricRandom(),
Ogre::Math::SymmetricRandom(),
Ogre::Math::SymmetricRandom()) * Ogre::Math::RangeRandom(0.0, 70.0) );
}
oBall->body()->setRestitution(1.0);
oBall->body()->activate(true);
enemies_[oBall->entity_name()] = Enemy(oBall, Ogre::Math::UnitRandom() * 5);
}
示例13: createScene
//-------------------------------------------------------------------------------------
void TutorialApplication::createScene(void)
{
mElapsedTime = 0;
createPhysics();
createLights();
// create actual soft mesh
string name = "Swimmer";
string path = "swimmer.mesh";
Ogre::Entity* entity = mSceneMgr->createEntity( name, path);
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode( name + ".SceneNode" );
node->attachObject(entity);
node->setPosition(ROOT_POSITION);
// save
mFigureEnt = entity;
mFigureNode = node;
mFigureEnt->getSkeleton()->reset();
// pose controller
loadSkeletonController(SKELETON_CONTROLLER_FILENAME);
}
示例14: createOgreHead
void DPSHelper::createOgreHead(void)
{
Ogre::Vector3 pos = Ogre::Vector3(0,100,0);
Ogre::Quaternion rot = Ogre::Quaternion::IDENTITY;
//Create Ogre stuff.
Ogre::Entity* ogreHeadEntity = mSceneMgr->createEntity("ogrehead.mesh");
Ogre::SceneNode* ogreHeadNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(pos, rot);
ogreHeadNode->attachObject(ogreHeadEntity);
ogreHeadNode->setScale(Ogre::Vector3(1,1,1));
ogreHeadEntity->setCastShadows(true);
//setColor(mNinjaEntity, Ogre::Vector3(0.3021,0.3308,0.3671));
//mNinjaEntity->setMaterialName("Examples/Rockwall");
//Create shape.
BtOgre::StaticMeshToShapeConverter converter(ogreHeadEntity);
//BtOgre::AnimatedMeshToShapeConverter converter(mNinjaEntity);
//mNinjaShape = converter.createTrimesh();
btCollisionShape* ogreHeadShape = converter.createConvex();
//mNinjaShape = converter.createConvex();
//Calculate inertia.
btScalar mass = 1;
btVector3 inertia;
ogreHeadShape->calculateLocalInertia(mass, inertia);
//Create BtOgre MotionState (connects Ogre and Bullet).
BtOgre::RigidBodyState *ogreheadState = new BtOgre::RigidBodyState(ogreHeadNode);
//Create the Body.
btRigidBody* ogreHeadBody = new btRigidBody(mass, ogreheadState, ogreHeadShape, inertia);
phyWorld->addRigidBody(ogreHeadBody);
}
示例15: _drawGridPlane
void _drawGridPlane(void)
{
Ogre::ManualObject* gridPlane = mSceneMgr->createManualObject("GridPlane");
Ogre::SceneNode* gridPlaneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("GridPlaneNode");
Ogre::MaterialPtr gridPlaneMaterial = Ogre::MaterialManager::getSingleton().create("GridPlanMaterial", "General");
gridPlaneMaterial->setReceiveShadows(false);
gridPlaneMaterial->getTechnique(0)->setLightingEnabled(true);
gridPlaneMaterial->getTechnique(0)->getPass(0)->setDiffuse(1, 1, 1, 0);
gridPlaneMaterial->getTechnique(0)->getPass(0)->setAmbient(1, 1, 1);
gridPlaneMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1, 1, 1);
gridPlane->begin("GridPlaneMaterial", Ogre::RenderOperation::OT_LINE_LIST);
for (int i = 0; i < 21; i++)
{
gridPlane->position(-500.0f, 0.0f, 500.0f - i * 50);
gridPlane->position(500.0f, 0.0f, 500.0f - i * 50);
gridPlane->position(-500.f + i * 50, 0.f, 500.0f);
gridPlane->position(-500.f + i * 50, 0.f, -500.f);
}
gridPlane->end();
gridPlaneNode->attachObject(gridPlane);
}