本文整理汇总了C++中ogre::SceneNode::createChildSceneNode方法的典型用法代码示例。如果您正苦于以下问题:C++ SceneNode::createChildSceneNode方法的具体用法?C++ SceneNode::createChildSceneNode怎么用?C++ SceneNode::createChildSceneNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SceneNode
的用法示例。
在下文中一共展示了SceneNode::createChildSceneNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createScene
//-------------------------------------------------------------------------------------
void TutorialApplication::createScene(void)
{
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.25, 0.25, 0.25));
// add the ninja
Ogre::Entity *ent = mSceneMgr->createEntity("Ninja", "ninja.mesh");
Ogre::SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode("NinjaNode");
node->attachObject(ent);
// create the light
Ogre::Light *light = mSceneMgr->createLight("Light1");
light->setType(Ogre::Light::LT_POINT);
light->setPosition(Ogre::Vector3(250, 150, 250));
light->setDiffuseColour(Ogre::ColourValue::White);
light->setSpecularColour(Ogre::ColourValue::White);
// Create the scene node
node = mSceneMgr->getRootSceneNode()->createChildSceneNode("CamNode1", Ogre::Vector3(-400, 200, 400));
// Make it look towards the ninja
node->yaw(Ogre::Degree(-45));
// Create the pitch node
node = node->createChildSceneNode("PitchNode1");
node->attachObject(mCamera);
// create the second camera node/pitch node
node = mSceneMgr->getRootSceneNode()->createChildSceneNode("CamNode2", Ogre::Vector3(0, 200, 400));
node = node->createChildSceneNode("PitchNode2");
}
示例2: testModelMountScaling
void ModelMountTestCase::testModelMountScaling()
{
Ogre::Root root;
Ogre::SceneManager* sceneManager = root.createSceneManager(Ogre::ST_GENERIC);
TestModel model(*sceneManager);
//First test with a straight forward case.
Ogre::SceneNode* node = sceneManager->getRootSceneNode()->createChildSceneNode();
//We get an error when it's destroyed. So we don't destroy it.
SceneNodeProvider* nodeProvider = new SceneNodeProvider(node, nullptr);
Model::ModelMount mount(model, nodeProvider);
scaleAndTestMount(model, mount, nodeProvider->getNode());
//Test with the parent node being scaled
node->setScale(Ogre::Vector3(3.0f, 0.2f, 200.0f));
Ogre::SceneNode* subNode = node->createChildSceneNode();
nodeProvider = new SceneNodeProvider(subNode, nullptr);
Model::ModelMount mount2(model, nodeProvider);
scaleAndTestMount(model, mount2, nodeProvider->getNode());
//Test with the parent node being scaled and rotated
node->setScale(Ogre::Vector3(3.0f, 0.2f, 200.0f));
node->yaw(Ogre::Degree(42));
node->pitch(Ogre::Degree(76));
node->roll(Ogre::Degree(98));
subNode = node->createChildSceneNode();
nodeProvider = new SceneNodeProvider(subNode, nullptr);
Model::ModelMount mount3(model, nodeProvider);
scaleAndTestMount(model, mount3, nodeProvider->getNode());
}
示例3: instance
TwoBogieVehicle* instance(){
UniqueIdGenerator& gen = UniqueIdGenerator::getSingleton();
Entity* fBogie = mFrontBogie->clone(mFrontBogieEntityName+gen.getAsHexadecimal());
SceneNode* fBogieN = mTargetGround->createChildSceneNode();
fBogieN->attachObject(fBogie);
fBogieN->setScale(mFrontBogieScale);
Entity* rBogie = mRearBogie->clone(mRearBogieEntityName+gen.getAsHexadecimal());
SceneNode* rBogieN = mTargetGround->createChildSceneNode();
rBogieN->attachObject(rBogie);
rBogieN->setScale(mRearBogieScale);
Entity* body = mBody->clone(mBodyEntityName+gen.getAsHexadecimal());
SceneNode* bodyN = mTargetGround->createChildSceneNode(Ogre::Vector3(0.0f,1,0.0f));
bodyN->setScale(mBodyScale);
bodyN->attachObject(body);
// Initial body rotation
//bodyN->roll(Ogre::Radian(-Ogre::Math::HALF_PI));
if (mBodyRotate.x) {
bodyN->rotate(Ogre::Vector3::UNIT_X, Ogre::Radian(mBodyRotate.x));
}
if (mBodyRotate.y) {
bodyN->rotate(Ogre::Vector3::UNIT_Y, Ogre::Radian(mBodyRotate.y));
}
if (mBodyRotate.z) {
bodyN->rotate(Ogre::Vector3::UNIT_Z, Ogre::Radian(mBodyRotate.z));
}
return new TwoBogieVehicle( fBogieN,fBogie,rBogieN,rBogie,bodyN,body,mGapSize,mLength,mFrontBogieOffset,mRearBogieOffset,mBogieHeight );
}
示例4: show
void Board::show(Ogre::SceneNode* const node)
{
// corner node of a level
Ogre::SceneNode* levNode = 0;
Ogre::SceneNode* rowNode = 0;
Ogre::SceneNode* colNode = 0;
// index of the square in the vector of squares
unsigned int i = 0;
for(unsigned int level = 0; level < m_model->getLevels(); ++level)
{
levNode = (levNode == 0) ? node : levNode->createChildSceneNode();
for(unsigned int row = 0; row < m_model->getRows(); ++row)
{
rowNode = (rowNode == 0 || row == 0) ? levNode : rowNode->createChildSceneNode();
for(unsigned int col = 0; col < m_model->getCols(); ++col, ++i)
{
colNode = (col == 0) ? rowNode : colNode->createChildSceneNode();
Ogre::Vector3 squareOrigin = colNode->getPosition();
Color squareColor = ((row + col + level) % 2 == 0) ? COLOR_WHITE : COLOR_BLACK;
m_squares[i] = new Square(colNode, squareColor);
// correctly position the node
if(level > 0 && row == 0 && col == 0)
// raise the square
squareOrigin.y += LEVEL_MARGIN;
else if(row > 0 && col == 0)
// add a row to the board
squareOrigin.z -= m_squares[i]->getEntity()->getBoundingBox().getSize().z;
else
// add a cell to a column of the board
squareOrigin.x += m_squares[i]->getEntity()->getBoundingBox().getSize().x;
// update the node's position accordingly
colNode->setPosition(squareOrigin);
}
}
}
// finally we center the entire board over the x and z axis
// take a single square for reference
Square* refSquare = m_squares[0];
Ogre::Vector3 boardOrigin = node->getPosition();
boardOrigin.x -= (refSquare->getEntity()->getBoundingBox().getSize().x * m_model->getCols()) / 2.0;
boardOrigin.z += (refSquare->getEntity()->getBoundingBox().getSize().z * m_model->getRows()) / 2.0;
node->setPosition(boardOrigin);
}
示例5:
void AWGraphics::SceneDirector::createPlayer()
{
// Add player entity to the scene
Ogre::Entity* ogreEntity = mSceneMgr->createEntity("ogrehead.mesh");
Ogre::SceneNode* parentNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Ogre::SceneNode* ogreNode = parentNode->createChildSceneNode();
ogreNode->attachObject(ogreEntity);
ogreNode->rotate(Ogre::Vector3(0.0, 1.0, 0.0), Ogre::Radian(Ogre::Degree(180)));
ogreNode->setPosition(0, 80, 0);
mPlayerNode = parentNode;
// Initialize and add a light
mSceneMgr->setAmbientLight(Ogre::ColourValue(.5, .5, .5));
Ogre::Light* light = mSceneMgr->createLight("MainLight");
light->setType(Ogre::Light::LT_DIRECTIONAL);
light->setDirection(Ogre::Vector3(0, -1, 1));
/*// Directional light
Ogre::Light* directionalLight = mSceneMgr->createLight("DirectionalLight");
directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
directionalLight->setDiffuseColour(Ogre::ColourValue(.8, .6, .2));
directionalLight->setSpecularColour(Ogre::ColourValue(.8, .6, .2));
*/
// Add skydome
mSceneMgr->setSkyDome(true, "CloudySky", 5, 8); // cannot find... :(
}
示例6:
Ogre::SceneNode *VEffect::createSceneNode()
{
if (mBaseNode != VNULL)
return mBaseNode;
VGraphicsSystem *gfxSystem = VENGINE.getGfxSystem();
assert(gfxSystem != VNULL);
Ogre::SceneNode *baseNode = gfxSystem->getBaseSceneNode();
assert(baseNode != VNULL);
mBaseNode = baseNode->createChildSceneNode();
assert(mBaseNode != VNULL);
VElementIterator itr = mElements.begin();
while (itr != mElements.end())
{
if (*itr)
{
(*itr)->createSceneNode(mBaseNode);
}
++itr;
}
return mBaseNode;
}
示例7: createProjectile
void ProjectileManager::createProjectile(const Ogre::Vector3& tankPosition, const Ogre::Quaternion& turretOrientation,
const Ogre::Degree& angle, const float& velocity, const float& dmg){
std::ostringstream oss;
oss << "Projectile" << time(0) << projectiles.size() << counter++;
Ogre::ParticleSystem* particleSystem = mSceneMgr->createParticleSystem(oss.str(), "Examples/PurpleFountain");
scaleBy(1.f, particleSystem);
Ogre::SceneNode* parentParticleSn = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Ogre::SceneNode* particleSn = parentParticleSn->createChildSceneNode();
Ogre::Vector3 start(-115.f, 10.f, 0.f);
parentParticleSn->setPosition(tankPosition);
particleSn->setPosition(start);
parentParticleSn->yaw(turretOrientation.getYaw());
particleSn->attachObject(particleSystem);
particleSn->roll(Ogre::Degree(-90.f));
particleSn->scale(Ogre::Vector3(0.1f));
projectiles.insert(new Projectile(start, particleSn, angle, velocity, dmg));
}
示例8: insertBegin
void Actors::insertBegin(const MWWorld::Ptr &ptr)
{
Ogre::SceneNode* cellnode;
CellSceneNodeMap::const_iterator celliter = mCellSceneNodes.find(ptr.getCell());
if(celliter != mCellSceneNodes.end())
cellnode = celliter->second;
else
{
//Create the scenenode and put it in the map
cellnode = mRootNode->createChildSceneNode();
mCellSceneNodes[ptr.getCell()] = cellnode;
}
Ogre::SceneNode* insert = cellnode->createChildSceneNode();
const float *f = ptr.getRefData().getPosition().pos;
insert->setPosition(f[0], f[1], f[2]);
insert->setScale(ptr.getCellRef().mScale, ptr.getCellRef().mScale, ptr.getCellRef().mScale);
// Convert MW rotation to a quaternion:
f = ptr.getCellRef().mPos.rot;
// Rotate around X axis
Ogre::Quaternion xr(Ogre::Radian(-f[0]), Ogre::Vector3::UNIT_X);
// Rotate around Y axis
Ogre::Quaternion yr(Ogre::Radian(-f[1]), Ogre::Vector3::UNIT_Y);
// Rotate around Z axis
Ogre::Quaternion zr(Ogre::Radian(-f[2]), Ogre::Vector3::UNIT_Z);
// Rotates first around z, then y, then x
insert->setOrientation(xr*yr*zr);
ptr.getRefData().setBaseNode(insert);
}
示例9: _prepare
//-----------------------------------------------------------------------
void EntityRenderer::_prepare(ParticleTechnique* technique)
{
/**
- This renderer is a ´hacky´ solution to display geometry-based particles. It pre-creates a
number of SceneNodes (childs of the parent Node to which the ParticleSystem is attached) and
Entities and uses these pools to display the particles. There are better solutions, but
this one is simple and fast enough, although it has some drawbacks.
- Future solutions should rather make use of hardware instancing to display a large number of
geometry-based particles at once.
*/
// Use the given technique, although it should be the same as mParentTechnique (must be set already)
if (!technique || mRendererInitialised)
return;
std::stringstream ss;
ss << this;
mEntityName = mMeshName + ss.str();
mQuota = technique->getVisualParticleQuota();
Ogre::SceneNode* parentNode = technique->getParentSystem()->getParentSceneNode();
Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().load(mMeshName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::Mesh* meshPointer = mesh.getPointer();
Vector3 size = meshPointer->getBounds().getSize();
mBoxWidth = size.x == 0.0f ? 1.0f : size.x;
mBoxHeight = size.y == 0.0f ? 1.0f : size.y;
mBoxDepth = size.z == 0.0f ? 1.0f : size.z;
if (parentNode)
{
// Create number of VisualData objects including SceneNodes
String sceneNodeName;
for (size_t i = 0; i < mQuota; i++)
{
sceneNodeName = "ParticleUniverse" + ss.str() + StringConverter::toString(i);
EntityRendererVisualData* visualData =
PU_NEW_T(EntityRendererVisualData, MEMCATEGORY_SCENE_OBJECTS)(parentNode->createChildSceneNode(sceneNodeName));
mAllVisualData.push_back(visualData); // Managed by this renderer
mVisualData.push_back(visualData); // Used to assign to a particle
}
// Create number of Entities
Ogre::Entity* entity = technique->getParentSystem()->getSceneManager()->createEntity(mEntityName, mMeshName); // Base entity
vector<EntityRendererVisualData*>::const_iterator it;
vector<EntityRendererVisualData*>::const_iterator itEnd = mAllVisualData.end();
size_t j;
for (it = mAllVisualData.begin(), j = 0; it != itEnd; ++it, ++j)
{
Ogre::Entity* clonedEntity = entity->clone(mEntityName + StringConverter::toString(j));
clonedEntity->setMaterialName(technique->getMaterialName());
clonedEntity->setRenderQueueGroup(mQueueId);
mEntities.push_back(clonedEntity);
(*it)->node->attachObject(clonedEntity);
}
technique->getParentSystem()->getSceneManager()->destroyEntity(mEntityName);
}
_makeNodesVisible(false);
mRendererInitialised = true;
}
示例10: getBase
Ogre::SceneNode * WheelAnimalSceneObj::getBaseCenter()
{
if(_sn == NULL)
{
_sn = Orz::OgreGraphicsManager::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(getCenterPoint());
//_sn->yaw(Ogre::Radian(Ogre::Math::PI));
for(int i=0 ; i<(BASE_ALL-BASE_0); ++i)
{
Ogre::SceneNode * base = getBase(i);
Ogre::Node * parent = base->getParent();
Ogre::Vector3 p = base->getPosition();
if(parent)
{
parent->removeChild(base);
}
base->translate(-getCenterPoint());
_sn->addChild(base);
Ogre::SceneManager * sm = OgreGraphicsManager::getSingleton().getSceneManager();
Ogre::Entity * ent = sm->createEntity("ring"+Ogre::StringConverter::toString(i), "zp_dwdzgh.mesh");
Ogre::SceneNode * node = base->createChildSceneNode("ring"+Ogre::StringConverter::toString(i),Ogre::Vector3(0.f, 10.f, 0.f));
node->setScale(0.6f,0.6f,0.6f);
node->attachObject(ent);
Orz::OgreGraphicsManager::getSingleton().getSceneManager()->getSceneNode("ring"+Ogre::StringConverter::toString(i))->setVisible(false);
}
}
return _sn;
}
示例11: DrawNewCore
void TestGame::DrawNewCore(Logic::CoreBuiltEvnt *evnt){
Ogre::Entity* drop= mSceneMgr->createEntity("Mesh"+evnt->building->mSysName, "BaseDropNew.mesh");
drop->setCastShadows(true);
const Ogre::AxisAlignedBox test =drop->getBoundingBox();
Control::ClickHelper* helpr = new Control::ClickHelper(Logic::CHT_BUILDING);
helpr->target = evnt->building;
drop->setUserAny(Ogre::Any(helpr));
Ogre::SceneNode *coreNode = evnt->country->mNode->createChildSceneNode();
Ogre::Vector3 tempvect = calculateActualPointFromCenter(evnt->country->mCapital.mPosition,evnt->tile->mPosition);
tempvect= tempvect*TILESIZE;
coreNode->attachObject(drop);
coreNode->translate(tempvect);
coreNode->pitch(Ogre::Degree(90));
coreNode->scale(0.5,0.5,0.5);
Ogre::AnimationState* temp= drop->getAnimationState("drop");
temp->setLoop(false);
temp->setEnabled(true);
mAllAnimation .insert(temp);
Ogre::Entity* basePlane= mSceneMgr->createEntity("MeshBaseFloor"+evnt->building->mSysName, "BaseCloseLook.mesh");
basePlane->setMaterialName("BaseCloseLook/Rockwall");
Ogre::SceneNode *BaseDraw = evnt->country->mNode->createChildSceneNode(),*camspot;
BaseDraw->attachObject(basePlane);
BaseDraw->translate(2000*evnt->building->mSlot,0,0);
camspot = BaseDraw->createChildSceneNode("CamPoint_"+evnt->building->mSysName);
camspot->setPosition(0,45,45);
camspot->lookAt(Ogre::Vector3(0,0,0), Ogre::Node::TS_PARENT);
helpr = new Control::ClickHelper(Logic::CHT_EMPTYSPACE);
helpr->target = evnt->building;
basePlane->setUserAny(Ogre::Any(helpr));
}
示例12: _prepare
//-----------------------------------------------------------------------
void SceneDecoratorExtern::_prepare(ParticleTechnique* technique)
{
if (mEntitySet)
{
if (!mParentTechnique->getParentSystem())
{
return;
}
// Attach entity to a child scenenode. If the parent system is attached to a TagPoint, the entity cannot be attached.
Ogre::SceneNode* sceneNode = mParentTechnique->getParentSystem()->getParentSceneNode();
if (sceneNode)
{
std::stringstream ss;
ss << this;
String sceneNodeName = "ParticleUniverse" + ss.str() + StringConverter::toString(mCount++);
mSubnode = sceneNode->createChildSceneNode(sceneNodeName);
mSubnode->setScale(mScale);
mSubnode->setPosition(mPosition);
if (!mEntity)
{
createEntity();
mSubnode->attachObject(mEntity);
}
}
}
}
示例13: mNode
SceneNodeProvider::SceneNodeProvider(Ogre::SceneNode& parentNode, Ogre::MovableObject* object) :
mParentNode(parentNode), mNode(0), mAttachedObject(object)
{
mNode = parentNode.createChildSceneNode();
if (mAttachedObject) {
mAttachedObject->detachFromParent();
mNode->attachObject(mAttachedObject);
}
}
示例14: updateRain
void SkyManager::updateRain(float dt)
{
// Move existing rain
// Note: if rain gets disabled, we let the existing rain drops finish falling down.
float minHeight = 200;
for (std::map<Ogre::SceneNode*, NifOgre::ObjectScenePtr>::iterator it = mRainModels.begin(); it != mRainModels.end();)
{
Ogre::Vector3 pos = it->first->getPosition();
pos.z -= mRainSpeed * dt;
it->first->setPosition(pos);
if (pos.z < -minHeight)
{
it->second.setNull();
Ogre::SceneNode* parent = it->first->getParentSceneNode();
mSceneMgr->destroySceneNode(it->first);
mSceneMgr->destroySceneNode(parent);
mRainModels.erase(it++);
}
else
++it;
}
// Spawn new rain
float rainFrequency = mRainFrequency;
float startHeight = 700;
if (mRainEnabled)
{
mRainTimer += dt;
if (mRainTimer >= 1.f/rainFrequency)
{
mRainTimer = 0;
const float rangeRandom = 100;
float xOffs = (std::rand()/(RAND_MAX+1.0)) * rangeRandom - (rangeRandom/2);
float yOffs = (std::rand()/(RAND_MAX+1.0)) * rangeRandom - (rangeRandom/2);
Ogre::SceneNode* sceneNode = mCamera->getParentSceneNode()->createChildSceneNode();
sceneNode->setInheritOrientation(false);
// Create a separate node to control the offset, since a node with setInheritOrientation(false) will still
// consider the orientation of the parent node for its position, just not for its orientation
Ogre::SceneNode* offsetNode = sceneNode->createChildSceneNode(Ogre::Vector3(xOffs,yOffs,startHeight));
NifOgre::ObjectScenePtr objects = NifOgre::Loader::createObjects(offsetNode, mRainEffect);
for (unsigned int i=0; i<objects->mEntities.size(); ++i)
{
objects->mEntities[i]->setRenderQueueGroup(RQG_Alpha);
objects->mEntities[i]->setVisibilityFlags(RV_Sky);
}
for (unsigned int i=0; i<objects->mParticles.size(); ++i)
{
objects->mParticles[i]->setRenderQueueGroup(RQG_Alpha);
objects->mParticles[i]->setVisibilityFlags(RV_Sky);
}
mRainModels[offsetNode] = objects;
}
}
}
示例15: createInstance
Monster* MonsterFactory::createInstance(SceneManager* sceneMgr, Maze* maze, MonsterManager* monsterMgr)
{
Ogre::SceneNode* monsterNode = sceneMgr->getRootSceneNode()->createChildSceneNode();
Ogre::Entity* entity = sceneMgr->createEntity(mParams["mesh"]);
//entity->setCastShadows(true);
monsterNode->attachObject(entity);
Monster* mon;
mon = new Monster(monsterNode, entity, maze, monsterMgr);
if (mParams.find("radius") != mParams.end())
mon->setRadius((float)atof(mParams["radius"].c_str()));
if (mParams.find("blood") != mParams.end())
{
mon->setBlood((float)atof(mParams["blood"].c_str()));
mon->setMaxBlood(mon->getBlood());
}
if (mParams.find("speed") != mParams.end())
mon->setSpeed((float)atof(mParams["speed"].c_str()));
if (mParams.find("spell") != mParams.end())
mon->setType((mParams["spell"].c_str()));
if (mParams.find("scale") != mParams.end())
{
float scale = (float)atof(mParams["scale"].c_str());
mon->setScale(scale, scale, scale);
}
//mon->setScale(2, 2, 2);
// 创建怪物头顶血条
BillboardSet* healthHUD = sceneMgr->createBillboardSet();
healthHUD->setMaterialName("Glass/Billboard");
healthHUD->setDefaultWidth(100);
healthHUD->setDefaultHeight(14);
SceneNode* hudNode = monsterNode->createChildSceneNode();
hudNode->attachObject(healthHUD);
/*Billboard* b2 = healthHUD->createBillboard(0, entity->getBoundingBox().getSize().y, 0);
b2->setColour(ColourValue::Black);*/
Billboard* b = healthHUD->createBillboard(0, entity->getBoundingBox().getSize().y, 0);
//b->setColour(ColourValue(0, 0.75f, 0));
//b->setDimensions(96, 12);
mon->setHealthHUD(healthHUD);
// 测试粒子by kid
Ogre::ParticleSystem* ps = sceneMgr->createParticleSystem(monsterNode->getName() + "frozen", "Glass/MonsterFrozen");
monsterNode->attachObject(ps);
ps->setVisible(false);
ps = sceneMgr->createParticleSystem(monsterNode->getName() + "burn", "Glass/MonsterBurn");
monsterNode->attachObject(ps);
ps->setVisible(false);
return mon;
}