コード例 #1
0
ファイル: main.cpp プロジェクト: AnSuGuen/2016-Game-Engine
	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);
	}
コード例 #2
0
ManualObject* ShowNormalsGenerator::buildManualObject() const
{
	if (mTriangleBuffer == NULL)
		OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "The input triangle buffer must not be null", "Procedural::ShowNormalsGenerator::buildManualObject()");
	SceneManager* sceneMgr = Ogre::Root::getSingleton().getSceneManagerIterator().begin()->second;
	if (sceneMgr == NULL)
		OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Scene Manager must be set in Root", "Procedural::ShowNormalsGenerator::buildManualObject()");
	ManualObject* manual = sceneMgr->createManualObject();
	manual->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_LIST);
	const std::vector<TriangleBuffer::Vertex>& vertices = mTriangleBuffer->getVertices();
	for (std::vector<TriangleBuffer::Vertex>::const_iterator it = vertices.begin(); it!= vertices.end(); ++it)
	{
		manual->position(it->mPosition);
		manual->position(it->mPosition + it->mNormal * mSize);

		if (mVisualStyle == VS_ARROW)
		{
			Vector3 axis2 = it->mNormal.perpendicular();
			Vector3 axis3 = it->mNormal.crossProduct(axis2);

			manual->position(it->mPosition + it->mNormal * mSize);
			manual->position(it->mPosition + (.8f * it->mNormal  + .1f * axis2) * mSize);

			manual->position(it->mPosition + it->mNormal * mSize);
			manual->position(it->mPosition + .8f * (it->mNormal  - .1f * axis2) * mSize);

			manual->position(it->mPosition + it->mNormal * mSize);
			manual->position(it->mPosition + .8f * ( it->mNormal + .1f * axis3)* mSize);

			manual->position(it->mPosition + it->mNormal * mSize);
			manual->position(it->mPosition + .8f * (it->mNormal - .1f * axis3)* mSize);
		}
	}
	manual->end();

	return manual;
}