Hi Jefferson,

I don't know how your skybox is, but if it's an "infinite distance" skybox, 
then I personnaly choose to render a small box (or sphere) that fits my 
near/far values (Ex: a skysphere that have a radius of 1 when near=.01 and 
far=100). I then put that skybox under a special transform node that disables 
any translation (= does as if the box was at infinite distance - See link 
below). Of course Depth-Buffer writes are disabled and the skybox is drawn 
first, which is not always what you want (especially about performance on 
complex skyboxes, where drawing last is better).

Hope it helps.

If needed, the "MoveWithEyePointTransform" class: 
http://pvle.sourceforge.net/Doc/Html/classMoveWithEyePointTransform.html
And its source: 
http://pvle.sourceforge.net/Doc/Html/MoveWithEyePointTransform_8h-source.html 
(Roughly 4 lines of code!)

Sukender
PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/

Le Tue, 02 Dec 2008 21:54:05 +0100, Jefferson Pinheiro <[EMAIL PROTECTED]> a 
écrit:

> Ah, thanks, that solved the problem.
>
> However, there is now a new problem: is it possible to change this view
> distance for everything, except the skybox (so that the skybox is always
> rendered)? My skybox, currently, is on a Group, that is child of root.
>
> On Tue, Dec 2, 2008 at 5:05 PM, Robert Osfield <[EMAIL PROTECTED]>wrote:
>
>> HI Jefferson,
>>
>> The OSG by default doesn't enable the near and far planes for culling
>> purposes, as doing so would require end users to accurately manage
>> their near/far plane.
>>
>> To enable the near/far culling simple do:
>>
>>  viewer->getCamera()->setCullingMode(osg::CullSettings::VIEW_FRUSTUM_CULLING
>> |
>>
>> osg::CullSettings::SMALL_FEATURE_CULLING);
>>
>> You may also want to disable the compute and near/far planes.
>>
>>
>>  
>> viewer->getCamera()->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
>>
>> Robert.
>>
>> On Tue, Dec 2, 2008 at 7:48 PM, Jefferson Pinheiro
>> <[EMAIL PROTECTED]> wrote:
>> > For performance reasons, I want to render only that which is close to my
>> > camera. I tried changing zNear and zFar, but they make absolutely no
>> effect
>> > (I tried values such as 100,200; 10,20; 0.000001;0.000002). However, for
>> > instance, changing the FOV (which is 80 now), does changes the FOV. My
>> world
>> > scale is 1 unit = 1 cm. What might be wrong?
>> >
>> >     {
>> >         viewer.setCameraManipulator(cm); //cm = class CamManipCarro :
>> public
>> > osgGA::MatrixManipulator (a custom camera manpulator)
>> >
>> >         osg::ref_ptr<osg::GraphicsContext::Traits> traits = new
>> > osg::GraphicsContext::Traits;
>> >         traits->x = 0;
>> >         traits->y = 0;
>> >         traits->width = GetSystemMetrics(SM_CXSCREEN);
>> >         traits->height = GetSystemMetrics(SM_CYSCREEN);
>> >         traits->windowDecoration = false;
>> >         traits->doubleBuffer = true;
>> >         //traits->sharedContext = 0;
>> >         osg::ref_ptr<osg::GraphicsContext> gc =
>> > osg::GraphicsContext::createGraphicsContext(traits.get());
>> >
>> > // HERE !! Changing the last 2 parameters makes no effect. I wanted it
>> would
>> > render only that which is between 100 and 200 units from my camera.
>> >         viewer.getCamera()->setProjectionMatrixAsPerspective(80,(double)
>> > GetSystemMetrics(SM_CXSCREEN) / (double)
>> > GetSystemMetrics(SM_CYSCREEN),100,200);
>> >
>> >
>> >         viewer.getCamera()->setNearFarRatio(0.000002);
>> >         viewer.getCamera()->setGraphicsContext(gc.get());
>> >         viewer.getCamera()->setViewport(new osg::Viewport(0,0,
>> > traits->width, traits->height));
>> >         GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
>> >         viewer.getCamera()->setDrawBuffer(buffer);
>> >         viewer.getCamera()->setReadBuffer(buffer);
>> >
>> >         osg::Camera* hudCamera = createHUD();
>> >         hudCamera->setGraphicsContext(gc.get());
>> >         hudCamera->setViewport(0,0,traits->width, traits->height);
>> >         viewer.addSlave(hudCamera, false);
>> >
>> >         viewer.setSceneData(root);
>> >         viewer.realize();
>> >         viewer.getCamera()->setUpdateCallback(new
>> CameraUpdateCallback());
>> >     }
>> >
>> >
>> > --
>> > Jefferson Pinheiro
>> >
>> > _______________________________________________
>> > osg-users mailing list
>> > [email protected]
>> >
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>> >
>> >
>> _______________________________________________
>> osg-users mailing list
>> [email protected]
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

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

Reply via email to