创建 mDecal = Ogitors::OgitorsRoot::getSingletonPtr()->GetSceneManager()->createManualObject(sName); mDecal->setCastShadows(false); mDecal->setDynamic(true); mDecal->setRenderQueueGroup(RENDER_QUEUE_WORLD_GEOMETRY_2); if (uShapeFlag == RenderOperation::OT_TRIANGLE_LIST) { int x_size = 4; int z_size = 4; mDecal->begin("Decal" , RenderOperation::OT_TRIANGLE_LIST); for (int i=0; i<x_size; i++) { for (int j=0; j<=z_size; j++) { mDecal->position(Ogre::Vector3(i, 0, j)); mDecal->textureCoord((float)i / (float)x_size, (float)j / (float)z_size); } } for (int i=0; i<x_size; i++) { for (int j=0; j<z_size; j++) { mDecal->quad( i * (x_size+1) + j, i * (x_size+1) + j + 1, (i + 1) * (x_size+1) + j + 1,(i + 1) * (x_size+1) + j); } } mDecal->end(); } Ogitors::OgitorsRoot::getSingletonPtr()->GetSceneManager()->getRootSceneNode()->createChildSceneNode()->attachObject(mDecal); 设置 int x_size = 4; int z_size = 4; float radius = 1.57f; float offset = 0.2f; mDecal->beginUpdate(0); if ( mPositions.size() > 0) { float x = mPositions[0].x; float y = mPositions[0].y; float z = mPositions[0].z; Ogre::Real x1 = x - radius; Ogre::Real z1 = z - radius; Ogre::Real x_step = radius * 2/ x_size; Ogre::Real z_step = radius * 2/ z_size; for (int i=0; i<=x_size; i++) { for (int j=0; j<=z_size; j++) { mDecal->position(Ogre::Vector3(x1, OgitorsRoot::getSingletonPtr()->getTerrainHeight(x1, z1) + offset, z1)); mDecal->textureCoord((float)i / (float)x_size, (float)j / (float)z_size); z1 += z_step; } x1 += x_step; z1 = z - radius; } for (int i=0; i<x_size; i++) { for (int j=0; j<z_size; j++) { mDecal->quad( i * (x_size+1) + j, i * (x_size+1) + j + 1, (i + 1) * (x_size+1) + j + 1, (i + 1) * (x_size+1) + j); } } } mDecal->end();