//-------------------------------------------------------------------------------------
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");
}
Esempio n. 2
0
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());
}
	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 );
	}
Esempio n. 4
0
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);
}
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... :(
}
Esempio n. 6
0
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;
}
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));
}
Esempio n. 8
0
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);
}
	//-----------------------------------------------------------------------
	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;
	}
Esempio n. 10
0
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;
}
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));
}
	//-----------------------------------------------------------------------
	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);
				}
			}
		}
	}
Esempio n. 13
0
SceneNodeProvider::SceneNodeProvider(Ogre::SceneNode& parentNode, Ogre::MovableObject* object) :
	mParentNode(parentNode), mNode(0), mAttachedObject(object)
{
	mNode = parentNode.createChildSceneNode();
	if (mAttachedObject) {
		mAttachedObject->detachFromParent();
		mNode->attachObject(mAttachedObject);
	}
}
Esempio n. 14
0
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;
        }
    }
}
Esempio n. 15
0
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;
}
Esempio n. 16
0
void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_)
{
    Ogre::SceneNode* root = mMwRoot;
    Ogre::SceneNode* cellnode;
    if(mCellSceneNodes.find(ptr.getCell()) == mCellSceneNodes.end())
    {
        //Create the scenenode and put it in the map
        cellnode = root->createChildSceneNode();
        mCellSceneNodes[ptr.getCell()] = cellnode;
    }
    else
    {
        cellnode = mCellSceneNodes[ptr.getCell()];
    }

    Ogre::SceneNode* insert = cellnode->createChildSceneNode();
    const float *f = ptr.getRefData().getPosition().pos;

    insert->setPosition(f[0], f[1], f[2]);
    insert->setScale(ptr.getCellRef().scale, ptr.getCellRef().scale, ptr.getCellRef().scale);


    // Convert MW rotation to a quaternion:
    f = ptr.getCellRef().pos.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);

    if (!enabled)
         insert->setVisible (false);
    ptr.getRefData().setBaseNode(insert);
    mIsStatic = static_;
}
Esempio n. 17
0
//--------------------------------------------------------------------------------------
void LapTrainer::createScene(void)
{
		//Create right stick
		Ogre::Entity* StickRight = mSceneMgr->createEntity("StickRight", "instrument_stick.mesh");
		StickRight -> setCastShadows(true);
		Ogre::SceneNode* RightNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("RightNode", Ogre::Vector3(0,0,0),Ogre::Quaternion(1,0,0,0));
		//RightNode->setPosition(Ogre::Vector3(300, 100, 100));
		RightNode->setPosition(Ogre::Vector3(300, 500, 500));//alex
		RightNode->setOrientation(0.383022, -0.383022, 0.821394, -0.178606);//alex
		RightNode->scale( 1, 1, 1); 
		Ogre::SceneNode* child = RightNode->createChildSceneNode("MoveNodeRight");
		child->attachObject(StickRight);
		child->translate(0,0,0);


		//Create left stick
		Ogre::Entity* entPenguin2 = mSceneMgr->createEntity("StickLeft", "instrument_stick.mesh");
		entPenguin2 -> setCastShadows(true);
		Ogre::SceneNode* nodPenguin2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("LeftNode", Ogre::Vector3(0,0,0),Ogre::Quaternion(1,0,0,0));
		//nodPenguin2->setPosition(Ogre::Vector3(-300, 100, 100));
		nodPenguin2->setPosition(Ogre::Vector3(-300, 500, 500));//alex
		//nodPenguin2->setOrientation(0.821394, -0.178606, 0.383022, -0.383022);//alex //this stick is not working
		nodPenguin2->setOrientation(0.821394, -0.178606, 0.383022, -0.383022);//alex //this stick is not working
		nodPenguin2->scale( 1, 1, 1); 
		Ogre::SceneNode* child2 = nodPenguin2->createChildSceneNode("MoveNodeLeft");
		child2->attachObject(entPenguin2);
		child2->translate(0,0,0);

		Ogre::Entity* Element1 = mSceneMgr->createEntity("Element1", "exercise1.mesh");//Place your mesh here
		Element1 -> setCastShadows(true);
		Ogre::SceneNode* Element1Node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Element1Node", Ogre::Vector3(0, -200, 200));//X-Y-Z
		Element1Node->scale( 400, 400, 400); 
		Element1Node->attachObject(Element1);

		Ogre::Entity* Element2 = mSceneMgr->createEntity("Element2", "Sphere002.mesh");//Place your mesh here
		Element2 -> setCastShadows(true);
		//Ogre::SceneNode* Element2Node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Element2Node", Ogre::Vector3(0, 50, 100));//X-Y-Z
		Ogre::SceneNode* Element2Node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Element2Node", Ogre::Vector3(0,0,0),Ogre::Quaternion(1,0,0,0));
		Element2Node->setPosition(Ogre::Vector3(300, 500, 500));
		Element2Node->setOrientation(0.383022, -0.383022, 0.821394, -0.178606);
		Element2Node->scale( 60, 60, 60); 
		Element2Node->attachObject(Element2);

		Ogre::Entity* Element3 = mSceneMgr->createEntity("Element3", "Sphere002.mesh");//Place your mesh here
		Element3 -> setCastShadows(true);
		//Ogre::SceneNode* Element2Node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Element2Node", Ogre::Vector3(0, 50, 100));//X-Y-Z
		Ogre::SceneNode* Element3Node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Element3Node", Ogre::Vector3(0,0,0),Ogre::Quaternion(1,0,0,0));
		Element3Node->setPosition(Ogre::Vector3(-300, 500, 500));
		Element3Node->setOrientation(0.821394, -0.178606, 0.383022, -0.383022);
		Element3Node->scale( 60, 60, 60); 
		Element3Node->attachObject(Element3);


}
Esempio n. 18
0
    void CharacterPreview::setup ()
    {
        mSceneMgr = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);

        // This is a dummy light to turn off shadows without having to use a separate set of shaders
        Ogre::Light* l = mSceneMgr->createLight();
        l->setType (Ogre::Light::LT_DIRECTIONAL);
        l->setDiffuseColour (Ogre::ColourValue(0,0,0));

        /// \todo Read the fallback values from INIImporter (Inventory:Directional*)
        l = mSceneMgr->createLight();
        l->setType (Ogre::Light::LT_DIRECTIONAL);
        l->setDirection (Ogre::Vector3(0.3, -0.7, 0.3));
        l->setDiffuseColour (Ogre::ColourValue(1,1,1));

        mSceneMgr->setAmbientLight (Ogre::ColourValue(0.5, 0.5, 0.5));

        mCamera = mSceneMgr->createCamera (mName);
        mCamera->setAspectRatio (float(mSizeX) / float(mSizeY));

        Ogre::SceneNode* renderRoot = mSceneMgr->getRootSceneNode()->createChildSceneNode("renderRoot");

        //we do this with mwRoot in renderingManager, do it here too.
        renderRoot->pitch(Ogre::Degree(-90));

        mNode = renderRoot->createChildSceneNode();

        mAnimation = new NpcAnimation(mCharacter, mNode,
                                      0, true, (renderHeadOnly() ? NpcAnimation::VM_HeadOnly : NpcAnimation::VM_Normal));

        Ogre::Vector3 scale = mNode->getScale();
        mCamera->setPosition(mPosition * scale);
        mCamera->lookAt(mLookAt * scale);

        mCamera->setNearClipDistance (0.01);
        mCamera->setFarClipDistance (1000);

        mTexture = Ogre::TextureManager::getSingleton().getByName (mName);
        if (mTexture.isNull ())
            mTexture = Ogre::TextureManager::getSingleton().createManual(mName,
                Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, mSizeX, mSizeY, 0, Ogre::PF_A8R8G8B8, Ogre::TU_RENDERTARGET);

        mRenderTarget = mTexture->getBuffer()->getRenderTarget();
        mRenderTarget->removeAllViewports ();
        mViewport = mRenderTarget->addViewport(mCamera);
        mViewport->setOverlaysEnabled(false);
        mViewport->setBackgroundColour(Ogre::ColourValue(0, 0, 0, 0));
        mViewport->setShadowsEnabled(false);
        mRenderTarget->setActive(true);
        mRenderTarget->setAutoUpdated (false);

        onSetup ();
    }
	//-----------------------------------------------------------------------
	void LightRenderer::_prepare(ParticleTechnique* technique)
	{
		if (!technique || mRendererInitialised)
			return;

		std::stringstream ss; 
		ss << this;
		mLightName = ss.str();
		mQuota = technique->getVisualParticleQuota();
		Ogre::SceneNode* parentNode = technique->getParentSystem()->getParentSceneNode();

		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);
				LightRendererVisualData* visualData = 
					PU_NEW_T(LightRendererVisualData, 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 Lights
			vector<LightRendererVisualData*>::const_iterator it;
			vector<LightRendererVisualData*>::const_iterator itEnd = mAllVisualData.end();
			size_t j;
			Ogre::Light* light;
			for (it = mAllVisualData.begin(), j = 0; it != itEnd; ++it, ++j)
			{
				light = technique->getParentSystem()->getSceneManager()->createLight(mLightName + StringConverter::toString(j));
				(*it)->node->attachObject(light);
				light->setType(mLightType);
				light->setAttenuation(mAttenuationRange, mAttenuationConstant, mAttenuationLinear, mAttenuationQuadratic);
				light->setDiffuseColour(DEFAULT_DIFFUSE); // The light always gets the diffuse colour from the particle
				light->setSpecularColour(mSpecularColour);
				light->setSpotlightFalloff(mSpotlightFalloff);
				light->setSpotlightInnerAngle(mSpotlightInnerAngle);
				light->setSpotlightOuterAngle(mSpotlightOuterAngle);
				light->setPowerScale(mPowerScale);
				light->setRenderQueueGroup(mQueueId);
				light->setVisible(false);
				mLights.push_back(light);
				(*it)->light = light;
			}
		}

		_makeNodesVisible(false); // Make them invisibe, otherwise they light the scene before start
		mRendererInitialised = true;
	}
Esempio n. 20
0
void DrawToolOGRE::pushMatrix()
{
    if(pOgreDrawInternal == NULL)
    {
        pOgreDrawInternal = (Ogre::ManualObject*)pSceneMgr->createMovableObject("drawUtilityInternal","ManualObject");
    }
    pOgreDrawInternal->clear();
    // save the OgreDraw pointer
    pOgreDrawSave = pOgreDraw;
    // drawing of primitive is handled to OgreDrawInternal
    pOgreDraw = pOgreDrawInternal;
    Ogre::SceneNode* currentSceneNode = sceneNodeStack.top();
    sceneNodeStack.push(currentSceneNode->createChildSceneNode());
}
Esempio n. 21
0
Ogre::Entity* ManipulatorObject::AddEntity( const STRING& meshname, const POS& worldPos, bool bOp, const ORIENT& orient, const SCALE& scale )
{
	static int counter = 0;

	Ogre::String entName("Entity_");
	entName += Ogre::StringConverter::toString(counter++);

	Ogre::Entity* newEntity = RenderManager.m_pSceneMgr->createEntity(entName, meshname);
	if(!newEntity)
		return nullptr;

	Ogre::SceneNode* pNode = RenderManager.m_pSceneMgr->getRootSceneNode()->createChildSceneNode(worldPos, orient);
	pNode->setScale(scale);
	pNode->attachObject(newEntity);

	//每个Entity创建一个包围盒节点
	Ogre::WireBoundingBox* aabb = new Ogre::WireBoundingBox;
	aabb->setMaterial("BaseWhiteNoLighting");
	aabb->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY);
	Ogre::SceneNode* aabbNode = pNode->createChildSceneNode(entName);
	aabbNode->attachObject(aabb);
	aabbNode->setVisible(false);

	_UpdateAABBOfEntity(newEntity);

	//设置查询掩码
	newEntity->setQueryFlags(eQueryMask_Entity);

	SObjectInfo* objInfo = new SObjectInfo;
	objInfo->m_meshname = meshname;
	objInfo->m_pos = worldPos;
	objInfo->m_rot = orient;
	objInfo->m_scale = scale;

	m_objects.insert(std::make_pair(newEntity, objInfo));

	//可撤销操作
	if (bOp)
	{
		opObjectAddRemove* op = ManipulatorSystem.GetOperation().NewOperation<opObjectAddRemove>();
		opObjectAddRemove::SOpItem item;
		item.bAddOrRemove = true;
		item.ent = newEntity;
		item.objInfo = *objInfo;
		op->AddOp(item);
		ManipulatorSystem.GetOperation().Commit(op);
	}
	
	return newEntity;
}
Esempio n. 22
0
RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine, MWWorld::Environment& environment)
:mRendering(_rend), mObjects(mRendering), mActors(mRendering, environment), mAmbientMode(0), mDebugging(engine)
{
    mRendering.createScene("PlayerCam", 55, 5);

    // Set default mipmap level (NB some APIs ignore this)
    TextureManager::getSingleton().setDefaultNumMipmaps(5);

    // Load resources
    ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

    // Turn the entire scene (represented by the 'root' node) -90
    // degrees around the x axis. This makes Z go upwards, and Y go into
    // the screen (when x is to the right.) This is the orientation that
    // Morrowind uses, and it automagically makes everything work as it
    // should.
    SceneNode *rt = mRendering.getScene()->getRootSceneNode();
    mMwRoot = rt->createChildSceneNode();
    mMwRoot->pitch(Degree(-90));
    mObjects.setMwRoot(mMwRoot);
    mActors.setMwRoot(mMwRoot);
        
    //used to obtain ingame information of ogre objects (which are faced or selected)
    mRaySceneQuery = mRendering.getScene()->createRayQuery(Ray());

    Ogre::SceneNode *playerNode = mMwRoot->createChildSceneNode ("player");
    playerNode->pitch(Degree(90));
    Ogre::SceneNode *cameraYawNode = playerNode->createChildSceneNode();
    Ogre::SceneNode *cameraPitchNode = cameraYawNode->createChildSceneNode();
    cameraPitchNode->attachObject(mRendering.getCamera());
    
    //mSkyManager = 0;
    mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera());

    mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode);
    mSun = 0;
}
Esempio n. 23
0
Penguin::Penguin(Ogre::SceneManager* sceneMgr, std::string name) {
  Ogre::Entity* entPenguin = sceneMgr->createEntity(name, "penguin.mesh");
  mAnimationState = entPenguin->getAnimationState("amuse");
  mAnimationState->setLoop(true);
  mAnimationState->setEnabled(true);
  entPenguin->setCastShadows(true);
  Ogre::SceneNode* penguinNode = sceneMgr->getRootSceneNode()->createChildSceneNode(name, Ogre::Vector3(0,30,0));
  penguinNode->attachObject(entPenguin);
  penguinNode->scale(60 / 63.0057, 50 / 47.99059, 50 / 49.27139);
  Ogre::Camera* cam = sceneMgr->getCamera("GameCam");
  cameraNode = penguinNode->createChildSceneNode("CameraNode");
  cameraNode->attachObject(cam);

  setNode(penguinNode);
}
Esempio n. 24
0
void CameraComponent::createCamera(void)
{
	mCamera = mSceneMgr->createCamera("CarCam");

    /* Attach the camera to our car and place it in the correct position */
    CarOgreComponent* ogreComp = (CarOgreComponent*)parentEntity->getComponent(COMPONENT_OGRE);
	Ogre::SceneNode* carRootNode = ogreComp->getNode();
    Ogre::SceneNode* camNode = carRootNode->createChildSceneNode("CamNode");
    camNode->translate(currentPos);
    camNode->attachObject(mCamera);
      
    //mCamera->setPosition(Ogre::Vector3(0,15,30));
    mCamera->lookAt(Ogre::Vector3(0,0,80));
    mCamera->setNearClipDistance(5);
	
    //mCameraMan = new OgreBites::SdkCameraMan(mCamera);
}
Esempio n. 25
0
void createPalms(Ogre::SceneManager *mSceneMgr)
{
	const int NumberOfPalms = 12;

	Ogre::SceneNode* mPalmsSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
		
	for (int k = 0; k < NumberOfPalms; k++)
	{
		Ogre::Vector3 RandomPos = Ogre::Vector3(rnd_(500,2500),
			0,
			rnd_(500,2500));

		Ogre::RaySceneQuery * raySceneQuery = mSceneMgr->
			createRayQuery(Ogre::Ray(RandomPos + Ogre::Vector3(0,1000000,0), 
			Ogre::Vector3::NEGATIVE_UNIT_Y));

		Ogre::RaySceneQueryResult& qryResult = raySceneQuery->execute();
		Ogre::RaySceneQueryResult::iterator i = qryResult.begin();

		if (i != qryResult.end() && i->worldFragment)
		{
			if (i->worldFragment->singleIntersection.y>105 || i->worldFragment->singleIntersection.y<20)
			{
				k--;
				continue;
			}

			RandomPos.y = i->worldFragment->singleIntersection.y;
		}
		else
		{
			k--;
			continue;
		}

		Ogre::Entity *mPalmEnt = mSceneMgr->createEntity("Palm"+Ogre::StringConverter::toString(k), "Palm.mesh");
		Ogre::SceneNode *mPalmSN = mPalmsSceneNode->createChildSceneNode();

		mPalmSN->rotate(Ogre::Vector3(-1,0,rnd_(-0.3,0.3)), Ogre::Degree(90));
		mPalmSN->attachObject(mPalmEnt);
		Ogre::Real Scale = rnd_(50,75);
		mPalmSN->scale(Scale,Scale,Scale);
		mPalmSN->setPosition(RandomPos);
	}
}
Esempio n. 26
0
    void CharacterPreview::setup ()
    {
        mSceneMgr = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);
        mCamera = mSceneMgr->createCamera (mName);
        mCamera->setAspectRatio (float(mSizeX) / float(mSizeY));

        Ogre::SceneNode* renderRoot = mSceneMgr->getRootSceneNode()->createChildSceneNode("renderRoot");

        //we do this with mwRoot in renderingManager, do it here too.
        renderRoot->pitch(Ogre::Degree(-90));

        mNode = renderRoot->createChildSceneNode();

        mAnimation = new NpcAnimation(mCharacter, mNode,
            MWWorld::Class::get(mCharacter).getInventoryStore (mCharacter), RV_PlayerPreview);

        mNode->setVisible (false);

        Ogre::Vector3 scale = mNode->getScale();
        mCamera->setPosition(mPosition * scale);
        mCamera->lookAt(mLookAt * scale);

        mCamera->setNearClipDistance (0.01);
        mCamera->setFarClipDistance (1000);

        mTexture = Ogre::TextureManager::getSingleton().getByName (mName);
        if (mTexture.isNull ())
            mTexture = Ogre::TextureManager::getSingleton().createManual(mName,
                Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, mSizeX, mSizeY, 0, Ogre::PF_A8R8G8B8, Ogre::TU_RENDERTARGET);

        mRenderTarget = mTexture->getBuffer()->getRenderTarget();
        mRenderTarget->removeAllViewports ();
        mViewport = mRenderTarget->addViewport(mCamera);
        mViewport->setOverlaysEnabled(false);
        mViewport->setBackgroundColour(Ogre::ColourValue(0, 0, 0, 0));
        mViewport->setShadowsEnabled(false);
        mViewport->setMaterialScheme("local_map");
        mViewport->setVisibilityMask (RV_PlayerPreview);
        mRenderTarget->setActive(true);
        mRenderTarget->setAutoUpdated (false);

        onSetup ();
    }
Esempio n. 27
0
int CUIMain::LoadWorld(void)
{
	Ogre::SceneNode* RootNode = mSceneMgr->getRootSceneNode();

	Ogre::Plane plane(Ogre::Vector3::UNIT_Y, -1); //1 unit under the ground
	Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
		2000,2000,20,20,true,1,5,5,Ogre::Vector3::UNIT_Z);
	Ogre::Entity *GroundEnt = mSceneMgr->createEntity("GroundEntity", "ground");
	GroundEnt->setQueryFlags(QUERY_MASK_MOUSE_MOVEMENT);
	GroundEnt->setMaterialName("Rockwall");
	RootNode->createChildSceneNode()->attachObject(GroundEnt);

	CharacterInfo local_player_info;
	mWorld.LocalPlayer = new CLocalPlayer(mWorld, RootNode->createChildSceneNode());
	AttachMeshes(mWorld.LocalPlayer, local_player_info);
	mWorld.LocalPlayer->SetMoveSpeed(100);
	mWorld.LocalPlayer->SetState(State_Idle);

	//Test:
	CreateNewPlayer(0, CharacterInfo());

	Ogre::SceneNode *DestMarkerNode = RootNode->createChildSceneNode();
	Ogre::Entity *DestMarker = mSceneMgr->createEntity("Ent-DestMarker", "arrow.mesh");
	DestMarker->setQueryFlags(0);
	DestMarkerNode->attachObject(DestMarker);
	DestMarkerNode->setVisible(false);
	mWorld.LocalPlayer->SetDestinationMarker(DestMarkerNode, DestMarker);

	mMoveDestinationIndicator = RootNode->createChildSceneNode();
	Ogre::Entity* MouseIndicatorEntity = mSceneMgr->createEntity("Ent-MouseIndicator", "arrow.mesh");
	MouseIndicatorEntity->setQueryFlags(0);
	MouseIndicatorEntity->setMaterialName("ArrowTransparent");
	mMoveDestinationIndicator->attachObject(MouseIndicatorEntity);
	mMoveDestinationIndicator->scale(0.8, 0.8, 0.8);

	mEntityHoveringIndicator = RootNode->createChildSceneNode();
	mEntitySelectionIndicator = RootNode->createChildSceneNode();
	Ogre::Entity* HoverIndicatorEntity = mSceneMgr->createEntity("Ent-HoveringIndicator", "arrows.mesh");
	Ogre::Entity* SelectionIndicatorEntity = mSceneMgr->createEntity("Ent-SelectionIndicator", "arrows.mesh");
	HoverIndicatorEntity->setQueryFlags(0);
	SelectionIndicatorEntity->setQueryFlags(0);
	HoverIndicatorEntity->setMaterialName("ArrowTransparent");
	mEntitySelectionIndicator->setInheritOrientation(false);
	mEntityHoveringIndicator->attachObject(HoverIndicatorEntity);
	mEntitySelectionIndicator->attachObject(SelectionIndicatorEntity);
	mEntityHoveringIndicator->setVisible(false);
	mEntitySelectionIndicator->setVisible(false);

	return 1;
}
	//-----------------------------------------------------------------------
	void SceneDecoratorExtern::_notifyStart (void)
	{
		// Scale the node
		if (!mSubnode && mParentTechnique->getParentSystem())
		{
			std::stringstream ss; 
			ss << this;
			String sceneNodeName = "ParticleUniverse" + ss.str() + StringConverter::toString(mCount++);
			Ogre::SceneNode* sceneNode = mParentTechnique->getParentSystem()->getParentSceneNode();
			mSubnode = sceneNode->createChildSceneNode(sceneNodeName);
		}

		if (!mEntity)
		{
			createEntity();
			mSubnode->attachObject(mEntity);
		}

		mSubnode->setScale(mScale);
		mSubnode->setPosition(mPosition);
	}
Esempio n. 29
0
Ogre::SceneNode* AssetLoader::readAsset(Ogre::SceneManager* sceneMgr, const char* assetFileName, const char* assetName)
{
	Assimp::Importer importer;
	const aiScene* scene = importer.ReadFile(assetFileName, aiProcessPreset_TargetRealtime_Quality|aiProcess_FlipUVs);
	if (!scene) {
		return false;
	}

//	this->createCamera(sceneMgr, Ogre::String("camera1"));

	Ogre::SceneNode* rootNode = sceneMgr->getRootSceneNode();
	Ogre::SceneNode* scnNode = rootNode->createChildSceneNode(assetName);

	for (size_t i = 0; i < scene->mRootNode->mNumChildren; i++)
	{	
		aiNode* cnd = scene->mRootNode->mChildren[i];
		Ogre::SceneNode* node = createChildSceneNodeWithTransform(scnNode, cnd);

		readModel(sceneMgr, node, scene, cnd);
	}

	return scnNode;
}
Esempio n. 30
0
	void createScene()
	{
		/*Ogre::Entity* ent = mSceneMgr->createEntity("MyEntity","Sinbad.mesh");
		Ogre::Entity* ent2 = mSceneMgr->createEntity("MyEntity2","Sinbad.mesh");
		Ogre::Entity* ent3 = mSceneMgr->createEntity("MyEntity3","Sinbad.mesh");
		Ogre::Entity* ent4 = mSceneMgr->createEntity("MyEntity4","Sinbad.mesh");*/
		/*Ogre::SceneNode* node1 = mSceneMgr->createSceneNode("Node1");
		Ogre::SceneNode* node2 = mSceneMgr->createSceneNode("Node2");
		Ogre::SceneNode* node3 = mSceneMgr->createSceneNode("Node3");
		Ogre::SceneNode* node4 = mSceneMgr->createSceneNode("Node4");*/
		
       /* node1->setPosition(10,10,0);
		mSceneMgr->getRootSceneNode()->addChild(node1);

		node2->setPosition(10,0,0);
		node2->pitch(Ogre::Radian(Ogre::Math::HALF_PI));
		node1->addChild(node2);
        node2->attachObject(ent2);

		node3->translate(20,0,0); 
		node3->yaw(Ogre::Degree(90.0f)); 
		node1->addChild(node3);
        node3->attachObject(ent3);

		node4->setPosition(30,0,0); 
		node4->roll(Ogre::Radian(Ogre::Math::HALF_PI)); 
		node1->addChild(node4);
		node1->attachObject(ent);
		
		node4->attachObject(ent4);*/

		/*mSceneMgr->getRootSceneNode()->addChild(node1);
		node1->setPosition(0,0,0);
		node1->attachObject(ent);

		node1->addChild(node2);
		node2->translate(10,0,0);
		node2->pitch(Ogre::Degree(90.0f));
		node2->attachObject(ent2);

		node2->addChild(node3);
		node3->translate(10,0,0);
		node3->pitch(Ogre::Degree(-90.0f));
		node3->yaw(Ogre::Radian(Math::HALF_PI));
		node3->attachObject(ent3);

		node3->addChild(node4);
		node4->translate(0,0,10);
		node4->yaw(Ogre::Degree(-90.0f));
		node4->roll(Ogre::Degree(90.0f));
		node4->attachObject(ent4);*/
		
	/*	Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1"); 
		node->setPosition(10,10,0); 
		mSceneMgr->getRootSceneNode()->addChild(node); 
		node->attachObject(ent);

		Ogre::SceneNode* node2 = node->createChildSceneNode("node2"); 
		node2->setPosition(10,0,0); 
		node2->attachObject(ent2);
		node2->scale(2.0f,2.0f,2.0f);

		Ogre::SceneNode* node3 = node->createChildSceneNode("node3",Ogre::Vector3(20,0,0));
		node3->scale(0.2f,0.2f,0.2f);
		node3->attachObject(ent3);*/

		Ogre::Entity* ent = mSceneMgr->createEntity("MyEntity","Sinbad.mesh");
        Ogre::SceneNode* node = mSceneMgr->createSceneNode("Node1");
        node->setPosition(0,0,400);
        node->yaw(Ogre::Degree(180.0f));
        mSceneMgr->getRootSceneNode()->addChild(node);
        node->attachObject(ent);

		Ogre::Entity* ent2 = mSceneMgr->createEntity("MyEntity2","Sinbad.mesh");
        Ogre::SceneNode* node2 = node->createChildSceneNode("node2");
        node2->yaw(Ogre::Degree(45.0f));
        node2->translate(0,0,20);
        node2->attachObject(ent2);

		Ogre::Entity* ent3 = mSceneMgr->createEntity("MyEntity3","Sinbad.mesh");
        Ogre::SceneNode* node3 = node->createChildSceneNode("node3");
        node3->yaw(Ogre::Degree(45.0f));
        node3->translate(0,0,20,Ogre::Node::TS_LOCAL);
        node3->attachObject(ent3);
	}