On Tuesday 25 January 2011 20:23:36 Frank Sullivan wrote:
> Greetings,
> 
> My application is going to be run on different displays, some of which
> might be rotated 90, 180, or 270 degrees from their typical position. I've
> basically set things up so that my app reads the screen orientation from a
> config file, and does what it needs to do to make sure that things look
> 'upright' if that screen orientation is anything other than 0 degrees.
> 
> For the HUD, I have an osg::Projection node that is a parent to all of the
> HUD items. If the screen orientation is non-zero, then the projection
> matrix that I use contains some built-in rotation, like so:
> 
> 
> Code:
> osg::Matrix orthoMat = osg::Matrix::ortho(0, screenWidth, 0, screenHeight,
> 0.1, 1000.0f); osg::Matrix rotMat =
> osg::Matrix::rotate(screenOrientationAngle, 0, 0, 1); osg::Matrix
> finalProjMat = orthoMat * rotMat;
> 
> 
> 
> Just in case you are wondering: if the screen is rotated 90 or 270 degrees,
> I also swap the width and height so that my HUD items don't look
> stretched. I also use a trick to make sure that items appear in the
> correct place when the aspect ratio changes, but I don't bore you with the
> details of that.
> 
> This all seems to work well with one hitch: it seems to mess up the
> computePixelSizeVector calculation. I'm not quite sure how this
> calculation works, but when I embed some rotation into my projection
> matrix, it seems to have the effect of setting the w component of the
> pixelSizeVector to some huge number, and invariably all HUD items are
> culled by small feature.
> 
> I solved this by disabling the small feature culling, but since this is
> done on the camera, it will probably be global to the whole scene, which
> is probably not desirable. I'm sure I can find some other way (turning
> culling inactive for all HUD-related nodes, perhaps).
> 
> I'd like to do this same sort of thing for the main scene rendering, i.e.
> set the projection matrix on the camera to its normal projection matrix
> (using the reciprocal of the aspect ratio if necessary), multiplied by a
> rotation matrix. However, since running into that snag, I'm starting to
> wonder if this isn't a terrible idea. =]
> 
> I have no idea what I might be messing up. =P
> 
> Thank you!
> 
> Cheers,
> Frank

Hi Frank,

have you considered using the screen rotation functionality of your platform? 
Most modern Windows and X11 display drivers can rotate the screen for you. No 
change to your application should be needed, and (mouse) pointer input should 
continue to work as normal.

Depending on your combination of platform, hardware, and drivers, you might 
get sub-optimal performance in any but the standard 0 degree rotation. But it 
might be worth a try to see if your combination works sufficiently well.

Cheers,

Magnus
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to