[Reprint please ensure the completeness and correctness of the content]
Sky
The realization of the sky in Ogre is very simple, in its scenemanager has implemented the method of adding the sky (the author's current skill is not enough to write a more efficient Sky rendering method), here is just about how to use the specific.
There are three ways to achieve the Ogre Sky:
Skybox
The Sky box, six sides of the camera bag up (so that will never go out). Here is the definition of its function:
1 Virtual voidSetskybox (2 BOOLEnable//is enabled3 Conststring& Materialname,//Material name4Real distance = the,//The distance from each face to the camera in the world coordinate system5 BOOLDrawfirst =true,//Render Queue6 Constquaternion& orientation = quaternion::identity,//the angle of rotation of the box7 Conststring& groupName = Resourcegroupmanager::D efault_resource_group_name//name of the resource group8);
There are some concepts that may not be clear, such as resource groups, which will be explained later, and now we'll learn how to use these features. Adding Skybox to the game requires only one line of code:
1 // DemoManager.cpp 2 Sm->setskybox (true"examples/spaceskybox");
There are default values for parameters that are not written, and there is generally no need to modify them at this stage. A variety of sky materials are available in the OGRE and can be found in the (Ogre_path) \media\materials\scripts\examples.material. You can also define some materials yourself.
Stick Two sheets:
Skydome
Note that it is dome, not demo. (I always thought it was a demo before I wrote it.)
The Sky Dome is also a box, but the image is mapped in spherical form, and looks like a hemisphere. Its function is defined as:
1 Virtual voidSetskydome (2 BOOLEnableConststring&Materialname,3Real curvature =Ten,4Real tiling =8,5Real distance =4000,6 BOOLDrawfirst =true,7 Constquaternion& Orientation =quaternion::identity,8 intXsegments = -,9 intYsegments = -,Ten intYsegments_keep =-1, One Conststring& GroupName =Resourcegroupmanager::D efault_resource_group_name A);
A little more words, it is not written in the comments.
Curvature: curvature. The higher the value, the smoother the effect; the lower the value, the better the sense of distance.
Tiling: Number of map repetitions.
Xsegments,ysegments: Vertex buffer and index buffer size (vertexbufferusage and Indexbufferusage).
Ysegments_keep: Whether the buffer is reserved.
Add the same way as Skybox. :
Skyplane
The surface of the sky, a plane above the camera. Its function is defined as:
1 Virtual voidSetskyplane (2 BOOLEnable,3 Constplane& Plane,//first, we need to define a plane .4 Conststring&Materialname,5Real scale = +,6Real tiling =Ten,7 BOOLDrawfirst =true,8Real bow =0,//curvature. 0 is a horizontal plane, the higher the number of the higher the rate of curvature. 9 intXsegments =1,Ten intYsegments =1, One Conststring& GroupName =Resourcegroupmanager::D efault_resource_group_name A);
There is a difference in how it is added.
1 // 2 Plane Plane; 3 PLANE.D = 1000 4 plane.normal = vector3::negative_unit_y; 5 Sm->_setskyplane (true , Plane, Span style= "color: #800000;" > " examples/cloudysky " , 500 , 20 , false , 0.5f , 150 , 150 );
If there are no last 6 parameters then the effect is OK, but the biggest problem is that it is a horizontal plane. The choice of these parameters needs to be changed according to the actual situation, multiple attempts to get the best results.
:
Fog
The sky is often used in conjunction with fog to make its effect more realistic.
function definition:
1 void Setfog (2 Const colourvalue& colour = colourvalue::white,3 0.0010.01.0);
Fogmode is the way fog is generated, there are four kinds: fog_none (none), fog_linear (linear Generation), Fog_exp (exponential generation), FOG_EXP2 (two-time exponential generation). It is enough to use linear generation in general.
Add Fog:
1 // DemoManager.cpp 2 Colourvalue fadecolour (0.90.90.9); 3 0.0f 15000.0f 28000.0f);
:
Tips
Some materials of the sky will move, I want to let it still do?
In (ogre_path) \media\materials\scripts\examples.material can find its corresponding material information, the Scroll_anim and the like to remove the animation on the line.
Some classes cannot be found, such as Vector3?
Precede the class with Ogre: Or add the Using namespace Ogre.
Auto exit and no error?
Look at Ogre.log.
Ogre: Sky