Owed by: Spring Night rain Http://blog.csdn.net/chunyexiyu reprint please indicate source
In most cases, if we need to rotate the content on the Overlay , we implement it by rotating the content itself, and other transformations such as the rotation of the sample material.
But there may be a few cases where we need to rotate the Overlay itself.
Material rotation, displacement, animation and other effects used more commonly, here is not elaborate, mainly to explain the Overlay of the rotation of the treatment.
Overlay supports scroll, scale,rotate several transformations.
Note : The coordinate system used by Overlay is not a normal screen coordinate system, but a Cartesian coordinate system.
The origin is in the center of the window,
The positive half of the X -axis is on the right (the rightmost size is 1and the leftmost is -1).
The positive half axis of the Y -axis is on top (top 1, Bottom is -1)
Here is an example of a transformation program
Create a Overlay, Occupy screen scale (0,0), (0.2, 0.2)
// name Ogre::Stringoverlayname = "Overlay1"; Ogre::Stringcontainname = "Cont1"; Ogre::Stringtextname = "Text1"; Create Overlay Ogre::overlaymanager *poverlaymanager =Ogre::overlaymanager:: Getsingletonptr(); m_poverlay = Poverlaymanager,create(overlayname); m_poverlay,setzorder(254); M_poverlay,show(); Create Border Panel container Ogre::overlaycontainer*m_pcontainer = static_cast<Ogre:: Overlaycontainer*> (poverlaymanager-createoverlayelement("Borderpanel", containname)); M_pcontainer,setmetricsmode(gmm_relative); M_pcontainer,setposition(0, 0); M_pcontainer,setwidth(0.2); M_pcontainer,setheight(0.2); M_pcontainer-setmaterialname("Core/statsblockcenter"); //Add container to overlay m_poverlay,add2d(m_pcontainer); Create TextArea overlayelement* m_ptextarea = poverlaymanager-createoverlayelement(" TextArea ",textname); M_ptextarea,setmetricsmode(gmm_relative); M_ptextarea,setposition(0, 0); M_ptextarea,setwidth(0.2); M_ptextarea,setheight(0.1); M_ptextarea-setparameter("Font_name","Bluehighway"); M_ptextarea-setparameter("Char_height",stringconverter::toString (Ogre::Real(0.05))); M_ptextarea-setparameter("Horz_align","left"); M_ptextarea-setcolour(Ogre::colourvalue(0.0, 1.0, 0.0)); M_ptextarea-setcaption(Ogre::displaystring(L"Test triangle \ntesttest ")); M_pcontainer,addChild(m_ptextarea); |
Called before frame render : The rotation of the specified point is deferred
A. in Cartesian coordinates,overlay is located at ( -1,1), ( -0.8,0.8), and overlay rotate is based on
(0,0) is rotated, and the Overlay size has been adjusted for reference.
B. for us, we only use the rotation of the extension ( -0,8, 0.8) point.
Based on matrix solution method : The result matrix of rotation of a point
Rotation + offset (x-x*[email protected]+[email protected], Y–x*[email Protected]*[email protected])
Static UINT S_ncount = 0; { Ogre::Radianradangle = Ogre::degree(s_ncount++); m_poverlay,setRotate(radangle); Double x =-0.8; Double y = 0.8; m_poverlay-setscroll( x - x*cos(radangle. Valueradians()) +y*sin(radangle. Valueradians()), y - x* sin(radangle. Valueradians())-y*cos(radangle. Valueradians())); } |
Owed by: Spring Night rain Http://blog.csdn.net/chunyexiyu reprint please indicate source
Overlay rotation of the ogre