Ogre笔记(2)
创建平面:
Ogre::Plane plane(Vector3::UNIT_Y, -10); // 通过法线创建一个平面
Ogre::MeshManager::getSingleton().createPlane("plane",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1500,1500,20,20,true,1,5,5,Vector3::UNIT_Z); // Vector3::UNIT_Z定义了面的正向
Ogre::Entity* ent = mSceneMgr->createEntity("LightPlaneEntity", "plane");
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
ent->setMaterialName("Examples/BeachStones"); // 设定材质
点光源:
Ogre::Light* light1 = mSceneMgr->createLight("Light1");
light1->setType(Ogre::Light::LT_POINT);
light1->setPosition(0,20,0);light1->setDiffuseColour(1.0f,1.0f,1.0f);
聚光源:
Ogre::Light* light = mSceneMgr->createLight("Light1");
light->setType(Ogre::Light::LT_SPOTLIGHT);
light->setDirection(Ogre::Vector3(1,-1,0));
light->setSpotlightInnerAngle(Ogre::Degree(5.0f));
light->setSpotlightOuterAngle(Ogre::Degree(45.0f));
light->setSpotlightFalloff(0.0f);
light->setDiffuseColour(Ogre::ColourValue(0.0f,1.0f,0.0f));
node2->attachObject(light);
方向光源:
Ogre::Light* light = mSceneMgr->createLight("Light1");
light->setType(Ogre::Light::LT_DIRECTIONAL);
light->setDirection(0,1,1);
light->setDiffuseColour(Ogre::ColourValue(1.0f,1.0f,0.0f));
设置阴影:
mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);
设置线框格式:
void createCamera()
{
mCamera = mSceneMgr->createCamera("MyCamera1");
mCamera->setPosition(0,100,200);
mCamera->lookAt(0,0,0);
mCamera->setPolygonMode(Ogre::PM_WIREFRAME);
}
设置镜头和视口:
void createCamera()
{
mCamera = mSceneMgr->createCamera("MyCamera1");
mCamera->setPosition(0,100,200);
mCamera->lookAt(0,0,0);
mCamera->setNearClipDistance(5);
}
void createViewports()
{
Ogre::Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(ColourValue(0.0f,0.0f,1.0f));
mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
}
---------------------------------------------------------------------------
You got a dream
You gotta protect it
People can't do something themselves
They wanna tell you you can do it
If you want something
Go get it
You got a dream
You gotta protect it
People can't do something themselves
They wanna tell you you can do it
If you want something
Go get it