Esempio n. 1
0
Ball* Application::createBall(Ogre::String nme, GameObject::objectType tp, Ogre::String meshName, int x, int y, int z, Ogre::Real scale, Ogre::SceneManager* scnMgr, GameManager* ssm, Ogre::Real mss, Ogre::Real rest, Ogre::Real frict, bool kinematic, Simulator* mySim) {

	createRootEntity(nme, meshName, x, y, z);
	Ogre::SceneNode* sn = mSceneManager->getSceneNode(nme);
	Ogre::Entity* ent = SceneHelper::getEntity(mSceneManager, nme, 0);
	const btTransform pos;
	OgreMotionState* ms = new OgreMotionState(pos, sn);
	sn->setScale(scale,scale,scale);
	ent->setMaterialName("ball");

	Ball* obj = new Ball(nme, tp, mSceneManager, ssm, sn, ent, ms, mySim, mss, rest, frict, scale, kinematic);
	obj->addToSimulator();

	return obj;
}
Esempio n. 2
0
Ogre::SceneNode* createBox(Ogre::SceneManager* sceneMgr, Ogre::String name)
{
	// create an ordinary Ogre mesh with texture
	Ogre::Entity* boxEnt = sceneMgr->createEntity(name , "cube.mesh");
	
	// we need the bounding box of the cube.mesh to set the size of the Bullet box
	Ogre::AxisAlignedBox boxBb = boxEnt->getBoundingBox();
	//Ogre::Vector3 size = boxBb.getSize();
	boxEnt->setMaterialName("Examples/BumpyMetal");
	
	// create the node
	Ogre::SceneNode* boxNode = sceneMgr->getRootSceneNode()->createChildSceneNode();
	boxNode->attachObject( boxEnt );
	return boxNode;
}
Esempio n. 3
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);
}
void
    RenderEntityComp::_create(const ZEntityResource* res, Ogre::SceneManager* scnMgr, Ogre::SceneNode* node)
{
    Ogre::Entity* ent = scnMgr->createEntity(res->getKey(), res->getResourceName());
    ent->setMaterialName("PRJZ/MinecraftCharacter");
    auto scale = World::WorldScale::computeAWorldScale();
    if(!ent)
        OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Failed to create Entity", "RenderEntityComp::_create");
    //Assume the center is is at units / 2.0
    _node = node->createChildSceneNode();
    _node->attachObject(ent);
    _node->setScale(scale.metersPerUnit, scale.metersPerUnit, scale.metersPerUnit);
   // childNode->translate(0.0f, -scale.unitsPerMeter / 2.0, 0.0f);
    _node->setVisible(false);
}
Esempio n. 5
0
    void SelectionBox::performSelection(std::list<AgentId> &selection, Ogre::Camera *mCamera)
    {
        if((mRight - mLeft) * (mBottom - mTop) < 0.0001)
            return;

        float left = (mLeft + 1.f) / 2.f;
        float right = (mRight + 1.f) / 2.f;
        float top = (1.f - mBottom) / 2.f;
        float bottom = (1.f - mTop) / 2.f;
        Ogre::Ray topLeft = mCamera->getCameraToViewportRay(left, top);
        Ogre::Ray topRight = mCamera->getCameraToViewportRay(right, top);
        Ogre::Ray bottomLeft = mCamera->getCameraToViewportRay(left, bottom);
        Ogre::Ray bottomRight = mCamera->getCameraToViewportRay(right, bottom);

        // These planes have now defined an "open box" which extends to infinity in front of the camera. You can think of
        // the rectangle we drew with the mouse as being the termination point of the box just in front of the camera.
        Ogre::PlaneBoundedVolume vol;
        const Ogre::Real min = .1, max = 500;
        vol.planes.push_back(Ogre::Plane(topLeft.getPoint(min), topRight.getPoint(min), bottomRight.getPoint(min)));         // front plane
        vol.planes.push_back(Ogre::Plane(topLeft.getOrigin(), topLeft.getPoint(max), topRight.getPoint(max)));         // top plane
        vol.planes.push_back(Ogre::Plane(topLeft.getOrigin(), bottomLeft.getPoint(max), topLeft.getPoint(max)));       // left plane
        vol.planes.push_back(Ogre::Plane(bottomLeft.getOrigin(), bottomRight.getPoint(max), bottomLeft.getPoint(max)));   // bottom plane
        vol.planes.push_back(Ogre::Plane(topRight.getOrigin(), topRight.getPoint(max), bottomRight.getPoint(max)));     // right plane

        Ogre::PlaneBoundedVolumeList volList;
        volList.push_back(vol);

        mVolQuery->setVolumes(volList);
        Ogre::SceneQueryResult result = mVolQuery->execute();

        // Finally we need to handle the results of the query. First we will deselect all previously selected objects,
        // then we will select all objects which were found by the query.
        std::list<Ogre::SceneNode *> nodes;
        Ogre::SceneQueryResultMovableList::iterator iter;

        for(iter = result.movables.begin(); iter != result.movables.end(); ++iter)
        {
            Ogre::MovableObject *movable = *iter;

            if(movable->getMovableType().compare("Entity") == 0)
            {
                Ogre::Entity *pentity = static_cast<Ogre::Entity *>(movable);
                nodes.push_back(pentity->getParentSceneNode());
            }
        }

        mEngine->level()->getAgentsIdsFromSceneNodes(nodes, selection);
    }
	void RttManager::CDepthReflectionListener::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
    {
		Hydrax *mHydrax = mRttManager->mHydrax;

		mHydrax->getMesh()->getEntity()->setVisible(false);

        Ogre::SceneManager::MovableObjectIterator EntityIterator = 
			mHydrax->getSceneManager()->getMovableObjectIterator("Entity");
        Ogre::Entity* CurrentEntity;
		unsigned int k;

        mMaterials.empty();

        while (EntityIterator.hasMoreElements())
        {
            CurrentEntity = static_cast<Ogre::Entity*>(EntityIterator.peekNextValue());

			for(k = 0; k < CurrentEntity->getNumSubEntities(); k++)
			{
				mMaterials.push(CurrentEntity->getSubEntity(k)->getMaterialName());

			    CurrentEntity->getSubEntity(k)->setMaterialName(mHydrax->getMaterialManager()->getMaterial(MaterialManager::MAT_DEPTH)->getName());
			}

            EntityIterator.moveNext();
        }

        mRttManager->mPlanes[RTT_DEPTH_REFLECTION]->getParentNode()->translate(0,-mHydrax->getPlanesError(),0);
		
        bool IsInUnderwaterError = false;

		if (mHydrax->getCamera()->getDerivedPosition().y > mRttManager->mPlanes[RTT_DEPTH_REFLECTION]->getParentNode()->getPosition().y)
		{
			mCameraPlaneDiff = 0;
			IsInUnderwaterError = true;
		}
		else
		{
			mCameraPlaneDiff = 0;
		}

        mHydrax->getCamera()->enableReflection(mRttManager->mPlanes[RTT_DEPTH_REFLECTION]);

		if (!IsInUnderwaterError)
		{
            mHydrax->getCamera()->enableCustomNearClipPlane(mRttManager->mPlanes[RTT_DEPTH_REFLECTION]);
		}
    }
Esempio n. 7
0
void MainWindow::updateOGRE()
{
	QMutexLocker locker(&mutex);
	static bool updateGUI=true;


	Ogre::Root* mRoot = Ogre::Root::getSingletonPtr();
	mRoot->_fireFrameStarted();

	// loop through ogre widgets and update animation
	QList<OgreWidget*> rendlist = this->findChildren<OgreWidget*>();
	foreach (OgreWidget* w, rendlist)
	{

		// update animation for OgreWidget's sceneManager
		if (w->mRenderWindow && w->updatesEnabled())
		{
			// update OgreWidget
			w->update();
			//emit w->paintEvent(new QPaintEvent(w->rect()));
			for (Ogre::SceneManager::MovableObjectIterator mit = w->getSceneManager()->getMovableObjectIterator("Entity");
				mit.hasMoreElements(); mit.moveNext() )
			{
				Ogre::Entity *entity = static_cast<Ogre::Entity*>(mit.peekNextValue());
				if (updateGUI) {
					updateGUI = false;

				}
				// check has skeleton to avoid crash for non animable entities
				if (entity->hasSkeleton())
				{
					for (Ogre::AnimationStateIterator animIt = entity->getAllAnimationStates()->getAnimationStateIterator();
						animIt.hasMoreElements(); animIt.moveNext() )
					{
						Ogre::AnimationState *animState = animIt.peekNextValue();
						if ( animState->getEnabled() )
						{
							//std::cout << entity->getName() << " ZZZZZZZZZZZ " << animState->getAnimationName();
							animState->addTime(w->getRenderWindow()->getBestFPS()/10000);
						}
					}
				}
			}
		}
	}
	mRoot->_fireFrameRenderingQueued();
	mRoot->_fireFrameEnded();
}
Esempio n. 8
0
//-----------------------------------------------------------------------------
Ogre::SceneNode* SSAOApp::_loadMesh(const Ogre::String &_name, const Ogre::Vector3 &_pos)
{
    std::string entityName = _name+Ogre::StringConverter::toString(mScenePairs.size());

    Ogre::Entity *ent = mSceneMgr->createEntity(entityName, _name+".mesh");
    Ogre::SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode(ent->getName()+"Node", _pos);


    ent->setMaterialName("SSAO/DiffuseLight_GBuffer");
    node->attachObject(ent);

    mScenePairs.push_back(SSAOApp::ScenePair(ent, node));


    return node;
}
OgreCharacterController::OgreCharacterController(Ogre::Camera * Camera, const Ogre::String& name, const Ogre::Vector3& position)
  : CharacterController(Camera, position, name, "Sinbad.mesh", Ogre::Vector3(3, 3, 3)), lastTop(0), lastBase(0), 
  mSword1(0), mSword2(0), swordsOut(false), sliceDir(false), animTimer(0)
{
  Ogre::SceneManager * smgr = Camera->getSceneManager();
  Ogre::Entity * ent = getEntity();

  ent->getSkeleton()->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);

  mSword1 = smgr->createEntity("Sword1", "Sword.mesh");
  mSword2 = smgr->createEntity("Sword2", "Sword.mesh");
  ent->attachObjectToBone("Sheath.L", mSword1);
  ent->attachObjectToBone("Sheath.R", mSword2);

  getTargetNode()->setFixedYawAxis(true);
}
Esempio n. 10
0
/*
 * Create a fake Plane for Drag and Drop
 */   
void MyFrameListener::createBackGround() {
  Ogre::SceneManager* mSceneMgr = Ogre::Root::getSingleton().
                                  getSceneManager("mainSM");
  Ogre::Plane *mPlane = new Ogre::Plane(Ogre::Vector3::UNIT_Z, -2);

  Ogre::MeshManager::getSingleton().createPlane("backPlane",
                                                Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                                                *mPlane,800, 800, 20, 20, true, 1, 5, 5
                                                , Ogre::Vector3::UNIT_Y);
  Ogre::Entity* plane = mSceneMgr->createEntity("backPlane");
  plane->setQueryFlags(PLANE_DRAG_DROP);
  plane->setMaterialName("sheet");
  Ogre::Root::getSingleton().
      getSceneManager("mainSM")->getRootSceneNode()->
      attachObject(plane);
}
Esempio n. 11
0
void OgreWidget::placeObjectOnTerrain(const QString meshName, const Ogre::Vector3 position, const float rotationY, const Ogre::Vector3 scale)
{
    Ogre::Quaternion rotation;
    QString name(meshName);
    name.replace(".mesh", "");

    Ogre::Entity* entity = mSceneManager->createEntity(name.toStdString(), meshName.toStdString());
    entity->setQueryFlags(0xFFFFFFFF);
    rotation.FromAngleAxis(Ogre::Degree(rotationY), Ogre::Vector3::UNIT_Y);
    Ogre::SceneNode* sceneNode = mSceneManager->getRootSceneNode()->createChildSceneNode(
                position + Ogre::Vector3(0, mTerrainGroup->getHeightAtWorldPosition(position) + mTerrainPos.y - 0.2, 0),
                rotation);
    sceneNode->setScale(scale);
    sceneNode->attachObject(entity);
    addMeshInformation(entity, sceneNode);
}
Esempio n. 12
0
	Mesh* OgreSubsystem::createMesh(String mesh,String name)
	{
		String nombre = name;
		if(name=="AUTO_NAME_ME")
		{
			nombre = "OryxSceneNodeAutoNamed"+StringUtils::toString(mAutoNameIndex);
			++mAutoNameIndex;
		}
		Ogre::Entity* ent = mSceneManager->createEntity(nombre,mesh);
		Ogre::SceneNode* node  = mSceneManager->createSceneNode(nombre);
		node->attachObject(ent);
		ent->setCastShadows(false);
		Mesh* m = new Mesh(nombre,node,ent);
		mSceneNodes.push_back(m);
		return m;
	}
Esempio n. 13
0
void
	Player::stopAnimation(std::string anim)
{
	Ogre::SceneManager::MovableObjectIterator iterator = SceneManager()->getMovableObjectIterator("Entity");
	while(iterator.hasMoreElements())
	{
		Ogre::Entity* e = static_cast<Ogre::Entity*>(iterator.getNext());

		if (e->hasSkeleton())
		{
			Ogre::AnimationState *animation = e->getAnimationState(anim);
			animation->setEnabled(false);
			animation->setTimePosition(0);
		}
	}
}
void SceneLoader::createWall( Ogre::Vector3 pos, Ogre::Real scale )
{
	Ogre::Entity* ent = mSceneMgr->createEntity("atd_cube.mesh");
//  	Ogre::MeshPtr mesh = ent->getMesh();
//  	mesh->freeEdgeList();
//  	mesh->buildEdgeList();

	ent->setCastShadows(true);
	ent->setQueryFlags(AugmentedTowerDefense::MASK_WALLS);
	Ogre::SceneNode* node = mSceneRootNode->createChildSceneNode("Wall_" + AugmentedTowerDefense::HelperClass::ToString(mWallCount));
	node->setPosition(pos);
	node->setScale(Ogre::Vector3::UNIT_SCALE*scale);
	node->attachObject(ent);
	
	mWallCount++;
}
Esempio n. 15
0
//-------------------------------------------------------------------------------------
void GameMain::createScene(void)
{
	createCamera();    // Camera
	createViewports(); // Viewport
	createEnvir();     // Environment: Light, Sky, etc.

	//-------------------------
	// 地平面
	Ogre::MeshManager::getSingleton().createPlane("floor", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
		Ogre::Plane(Ogre::Vector3::UNIT_Y, 0), 100, 100, 10, 10, true, 1, 10, 10, Ogre::Vector3::UNIT_Z);

	// create a floor entity, give it a material, and place it at the origin
	Ogre::Entity* floor = mSceneMgr->createEntity("Floor", "floor");
    floor->setMaterialName("Examples/Rockwall");
	floor->setCastShadows(false);
    mSceneMgr->getRootSceneNode()->attachObject(floor);

	//-------------------------
	// 创建障碍物分布地图
	//-------------------------
	// 创建障碍物
	/*Ogre::SceneNode * boxNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
	Entity * boxEntity = mSceneMgr->createEntity("Box","cube.mesh");
	boxEntity->setMaterialName("Examples/BumpyMetal");
	
	boxNode->attachObject( boxEntity );
	boxNode->scale( 0.01f, 0.01f, 0.01f );
	boxNode->setPosition( 0,0.5,0 );

	boxNodes.push_back( boxNode );
	boxEntitys.push_back( boxEntity );*/

	Ogre::SceneNode * ogreHeadNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
	Entity * ogreHeadEntity = mSceneMgr->createEntity("OgreHead","ogrehead.mesh");
	
	ogreHeadNode->attachObject( ogreHeadEntity );
	ogreHeadNode->scale( 0.02f, 0.02f, 0.02f );
	//ogreHeadNode->setPosition( 1, 0, 1 );
	ogreHeadNode->setPosition( 15, 0.5, -20 );

	boxNodes.push_back( ogreHeadNode );
	boxEntitys.push_back( ogreHeadEntity );

	//-------------------------
	// 创建角色
	mPlayer = new GamePlayer( mCamera, ogreHeadNode );
}
Esempio n. 16
0
void Actor::AddBoneVisualizer()
{
	SkeletonInstance* pSkeletonInstance = _pBodyEntity->getSkeleton();

	if (!pSkeletonInstance)
	{
		return;
	}

	Skeleton::BoneIterator it = pSkeletonInstance->getBoneIterator();
	while (it.hasMoreElements())
	{
		Bone* pBone = it.getNext();

		Bone::ChildNodeIterator cit = pBone->getChildIterator();
		int iCount = 0;
		while (cit.hasMoreElements())
		{
			Node* pChild = cit.getNext();
			iCount++;

			String strName = pBone->getName() + "_" + pChild->getName();
			Ogre::Entity* ent = OgreFramework::getSingletonPtr()->m_pSceneMgr->createEntity(strName, "bone.mesh");
			TagPoint* pTag	= _pBodyEntity->attachObjectToBone(pBone->getName(), ent);

			ent->setVisible(_bShowBone);

			_Entitys.push_back(ent);

			_BoneVisuals[pTag] = pChild;
		}

		if (iCount == 0)
		{
			Ogre::Entity* ent = OgreFramework::getSingletonPtr()->m_pSceneMgr->createEntity(pBone->getName(), "bone.mesh");
			TagPoint* pTag	= _pBodyEntity->attachObjectToBone(pBone->getName(), ent);

			ent->setVisible(_bShowBone);

			_Entitys.push_back(ent);

			_BoneVisuals[pTag] = 0;
		}
	}

	_UpdateBoneVisualizer();
}
Esempio n. 17
0
void Cube::save(Ogre::String file)
{
  if (rndCounter == 0)
  {
    std::ofstream output(file.c_str());

    // Write cube size
    output << size << std::endl;

    for (int i = 0; i < size; ++i)
      for (int j = 0; j < size; ++j)
        for (int k = 0; k < size; ++k)
        {
          CubeElement *e = data[i][j][k];
          Ogre::Entity *ent = static_cast<Ogre::Entity*>(e->node->getAttachedObject(0));
          Ogre::SceneNode *node = e->node;
          // Write name, indexes and position
          output << node->getName() << "\n"
                 << "\t" << i << " " << j << " " << k << "\n" // index in data array
                 << "\t" << node->getPosition().x << " " << node->getPosition().y << " " << node->getPosition().z << "\n"; // position
          // Write orientation
          Ogre::Vector3 orient_axis;
          Ogre::Degree orient_angle;
          node->getOrientation().ToAngleAxis(orient_angle, orient_axis);
          output << "\t" << orient_axis.x << " " << orient_axis.y << " " << orient_axis.z << " " // orientation axis
                 << orient_angle.valueDegrees() << "\n"; // orientation angle
          output << "\t" << ent->getSubEntity(0)->getMaterialName() << "\n"
                 << "\t" << ent->getSubEntity(1)->getMaterialName() << "\n"
                 << "\t" << ent->getSubEntity(2)->getMaterialName() << "\n"
                 << "\t" << ent->getSubEntity(3)->getMaterialName() << "\n"
                 << "\t" << ent->getSubEntity(4)->getMaterialName() << "\n"
                 << "\t" << ent->getSubEntity(5)->getMaterialName() << "\n";
          // Write pivot info
          output << "\t" << e->isPivot << "\n";
          if (e->isPivot)
          {
            // pivot indexes
            output << "\t" << e->pivotArrays[0] << " " << e->pivotArrayIndexes[0] << "\n"
                   << "\t" << e->pivotArrays[1] << " " << e->pivotArrayIndexes[1] << "\n";
          }
          // flush
          output << std::endl;
        }

    output.close();
  }
}
Esempio n. 18
0
    const char *mesh_anim_name ( void *mesh, int index ) {
        Ogre::Entity *e = static_cast<Ogre::Entity *> ( mesh );
        auto iter = e->getAllAnimationStates()->getAnimationStateIterator();

        int c = 0;
        while ( iter.hasMoreElements() ) {
            auto s = iter.getNext();

            if ( c == index ) {
                return s->getAnimationName().c_str();
            }

            c++;
        }

        return "";
    }
Esempio n. 19
0
void Player::create(Ogre::Degree p, Ogre::Degree r, Ogre::Degree y)
{
    Ogre::MeshManager::getSingleton().create("cube.mesh", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    Ogre::Entity* entity = sceneMgr->createEntity(Ogre::MeshManager::getSingleton().getByName(
     "cube.mesh", 
     Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME));
    Ogre::Vector3 newPos(position.x, position.y, position.z);
    endPos = newPos;
    rootNode = sceneMgr->getRootSceneNode()->createChildSceneNode(name, newPos);
    rootNode->setScale(length()/100.0, length()/100.0, length()/100.0);
    rootNode->attachObject(entity);
    // rootNode->setScale(.6, .6, .6);
    entity->setMaterialName("Cube/Blend"); 
    rootNode->pitch(Ogre::Degree(p));
    rootNode->roll(Ogre::Degree(r));
    startPosition = position;
}
Esempio n. 20
0
bool MyFrameListener::deleteBoard()
{
	for (int i=0; i<_XMAX; i++)
	{
		for (int j=0; j<_YMAX; j++)
		{
			myBoard[i][j]=0;
		}
	}
	for (int i=0; i<_XMAX; i++)
	{
		for (int j=0; j<_YMAX; j++)
		{
			myBoardPlayer[i][j]=0;
		}
	}

	_maxFires=0;

	_sceneManager->getRootSceneNode()->removeAndDestroyAllChildren();
	_sceneManager->clearScene();

	// Añadir el plano a la escena
	// Creacion del plano
	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);

	// Añadir el plano a la escena
	Ogre::SceneNode* nodeG = _sceneManager->createSceneNode("nodeG");
	Ogre::Entity* grEnt = _sceneManager->createEntity("pEnt", "pl1");
	grEnt->setMaterialName("Ground");
	nodeG->attachObject(grEnt);

	// Sombras
	_sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
	Ogre::Light* light = _sceneManager->createLight("light1");
	light->setType(Ogre::Light::LT_DIRECTIONAL);
	light->setDirection(Ogre::Vector3(1,-1,0));
	nodeG->attachObject(light);
	_sceneManager->getRootSceneNode()->addChild(nodeG);


	return true;
}
Esempio n. 21
0
void ClientCourt::makePlane(std::string name, const Ogre::Vector3& planeNormal, const Ogre::Vector3& textureUp, const Ogre::String& texture, const int distance, const int length, const int height, Ogre::SceneNode* parent) {
	Ogre::Real tile = 5;
	if(texture == "Examples/TennisCourt")
		tile = 1;
	Ogre::Plane plane(planeNormal, -distance);
	Ogre::MeshManager::getSingleton().createPlane(
		name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
        	plane, length, height, 1, 1, true, 1, tile, tile, textureUp
	);
	Ogre::Entity* entSide = graphicsEngine->createEntity(name);
	if (parent == NULL)
		parentNode->attachObject(entSide);
	else
		parent->attachObject(entSide);
	entSide->setMaterialName(texture);
	entSide->setCastShadows(false);
}
// add a control point
Ogre::String CTrack::mAdd( ControlPoint tCP )
{
	Ogre::Entity *ent;
	char name[16];
	sprintf(name, "ControlPoint%d", mCount++);
	ent = mSm->createEntity(name, "point.mesh");
	ent->setQueryFlags(ObjectControl::CONTROL_POINT);

	Ogre::SceneNode *mCurrentObject = mSm->getRootSceneNode()->createChildSceneNode(std::string(name) + "Node", tCP.pos);
	mCurrentObject->attachObject(ent);
	mCurrentObject->setScale(0.05f, 0.05f, 0.05f);

	tCP.name = mCurrentObject->getName();

	CPs.push_back(tCP);

	return mCurrentObject->getName();
}
Esempio n. 23
0
void ParticleEffect::Initialize(Ogre::SceneManager *sceneManager, Ogre::SceneNode* parentNode, Ogre::String object_name, Ogre::String material_name, PhysicsEngine &physicsEngine, unsigned int parentID)
{
	PhysicsEntity::Initialize(sceneManager, parentNode, physicsEngine, parentID);
	bodyType = ENTITY_BODY_METAPHYSICAL;

	 Ogre::Entity* entity = sceneManager->createEntity(object_name);

	/* Apply a material to the entity */
	materialName = material_name + std::to_string(objectID);
	Ogre::MaterialPtr origMat = Ogre::MaterialManager::getSingleton().getByName(material_name);
	Ogre::Material* mat = origMat.get();
	mat->clone(materialName);
	entity->setMaterialName(materialName);

	sceneNode->attachObject(entity);
	sceneNode->translate(0,0,0);
	
}
Esempio n. 24
0
 Ogre::Entity* EC_OgreAnimationController::GetEntity()
 {
     if (!mesh_entity_)
         return 0;
     
     OgreRenderer::EC_OgreMesh &mesh = *checked_static_cast<OgreRenderer::EC_OgreMesh*>(mesh_entity_.get());
     Ogre::Entity* entity = mesh.GetEntity();
     if (!entity)
         return 0;
     
     if (entity->getMesh()->getName() != mesh_name_)
     {
         mesh_name_ = entity->getMesh()->getName();
         ResetState();
     }
     
     return entity;
 }
Esempio n. 25
0
Bomb::Bomb(Map *curMap, Ogre::Vector3 mapPos) :
m_map(curMap), m_mapPosition(mapPos), m_animAmount(0.0f)
{
	m_sceneMgr = Ogre::Root::getSingleton().getSceneManager("MapSceneManager");

	m_sceneNode = m_sceneMgr->getSceneNode("MapNode")->createChildSceneNode(m_mapPosition * 100);
	m_sceneNode->scale(0.3f, 0.3f, 0.3f);
	
	//Ogre::SceneNode *entNode = m_sceneNode->createChildSceneNode(Ogre::Vector3(0.0f, 7.5f, 0.0f));
	Ogre::SceneNode *entNode = m_sceneNode->createChildSceneNode(Ogre::Vector3(0.0f, 7.5f, 0.0f));
	Ogre::Entity *ent = m_sceneMgr->createEntity(Ogre::SceneManager::PrefabType::PT_SPHERE);
	entNode->attachObject(ent);
	ent->setMaterialName("Color/Maroon");

	// Set spline points for animation.
	m_spline.addPoint(m_mapPosition * 100);
	m_spline.addPoint(m_mapPosition * 100 + Ogre::Vector3(0.0f, 50.0f - std::fmod(m_mapPosition.y, 50.0f), 0.0f));
}
Esempio n. 26
0
SnapToMovement::SnapToMovement(Eris::Entity& entity, Ogre::Node& node, float snapThreshold, Ogre::SceneManager& sceneManager, bool showDebugOverlay) :
	mEntity(entity), mNode(node), mSnapThreshold(snapThreshold), mSceneManager(sceneManager)
{
	if (showDebugOverlay) {
		for (int i = 0; i < 30; ++i) {
			Ogre::SceneNode* node = mSceneManager.getRootSceneNode()->createChildSceneNode();
			Ogre::Entity* sphereEntity = mSceneManager.createEntity(node->getName() + "_entity", "3d_objects/primitives/models/sphere.mesh");
			//start out with a normal material
			sphereEntity->setMaterialName("/global/authoring/point");
			sphereEntity->setRenderingDistance(300);
			// 		entity.setQueryFlags(MousePicker::CM_UNDEFINED);
			node->setScale(0.25, 0.25, 0.25);
			node->attachObject(sphereEntity);
			node->setVisible(false);
			mDebugNodes.push_back(node);
		}
	}
}
void SceneLoader::createFloor( Ogre::Real width, Ogre::Real height )
{
	Ogre::Plane plane(Ogre::Vector3::UNIT_Z, 0);

	Ogre::MeshManager::getSingleton().createPlane("FloorPlane", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
		plane, width, height, 20, 20, true, 1, 1, 1, Ogre::Vector3::UNIT_Y);

	Ogre::Entity* entFloor = mSceneMgr->createEntity("FloorEntity", "FloorPlane");
	entFloor->setMaterialName("Examples/GrassFloor");
	entFloor->setCastShadows(false);

	mSceneRootNode->attachObject(entFloor);

// 	Ogre::Entity* ent = mSceneMgr->createEntity("atd_cube.mesh");
// 	Ogre::SceneNode* node = mSceneRootNode->createChildSceneNode("Floor");
// 	node->setScale(Ogre::Vector3::UNIT_SCALE*mWallCubeScale*Ogre::Vector3(mRows,mCols,1));
// 	node->attachObject(ent);
}
Esempio n. 28
0
CollisionModel3D *EditorFrameHandler::GetCollisionModel(const char *modelname)
{	
	CollisionModel3D *hashres=NULL, *CollisionModel = NULL;
	bool bres = CollisionModels.Find(modelname, &hashres);

    if (!bres)
    {
        CollisionModel = newCollisionModel3D(false);

        size_t vertex_count,index_count;
        Ogre::Vector3* vertices;
        unsigned long* indices;

        Ogre::SceneManager *SceneMgr = CommonDeclarations::GetSceneManager();

        Ogre::Entity *entity = SceneMgr->createEntity("tmpcollis", modelname);

		Collidable::getMeshInformation(entity->getMesh().getPointer(),vertex_count,vertices,index_count,indices,Ogre::Vector3(0,0,0),Ogre::Quaternion::IDENTITY,Ogre::Vector3(1,1,1));

        SceneMgr->destroyEntity(entity);

        size_t index;
        int numTris = (int)index_count / 3;
        CollisionModel->setTriangleNumber(numTris);
        for (unsigned i=0;i<index_count;i+=3)
        {
            index = indices[i];
            CollisionModel->addTriangle(vertices[indices[i+0]].x,vertices[indices[i+0]].y,vertices[indices[i+0]].z,
                vertices[indices[i+1]].x,vertices[indices[i+1]].y,vertices[indices[i+1]].z,
                vertices[indices[i+2]].x,vertices[indices[i+2]].y,vertices[indices[i+2]].z);
        }
        CollisionModel->finalize();

        delete[] vertices;
        delete[] indices;

		CollisionModels.Insert(modelname,CollisionModel);

    } else
    {
        CollisionModel = hashres;
    }
	return CollisionModel;
}
bool
buildGroundShape(Ogre::SceneManager* sceneMgr, btDynamicsWorld* dynamicsWorld, btAlignedObjectArray<btCollisionShape*>& collisionShapes)
{
    btBoxShape* groundShape = new btBoxShape(btVector3(btScalar(150.0f),btScalar(1.0f),btScalar(150.0f)));
    //btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0), 1);
    //groundShape->setLocalScaling(btVector3(1,1,1));

    btDefaultMotionState* groundMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,-1,0)));
    btRigidBody::btRigidBodyConstructionInfo groundRigidBodyCI(0,groundMotionState,groundShape,btVector3(0,0,0));
    btRigidBody* groundRigidBody = new btRigidBody(groundRigidBodyCI);
    groundRigidBody->setCcdMotionThreshold(1.0f);
    groundRigidBody->setRestitution(0.0f);
    groundRigidBody->setFriction(1.0f);

    const btTransform& transform = groundRigidBody->getWorldTransform();
    btVector3 trans = transform.getOrigin();
    btQuaternion rot = transform.getRotation();

    dynamicsWorld->addRigidBody(groundRigidBody);

    collisionShapes.push_back(groundShape);

    // build plane if scene manager exist
    if (sceneMgr)
    {
        Ogre::Plane* plane = new Ogre::MovablePlane("Plane");
	    plane->d = 0;
	    plane->normal = Ogre::Vector3::UNIT_Y;
	
	    Ogre::MeshManager::getSingleton().createPlane("PlaneMesh", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, *plane,
		    256, 256, 1, 1, true, 1, 1, 1, Ogre::Vector3::UNIT_Z);

        Ogre::Entity* ent = sceneMgr->createEntity("PlaneEntity", "PlaneMesh");
        assert(ent);
        ent->setCastShadows(false);
        ent->setMaterialName("DefaultPlane");
	    
        Ogre::SceneNode* node = sceneMgr->getRootSceneNode()->createChildSceneNode("PlaneNode");
	    node->attachObject(ent);
	    node->setPosition(Ogre::Vector3::ZERO);
    } // End if

    return true;
}
	void OgreColladaContentImporter::sceneNodeCreated(Ogre::SceneNode* pNode, FCDSceneNode* pFColladaSceneNode)
	{
		NxOgre::ActorParams actorParams;
		NxOgre::ShapeParams shapeParams;
		Ogre::Vector3 boxSize;
		Ogre::Vector3 scale;
		Ogre::Entity *pEntity;
		std::list<Ogre::Entity*> entityList;
		std::list<Ogre::Entity*>::iterator entityListIter;
		NxVec3 row;

		pEntity = NULL;
		Ogre::SceneNode::ObjectIterator  iter = pNode->getAttachedObjectIterator();

		while (iter.hasMoreElements())
		{
			pEntity = dynamic_cast<Ogre::Entity*>(iter.getNext());

			if (pEntity != NULL)
			{
				entityList.push_back(pEntity);
			}
		}

		shapeParams.setToDefault();
		//scale = pNode->_getDerivedScale();
		//shapeParams.mMeshScale = NxVec3(scale.x, scale.y, scale.z);
		for (entityListIter = entityList.begin(); entityListIter != entityList.end(); ++entityListIter)
		{

			pEntity = *entityListIter;
			boxSize = pEntity->getBoundingBox().getSize();

			pNode->detachObject(pEntity);
			actorParams.setToDefault();
			actorParams.mMass = 0.0f;
			actorParams.mBodyFlags |= NX_BF_KINEMATIC;

			GameObjectFactory::getSingleton().makeBody(pEntity->getName(), pNode, pEntity, scene
				,new NxOgre::CubeShape(boxSize.x, boxSize.y, boxSize.z, shapeParams), actorParams);
		}

		sceneNodes.push_back(pNode);
	}