欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Ogre 绘制基本图形

程序员文章站 2022-03-31 14:52:44
...

Ogre 绘制基本图形

ManualObject* lManualObject;

lManualObject=mSceneMgr->createManualObject("mo");
	lManualObject->begin("BaseWhiteNoLighting");
	
	Ogre::Real cm = -5.0 ;
	Ogre::Real cp = 5.0;
		
	lManualObject->position(cm, cp, cm);// a vertex
	lManualObject->colour(Ogre::ColourValue(0.0f,1.0f,0.0f,1.0f));
	lManualObject->position(cp, cp, cm);// a vertex
	lManualObject->colour(Ogre::ColourValue(1.0f,1.0f,0.0f,1.0f));
	lManualObject->position(cp, cm, cm);// a vertex
	lManualObject->colour(Ogre::ColourValue(1.0f,0.0f,0.0f,1.0f));
	lManualObject->position(cm, cm, cm);// a vertex
	lManualObject->colour(Ogre::ColourValue(0.0f,0.0f,0.0f,1.0f));

	lManualObject->position(cm, cp, cp);// a vertex
	lManualObject->colour(Ogre::ColourValue(0.0f,1.0f,1.0f,1.0f));
	lManualObject->position(cp, cp, cp);// a vertex
	lManualObject->colour(Ogre::ColourValue(1.0f,1.0f,1.0f,1.0f));
	lManualObject->position(cp, cm, cp);// a vertex
	lManualObject->colour(Ogre::ColourValue(1.0f,0.0f,1.0f,1.0f));
	lManualObject->position(cm, cm, cp);// a vertex
	lManualObject->colour(Ogre::ColourValue(0.0f,0.0f,1.0f,1.0f));

		// face behind / front
	lManualObject->triangle(0,1,2);
	lManualObject->triangle(2,3,0);
	lManualObject->triangle(4,6,5);
	lManualObject->triangle(6,4,7);

		// face top / down
	lManualObject->triangle(0,4,5);
	lManualObject->triangle(5,1,0);
	lManualObject->triangle(2,6,7);
	lManualObject->triangle(7,3,2);

		// face left / right
	lManualObject->triangle(0,7,4);
	lManualObject->triangle(7,0,3);
	lManualObject->triangle(1,5,6);
	lManualObject->triangle(6,2,1);   
	
	lManualObject->end();


	Ogre::String lNameOfTheMesh = "MeshCubeAndAxe";
	lManualObject->convertToMesh(lNameOfTheMesh);

	Entity* entity = mSceneMgr->createEntity(lNameOfTheMesh);

	mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entity);

posted @ 2014-08-09 22:35 00000000O 阅读(...) 评论(...) 编辑 收藏