Exemple #1
0
void Actors::updateObjectCell(const MWWorld::Ptr &old, const MWWorld::Ptr &cur)
{
    Ogre::SceneNode *node;
    MWWorld::CellStore *newCell = cur.getCell();

    CellSceneNodeMap::const_iterator celliter = mCellSceneNodes.find(newCell);
    if(celliter != mCellSceneNodes.end())
        node = celliter->second;
    else
    {
        node = mRootNode->createChildSceneNode();
        mCellSceneNodes[newCell] = node;
    }
    node->addChild(cur.getRefData().getBaseNode());

    PtrAnimationMap::iterator iter = mAllActors.find(old);
    if(iter != mAllActors.end())
    {
        Animation *anim = iter->second;
        mAllActors.erase(iter);
        anim->updatePtr(cur);
        mAllActors[cur] = anim;
    }

    mRendering->updateWaterRippleEmitterPtr (old, cur);
}
Exemple #2
0
void EC_WaterPlane::AttachEntity()
{
    if (attached_ || entity_ == 0)
        return;

    EC_Placeable* placeable = dynamic_cast<EC_Placeable* >(FindPlaceable().get());
    
    // If there exist placeable attach node and entity to it
    if (placeable != 0 )
    {
        Ogre::SceneNode* node = placeable->GetSceneNode();
        node->addChild(node_);
        node_->attachObject(entity_);
        node_->setVisible(true);
    }
    else
    {
        // There is no placeable attacht entity to OgreSceneRoot 
        Ogre::SceneManager* sceneMgr = world_.lock()->GetSceneManager();
        node_->attachObject(entity_);
        sceneMgr->getRootSceneNode()->addChild(node_);
        node_->setVisible(true);
        attachedToRoot_ = true;
    }

    attached_ = true;
}
Exemple #3
0
VOID CFairyObject::SetVisible(BOOL bVisible)
{
	if(m_bVisible == bVisible) return;

	//确认是人物模型
	if(m_pFairyObj->getType() != EOBJ_TYPE_ACTOR) return;
	
	//确认资源已经Load
	Fairy::Actor* pActor = ((Fairy::ActorObject*)m_pFairyObj.get())->getActor();
	if(!pActor) return;

	Ogre::SceneNode* pParentNode = ((Fairy::ActorObject*)m_pFairyObj.get())->getSceneNode();
	Ogre::SceneNode* pActorNode = (((Fairy::ActorObject*)m_pFairyObj.get())->getActor())->getSceneNode();

	if(bVisible)
	{
		pParentNode->addChild(pActorNode);
	}
	else
	{
		pParentNode->removeChild(pActorNode);
	}

	m_bVisible = bVisible;
}
void EC_OgreMovableTextOverlay::AttachNode()
{
    // Using the link scene node is necessary here so that the overlays can use the _update() trick to avoid stutter
    if ((node_) && (!attached_) && (placeable_))
    {
        Ogre::SceneNode* parent =
            checked_static_cast<EC_OgrePlaceable*>(placeable_.get())->GetLinkSceneNode();
        parent->addChild(node_);
        attached_ = true;
    }
}
Exemple #5
0
void Objects::updateObjectCell(const MWWorld::Ptr &old, const MWWorld::Ptr &cur)
{
    Ogre::SceneNode *node;
    MWWorld::CellStore *newCell = cur.getCell();

    if(mCellSceneNodes.find(newCell) == mCellSceneNodes.end()) {
        node = mRootNode->createChildSceneNode();
        mCellSceneNodes[newCell] = node;
    } else {
        node = mCellSceneNodes[newCell];
    }
    node->addChild(cur.getRefData().getBaseNode());
}
Exemple #6
0
void EC_Mesh::AttachEntity()
{
    if ((attached_) || (!entity_) || (!placeable_))
        return;
    
    EC_Placeable* placeable = checked_static_cast<EC_Placeable*>(placeable_.get());
    Ogre::SceneNode* node = placeable->GetSceneNode();
    node->addChild(adjustment_node_);
    adjustment_node_->attachObject(entity_);

    // Honor the EC_Placeable's isVisible attribute by enforcing its values on this mesh.
    adjustment_node_->setVisible(placeable->visible.Get());

    attached_ = true;
}
Exemple #7
0
void
Objects::updateObjectCell(const MWWorld::Ptr &ptr)
{
    Ogre::SceneNode *node;
    MWWorld::CellStore *newCell = ptr.getCell();

    if(mCellSceneNodes.find(newCell) == mCellSceneNodes.end()) {
        node = mMwRoot->createChildSceneNode();
        mCellSceneNodes[newCell] = node;
    } else {
        node = mCellSceneNodes[newCell];
    }
    node->addChild(ptr.getRefData().getBaseNode());

    /// \note Still unaware how to move aabb and static w/o full rebuild,
    /// moving static objects may cause problems
    insertMesh(ptr, MWWorld::Class::get(ptr).getModel(ptr));
}
void Camera::onSetTarget(const GameHandle& target)
{
	//! \hack const offset for camera
	v3 offset(0.0f, 3.0f, -14);

	Ogre::SceneManager* sceneMgr = Ogre::Root::getSingleton().getSceneManager(BFG_SCENEMANAGER);

	if (!sceneMgr->hasSceneNode(stringify(target)))
	{
		errlog << "Target (" << stringify(target) << ") for camera (" << mHandle << ") does not exist!";
		return;
	}

	Ogre::SceneNode* newParent = sceneMgr->getSceneNode(stringify(target));
	Ogre::SceneNode* oldParent = mCameraNode->getParentSceneNode();
	oldParent->removeChild(mCameraNode);
	newParent->addChild(mCameraNode);

	mCameraNode->setPosition(toOgre(offset));
}
Exemple #9
0
void EC_WaterPlane::ComponentAdded(IComponent* component, AttributeChange::Type type)
{
    if (component->TypeName() == EC_Placeable::TypeNameStatic())
    {
        DetachEntity();

        EC_Placeable* placeable = static_cast<EC_Placeable* >(component);
        if (placeable == 0)
            return;
        if (entity_ == 0)
            return;

        Ogre::SceneNode* node = placeable->GetSceneNode();
        
        node->addChild(node_);
        node_->attachObject(entity_);
        node_->setVisible(true);

        attached_ = true;
    }
}
	void createScene()
	{ 

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

		 
	/*			
		Ogre::Entity* entMesh01 = mSceneMgr->createEntity("MyEntity1","ogrehead.mesh");
		Ogre::SceneNode* nodeMesh01 = mSceneMgr->createSceneNode("NodeMesh01");
		mSceneMgr->getRootSceneNode()->addChild(nodeMesh01);
		nodeMesh01->setPosition(0.0,0.0,0.0);
		nodeMesh01->attachObject(entMesh01);
	*/	
		
		Ogre::Entity* ent01 = mSceneMgr->createEntity("MyEntity1","ejes01.mesh");
		Ogre::SceneNode* node01 = mSceneMgr->createSceneNode("Node01");
		mSceneMgr->getRootSceneNode()->addChild(node01);
		node01->attachObject(ent01);

		Ogre::Entity* ent02 = mSceneMgr->createEntity("MyEntity2","cuadriculaX01.mesh");
		Ogre::SceneNode* node02 = mSceneMgr->createSceneNode("Node02");
		mSceneMgr->getRootSceneNode()->addChild(node02);
		node02->attachObject(ent02);

		Ogre::SceneNode* nodeSinbad = mSceneMgr->createSceneNode("NodeSinbad");
		Ogre::SceneNode* nodeEjeSinbad = mSceneMgr->createSceneNode("NodeEjeSinbad");
		Ogre::SceneNode* nodeNinja = mSceneMgr->createSceneNode("NodeNinja");

		Ogre::Entity* entSinbad = mSceneMgr->createEntity("MyEntitySinbad","sinbad.mesh");
		Ogre::Entity* entEjeSinbad = mSceneMgr->createEntity("MyEntityEjeSinbad","ejes01.mesh");
		Ogre::Entity* entNinja = mSceneMgr->createEntity("MyEntityNinja","ninja.mesh");
		
		mSceneMgr->getRootSceneNode()->addChild(nodeEjeSinbad);
		nodeEjeSinbad->attachObject(entEjeSinbad);
		nodeEjeSinbad->addChild(nodeSinbad);
		nodeEjeSinbad->addChild(nodeNinja);


		nodeSinbad->attachObject(entSinbad);
		nodeNinja->attachObject(entNinja);

		//eje
		nodeEjeSinbad->setScale(0.6,0.6,0.6);
		nodeEjeSinbad->setPosition(5.0,0.0,0.0);
		nodeEjeSinbad->translate(2.0,0.0,2.0);
		nodeEjeSinbad->yaw(Ogre::Degree(45.0f)); //rota en Y
		//nodeEjeSinbad->pitch(Ogre::Degree(45.0f));//rota en X
		//nodeEjeSinbad->roll(Ogre::Degree(45.0f));//rota en Z

		//Hijo Sinbad
		nodeSinbad->setScale(0.8,0.8,0.8);
		nodeSinbad->translate(0.0,0.0,8.0,Ogre::Node::TS_WORLD);

		//Hijo Ninja
		nodeNinja->setScale(0.04,0.04,0.04);
		nodeNinja->yaw(Ogre::Degree(180.0f));
		nodeNinja->setPosition(4.0,-4.0,5.0);

		/*nodeSinbad->attachObject(entEjeSinbad);
		nodeSinbad->attachObject(ejeSinbad);
		*/

	}
Exemple #11
0
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_);
}
Exemple #12
0
    void createScene() {
        Ogre::SceneNode* nroca = mSceneMgr->createSceneNode("nroca");
        Ogre::Entity *roca = mSceneMgr->createEntity("roca", "cube.mesh");
        nroca->attachObject(roca);
        mSceneMgr->getRootSceneNode()->addChild(nroca);

        Ogre::SceneNode* ntronco = mSceneMgr->createSceneNode("ntronco");
        Ogre::Entity *tronco = mSceneMgr->createEntity("tronco", "cube.mesh");
        ntronco->attachObject(tronco);
        mSceneMgr->getRootSceneNode()->addChild(ntronco);

        Ogre::SceneNode* ncabeza = mSceneMgr->createSceneNode("ncabeza");
        Ogre::Entity *cabeza = mSceneMgr->createEntity("cabeza", "cube.mesh");
        ncabeza->attachObject(cabeza);
        ntronco->addChild(ncabeza);

        Ogre::SceneNode* nbase = mSceneMgr->createSceneNode("nbase");
        Ogre::Entity *base = mSceneMgr->createEntity("base", "cube.mesh");
        nbase->attachObject(base);
        ncabeza->addChild(nbase);

        Ogre::SceneNode* nsombrero = mSceneMgr->createSceneNode("nsombrero");
        Ogre::Entity *sombrero = mSceneMgr->createEntity("sombrero", "cube.mesh");
        nsombrero->attachObject(sombrero);
        nbase->addChild(nsombrero);

        Ogre::SceneNode* nbrazoizq = mSceneMgr->createSceneNode("nbrazoizq");
        Ogre::Entity *brazoizq = mSceneMgr->createEntity("brazoizq", "cube.mesh");
        nbrazoizq->attachObject(brazoizq);
        ntronco->addChild(nbrazoizq);

        Ogre::SceneNode* nbrazoder = mSceneMgr->createSceneNode("nbrazoder");
        Ogre::Entity *brazoder = mSceneMgr->createEntity("brazoder", "cube.mesh");
        nbrazoder->attachObject(brazoder);
        ntronco->addChild(nbrazoder);

        Ogre::SceneNode* npiernaizq = mSceneMgr->createSceneNode("npiernaizq");
        Ogre::Entity *piernaizq = mSceneMgr->createEntity("piernaizq", "cube.mesh");
        npiernaizq->attachObject(piernaizq);
        ntronco->addChild(npiernaizq);

        Ogre::SceneNode* npiernader = mSceneMgr->createSceneNode("npiernader");
        Ogre::Entity *piernader = mSceneMgr->createEntity("piernader", "cube.mesh");
        npiernader->attachObject(piernader);
        ntronco->addChild(npiernader);

        Ogre::SceneNode* npieder = mSceneMgr->createSceneNode("npieder");
        Ogre::Entity *pieder = mSceneMgr->createEntity("pieder", "cube.mesh");
        npieder->attachObject(pieder);
        npiernader->addChild(npieder);



        nroca->setPosition(0,7,0);
        nroca->setScale(7,7,7);
        nroca->pitch(Degree(30));
        nroca->roll(Degree(-45));
        ntronco->setPosition(-20,4,0);
        ntronco->setScale(1,3,1);
        ntronco->roll(Degree(17));
        ncabeza->setPosition(0.25,1.35,0);
        ncabeza->setScale(1,0.33,1);
        ncabeza->roll(Degree(-10));
        nbase->setPosition(0.25,2,0);
        nbase->setScale(1,0.15,1);
        nbase->roll(Degree(-30));
        nsombrero->setPosition(0,2.5,0);
        nsombrero->setScale(0.5,3.5,0.5);
        nbrazoder->setScale(0.5,1,0.5);
        nbrazoder->setPosition(-2,0.65,-2.25);
        nbrazoder->roll(Degree(90));
        nbrazoder->pitch(Degree(-30));
        nbrazoizq->setScale(0.5,1,0.5);
        nbrazoizq->setPosition(-2,0.65,2.25);
        nbrazoizq->roll(Degree(100));
        nbrazoizq->pitch(Degree(30));
        npiernaizq->setPosition(-1.75,-1.75,-0.25);
        npiernaizq->setScale(0.5,1,0.5);
        npiernaizq->roll(Degree(-45));
        npiernader->setPosition(1,-1.35,0.5);
        npiernader->setScale(0.5,0.5,0.5);
        npiernader->roll(Degree(35));
        npieder->setPosition(2.25,-1.25,1.75);
        npieder->roll(Degree(90));




        Ogre::Plane pl1(Ogre::Vector3::UNIT_Y, -5);
        Ogre::MeshManager::getSingleton().createPlane("pl1",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,pl1,200,200,1,1,true,1,20,20,Ogre::Vector3::UNIT_Z);
        Ogre::SceneNode* nground = mSceneMgr->createSceneNode("ground");
        Ogre::Entity *ground = mSceneMgr->createEntity("pEnt","pl1");
        ground->setMaterialName("Ground");
        nground->attachObject(ground);
        mSceneMgr->getRootSceneNode()->addChild(nground);

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