|
楼主 |
发表于 2009-9-6 00:55:27
|
显示全部楼层
其中initCamera的代码如下:
- void ShapefileHandler::initCamera(Camera* camera){
- ComputeBoundsVisitor v;
- camera->accept (v);
- BoundingBox box=v.getBoundingBox ();
- int w=(box.xMax ()-box.xMin());
- int h=(box.yMax ()-box.yMin());
- int txt_width=800,txt_height=450;
-
- camera->setClearColor(osg::Vec4(1.f,1.f,1.f,1.0f));
- camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- camera->setProjectionMatrix(osg::Matrix::ortho2D(-w/2,w/2,-h/2,h/2));
- camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
- camera->setViewport(0,0,txt_width,txt_height);
- camera->setRenderOrder(osg::Camera::POST_RENDER);
- camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
-
- HowtoManipulator mani(NULL);
- mani.setNode(camera);
- mani.home(0);
- camera->setViewMatrix (mani.getInverseMatrix());
- Texture2D* txt=new Texture2D();
-
- txt->setWrap (Texture2D::WRAP_S ,Texture2D::REPEAT );
- txt->setWrap (Texture2D::WRAP_T ,Texture2D::REPEAT );
- txt->setFilter(Texture::MIN_FILTER,Texture::LINEAR);
- txt->setFilter(Texture::MAG_FILTER,Texture::NEAREST);
- camera->attach(osg::Camera::COLOR_BUFFER,txt);
- mTextMap[camera->getName()]=txt;
- }
复制代码 |
|