当前位置: 首页>>代码示例>>C++>>正文


C++ SceneManager::createSceneNode方法代码示例

本文整理汇总了C++中ogre::SceneManager::createSceneNode方法的典型用法代码示例。如果您正苦于以下问题:C++ SceneManager::createSceneNode方法的具体用法?C++ SceneManager::createSceneNode怎么用?C++ SceneManager::createSceneNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ogre::SceneManager的用法示例。


在下文中一共展示了SceneManager::createSceneNode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AddConstructionCapability

void LagomPlayerBase::AddConstructionCapability(LagomActorFactory* f)
{
	if(!f)
		return;
	if(_actorFactories.find(f) != _actorFactories.end())
		return;
	
	Ogre::SceneManager* manager = _state.GetSceneManager();
	
	Ogre::SceneNode* node = manager->createSceneNode();
	Ogre::Entity*	constructionObject = manager->createEntity(f->Mesh.c_str());

	Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(getIntFactory().ConstructingMaterial);
	materialPtr->setSelfIllumination(1.0f,1.0f,1.0f);
	constructionObject->setCastShadows(false);
	constructionObject->setRenderQueueGroup(RENDER_QUEUE_SKIES_LATE);
	constructionObject->setMaterialName(getIntFactory().ConstructingMaterial);
	node->attachObject(constructionObject);
	node->setScale( f->MeshScale );

	_actorFactories.insert(FactoryMap::value_type(f,node));

	
	if(	_selectedActorFactory ==_actorFactories.end())
		_selectedActorFactory=_actorFactories.begin();
}
开发者ID:jaschmid,项目名称:Lagom,代码行数:26,代码来源:lagom_player_base.cpp

示例2: drawDistanceData

EC_Mesh::EC_Mesh(Scene* scene) :
    IComponent(scene),
    nodeTransformation(this, "Transform", Transform(float3(0,0,0),float3(0,0,0),float3(1,1,1))),
    meshRef(this, "Mesh ref", AssetReference("", "OgreMesh")),
    skeletonRef(this, "Skeleton ref", AssetReference("", "OgreSkeleton")),
    meshMaterial(this, "Mesh materials", AssetReferenceList("OgreMaterial")),
    drawDistance(this, "Draw distance", 0.0f),
    castShadows(this, "Cast shadows", false),
    entity_(0),
    attached_(false)
{
    if (scene)
        world_ = scene->GetWorld<OgreWorld>();

    static AttributeMetadata drawDistanceData("", "0", "10000");
    drawDistance.SetMetadata(&drawDistanceData);

    static AttributeMetadata materialMetadata;
    materialMetadata.elementType = "assetreference";
    meshMaterial.SetMetadata(&materialMetadata);

    meshAsset = AssetRefListenerPtr(new AssetRefListener());
    skeletonAsset = AssetRefListenerPtr(new AssetRefListener());
    
    OgreWorldPtr world = world_.lock();
    if (world)
    {
        Ogre::SceneManager* sceneMgr = world->OgreSceneManager();
        adjustment_node_ = sceneMgr->createSceneNode(world->GetUniqueObjectName("EC_Mesh_adjustment_node"));

        connect(this, SIGNAL(ParentEntitySet()), SLOT(UpdateSignals()));
        connect(meshAsset.get(), SIGNAL(Loaded(AssetPtr)), this, SLOT(OnMeshAssetLoaded(AssetPtr)), Qt::UniqueConnection);
        connect(skeletonAsset.get(), SIGNAL(Loaded(AssetPtr)), this, SLOT(OnSkeletonAssetLoaded(AssetPtr)), Qt::UniqueConnection);
    }
}
开发者ID:katik,项目名称:naali,代码行数:35,代码来源:EC_Mesh.cpp

示例3: createScene

	 void createScene(){
		 _sceneManager->setAmbientLight(Ogre::ColourValue(1.0f,1.0f,1.0f));
		 Ogre::SceneNode* nodeEsfera02;
		 Ogre::Light* light02;

		 Ogre::SceneNode* nM01 = _sceneManager->createSceneNode("nm01");
		 Ogre::Entity* entMesh01 = _sceneManager->createEntity("Entnm01", "proyectoOgreI.mesh");
		 _sceneManager->getRootSceneNode()->addChild(nM01);
		 nM01->attachObject(entMesh01);
		 entMesh01->setMaterialName("mat02");

		 Ogre::SceneNode* nM02 = _sceneManager->createSceneNode("nm02");
		 Ogre::Entity* entMesh02 = _sceneManager->createEntity("Entnm02", "ejes01.mesh");
		 _sceneManager->getRootSceneNode()->addChild(nM02);
		 nM02->attachObject(entMesh02);
		 nM02->scale(10.0f,10.0f,10.0f);

		 Ogre::SceneNode* nM03 = _sceneManager->createSceneNode("nm03");
		 Ogre::Entity* entMesh03 = _sceneManager->createEntity("Entnm03", "ogrehead.mesh");
		 _sceneManager->getRootSceneNode()->addChild(nM03);
		 nM03->attachObject(entMesh03);
		 nM03->scale(5.0f,5.0f,5.0f);
		 entMesh03->setMaterialName("mat01");

		 Ogre::Entity* entEsfera02 = _sceneManager->createEntity("EntEsfera02","sphere.mesh");
		//Ogre::SceneNode* nodeEsfera02 = mSceneMgr->createSceneNode("NodeEsfera02");
		nodeEsfera02 = _sceneManager->createSceneNode("NodeEsfera02");
		_sceneManager->getRootSceneNode()->addChild(nodeEsfera02);
		nodeEsfera02->attachObject(entEsfera02);

		 //NODO LUZ
		float lightScale = 0.9f;
		Ogre::SceneNode* nodeLuz02 = _sceneManager->createSceneNode("NodeLuz02");		
		light02 = _sceneManager->createLight("LuzPoint01");
		light02->setType(Ogre::Light::LT_POINT);		
		light02->setDiffuseColour(lightScale*Ogre::ColourValue(2.0f,2.0f,2.0f));	
		nodeLuz02->attachObject(light02);


		nodeEsfera02->addChild(nodeLuz02);
		nodeEsfera02->setScale(0.05f,0.05f,0.05f);
		nodeEsfera02->setPosition(-500.0f,500.0f,500.0f);

	 }
开发者ID:luiscarlo6,项目名称:Computacion-Grafica-USB,代码行数:44,代码来源:OgreSemana10.cpp

示例4: idPrefix

//!
//! Processes the node's input data to generate the node's output table.
//!
void Model2SceneNode::processScene()
{
	// load the input vtk parameter 
	VTKTableParameter * inputParameter = dynamic_cast<VTKTableParameter*>(getParameter(m_inputVTKTableParameterName));
	if (!inputParameter || !inputParameter->isConnected())
		return;

	// get the source parameter (output of source node) connected to the input parameter
	VTKTableParameter * sourceParameter = dynamic_cast<VTKTableParameter*>(inputParameter->getConnectedParameter());

	inputParameter->setVTKTable(sourceParameter->getVTKTable());

	vtkTable * xyzTable = inputParameter->getVTKTable();

	if (!m_sceneNode)
		createSceneNode();


	if (!m_entity || !xyzTable || !m_sceneNode)
		return;

	//Get columns named "NodeID", "X", "Y" and "Z"
	vtkIdTypeArray *colNodeId = dynamic_cast<vtkIdTypeArray*>(xyzTable->GetColumnByName("NodeId"));
	vtkDoubleArray *colX = dynamic_cast<vtkDoubleArray*>(xyzTable->GetColumnByName("X"));
	vtkDoubleArray *colY = dynamic_cast<vtkDoubleArray*>(xyzTable->GetColumnByName("Y"));
	vtkDoubleArray *colZ = dynamic_cast<vtkDoubleArray*>(xyzTable->GetColumnByName("Z"));

	destroyAllAttachedMovableObjects(m_sceneNode);
	destroyAllChildren(m_sceneNode);

	Ogre::String idPrefix(QString(m_name + ":").toStdString());

	Ogre::SceneManager *sceneManager = OgreManager::getSceneManager();

	for (int i=0; i<xyzTable->GetNumberOfRows(); i++)
	{
		int colIDValue = colNodeId->GetValue(i);
		Ogre::String nodeID(idPrefix + Ogre::StringConverter::toString(colIDValue));

		// create new scene node for each item
		Ogre::SceneNode *sceneItem = sceneManager->createSceneNode(nodeID);

		// create new entity for each item
		Ogre::Entity *entityItem = m_entity->clone(nodeID);
		
		sceneItem->attachObject(entityItem);

		double x = colX->GetValue(i);
		double y = colY->GetValue(i);
		double z = colZ->GetValue(i);
		sceneItem->setPosition(Ogre::Real(x), Ogre::Real(y), Ogre::Real(z));
		sceneItem->setScale(m_size);
		m_sceneNode->addChild(sceneItem);
		
	}
}
开发者ID:banduladh,项目名称:levelfour,代码行数:59,代码来源:Model2SceneNode.cpp

示例5: mCameraNode

FirstPersonCameraMount::FirstPersonCameraMount(const CameraSettings& cameraSettings, Ogre::SceneManager& sceneManager) :
	CameraMountBase(cameraSettings), mCameraNode(0)
{
	mCameraRootNode = sceneManager.createSceneNode(OgreInfo::createUniqueResourceName("FirstPersonCameraNodeRootNode"));
	mCameraRootNode->setInheritOrientation(false);
	//rotate to sync with WF world
	mCameraRootNode->rotate(Ogre::Vector3::UNIT_Y, Ogre::Degree(-90));

	mCameraPitchNode = mCameraRootNode->createChildSceneNode(OgreInfo::createUniqueResourceName("FirstPersonCameraPitchNode"));
	mCameraNode = mCameraPitchNode->createChildSceneNode(OgreInfo::createUniqueResourceName("FirstPersonCameraNode"));

}
开发者ID:sajty,项目名称:ember,代码行数:12,代码来源:FirstPersonCameraMount.cpp

示例6: popup

void MyFrameListener::popup(){
   Ogre::SceneManager* mSceneMgr = Ogre::Root::getSingleton().
                                  getSceneManager("mainSM");
  Ogre::SceneNode* nodeBoard = mSceneMgr->createSceneNode("popup");
  Ogre::Entity* _board = mSceneMgr->createEntity("Popup.mesh");
  std::cout << "puntos" << _points <<endl;
  if(_points == 0 ) {
    _board->setMaterialName("YouLose");
  }
  _points = 0;
  nodeBoard->attachObject(_board);
  Ogre::Vector3 vector = Ogre::Vector3(0, 2, 1.5);
  nodeBoard->setPosition(vector);
  mSceneMgr->getRootSceneNode()->addChild(nodeBoard);
}
开发者ID:flush,项目名称:CEDV-2015,代码行数:15,代码来源:MyFrameListener.cpp

示例7: IComponent

EC_Placeable::EC_Placeable(Scene* scene) :
    IComponent(scene),
    sceneNode_(0),
    boneAttachmentNode_(0),
    parentBone_(0),
    parentPlaceable_(0),
    parentMesh_(0),
    attached_(false),
    transform(this, "Transform"),
    drawDebug(this, "Show bounding box", false),
    visible(this, "Visible", true),
    selectionLayer(this, "Selection layer", 1),
    parentRef(this, "Parent entity ref", EntityReference()),
    parentBone(this, "Parent bone name", "")
{
    if (scene)
        world_ = scene->GetWorld<OgreWorld>();
    
    // Enable network interpolation for the transform
    static AttributeMetadata transAttrData;
    static AttributeMetadata nonDesignableAttrData;
    static bool metadataInitialized = false;
    if(!metadataInitialized)
    {
        transAttrData.interpolation = AttributeMetadata::Interpolate;
        nonDesignableAttrData.designable = false;
        metadataInitialized = true;
    }
    transform.SetMetadata(&transAttrData);

    OgreWorldPtr world = world_.lock();
    if (world)
    {
        Ogre::SceneManager* sceneMgr = world->GetSceneManager();
        sceneNode_ = sceneMgr->createSceneNode(world->GetUniqueObjectName("EC_Placeable_SceneNode"));
// Would like to do this for improved debugging in the Profiler window, but because we don't have the parent entity yet, we don't know the id or the name of this entity.
//        sceneNode_ = sceneMgr->createSceneNode(world->GetUniqueObjectName(("EC_Placeable_SceneNode_" + QString::number(ParentEntity()->Id()) + "_" + ParentEntity()->Name()).toStdString()));
    
        // Hook the transform attribute change
        connect(this, SIGNAL(AttributeChanged(IAttribute*, AttributeChange::Type)),
            SLOT(HandleAttributeChanged(IAttribute*, AttributeChange::Type)));

        connect(this, SIGNAL(ParentEntitySet()), SLOT(RegisterActions()));
    
        AttachNode();
    }
}
开发者ID:Ilikia,项目名称:naali,代码行数:47,代码来源:EC_Placeable.cpp

示例8: fallInertia

LagomPlayerBase::LagomPlayerBase(GameState* state) : 
	LagomUnitImp<LagomPlayerBase>(*state,Vector3(0.0f, getIntFactory().GroundOffset, 0.0f)),
	_selectedActorFactory(_actorFactories.end()),
	_constructionObject(nullptr),
	_hoverConstructing(false),
	_draggingConstruction(false),
	_buildCooldown(0.0f),
	_buildCooldownMax(1.0f),
	_factoryHighlightRemaining(0.0f)
{

	Ogre::SceneManager* manager = state->GetSceneManager();
	_sceneNode = manager->createSceneNode(getIntFactory().Name);
	_mainEntity = manager->createEntity(getIntFactory().Name,getIntFactory().Mesh);
    _mainEntity->setMaterialName(getIntFactory().Material);
	_materialInstance = _mainEntity->getSubEntity(0);
    _sceneNode->attachObject(_mainEntity);
    _sceneNode->setPosition(_location);
	_sceneNode->setScale(GetFactory()->MeshScale);

	_btCollisionShape = new (alignedMalloc<btCylinderShape>()) btCylinderShape(btVector3(getIntFactory().CollisionRange,getIntFactory().GroundOffset,getIntFactory().CollisionRange));
	_btDefaultMotionState = new (alignedMalloc<btDefaultMotionState>())
		btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0.0f,getIntFactory().GroundOffset,0.0f)));

	btScalar mass = 0.0f;
    btVector3 fallInertia(0,0,0);
    _btCollisionShape->calculateLocalInertia(mass,fallInertia);

	btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(mass,_btDefaultMotionState,_btCollisionShape,fallInertia);

	_btRigidBody = new (alignedMalloc<btRigidBody>()) btRigidBody(rigidBodyCI);
	assert((int)_btRigidBody % 16 == 0);
	_btRigidBody->setActivationState(DISABLE_DEACTIVATION);
	_health = getIntFactory().Health;

	RestrictConstruction();

	RegisterInput();
}
开发者ID:jaschmid,项目名称:Lagom,代码行数:39,代码来源:lagom_player_base.cpp

示例9: SetAttachmentMesh

bool EC_Mesh::SetAttachmentMesh(uint index, const std::string& mesh_name, const std::string& attach_point, bool share_skeleton)
{
    if (!ViewEnabled())
        return false;
    OgreWorldPtr world = world_.lock();

    if (!entity_)
    {
        LogError("EC_Mesh::SetAttachmentMesh: No mesh entity created yet, can not create attachments!");
        return false;
    }
    
    Ogre::SceneManager* sceneMgr = world->OgreSceneManager();
    
    size_t oldsize = attachment_entities_.size();
    size_t newsize = index + 1;
    
    if (oldsize < newsize)
    {
        attachment_entities_.resize(newsize);
        attachment_nodes_.resize(newsize);
        for(uint i = oldsize; i < newsize; ++i)
        {
            attachment_entities_[i] = 0;
            attachment_nodes_[i] = 0;
        }
    }
    
    RemoveAttachmentMesh(index);
    
    Ogre::Mesh* mesh = PrepareMesh(mesh_name, false);
    if (!mesh)
        return false;

    if (share_skeleton)
    {
        // If sharing a skeleton, force the attachment mesh to use the same skeleton
        // This is theoretically quite a scary operation, for there is possibility for things to go wrong
        Ogre::SkeletonPtr entity_skel = entity_->getMesh()->getSkeleton();
        if (entity_skel.isNull())
        {
            LogError("EC_Mesh::SetAttachmentMesh: Cannot share skeleton for attachment, not found");
            return false;
        }
        try
        {
            mesh->_notifySkeleton(entity_skel);
        }
        catch(const Ogre::Exception &/*e*/)
        {
            LogError("EC_Mesh::SetAttachmentMesh: Could not set shared skeleton for attachment");
            return false;
        }
    }

    try
    {
        QString entityName = QString("EC_Mesh_attach") + QString::number(index);
        attachment_entities_[index] = sceneMgr->createEntity(world->GetUniqueObjectName(entityName.toStdString()), mesh->getName());
        if (!attachment_entities_[index])
        {
            LogError("EC_Mesh::SetAttachmentMesh: Could not set attachment mesh " + mesh_name);
            return false;
        }

        attachment_entities_[index]->setRenderingDistance(drawDistance.Get());
        attachment_entities_[index]->setCastShadows(castShadows.Get());
        attachment_entities_[index]->setUserAny(entity_->getUserAny());
        // Set UserAny also on subentities
        for(uint i = 0; i < attachment_entities_[index]->getNumSubEntities(); ++i)
            attachment_entities_[index]->getSubEntity(i)->setUserAny(entity_->getUserAny());

        Ogre::Bone* attach_bone = 0;
        if (!attach_point.empty())
        {
            Ogre::Skeleton* skel = entity_->getSkeleton();
            if (skel && skel->hasBone(attach_point))
                attach_bone = skel->getBone(attach_point);
        }
        if (attach_bone)
        {
            Ogre::TagPoint* tag = entity_->attachObjectToBone(attach_point, attachment_entities_[index]);
            attachment_nodes_[index] = tag;
        }
        else
        {
            QString nodeName = QString("EC_Mesh_attachment_") + QString::number(index);
            Ogre::SceneNode* node = sceneMgr->createSceneNode(world->GetUniqueObjectName(nodeName.toStdString()));
            node->attachObject(attachment_entities_[index]);
            adjustment_node_->addChild(node);
            attachment_nodes_[index] = node;
        }
        
        if (share_skeleton && entity_->hasSkeleton() && attachment_entities_[index]->hasSkeleton())
        {
            attachment_entities_[index]->shareSkeletonInstanceWith(entity_);
        }
    }
    catch(Ogre::Exception& e)
    {
//.........这里部分代码省略.........
开发者ID:katik,项目名称:naali,代码行数:101,代码来源:EC_Mesh.cpp

示例10: createScene

			// funcion donde se coloca lo que se desea desplegar.
			void createScene(){
								

				_sceneManager->setAmbientLight(Ogre::ColourValue(0.2,0.2,0.2));
				_sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
				

			
				// LUZ
				

				Ogre::Light* LuzPuntual01 = _sceneManager->createLight("Luz01");
				LuzPuntual01->setType(Ogre::Light::LT_DIRECTIONAL);
				LuzPuntual01->setDiffuseColour(1.0,1.0,1.0);
				LuzPuntual01->setDirection(Ogre::Vector3( 1, -1, -1 ));

				Ogre::Light* LuzPuntual02 = _sceneManager->createLight("Luz02");
				LuzPuntual02->setType(Ogre::Light::LT_DIRECTIONAL);
				LuzPuntual02->setDiffuseColour(1.0,1.0,1.0);
				LuzPuntual02->setDirection(Ogre::Vector3( -1, -1, -1 ));



				//Chasis Carro
				_nodeChasisCarro = _sceneManager->createSceneNode("ChasisCarro");
				_sceneManager->getRootSceneNode()->addChild(_nodeChasisCarro);
				
				Ogre::Entity* _entChasisCarro = _sceneManager->createEntity("ChasisCarro", "chasisCarro.mesh");
				_nodeChasisCarro->attachObject(_entChasisCarro);



				/* Ruedas Izquierdas */
				_nodeRuedaSimple0 = _sceneManager->createSceneNode("RuedaSimple0");
				_sceneManager->getRootSceneNode()->addChild(_nodeRuedaSimple0);
			//	_nodeRuedaSimple00 = _nodeRuedaSimple0->createChildSceneNode("RuedaSimple00");
			//	_sceneManager->getRootSceneNode()->addChild(_nodeRuedaSimple00);

				Ogre::Entity* _entRuedaSimple0 = _sceneManager->createEntity("RuedaSimple0", "RuedaDetallada.mesh");
				_nodeRuedaSimple0->attachObject(_entRuedaSimple0);
			//	_nodeRuedaSimple00->attachObject(_entRuedaSimple0);

				_nodeRuedaSimple0->translate(9,3,5);


				_nodeRuedaSimple2 = _sceneManager->createSceneNode("RuedaSimple2");
				_sceneManager->getRootSceneNode()->addChild(_nodeRuedaSimple2);
			//	_nodeRuedaSimple22 = _nodeRuedaSimple2->createChildSceneNode("RuedaSimple22");
			//	_sceneManager->getRootSceneNode()->addChild(_nodeRuedaSimple22);
				
				Ogre::Entity* _entRuedaSimple2 = _sceneManager->createEntity("RuedaSimple2", "RuedaDetallada.mesh");
				_nodeRuedaSimple2->attachObject(_entRuedaSimple2);
			//	_nodeRuedaSimple22->attachObject(_entRuedaSimple2);

				_nodeRuedaSimple2->translate(9,3,-5);

				/* Ruedas Derechas */
				_nodeRuedaSimple1 = _sceneManager->createSceneNode("RuedaSimple1");
				_sceneManager->getRootSceneNode()->addChild(_nodeRuedaSimple1);
			//	_nodeRuedaSimple11 = _nodeRuedaSimple1->createChildSceneNode("RuedaSimple11");
			//	_sceneManager->getRootSceneNode()->addChild(_nodeRuedaSimple11);

				Ogre::Entity* _entRuedaSimple1 = _sceneManager->createEntity("RuedaSimple1", "RuedaDetallada.mesh");
				_nodeRuedaSimple1->attachObject(_entRuedaSimple1);
			//	_nodeRuedaSimple11->attachObject(_entRuedaSimple1);

				_nodeRuedaSimple1->translate(-7,3,5);


				_nodeRuedaSimple3 = _sceneManager->createSceneNode("RuedaSimple3");
				_sceneManager->getRootSceneNode()->addChild(_nodeRuedaSimple3);
			//	_nodeRuedaSimple33 = _nodeRuedaSimple3->createChildSceneNode("RuedaSimple33");
				//_sceneManager->getRootSceneNode()->addChild(_nodeRuedaSimple33);
				
				Ogre::Entity* _entRuedaSimple3 = _sceneManager->createEntity("RuedaSimple3", "RuedaDetallada.mesh");
				_nodeRuedaSimple3->attachObject(_entRuedaSimple3);
				//_nodeRuedaSimple33->attachObject(_entRuedaSimple3);

				_nodeRuedaSimple3->translate(-7,3,-5);


				/* ALA DERECHA INFERIOR

				Se crea el nodo padre de la nave llamado eje */
				eje = _sceneManager->getRootSceneNode()->createChildSceneNode("eje");

				padreDI = eje->createChildSceneNode("padreDI");

				Ogre::ManualObject* alad = _sceneManager->createManualObject("alad"); 

				alad->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_FAN);
				alad->colour(Ogre::ColourValue(0.0, 0.5, 0.0, 0.0));

				alad->position(4.0, -0.5, 0.0);  
				alad->position(15.0, -0.5, 0.0); 
				alad->position(15.0, 0.0, 0.0);
				alad->position(5.0, 0.0, 0.0);

				alad->index(0);
//.........这里部分代码省略.........
开发者ID:Isaj7,项目名称:finalOgre,代码行数:101,代码来源:main.cpp

示例11: AttachNode

void EC_Placeable::AttachNode()
{
    if (world_.expired())
    {
        LogError("EC_Placeable::AttachNode: No OgreWorld available to call this function!");
        return;
    }
    OgreWorldPtr world = world_.lock();
    
    try
    {
        // If already attached, detach first
        if (attached_)
            DetachNode();
        
        Ogre::SceneManager* sceneMgr = world->GetSceneManager();
        Ogre::SceneNode* root_node = sceneMgr->getRootSceneNode();
        
        // Three possible cases
        // 1) attach to scene root node
        // 2) attach to another EC_Placeable's scene node
        // 3) attach to a bone on a skeletal mesh
        // Disconnect from the EntityCreated & ParentMeshChanged signals, as responding to them might not be needed anymore.
        // We will reconnect signals as necessary
        disconnect(this, SLOT(CheckParentEntityCreated(Entity*, AttributeChange::Type)));
        disconnect(this, SLOT(OnParentMeshChanged()));
        disconnect(this, SLOT(OnComponentAdded(IComponent*, AttributeChange::Type)));
        
        // Try to attach to another entity if the parent ref is non-empty
        // Make sure we're not trying to attach to ourselves as the parent
        const EntityReference& parent = parentRef.Get();
        if (!parent.IsEmpty())
        {
            Entity* ownEntity = ParentEntity();
            if (!ownEntity)
                return;
            Scene* scene = ownEntity->ParentScene();
            if (!scene)
                return;

            Entity* parentEntity = parent.Lookup(scene).get();
            if (parentEntity == ownEntity)
            {
                // If we refer to self, attach to the root
                root_node->addChild(sceneNode_);
                attached_ = true;
                return;
            }
            
            if (parentEntity)
            {
                // Note: if we don't find the correct bone, we attach to the root
                QString boneName = parentBone.Get();
                if (!boneName.isEmpty())
                {
                    EC_Mesh* parentMesh = parentEntity->GetComponent<EC_Mesh>().get();
                    if (parentMesh)
                    {
                        Ogre::Bone* bone = parentMesh->GetBone(boneName);
                        if (bone)
                        {
                            // Create the node for bone attachment if it did not exist already
                            if (!boneAttachmentNode_)
                            {
                                boneAttachmentNode_ = sceneMgr->createSceneNode(world->GetUniqueObjectName("EC_Placeable_BoneAttachmentNode"));
                                root_node->addChild(boneAttachmentNode_);
                            }
                            
                            // Setup manual bone tracking, as Ogre does not allow to attach scene nodes to bones
                            attachmentListener.AddAttachment(parentMesh->GetEntity(), bone, this);
                            
                            boneAttachmentNode_->addChild(sceneNode_);
                            
                            parentBone_ = bone;
                            parentMesh_ = parentMesh;
                            connect(parentMesh, SIGNAL(MeshAboutToBeDestroyed()), this, SLOT(OnParentMeshDestroyed()), Qt::UniqueConnection);
                            attached_ = true;
                            return;
                        }
                        else
                        {
                            // Could not find the bone. Connect to the parent mesh MeshChanged signal to wait for the proper mesh to be assigned.
                            connect(parentMesh, SIGNAL(MeshChanged()), this, SLOT(OnParentMeshChanged()), Qt::UniqueConnection);
                            return;
                        }
                    }
                    else
                    {
                        // If can't find the mesh component yet, wait for it to be created
                        connect(parentEntity, SIGNAL(ComponentAdded(IComponent*, AttributeChange::Type)), this, SLOT(OnComponentAdded(IComponent*, AttributeChange::Type)), Qt::UniqueConnection);
                        return;
                    }
                }
                
                parentPlaceable_ = parentEntity->GetComponent<EC_Placeable>().get();
                if (parentPlaceable_)
                {
                    parentPlaceable_->GetSceneNode()->addChild(sceneNode_);
                    
                    // Connect to destruction of the placeable to be able to detach gracefully
//.........这里部分代码省略.........
开发者ID:Ilikia,项目名称:naali,代码行数:101,代码来源:EC_Placeable.cpp

示例12: IComponent

EC_WaterPlane::EC_WaterPlane(Scene* scene) :
    IComponent(scene),
    xSize(this, "x-size", 5000),
    ySize(this, "y-size", 5000),
    depth(this, "Depth", 20),
    position(this, "Position", float3::zero),
    rotation(this, "Rotation", Quat::identity),
    scaleUfactor(this, "U factor", 0.0002f),
    scaleVfactor(this, "V factor", 0.0002f),
    xSegments(this, "Segments in x", 10),
    ySegments(this, "Segments in y", 10),
    materialName(this, "Material", QString("Ocean")),
    materialRef(this, "Material ref"),
   //textureNameAttr(this, "Texture", QString("DefaultOceanSkyCube.dds")),
    fogColor(this, "Fog color", Color(0.2f,0.4f,0.35f,1.0f)),
    fogStartDistance(this, "Fog start dist.", 100.f),
    fogEndDistance(this, "Fog end dist.", 2000.f),
    fogMode(this, "Fog mode", 3),
    entity_(0),
    node_(0),
    attached_(false),
    attachedToRoot_(false)
{
    static AttributeMetadata metadata;
    static bool metadataInitialized = false;
    if(!metadataInitialized)
    {
        metadata.enums[Ogre::FOG_NONE] = "NoFog";
        metadata.enums[Ogre::FOG_EXP] = "Exponential";
        metadata.enums[Ogre::FOG_EXP2] = "ExponentiallySquare";
        metadata.enums[Ogre::FOG_LINEAR] = "Linear";
        metadataInitialized = true;
    }

    fogMode.SetMetadata(&metadata);

    if (scene)
        world_ = scene->GetWorld<OgreWorld>();
    OgreWorldPtr world = world_.lock();
    if (world)
    {
        Ogre::SceneManager *sceneMgr = world->GetSceneManager();
        node_ = sceneMgr->createSceneNode(world->GetUniqueObjectName("EC_WaterPlane_Root"));
    }

    QObject::connect(this, SIGNAL(AttributeChanged(IAttribute*, AttributeChange::Type)),
        SLOT(OnAttributeUpdated(IAttribute*, AttributeChange::Type)));

    lastXsize_ = xSize.Get();
    lastYsize_ = ySize.Get();

    connect(this, SIGNAL(ParentEntitySet()), this, SLOT(SetParent()));

    // If there exist placeable copy its position for default position and rotation.
   
    /*
    EC_Placeable* placeable = dynamic_cast<EC_Placeable*>(FindPlaceable().get());
    if (placeable != 0)
    {
        float3 vec = placeable->GetPosition();
        position.Set(vec,AttributeChange::Default);
   
        Quaternion rot =placeable->GetOrientation();
        rotation.Set(rot, AttributeChange::Default);
        ComponentChanged(AttributeChange::Default);
    }
    */
}
开发者ID:Ilikia,项目名称:naali,代码行数:68,代码来源:EC_WaterPlane.cpp

示例13: Create

void EC_Clone::Create()
{
    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 *placeable = entity->GetComponent<EC_Placeable>().get();
    assert(placeable);
    if (!placeable)
        return;

    Ogre::SceneManager *sceneMgr = renderer_.lock()->GetSceneManager();
    assert(sceneMgr);
    if (!sceneMgr)
        return;

    Ogre::Entity *originalEntity  = 0;
    Ogre::SceneNode *originalNode = 0;

    // Check out if this entity has EC_Mesh or EC_OgreCustomObject.
    if (entity->GetComponent(EC_Mesh::TypeNameStatic()))
    {
        EC_Mesh *ec_mesh= entity->GetComponent<EC_Mesh>().get();
        assert(ec_mesh);

        originalEntity = ec_mesh->GetEntity();
        //originalNode = placeable->GetSceneNode();
        originalNode = ec_mesh->GetAdjustmentSceneNode();

        sceneNode_ = sceneMgr->createSceneNode();
        sceneNode_->setPosition(originalNode->getPosition());
        originalNode->addChild(sceneNode_);
    }
    else if(entity->GetComponent(EC_OgreCustomObject::TypeNameStatic()))
    {
        EC_OgreCustomObject *ec_custom = entity->GetComponent<EC_OgreCustomObject>().get();
        assert(ec_custom);
        if (!ec_custom->IsCommitted())
        {
            LogError("Mesh entity have not been created for the target primitive. Cannot create EC_Clone.");
            return;
        }

        originalEntity = ec_custom->GetEntity();
        originalNode = placeable->GetSceneNode();

        sceneNode_ = sceneMgr->createSceneNode();
        sceneNode_->setPosition(originalNode->getPosition());
        originalNode->addChild(sceneNode_);
    }
    else
    {
        LogError("This entity doesn't have either EC_Mesh or EC_OgreCustomObject present. Cannot create EC_Clone.");
        return;
    }

    assert(originalEntity);
    if (!originalEntity)
        return;

    assert(sceneNode_);
    if (!sceneNode_)
        return;

    // Clone the Ogre entity.
    cloneName_ = renderer_.lock()->GetUniqueObjectName("EC_Clone_ent");
    entityClone_ = originalEntity->clone(cloneName_);
    assert(entityClone_);

    // Disable casting of shadows for the clone.
    entityClone_->setCastShadows(false);

    ///\todo If original entity has skeleton, (try to) link it to the clone.
/*
    if (originalEntity->hasSkeleton())
    {
        Ogre::SkeletonInstance *skel = originalEntity->getSkeleton();
        // If sharing a skeleton, force the attachment mesh to use the same skeleton
        // This is theoretically quite a scary operation, for there is possibility for things to go wrong
        Ogre::SkeletonPtr entity_skel = originalEntity->getMesh()->getSkeleton();
        if (entity_skel.isNull())
        {
            LogError("Cannot share skeleton for attachment, not found");
        }
        else
        {
            try
            {
                entityClone_->getMesh()->_notifySkeleton(entity_skel);
            }
            catch (Ogre::Exception &e)
//.........这里部分代码省略.........
开发者ID:A-K,项目名称:naali,代码行数:101,代码来源:EC_Clone.cpp

示例14: createScene

	 void createScene(){
		_sceneManager->setAmbientLight(Ogre::ColourValue(1.0f,1.0f,1.0f));
		_sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);

		_sceneManager->setSkyBox(true, "OMV/SkyBoxUnderwater1");

		Ogre::Plane plane(Ogre::Vector3::UNIT_Y , -5000.0);

		Ogre::MeshManager::getSingleton().createPlane("plane", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, 
						plane, 60000,100000,200,200,true, 1,10,10, Ogre::Vector3::UNIT_Z);
		Ogre::SceneNode* nodePlano;
		Ogre::Entity* entPlano = _sceneManager->createEntity("PlanoEntity","plane");
		nodePlano = _sceneManager->createSceneNode("NodePlano");
		nodePlano->attachObject(entPlano);
		_sceneManager->getRootSceneNode()->addChild(nodePlano);
		entPlano->setMaterialName("plano");
		nodePlano->translate(Ogre::Vector3(0.0f,0.0f,45000.0f));
		
		
		Ogre::SceneNode* nodeEsfera02;
		Ogre::Light* light02;
		Ogre::Entity* entEsfera02 = _sceneManager->createEntity("EntEsfera02","sphere.mesh");
		//Ogre::SceneNode* nodeEsfera02 = mSceneMgr->createSceneNode("NodeEsfera02");
		nodeEsfera02 = _sceneManager->createSceneNode("NodeEsfera02");
		_sceneManager->getRootSceneNode()->addChild(nodeEsfera02);
		nodeEsfera02->attachObject(entEsfera02);
		
		 //NODO LUZ
		float lightScale = 0.9f;
		Ogre::SceneNode* nodeLuz02 = _sceneManager->createSceneNode("NodeLuz02");		
		light02 = _sceneManager->createLight("LuzPoint01");
		light02->setType(Ogre::Light::LT_POINT);		
		light02->setDiffuseColour(lightScale*Ogre::ColourValue(2.0f,2.0f,2.0f));	
		nodeLuz02->attachObject(light02);


		nodeEsfera02->addChild(nodeLuz02);
		nodeEsfera02->setScale(0.05f,0.05f,0.05f);
		nodeEsfera02->setPosition(0.0f,5000.0f,0.0f);

		banderin[0] = new Banderin("Inicio",_sceneManager, 5105.0, -2000.0, 0.0);
		_sceneManager->getRootSceneNode()->addChild(banderin[0]->nodoBanderin);
		banderin[1] = new Banderin("Fin",_sceneManager, 5105.0, -2000.0, 90000.0);
		_sceneManager->getRootSceneNode()->addChild(banderin[1]->nodoBanderin);

		
		

		nave = new Nave(_sceneManager, _sceneManager->getCamera("Camera"));

		for (int i = 0; i < num_monedas; i++)
		{
			crearMoneda(i,4000,5000,90000);
		}

		for (int i = 0; i < num_aros; i++)
		{
			crearAro(i,4000,5000,90000);
		}

		for (int i = 0; i < num_obstaculo; i++)
		{
			crearObstaculo(i,4000,5000,90000);
		}
		
	 }
开发者ID:luiscarlo6,项目名称:Computacion-Grafica-USB,代码行数:66,代码来源:main.cpp


注:本文中的ogre::SceneManager::createSceneNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。