コード例 #1
0
ファイル: lagom_player_base.cpp プロジェクト: jaschmid/Lagom
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();
}
コード例 #2
0
ファイル: EC_Mesh.cpp プロジェクト: katik/naali
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);
    }
}
コード例 #3
0
	 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);

	 }
コード例 #4
0
//!
//! 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);
		
	}
}
コード例 #5
0
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"));

}
コード例 #6
0
void ThirdPersonCameraMount::createNodesForCamera(Ogre::SceneManager& sceneManager) {
	mCameraRootNode = sceneManager.createSceneNode(OgreInfo::createUniqueResourceName("ThirdPersonCameraRootNode"));
	mCameraRootNode->setInheritOrientation(false);
	mCameraRootNode->setInheritScale(false);
	//we need to adjust for the height of the  mesh
	mCameraRootNode->setPosition(Ogre::Vector3(0, 2, 0));
	//Start camera behind avatar
	mCameraRootNode->yaw(Ogre::Degree(180));

	mCameraPitchNode = mCameraRootNode->createChildSceneNode(OgreInfo::createUniqueResourceName("ThirdPersonCameraPitchNode"));
	mCameraPitchNode->setPosition(Ogre::Vector3(0, 0, 0));
	mCameraPitchNode->setInheritScale(false);

	//The camera node isn't actually attached to the pitch node. We'll instead adjust it each frame to match the pitch node, adjusted by collisions.
	mCameraNode = sceneManager.createSceneNode(OgreInfo::createUniqueResourceName("ThirdPersonCameraNode"));
	mCameraNode->setInheritScale(false);
	mCameraNode->setFixedYawAxis(true); //Important that we set this to disallow the camera from rolling.

	setCameraDistance(10);
	Ogre::Vector3 pos(0, 0, 10);
	mCameraNode->setPosition(pos);

}
コード例 #7
0
ファイル: MyFrameListener.cpp プロジェクト: flush/CEDV-2015
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);
}
コード例 #8
0
ファイル: EC_Placeable.cpp プロジェクト: Ilikia/naali
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();
    }
}
コード例 #9
0
ファイル: lagom_player_base.cpp プロジェクト: jaschmid/Lagom
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();
}
コード例 #10
0
ファイル: EC_Mesh.cpp プロジェクト: katik/naali
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)
    {
        LogError("EC_Mesh::SetAttachmentMesh: Could not set attachment mesh " + mesh_name + ": " + std::string(e.what()));
        return false;
    }
    return true;
}
コード例 #11
0
ファイル: main.cpp プロジェクト: Isaj7/finalOgre
			// 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);
				alad->index(1);
				alad->index(2);
				alad->index(3);
				alad->index(0);

				alad->end();
				padreDI->attachObject(alad);


				Ogre::ManualObject* alad2 = _sceneManager->createManualObject("alad2");
				alad2->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_FAN);
				alad2->colour(Ogre::ColourValue(0.0, 0.6, 0.0, 0.0));
	
				alad2->position(5.0,  0.0, 0.0);  
				alad2->position(15.0,  0.0, 0.0); 
				alad2->position(14.0, 0.0, -3.0);
				alad2->position(5.0,  0.0, -4.0);

				alad2->index(0);
				alad2->index(1);
				alad2->index(2);
				alad2->index(3);
				alad2->index(0);

				alad2->end();
				padreDI->attachObject(alad2);

	
				/* ALA DERECHA SUPERIOR */

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

				Ogre::ManualObject* aladS = _sceneManager->createManualObject("aladS");
				aladS->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_FAN);
				aladS->colour(Ogre::ColourValue(0.0, 0.5, 0.0, 0.0));

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

				aladS->index(0);
				aladS->index(1);
				aladS->index(2);
				aladS->index(3);
				aladS->index(0);

				aladS->end();
				padreDS->attachObject(aladS);


				Ogre::ManualObject* aladS2 = _sceneManager->createManualObject("aladS2");
				aladS2->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_FAN);
				aladS2->colour(Ogre::ColourValue(0.0, 0.6, 0.0, 0.0));
	
				aladS2->position(5.0,  0.5, 0.0);  
				aladS2->position(15.0,  0.5, 0.0); 
				aladS2->position(14.0, 0.5, -3.0);
				aladS2->position(5.0,  0.5, -3.0);

				aladS2->index(0);
				aladS2->index(1);
				aladS2->index(2);
				aladS2->index(3);
				aladS2->index(0);

				aladS2->end();
				padreDS->attachObject(aladS2);



			/* ALA IZQUIERDA INFERIOR */

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

				Ogre::ManualObject* aladI = _sceneManager->createManualObject("aladI");
				aladI->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_FAN);
				aladI->colour(Ogre::ColourValue(0.0, 0.5, 0.0, 0.0));

				aladI->position(-15.0, -0.5, 0.0);
				aladI->position(5.0, -0.5, 0.0);		
				aladI->position(-5.0, 0.0, 0.0);  
				aladI->position(-15.0, 0.0, 0.0); 


				aladI->index(0);
				aladI->index(1);
				aladI->index(2);
				aladI->index(3);
				aladI->index(0);

				aladI->end();
				padreII->attachObject(aladI);


				Ogre::ManualObject* aladI2 = _sceneManager->createManualObject("aladI2");
				aladI2->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_FAN);
				aladI2->colour(Ogre::ColourValue(0.0, 0.6, 0.0, 0.0));
	
				aladI2->position(-15.0,  0.0, 0.0); 
				aladI2->position(-5.0,  0.0, 0.0);  
				aladI2->position(-5.0,  0.0, -4.0);
				aladI2->position(-14.0, 0.0, -3.0);



				aladI2->index(0);
				aladI2->index(1);
				aladI2->index(2);
				aladI2->index(3);
				aladI2->index(0);

				aladI2->end();
				padreII->attachObject(aladI2);


			/* ALA IZQUIERDA SUPERIOR */

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

				Ogre::ManualObject* aladIS = _sceneManager->createManualObject("aladIS");
				aladIS->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_FAN);
				aladIS->colour(Ogre::ColourValue(0.0, 0.5, 0.0, 0.0));

				aladIS->position(-15.0, 0.0, 0.0);
				aladIS->position(5.0, 0.0, 0.0);		
				aladIS->position(-5.0, 0.5, 0.0);  
				aladIS->position(-15.0, 0.5, 0.0); 


				aladIS->index(0);
				aladIS->index(1);
				aladIS->index(2);
				aladIS->index(3);
				aladIS->index(0);

				aladIS->end();
				padreIS->attachObject(aladIS);


				Ogre::ManualObject* aladIS2 = _sceneManager->createManualObject("aladIS2");
				aladIS2->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_FAN);
				aladIS2->colour(Ogre::ColourValue(0.0, 0.6, 0.0, 0.0));
	
				aladIS2->position(-15.0,  0.5, 0.0); 
				aladIS2->position(-5.0,  0.5, 0.0);  
				aladIS2->position(-5.0,  0.5, -3.0);
				aladIS2->position(-14.0, 0.5, -2.0);

				aladIS2->index(0);
				aladIS2->index(1);
				aladIS2->index(2);
				aladIS2->index(3);
				aladIS2->index(0);

				aladIS2->end();
				padreIS->attachObject(aladIS2);

				/* Rotaciones de las alas */
				eje->scale(2.5,2.5,2.5);
				eje->translate(0,5,0);
				eje->yaw(Ogre::Degree(180));

				/* Trasladar las alas */
				padreIS->translate(4,0,0);
				padreDS->translate(-4,0,0);
				padreDI->translate(-4,0,0);
				padreII->translate(4,0,0); 

				eje->scale(0.1,0.1,0.1);

				//BordePista
				Ogre::SceneNode* _nodeBPista = _sceneManager->createSceneNode("BordePista");
				_sceneManager->getRootSceneNode()->addChild(_nodeBPista);
				
				Ogre::Entity* _entBPista = _sceneManager->createEntity("BordePista", "bordePista02.mesh");
				_nodeBPista->attachObject(_entBPista);
				_entBPista->setMaterialName("Examples/pared");


				//PisoObstaculo
				Ogre::SceneNode* _nodePObstaculo = _sceneManager->createSceneNode("PistaObstaculo");
				_sceneManager->getRootSceneNode()->addChild(_nodePObstaculo);
				
				Ogre::Entity* _entPObstaculo = _sceneManager->createEntity("PistaObstaculo", "pisoObstaculo02.mesh");
				_nodePObstaculo->attachObject(_entPObstaculo);

				//PisoNOObstaculo
				Ogre::SceneNode* _nodePNObstaculo = _sceneManager->createSceneNode("PistaNoObstaculo");
				_sceneManager->getRootSceneNode()->addChild(_nodePNObstaculo);
				
				Ogre::Entity* _entPNOObstaculo = _sceneManager->createEntity("PistaNoObstaculo", "pisoNoObstaculo02.mesh");
				_nodePNObstaculo->attachObject(_entPNOObstaculo);
				_entPNOObstaculo->setMaterialName("Examples/piso");


				//PosterInicioFinal
				Ogre::SceneNode* _nodePoster = _sceneManager->createSceneNode("PosterInicioFinal");
				_sceneManager->getRootSceneNode()->addChild(_nodePoster);
				
				Ogre::Entity* _entPoster = _sceneManager->createEntity("PosterInicioFinal", "posterInicioFinal02.mesh");
				_nodePoster->attachObject(_entPoster);

				
				//BanderaInicial
				Ogre::SceneNode* _nodeBInicial = _sceneManager->createSceneNode("BanderaInicial");
				_sceneManager->getRootSceneNode()->addChild(_nodeBInicial);
				
				Ogre::Entity* _entBanderaI = _sceneManager->createEntity("BanderaInicial", "banderaInicial02.mesh");
				_nodeBInicial->attachObject(_entBanderaI);

				//BanderaFinal
				Ogre::SceneNode* _nodeBFinal = _sceneManager->createSceneNode("BanderaFinal");
				_sceneManager->getRootSceneNode()->addChild(_nodeBFinal);
				
				Ogre::Entity* _entBanderaF = _sceneManager->createEntity("BanderaFinal", "banderaFinal.mesh");
				_nodeBFinal->attachObject(_entBanderaF);

				_sceneManager->setSkyDome(true,"Examples/cielo",5,8);


			}
コード例 #12
0
ファイル: EC_Placeable.cpp プロジェクト: Ilikia/naali
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
                    connect(parentPlaceable_, SIGNAL(AboutToBeDestroyed()), this, SLOT(OnParentPlaceableDestroyed()), Qt::UniqueConnection);
                    attached_ = true;
                    return;
                }
                else
                {
                    // If can't find the placeable component yet, wait for it to be created
                    connect(parentEntity, SIGNAL(ComponentAdded(IComponent*, AttributeChange::Type)), this, SLOT(OnComponentAdded(IComponent*, AttributeChange::Type)), Qt::UniqueConnection);
                    return;
                }
            }
            else
            {
                // Could not find parent entity. Check for it later, when new entities are created into the scene
                connect(scene, SIGNAL(EntityCreated(Entity*, AttributeChange::Type)), this, SLOT(CheckParentEntityCreated(Entity*, AttributeChange::Type)), Qt::UniqueConnection);
                return;
            }
        }
コード例 #13
0
ファイル: EC_WaterPlane.cpp プロジェクト: Ilikia/naali
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);
    }
    */
}
コード例 #14
0
ファイル: EC_Clone.cpp プロジェクト: A-K/naali
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)
            {
                LogError("Could not set shared skeleton for attachment: " + std::string(e.what()));
            }
        }
    }
*/

    const std::string &material_name = "Clone";
    try
    {
        entityClone_->setMaterialName(material_name);
    }
    catch (Ogre::Exception &e)
    {
        LogError("Could not set material \"" + std::string(material_name) + "\": " + std::string(e.what()));
        return;
    }

    sceneNode_->attachObject(entityClone_);
}
コード例 #15
0
	 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);
		}
		
	 }