|
楼主 |
发表于 2011-1-17 14:47:15
|
显示全部楼层
呵呵,就我这几天提出的问题,其实都是一环套一环的,目的就是为了我手头的这个虚拟现实。我做了一个Camera相机节点,挂接在根节点的下方。需要渲染的所有节点都挂在该相机下面。该相机直接使用attach方法,如下代码:
m_pBufferTexture = new osg::Texture2D;
m_pBufferTexture->setName("Buffer Texture For Scene Color");
m_pBufferTexture->setTextureSize(1024, 768);
m_pBufferTexture->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D:INEAR);
m_pBufferTexture->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR);
m_pBufferTexture->setInternalFormat(GL_RGBA);
m_pPreRenderCamera = new osg::Camera;
m_pPreRenderCamera->setRenderOrder(osg::Camera:RE_RENDER, INT_MAX);
m_pPreRenderCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
m_pPreRenderCamera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
m_pPreRenderCamera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
m_pPreRenderCamera->setClearColor(osg::vec4(0.0, 0.0, 0.0, 1.0));
m_pPreRenderCamera->setViewMatrix(osg::Matrixd::identity());
m_pPreRenderCamera->setProjectionMatrixAsPerspective(45.0, 1.0, 1.0, 100.0);
m_pPreRenderCamera->setName("ViewEx Pre Render Camera");
m_pPreRenderCamera->attach(osg::Camera::COLOR_BUFFER, m_pBufferTexture.get());
m_pPreRenderCamera->setViewport(0, 0, 1, 1);
上述代码中,m_pPreRenderCamera将直接挂接到场景的根节点下面,我需要渲染的场景(一座城市),则挂接在m_pPreRenderCamera的下面。 |
|