Example #1
0
	// Dibujado de raycast para depurar
	void CShootRaycast::drawRaycast(const Ray& raycast) {
		Graphics::CScene *scene = Graphics::CServer::getSingletonPtr()->getActiveScene();
		Ogre::SceneManager *mSceneMgr = scene->getSceneMgr();

		std::stringstream aux;
		aux << "laser" << _nameWeapon << _temporal;
		++_temporal;
		std::string laser = aux.str();

		Ogre::ManualObject* myManualObject =  mSceneMgr->createManualObject(laser); 
		Ogre::SceneNode* myManualObjectNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(laser+"_node"); 
 
		myManualObject->begin("laser", Ogre::RenderOperation::OT_LINE_STRIP);
		Vector3 v = raycast.getOrigin();
		myManualObject->position(v.x,v.y,v.z);

		for(int i=0; i < _distance;++i){
			Vector3 v = raycast.getPoint(i);
			myManualObject->position(v.x,v.y,v.z);
			// etc 
		}

		myManualObject->end(); 
		myManualObjectNode->attachObject(myManualObject);
	}// drawRaycast
Example #2
0
void MoveDemoApplication::createAxes()
{

	Ogre::ManualObject* pManualObject = mSceneMgr-> createManualObject( "ManualGridObj "); 
	if (pManualObject)
	{
		int nLength = 160 ;
		pManualObject-> begin( "",   Ogre::RenderOperation::OT_LINE_LIST); 
		pManualObject-> position(0,   0,   0); 
		pManualObject-> colour(Ogre::ColourValue::Red); 
		pManualObject-> position(nLength*4,   0,   0); 

		pManualObject-> position(0,   0,   0); 
		pManualObject-> colour(Ogre::ColourValue::Green); 
		pManualObject-> position(0,   nLength,   0); 

		pManualObject-> position(0,   0,   0); 
		pManualObject-> colour(Ogre::ColourValue::Blue); 
		pManualObject-> position(0,   0,   nLength); 
		pManualObject-> end(); 

		pManualObject->getSection(0)->getTechnique()->getPass(0)->setLightingEnabled(false);

		Ogre::SceneNode*pSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "ManualGridNode "); 
		if(pSceneNode) 
			pSceneNode-> attachObject(pManualObject);

	}

}
Example #3
0
void CubeWorld::createWorldChunks (void)
{
	//std::vector<int> VertexArray;
	Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create("BoxColor", "General", true );
	Ogre::Technique* tech = mat->getTechnique(0);
	Ogre::Pass* pass = tech->getPass(0);
	Ogre::TextureUnitState* tex = pass->createTextureUnitState();
	tex->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, Ogre::ColourValue(0, 0.5, 0));

	Ogre::ManualObject* MeshChunk = new Ogre::ManualObject("MeshMatChunk");
	MeshChunk->begin("TerrainImage");

	for (int z = 0; z < WORLD_SIZE; z += CHUNK_SIZE)
	{
		for (int y = 0; y < WORLD_SIZE; y += CHUNK_SIZE)
		{
			for (int x = 0; x < WORLD_SIZE; x += CHUNK_SIZE)
			{
				createChunk(MeshChunk, x,y,z); /* WFaces or not */
				//createChunkWater(x, y, z);
			}
		}
	}

}
Example #4
0
void CubeWorld::displaySimpleWorld (void)
{
	Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create("BoxColor", "General", true );
	Ogre::Technique* tech = mat->getTechnique(0);
	Ogre::Pass* pass = tech->getPass(0);
	Ogre::TextureUnitState* tex = pass->createTextureUnitState();
	tex->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, Ogre::ColourValue(0, 0.5, 0));

	Ogre::ManualObject* testBox  = createCubeMesh("TestBox1", "BoxColor");
        Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
	Ogre::MeshPtr Mesh = testBox->convertToMesh("TestBox2");
	Ogre::StaticGeometry* pGeom = new Ogre::StaticGeometry (mSceneMgr, "Boxes");

	Ogre::Entity* pEnt = mSceneMgr->createEntity("TestBox2");

	pGeom->setRegionDimensions(Ogre::Vector3(300, 300, 300));

	for (int z = 0; z < WORLD_SIZE; ++z)
	{
		for (int y = 0; y < WORLD_SIZE; ++y)
		{
			for (int x = 0; x < WORLD_SIZE; ++x)
			{
				if (GetBlock(x,y,z)) pGeom->addEntity(pEnt, Ogre::Vector3(x,y,z));
			}
		}
	}

	pGeom->build ();
}
Example #5
0
void MoveDemoApplication::createPath()
{
	Ogre::ManualObject* pManualObject = mSceneMgr-> createManualObject( "PathObj"); 


	if (pManualObject)
	{
		pManualObject-> begin( "",   Ogre::RenderOperation::OT_LINE_LIST); 
		pManualObject-> colour(Ogre::ColourValue(1.0 , 1.0 , 0 )); 

		pManualObject-> position(Vector3( 0.0f, 1.0f, 25.0f )); 
		pManualObject-> position(Vector3( 550.0f,  1.0f,  50.0f  )); 

		pManualObject-> position(Vector3( 550.0f,  1.0f,  50.0f  )); 
		pManualObject-> position(Vector3(-100.0f,  1.0f, -200.0f ) ); 

		pManualObject-> position(Vector3(-100.0f,  1.0f, -200.0f ) ); 
		pManualObject-> position(Vector3( 0.0f, 1.0f, 25.0f )); 

		pManualObject-> end(); 

		pManualObject->getSection(0)->getTechnique()->getPass(0)->setLightingEnabled(false);

		Ogre::SceneNode*pSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "PathNode "); 
		if(pSceneNode) 
			pSceneNode-> attachObject(pManualObject);

	}
}
void addLine(
	Ogre::Vector3 i_start,
	Ogre::Vector3 i_end,
	const Ogre::String& i_material,
	Ogre::ManualObject& io_object)
{
	io_object.begin(i_material, Ogre::RenderOperation::OT_LINE_LIST);
	io_object.position(i_start.x, i_start.y, i_start.z);
	io_object.position(i_end.x, i_end.y, i_end.z);
	io_object.end();
}
Example #7
0
//-------------------------------------------------------------------------------------
void BasicTutorial2::createScene(void)
{
    mSceneMgr->setAmbientLight(Ogre::ColourValue(0, 0, 0));
    //mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
 
	//Create cube
	    //Create a basic green color texture 
 
	Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create("BoxColor", "General", true );
	Ogre::Technique* tech = mat->getTechnique(0);
	Ogre::Pass* pass = tech->getPass(0);
	Ogre::TextureUnitState* tex = pass->createTextureUnitState();
 
	tex->setTextureName("grassTexture.png");
	//tex->setNumMipmaps(4);
	tex->setTextureAnisotropy(1);
	tex->setTextureFiltering(Ogre::FO_POINT, Ogre::FO_POINT, Ogre::FO_POINT);

	    //Create the one box and the supporting class objects
	Ogre::ManualObject* testBox  = createCubeMesh("TestBox1", "BoxColor");	
    Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
	Ogre::MeshPtr Mesh = testBox->convertToMesh("TestBox2");
	Ogre::StaticGeometry* pGeom = new Ogre::StaticGeometry (mSceneMgr, "Boxes");
	Ogre::Entity* pEnt = mSceneMgr->createEntity("TestBox2");
	
	//testBox->triangle
	pGeom->setRegionDimensions(Ogre::Vector3(300, 300, 300));
 
	World::Instance();
	 
	pGeom->build ();
 
        mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
	Ogre::Light* l = mSceneMgr->createLight("MainLight");
        l->setPosition(20,80,50);
	//Create Cube

 /*   Ogre::Entity* entNinja = mSceneMgr->createEntity("Ninja", "ninja.mesh");
    entNinja->setCastShadows(true);
    mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entNinja);*/
 
 
    Ogre::Light* directionalLight = mSceneMgr->createLight("directionalLight");
    directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
    directionalLight->setDiffuseColour(Ogre::ColourValue(.25, .25, 0));
    directionalLight->setSpecularColour(Ogre::ColourValue(.25, .25, 0));
 
    directionalLight->setDirection(Ogre::Vector3( 0, -1, 1 )); 
 
 
}
Example #8
0
Ogre::MeshPtr MultiShape::realizeMesh(const std::string& name)
	{
		Ogre::ManualObject * manual = Root::getInstance()->sceneManager->createManualObject(name);
				
		for (std::vector<Shape>::iterator it = shapes.begin(); it!=shapes.end(); it++)
		{
			manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_STRIP);
			it->_appendToManualObject(manual);
			manual->end();
		}		
		
		Ogre::MeshPtr mesh = manual->convertToMesh(name);
		return mesh;
	}
Example #9
0
Ogre::String GameBuildingSystem::BuildBuildings( Ogre::SceneManager *sceneMan, GameRoadGraphAreaTreeNode *roadRoot )
{
  Ogre::ManualObject *manObject = NULL;
  Ogre::String manObjectName    = "Buildings";
  manObject = sceneMan->createManualObject( manObjectName );
  manObject->setDynamic( false );
  
  BuildToArea( roadRoot, manObject );

  manObject->setCastShadows( true );

  sceneMan->getRootSceneNode()->createChildSceneNode()->attachObject( manObject );
  return manObjectName;
}
Example #10
0
void BasicTutorial3::createCursor( float radius )
{
	radius *= VOXEL_SCALE;

	// Assuming scene_mgr is your SceneManager.
	Ogre::ManualObject * circle = mSceneMgr->createManualObject("debugCursor");
 
    // accuracy is the count of points (and lines).
    // Higher values make the circle smoother, but may slowdown the performance.
    // The performance also is related to the count of circles.
    float const accuracy = 35;
 
    circle->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_STRIP);
 
    unsigned point_index = 0;
    for(float theta = 0; theta <= 2 * M_PI; theta += M_PI / accuracy) {
        circle->position(radius * cos(theta), 0, radius * sin(theta));
        circle->index(point_index++);
    }
    for(float theta = 0; theta <= 2 * M_PI; theta += M_PI / accuracy) {
        circle->position(radius * cos(theta), radius * sin(theta), 0);
        circle->index(point_index++);
    }
    circle->index(0); // Rejoins the last point to the first.
 
    circle->end();
 
    mCursor = mSceneMgr->getRootSceneNode()->createChildSceneNode("debugCursor");
	mCursor->attachObject(circle);
}
Example #11
0
Mesh* MultiShape::GenerateMesh(const String& Name, const String& Group)
{
    Ogre::ManualObject* TempMan = new Ogre::ManualObject("TempMan");

    for( ShapeIterator It = this->Shapes.begin() ; It != this->Shapes.end() ; ++It )
    {
        TempMan->begin("BaseWhiteNoLighting",Ogre::RenderOperation::OT_LINE_STRIP);
        (*It)._AppendToManualObject(TempMan);
        TempMan->end();
    }

    Mesh* NewMesh = MeshManager::GetSingletonPtr()->_WrapInternalMesh( TempMan->convertToMesh(Name,Group) );
    delete TempMan;
    return NewMesh;
}
Example #12
0
Ogre::ManualObject* OBJImp::loadObject(std::string fileName){
	Ogre::ManualObject* mObj = video.ogreSceneMgr->createManualObject(fileName);
	mObj->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_STRIP);
	std::cout << "Opening .obj file: " << fileName.c_str() << std::endl;
	std::ifstream file(fileName);
	if(!file){
		std::cout << "Opening file failed!\n";
		return NULL;
	} else {
		std::cout << "OBJ File loaded successfully!\n";
	}
	std::string line;
	int totalLines = 0;
	int currentLine = 0;
	//obj content storage
	std::string type;
	std::string tmp;
	double v1, v2, v3;
	Ogre::Vector3 tmpVec3;

	while(std::getline(file,line)){
		std::stringstream iss(line);
		std::getline(iss, type, ' ');
		std::getline(iss, tmp, ' ');
		if(tmp.find("#") != std::string::npos){
			break;
		}
		v1 = std::stod(tmp.c_str());
		std::getline(iss, tmp, ' ');
		if(tmp.find("#") != std::string::npos){
			break;
		}
		v2 = std::stod(tmp.c_str());
		std::getline(iss, tmp, ' ');
		if(tmp.find("#") != std::string::npos){
			break;
		}
		v3 = std::stod(tmp.c_str());
		tmpVec3.x = v1;
		tmpVec3.y = v2;
		tmpVec3.z = v3;

		tmpVerts.push_back(tmpVec3);
		mObj->position(tmpVec3);
	}
	mObj->end();
	return mObj;
}
Example #13
0
void
	Player::createHitBox(std::string name)
{
	Ogre::ManualObject* myManualObject =  mSceneManager->createManualObject(name); 
	myManualObject->setDynamic(true);
	Ogre::SceneNode* myManualObjectNode = mSceneManager->getRootSceneNode()->createChildSceneNode(name + "_node"); 

	Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create(name + "Material","General"); 
	myManualObjectMaterial->setReceiveShadows(false); 
	myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true);
	myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(1,0,0,0); 
	myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(1,0,0); 
	myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1,0,0);

	myManualObjectNode->attachObject(myManualObject);
}
Example #14
0
void LevelManager::drawTriangle(const Triangle *t)
{
    Ogre::ManualObject* manual = GLOBAL_SCN_MNGR->createManualObject();
    manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_STRIP);

    Ogre::Real height = 5.0f;
    manual->position(t->v1->x, height, t->v1->y);  // start position
    manual->position(t->v2->x, height, t->v2->y);  // start position
    manual->position(t->v3->x, height, t->v3->y);  // start position
    manual->position(t->v1->x, height, t->v1->y);  // start position

    manual->end();
    Ogre::SceneNode *node = GLOBAL_SCN_MNGR->getRootSceneNode()->createChildSceneNode();
    node->attachObject(manual);

}
Ogre::ManualObject* RecastInterface::_exportPolygonMeshToEntity(unsigned short* vertices,
														  int numVertices,
														  unsigned short* polygons,
														  int numPolys,
														  int maxPolys,
														  int numVertsPerPoly,
														  const Ogre::Vector3& origin)
{
	if(_polyMesh == nullptr || _detailMesh == nullptr)
	{
		return NULL;
	}

	int nIndex = 0;
	Ogre::ManualObject* manObj = _scene->createManualObject("recastTempMO");
	manObj->begin("arena_locker/blue",Ogre::RenderOperation::OT_TRIANGLE_LIST);
	for( int i = 0; i < numPolys; ++i)
	{
		const unsigned short* p = &polygons[i * numVertsPerPoly * 2];

		unsigned short vi[3];
		for(int j = 2; j < numVertsPerPoly; ++j)
		{
			if(p[j] == RC_MESH_NULL_IDX) break;
			vi[0] = p[0];
			vi[1] = p[j-1];
			vi[2] = p[j];
			for(int k = 0; k < 3; ++k)
			{
				const unsigned short* v = &vertices[vi[k]*3];
				const float x = origin[0] + v[0] * _recastParams.getCellSize();
				const float y = origin[1] + v[1] * _recastParams.getCellHeight();
				const float z = origin[2] + v[2] * _recastParams.getCellSize();

				manObj->position(x,y,z);
			}
			manObj->triangle(nIndex,nIndex+1,nIndex+2);
			nIndex += 3;
		}
	}

	manObj->end();

	return manObj;
}
void NavigationCell::debugDrawClassification( Ogre::Vector3 start, Ogre::Vector3 end )
{
    Ogre::Root *root = Ogre::Root::getSingletonPtr();
    Ogre::SceneManager* mgr = root->getSceneManager( "SceneManagerInstance" );
    Ogre::ManualObject* debug;
    Ogre::SceneNode* node;

    if( mgr->hasManualObject( "debugDrawClassification" ) )
        debug = mgr->getManualObject( "debugDrawClassification" );
    else
    {
        debug = mgr->createManualObject( "debugDrawClassification" );
        node = mgr->getRootSceneNode()->createChildSceneNode();
        node->attachObject( debug );
        node->translate( 0, 1, 0 );
        debug->setQueryFlags( 0 );
        debug->setRenderQueueGroup( Ogre::RENDER_QUEUE_OVERLAY );
    }

    debug->begin( "debug/blue", Ogre::RenderOperation::OT_LINE_LIST );
    debug->position( start );
    debug->position( end );
    debug->end();

//    debugDrawCell( debug, "debug/yellow", "debug/blue" );
}
Example #17
0
Ogre::SceneNode* SideVerifier::createSceneNode(Ogre::SceneNode* parent, std::string name,
                                               Ogre::Vector3 defaultTranslate)
{
    Ogre::SceneNode* node = parent->createChildSceneNode(name);
    node->translate(defaultTranslate);

    Ogre::ManualObject* myManualObject = new Ogre::ManualObject("manual1" + name);

    myManualObject->begin("manual1Material", Ogre::RenderOperation::OT_LINE_LIST);
    myManualObject->position(0, 0, 0);
    myManualObject->position(0, 0, -1);
    myManualObject->end();

    //DEBUG
//    node->attachObject(myManualObject);

    return node;
}
void NavigationMesh::setShow( bool show )
{
    Ogre::Root *root = Ogre::Root::getSingletonPtr();
    Ogre::SceneManager* mgr = root->getSceneManager( "SceneManagerInstance" );
    Ogre::ManualObject* debug;
    Ogre::SceneNode* debugNode;

    mShow = show;

    if( mgr->hasSceneNode( "debugDrawNode2" ) )
    {
        debugNode = mgr->getSceneNode( "debugDrawNode2" );
    }
    else
    {
        debugNode = mgr->getRootSceneNode()->createChildSceneNode( "debugDrawNode2" );
        debugNode->translate( 0, 1, 0 );    // Move up slightly to see lines better.
    }

    if( mgr->hasManualObject( "debugDraw2" ) )
        debug = mgr->getManualObject( "debugDraw2" );
    else
    {
        debug = mgr->createManualObject( "debugDraw2" );
        debugNode->attachObject( debug );
        debug->setQueryFlags( 0 );
        debug->setRenderQueueGroup( Ogre::RENDER_QUEUE_OVERLAY );
    }

    if( !mShow )
    {
        mgr->destroyManualObject( debug );
        return;
    }

    for( CellVector::iterator i = mCells.begin(); i != mCells.end(); i++ )
    {
        i->debugDrawCell( debug, "debug/yellow", "debug/blue" );
    }

    return;
}
Example #19
0
void MoveDemoApplication::createGrid()
{

	Ogre::ManualObject*   pManualObject   =   mSceneMgr-> createManualObject( "TestManualObject "); 
	if   (NULL   ==   pManualObject) 
		return   ; 

	pManualObject-> begin( " ",   Ogre::RenderOperation::OT_LINE_LIST); 
	{ 
		int startX=-1000 ; 
		int startZ = -1000;
		int endX=1000 ; 
		int endZ = 1000;
		int step = 50;
		//int nLength = 160 ;

		pManualObject-> colour(Ogre::ColourValue(0.5,0.5,0.5) ); 

		for (int idx = 0 ; idx< (endX - startX)/step ; ++idx )
		{
			pManualObject-> position(startX+step*idx,   0,   startZ); 
			pManualObject-> position(startX+step*idx,   0,   endZ); 
		}

		for (int idx = 0 ; idx< (endZ - startZ)/step ; ++idx )
		{
			pManualObject-> position(startX,   0,   startZ+step*idx ); 
			pManualObject-> position(endX,   0,   startZ+step*idx); 
		}

	} 
	pManualObject-> end(); 

	pManualObject->getSection(0)->getTechnique()->getPass(0)->setLightingEnabled(false);

	Ogre::SceneNode*   pSceneNode   =   mSceneMgr->getRootSceneNode()->createChildSceneNode( "TestSceneNode "); 
	if   (NULL   ==   pSceneNode) 
		return   ; 
	pSceneNode-> attachObject(pManualObject);


}
void ParticleFactory::CreateExplosionParticleGeometry(Ogre::String object_name, int num_particles){

		/* Retrieve scene manager and root scene node */
        //Ogre::SceneManager* scene_manager = ogre_root_->getSceneManager("MySceneManager");
        Ogre::SceneNode* root_scene_node = scene_manager->getRootSceneNode();

        /* Create the 3D object */
        Ogre::ManualObject* object = NULL;
        object = scene_manager->createManualObject(object_name);
        object->setDynamic(false);

        /* Create point list for the object */
		object->begin("", Ogre::RenderOperation::OT_POINT_LIST);

		/* Initialize random numbers */
		std::srand(std::time(0));

		/* Create a set of points which will be the particles */
		/* This is similar to drawing a sphere: we will sample points on a sphere, but will allow them to also
		   deviate a bit from the sphere along the normal (change of radius) */
		float trad = 0.04; // Defines the starting point of the particles
        float maxspray = 0.01; // This is how much we allow the points to deviate from the sphere
		float u, v, w, theta, phi, spray; // Work variables
		for (int i = 0; i < num_particles; i++){
			
			// Randomly select three numbers to define a point in spherical coordinates
			u = ((double) rand() / (RAND_MAX));
            v = ((double) rand() / (RAND_MAX));
            w = ((double) rand() / (RAND_MAX));

			// Use u to define the angle theta along one direction of a sphere
            theta = u * 2.0 * 3.1416;
			// Use v to define the angle phi along the other direction of the sphere
			phi = acos(2.0*v - 1.0);
			// Use we to define how much we can deviate from the surface of the sphere (change of radius)
            spray = maxspray*pow((float) w, (float) (1.0/3.0)); // Cubic root of w

			// Define the normal and point based on theta, phi and the spray
            Ogre::Vector3 normal = Ogre::Vector3(spray*cos(theta)*sin(phi), spray*sin(theta)*sin(phi), spray*cos(phi));
			object->position(normal.x*trad, normal.y*trad, normal.z*trad);
			object->normal(normal);
			object->colour(Ogre::ColourValue(i/(float) num_particles, 0.0, 1.0 - (i/(float) num_particles))); // We can use the color for debug, if needed
		}
		
		/* We finished the object */
        object->end();
		
        /* Convert triangle list to a mesh */
        object->convertToMesh(object_name);

}
Example #21
0
void
	Player::drawLine(std::string bone, int joint1, int joint2)
{
	if (!initSkel)
		createLine(bone, joint1, joint2);
	else if (initSkel)
	{
		vector<Ogre::Vector3> skeletonNodes = mKinect->getSkeletonNodes();
		Ogre::ManualObject* myManualObject = mSceneManager->getManualObject(bone);

		myManualObject->clear();

		Ogre::Vector3 bone1 = 20 * skeletonNodes[joint1] + Ogre::Vector3(-50, 30, 20);
		Ogre::Vector3 bone2 = 20 * skeletonNodes[joint2] + Ogre::Vector3(-50, 30, 20);

		myManualObject->begin(bone + "Material", Ogre::RenderOperation::OT_LINE_LIST);
		myManualObject->position(bone1.x, bone1.y, bone1.z); 
		myManualObject->position(bone2.x, bone2.y, bone2.z); 
		myManualObject->end();
	}
}
Example #22
0
	void _drawGridPlane(void)
	{
		Ogre::ManualObject* gridPlane = mSceneMgr->createManualObject("GridPlane");
		Ogre::SceneNode* gridPlaneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("GridPlaneNode");

		Ogre::MaterialPtr gridPlaneMaterial = Ogre::MaterialManager::getSingleton().create("GridPlanMaterial", "General");
		gridPlaneMaterial->setReceiveShadows(false);
		gridPlaneMaterial->getTechnique(0)->setLightingEnabled(true);
		gridPlaneMaterial->getTechnique(0)->getPass(0)->setDiffuse(1, 1, 1, 0);
		gridPlaneMaterial->getTechnique(0)->getPass(0)->setAmbient(1, 1, 1);
		gridPlaneMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1, 1, 1);

		gridPlane->begin("GridPlaneMaterial", Ogre::RenderOperation::OT_LINE_LIST);
		for (int i = 0; i < 21; i++)
		{
			gridPlane->position(-500.0f, 0.0f, 500.0f - i * 50);
			gridPlane->position(500.0f, 0.0f, 500.0f - i * 50);

			gridPlane->position(-500.f + i * 50, 0.f, 500.0f);
			gridPlane->position(-500.f + i * 50, 0.f, -500.f);
		}

		gridPlane->end();

		gridPlaneNode->attachObject(gridPlane);
	}
Example #23
0
 void RenderSystem::RenderLineSegments(std::string lsName, std::string materialName, const std::vector<MagicMath::Vector3>& startPos, const std::vector<MagicMath::Vector3>& endPos)
 {
     Ogre::ManualObject* pMObj = NULL;
     if (mpSceneMgr->hasManualObject(lsName))
     {
         pMObj = mpSceneMgr->getManualObject(lsName);
         pMObj->clear();
     }
     else
     {
         pMObj = mpSceneMgr->createManualObject(lsName);
         if (mpSceneMgr->hasSceneNode("ModelNode"))
         {
             mpSceneMgr->getSceneNode("ModelNode")->attachObject(pMObj);
         }
         else
         {
             mpSceneMgr->getRootSceneNode()->createChildSceneNode("ModelNode")->attachObject(pMObj);
         }
     }
     pMObj->begin(materialName, Ogre::RenderOperation::OT_LINE_LIST);
     int lineNum = startPos.size();
     for (int i = 0; i < lineNum; i++)
     {
         MagicMath::Vector3 start = startPos.at(i);
         MagicMath::Vector3 end = endPos.at(i);
         pMObj->position(start[0], start[1], start[2]);
         pMObj->position(end[0], end[1], end[2]);
     }
     pMObj->end();
 }
Example #24
0
Entity* EntityFactory::createBeamGun(const BeamGunConfig& config)
{
	EntityManager* entityMgr = engine_->entityMgr_;
	Entity* entity = entityMgr->create();

	float y = 0.1f;

	b2BodyDef bd;
	bd.type = b2_dynamicBody;
	bd.position.Set(config.posX_, config.posY_);
	b2Body* body = engine_->sysPhysics_->getWorld()->CreateBody(&bd);

	b2PolygonShape shape;
	b2Vec2 vertices[4];
	vertices[0].Set(0, y);
	vertices[1].Set(0, -y);
	vertices[2].Set(config.beamRange_, -y);
	vertices[3].Set(config.beamRange_, y);
	shape.Set(vertices, 4);

	b2FixtureDef sd;
	sd.shape = &shape;
	sd.density = 0;
	sd.filter.categoryBits = ComPhysics::CATEG_PlayerBeam;
	sd.filter.maskBits = ComPhysics::MASK_PlayerBeam;

	body->CreateFixture(&sd);

	ComPhysics* comPhysics = entityMgr->assignComponent<ComPhysics>(entity);
	comPhysics->setMainBody(body, entity);


	Ogre::SceneManager* sceneMgr = engine_->sysGraphics_->getSceneManager();
	Ogre::ManualObject* manual = sceneMgr->createManualObject();
	manual->begin("beam", Ogre::RenderOperation::OT_LINE_STRIP);
	manual->position(0, y, 0);
	manual->position(0, -y, 0);
	manual->position(config.beamRange_, -y, 0);
	manual->position(config.beamRange_, y, 0);
	manual->position(0, y, 0);
	manual->end();
	Ogre::SceneNode* node = engine_->sysGraphics_->getSceneRoot()->createChildSceneNode(
		Ogre::Vector3(config.posX_, config.posY_, 0));
	node->attachObject(manual);

	ComGraphics* comGraphics = entityMgr->assignComponent<ComGraphics>(entity);
	comGraphics->sceneNode_ = node;

	return entity;
}
void MainApplication::shoot()
{
    
    Ogre::String number2 = Ogre::StringConverter::toString(shotCounter + 1); 
    shots.push_back("manual1_node" + number2);
    /*
    Ogre::Entity* ogreHead = mSceneMgr -> createEntity("ogrehead.mesh");
    Ogre::SceneNode *headNode = mSceneMgr -> getRootSceneNode() -> createChildSceneNode("manual1_node" + number2);
    Ogre::Vector3 pos1(mSceneMgr-> getSceneNode("NinjaNode")->getPosition());
    headNode -> setPosition(pos1);
    headNode -> attachObject(ogreHead);
    */
    Ogre::ManualObject* myManualObject =  mSceneMgr->createManualObject("manual1" + number2); 
    Ogre::SceneNode* myManualObjectNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("manual1_node" + number2); 
     
    // NOTE: The second parameter to the create method is the resource group the material will be added to.
    // If the group you name does not exist (in your resources.cfg file) the library will assert() and your program will crash
    Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("manual1Material","General"); 
    myManualObjectMaterial->setReceiveShadows(false); 
    myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true); 
    myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(0,0,1,0); 
    myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(0,0,1); 
    myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(0,0,1); 
    //myManualObjectMaterial->dispose();  // dispose pointer, not the material
     
    Ogre::Vector3 pos1(mSceneMgr-> getSceneNode("NinjaNode")->getPosition());//Get position of player
     
    myManualObject->begin("manual1Material", Ogre::RenderOperation::OT_LINE_LIST); 
    myManualObject->position(pos1.x + 20, pos1.y, pos1.z); 
    myManualObject->position(pos1.x + 50, pos1.y, pos1.z); 
    // etc 
    myManualObject->end(); 
    myManualObjectNode->attachObject(myManualObject);
    shotCounter++;
    
}
Example #26
0
 void RenderSystem::RenderMesh3D(std::string meshName, std::string materialName, const MagicDGP::Mesh3D* pMesh)
 {
     InfoLog << "RenderSystem::RenderMesh3D" << std::endl;
     Ogre::ManualObject* pMObj = NULL;
     if (mpSceneMgr->hasManualObject(meshName))
     {
         pMObj = mpSceneMgr->getManualObject(meshName);
         pMObj->clear();
     }
     else
     {
         pMObj = mpSceneMgr->createManualObject(meshName);
         if (mpSceneMgr->hasSceneNode("ModelNode"))
         {
             mpSceneMgr->getSceneNode("ModelNode")->attachObject(pMObj);
         }
         else
         {
             mpSceneMgr->getRootSceneNode()->createChildSceneNode("ModelNode")->attachObject(pMObj);
         }
     }
     pMObj->begin(materialName, Ogre::RenderOperation::OT_TRIANGLE_LIST);
     int vertNum = pMesh->GetVertexNumber();
     for (int i = 0; i < vertNum; i++)
     {
         const MagicDGP::Vertex3D* pVert = pMesh->GetVertex(i);
         MagicMath::Vector3 pos = pVert->GetPosition();
         MagicMath::Vector3 nor = pVert->GetNormal();
         MagicMath::Vector3 color = pVert->GetColor();
         pMObj->position(pos[0], pos[1], pos[2]);
         pMObj->normal(nor[0], nor[1], nor[2]);
         pMObj->colour(color[0], color[1], color[2]);
     }
     int faceNum = pMesh->GetFaceNumber();
     for (int i = 0; i < faceNum; i++)
     {
         if (pMesh->GetFace(i)->IsValid())
         {
             const MagicDGP::Edge3D* pEdge = pMesh->GetFace(i)->GetEdge();
             pMObj->triangle(pEdge->GetVertex()->GetId(), pEdge->GetNext()->GetVertex()->GetId(), pEdge->GetPre()->GetVertex()->GetId());
         }
     }
     pMObj->end();
 }
Example #27
0
    /**
     * This is the most basic "triangle" example, done as a Scene in Ogre.
     */
    Ogre::SceneManager* createTriangleScene() {
        Ogre::SceneManager* scene = mRoot->createSceneManager(Ogre::ST_GENERIC);

        // Configure camera (~ view & projection transforms, i.e. gluLookAt + glOrtho)
        Ogre::Camera* camera = scene->createCamera("MainCamera"); // We can use an arbitrary name here
        camera->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
        camera->setOrthoWindow(2, 2);              // ~ glOrtho(-1, 1, -1, 1)
        camera->setAspectRatio((float) mWindow->getWidth() / mWindow->getHeight());
        camera->setNearClipDistance(0.5);
        camera->setPosition(Ogre::Vector3(0,0,1)); // Move camera away from (0, 0, 0), otherwise the triangle at z=0 will be clipped

        // Now add some geometry to the scene
        Ogre::ManualObject* triangle = scene->createManualObject("Triangle");

        // ~ glBegin, glVertex, glEnd
        // "BaseWhiteNoLighting" is a built-in name for a basic non-lit material
        triangle->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST);
        triangle->position(0, 0.5, 0);            // ~ glVertex.
                                                  // Contrary to OpenGL we *first* must create the vertex
        triangle->colour(Ogre::ColourValue::Red); // .. and then provide its attributes such as color (~ glColor)
        triangle->position(-0.5, -0.5, 0);
        triangle->colour(Ogre::ColourValue::Green);
        triangle->position(0.5, -0.5, 0);
        triangle->colour(Ogre::ColourValue::Blue);
        triangle->end();

        // Add the created triangle object to the scene graph
        // For this we create a SceneNode object, which will combine information about
        // the object's geometry with its modeling transform
        // (see frameRenderingQueued to understand how to rotate the triangle by changing this transform)
        scene->getRootSceneNode()->createChildSceneNode("Triangle")->attachObject(triangle);

        // Exercise 1: Create new object, add vertices, attach the object to a new SceneNode
        // ...

        return scene;
    }
Example #28
0
 void RenderSystem::RenderLightMesh3DWithTexture(std::string meshName, std::string materialName, const MagicDGP::LightMesh3D* pMesh)
 {
     InfoLog << "RenderSystem::RenderMesh3D" << std::endl;
     Ogre::ManualObject* pMObj = NULL;
     if (mpSceneMgr->hasManualObject(meshName))
     {
         pMObj = mpSceneMgr->getManualObject(meshName);
         pMObj->clear();
     }
     else
     {
         pMObj = mpSceneMgr->createManualObject(meshName);
         if (mpSceneMgr->hasSceneNode("ModelNode"))
         {
             mpSceneMgr->getSceneNode("ModelNode")->attachObject(pMObj);
         }
         else
         {
             mpSceneMgr->getRootSceneNode()->createChildSceneNode("ModelNode")->attachObject(pMObj);
         }
     }
     pMObj->begin(materialName, Ogre::RenderOperation::OT_TRIANGLE_LIST);
     int vertNum = pMesh->GetVertexNumber();
     for (int i = 0; i < vertNum; i++)
     {
         const MagicDGP::Vertex3D* pVert = pMesh->GetVertex(i);
         MagicMath::Vector3 pos = pVert->GetPosition();
         MagicMath::Vector3 nor = pVert->GetNormal();
         MagicMath::Vector3 texCord = pVert->GetTexCord();
         pMObj->position(pos[0], pos[1], pos[2]);
         pMObj->normal(nor[0], nor[1], nor[2]);
         pMObj->textureCoord(texCord[0], texCord[1]);
     }
     int faceNum = pMesh->GetFaceNumber();
     for (int i = 0; i < faceNum; i++)
     {
         MagicDGP::FaceIndex faceIdx = pMesh->GetFace(i);
         pMObj->triangle(faceIdx.mIndex[0], faceIdx.mIndex[1], faceIdx.mIndex[2]);
     }
     pMObj->end();
 }
Example #29
0
Ogre::MeshPtr Path::realizeMesh(const std::string& name)
{
    Ogre::SceneManager *smgr = Ogre::Root::getSingleton().getSceneManagerIterator().begin()->second;
    Ogre::ManualObject * manual = smgr->createManualObject();
    manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_STRIP);

    for (std::vector<Ogre::Vector3>::iterator itPos = mPoints.begin(); itPos != mPoints.end(); itPos++)
        manual->position(*itPos);
    if (mClosed)
        manual->position(*(mPoints.begin()));
    manual->end();

    Ogre::MeshPtr mesh;
    if (name=="")
        mesh = manual->convertToMesh(Utils::getName());
    else
        mesh = manual->convertToMesh(name);

    return mesh;
}
Example #30
0
void Pencil::createIndicator() {
    Ogre::ManualObject * circle = sceneMgr->createManualObject(name + "::indicator");
    float const radius = 2.0;
    float const accuracy = 35;
    circle->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_STRIP);
    unsigned point_index = 0;
    for (float theta = 0; theta <= 2 * Ogre::Math::PI; theta += Ogre::Math::PI / accuracy) {
        circle->position(radius * cos(theta), 0, radius * sin(theta));
        circle->index(point_index++);
    }
    circle->index(0); // Rejoins the last point to the first.
    circle->end();

    indicatorNode = surfPlaneNode->createChildSceneNode();
    indicatorNode->attachObject(circle);
    indicatorVisible = true;
}