Ogre Study Notes (3): mesh rendering process

Source: Internet
Author: User
First, an entity object must attach to a scenenode. 1. Create a scenenode:
Scenemanager: getrootscenenode () (a rootnode is created during scenemanager: init)
À scenenode: createchildscenenode ()
À node: createchild ()
The main operation is completed in this function. First, call the virtual function scenenode: createchildimpl (). This function also calls octreescenemanager: createscenenode (), this function will create a new class object of scenenode, Which is octreenode, and add it to scenenodelist mscenenodes. Then it performs coordinate transformation, and finally adds the pointer to childnodemap mchildren, then return this pointer; 2. attach entity to scenenode: attachobject (); 3. rendering starts from the root: startrendering () function. This function starts a loop and runs root: renderoneframe () each time ()
À root: _ updateallrendertargets
À rendersystem: _ updateallrendertargets ()
À renderwindow: Update ()
À d3d9renderwindow: Update (bool swap)
À rendertarget: Update ()
À viewport: Update ()
À camera: _ renderscene ()
À scenemanager: _ renderscene (Camera * camera, viewport * VP, bool includeoverlays) 4. after a large circle, we came to scenemanager: _ renderscene (). This function must be the main operation of rendering; 5. scenemanager: _ updatescenegraph () recursively calls the update of all scene nodes starting from the root node, mainly computing the transform; 6. set a series of parameters for autoparamdatasource. This class is used to provide some parameters for GPU programs. 7. scenemanager: preparerenderqueue (). Here is an ogre Scenario Management Concept renderqueue. Roughly speaking, this class aims to group objects by material and manage the rendering priority of objects. 8. octreescenemanager: _ findvisibleobjects ()
À octreescenemanager: walkoctree
À octreenode: _ addtorenderqueue
If you want to display the package box, you will call "Sn-> _ addboundingboxtoqueue (Queue );"
This operation uses scenemanager's space management algorithm to determine the visibility of all scenenode. If it is visible, add it to renderqueue. 9. after calculating the renderqueue, start to call a series of functions of rendersystem, such as _ setprojectionmatrix, to prepare for the real rendering operation; 10. scenemanager: _ rendervisibleobjects. The rendering operation is here.
À scenemanager: rendervisibleobjectsdefasequsequence
À scenemanager: _ renderqueuegroupobjects
À scenemanager: renderbasicqueuegroupobjects (this function traverses each renderprioritygroup in renderqueuegroup, then renders solids and then renders transparents)
À scenemanager: Runner: visit11. à scenemanager: rendersingleobject. This function sets the light and GPU programs, and then uses a renderoperation object to call d3d9rendersystem: _ render, that is, the real draw call. The renderoperation object is set by subentity: getrenderoperation à submesh: _ getrenderoperation, mainly indexdata and vertexdata.

Note: 1. In the scenemanager: renderobjects function, a visitor mode is used to access the queuedrenderablecollection (instances of this class are used to include solids and transparents in the renderprioritygroup ). 2. entity is derived from moveableobject, while subentity is derived from renderable; 3. one scenenode can attach multiple entity; in fact, scenenode can attach any moveableobject; 4. previously, we only mentioned indexdata and vertexdata. for rendering, material is the focus of attention. How does the mesh material interact with rendersystem? Conclusion: scenemanager forms an renderqueue after determining the visibility, and then uses renderopertation to contact rendersystem for each object in the queue to perform rendering operations. The general feeling is that some areas are quite complicated, and some people think it is relatively complicated. For example, you can find rendertarget through root, then know the viewport, find camear, and finally execute the rendering function of scenemanager, why don't I finish viewport scenemanaer ::_ renderscene and hand it over to the upper layer for control? After all, most programs require an renderwindow and a viewport. Another example is renderqueue (see). I don't know if it is complicated to process shadow. If objects is grouped by material and then solids is first rendered to each group before transparents, this transparent processing method is obviously insecure. If there are transparent objects in both groups, the picture will certainly have problems.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.