//定义平面变量,及其法线方向(UNIT_Y为Y轴正方向,NEGATIVE_UNIT_Y负方向)
//plane.d设置了平面的距离(法线为Y轴时,说成高度更容易理解)
Plane plane;
plane.normal = Vector3::UNIT_Y;
plane.d = 0;
//使用MeshManager管理器,createPlane参数如下:
//也可使用导入mesh文件,mesh文件可以用3dmax软件导出,但需要安装插件,oFusion或ogre3d,目前
//适用3dmax9.0版本以下。这里只是简单的平面,orge直接实现即可。
/*MeshPtr createPlane(
const String& name, const String& groupName, const Plane& plane,
Real width, Real height,
int xsegments = 1, int ysegments = 1,
bool normals = true, int numTexCoordSets = 1,
Real uTile = 1.0f, Real vTile = 1.0f, const Vector3& upVector = Vector3::UNIT_Y,
HardwareBuffer::Usage vertexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
HardwareBuffer::Usage indexBufferUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
bool vertexShadowBuffer = true, bool indexShadowBuffer = true);*/
MeshManager::getSingleton().createPlane("Myplane",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1450,1450,10,10,true,1,5,5,Vector3::UNIT_Z);
//UNIT_Z是平面的正方向
//创建实体
Entity* pPlaneEnt = mSceneMgr->createEntity( "plane", "Myplane" );
//赋予材质,OGRE的文件系统非常庞大。
//OGRE既可以读取普通的文件,又可以读取Zip压缩文件
//包括mesh文件、字体文件、纹理文件等
//这里通过setMaterialName读入材质名称,材质名称需唯一,往往保存在.material文件中
//只需设置好读取好material文件的路径,orge会自动寻找。
pPlaneEnt->setMaterialName("matZhebox");
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt);