Rendering in any engine is a process that consumes system resources. To render an object to the screen, a rendering operation is required, if tens of thousands of identical trees exist in the scenario, the system will perform tens of thousands of rendering operations.ProgramEfficiency will be very slow. If you can draw these trees with the same rendering state with one rendering operation, the efficiency will be improved several times.
The ogre: staticgeometry class provided by the Ogre engine is to implement batch rendering operations. If some objects are not intended to be rotated, scaled, or moved after being loaded into the scenario, they can be loaded to the scenario as static ry.
However, batch rendering is not highly efficient in all situations. If there are tens of thousands of trees in the scenario, but the camera can only see one tree at a certain angle, ogre will also render tens of thousands of trees together, which is less efficient than scene node objects with the vision cropping function. In this case, ogre also provides a solution, that is to divide all static ry into regions for batch rendering. If some areas are invisible to the camera, ogre will not render them, so that it can be ensured at any angle of view, the system provides stable rendering efficiency.
The specific division method is to first set a regional division origin point in the scenario, which is the center of the surrounding area, then set the volume XYZ of each region, and then add an object, finally, the build () method is called, and the ogre will automatically divide the rendering area for all objects.
DetailsCode:
Ogre: staticgeometry * m_pstaticgeometry = NULL;
M_pstaticgeometry = m_pscenemgr-> createstaticgeometry ("dims/staticgeometry"); // create a static ry
M_pstaticgeometry-> setregiondimensions (vector3 (1000,); // you can specify the rendering size for each batch.
M_pstaticgeometry-> setorigin (vector3 (500,500,500); // you can specify the origin location of the batch rendering part.
// Add several objects to the static ry. Note that only the pointer of the object in the same mesh needs to be passed in.
M_pstaticgeometry-> addentity (pentobject, position, orientation, scale );
// Division of batch rendering regions for static ry
M_pstaticgeometry-> build ();