osg::Camera 参数修改
2024-09-01 12:34:09
#ifdef _WIN32
#include <Windows.h>
#endif // _WIN32
#include<iostream> #include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgViewer/CompositeViewer> #include <osgDB/ReadFile> #include <osg/Geode>
#include <osg/Node>
#include <osg/Geometry>
#include <osg/GraphicsContext>
#include <osg/ShapeDrawable>
#include <osg/Material>
#include <osg/Image>
#include <osg/Texture2D>
#include <osg/TexEnv>
#include <osg/TexGen>
#include <osg/NodeVisitor>
#include <osg/MatrixTransform>
#include <osg/PositionAttitudeTransform>
#include <osg/AnimationPath>
#include <osg/Matrixd>
#include <osg/PagedLOD>
#include <osg/Camera> #include <osgGA/TrackballManipulator>
#include <osgGA/GUIEventHandler>
#include <osgGA/CameraManipulator>
#include <osgGA/StandardManipulator>
#include <osgGA/OrbitManipulator>
#include <osgGA/TrackballManipulator> #include <osgUtil/IntersectionVisitor>
#include <osgUtil/LineSegmentIntersector> osg::ref_ptr<osg::Group> createCameras(osg::ref_ptr<osg::Node> node1)
{ osg::ref_ptr<osg::Group> group1 = new osg::Group;
unsigned int width, height; osg::ref_ptr<osg::Camera> camera1 = new osg::Camera;
//osg::ref_ptr<osg::Node> node1 = osgDB::readNodeFile("D:\\参考手册\\BIM\\osg\\build20190628.osgb"); //camera1->setGraphicsContext(graphics1);
camera1->addChild(node1);
camera1->setViewport(, , , );
camera1->setClearColor(osg::Vec4(1.0, 1.0, 1.0, 0.0));
camera1->setName("camera1"); osg::ref_ptr<osg::Camera> cameraRight = new osg::Camera;
osg::Vec3d eyeRight, centerRight, upRight; //修改相机参数
eyeRight = osg::Vec3d(0.0, 0.0, 0.0);
centerRight = osg::Vec3d(0.0, 1.0, 0.0);
upRight = osg::Vec3d(0.0, 0.0, 0.0); cameraRight->addChild(node1);
cameraRight->setViewport(, , , );
cameraRight->setClearColor(osg::Vec4(1.0, 1.0, 1.0, 0.0));
cameraRight->setName("camera2"); //viewer->getCamera()->setViewMatrixAsLookAt(eye, center, up);
//cameraRight->setViewMatrixAsLookAt(eyeRight, centerRight, upRight);
cameraRight->setViewMatrix(osg::Matrix::rotate(osg::DegreesToRadians(-90.0),0.0,0.0,1.0)); //viewer1->addSlave(camera1.get());
group1->addChild(camera1.get());
group1->addChild(cameraRight.get()); return group1;
} int main()
{
osg::ref_ptr<osgViewer::Viewer> viewer1 = new osgViewer::Viewer;
osg::ref_ptr<osg::Group> group1 = new osg::Group;
//osg::ref_ptr<osg::Camera> camera1 = new osg::Camera; osg::ref_ptr<osg::Node> node1 = osgDB::readNodeFile("D:\\参考手册\\BIM\\osg\\build20190628.osgb");
//osg::ref_ptr<osg::Node> node2 = osgDB::readNodeFile("D:\\参考手册\\BIM\\osg\\build20190628.osgb"); //camera1->addChild(node1);
//camera1->setViewport(0, 0, 300, 220);
//camera1->setClearColor(osg::Vec4(0.0,0.0,0.0,0.0)); group1->addChild(node1.get());
//group1->addChild(camera1.get());
group1->addChild(createCameras(node1)); //createCameras1(node1, viewer1); viewer1->setSceneData(group1.get());
//createCamera(viewer1); viewer1->setUpViewInWindow(, , , , ); viewer1->run();
}
最新文章
- [nRF51822] 13、浅谈nRF51822和NRF24LE1/NRF24LU1/NRF24L01经典2.4G模块无线通信配置与流程
- 2016 CCPC 东北地区重现赛
- jquery easyui DataGrid 数据表格 属性
- c/s 与b/s构架
- 十六、Struts2文件上传与下载
- MSP430常见问题之IO端口类
- 【Uvalive 5834】 Genghis Khan the Conqueror (生成树,最优替代边)
- objective-c基础教程
- UVa340 Master-Mind Hints
- ZOJ 3935 2016
- ASP.NET MVC最新特性
- C-sizeof和strlen区别,以及sizeof如何计算结构体大小
- zw版足彩大数据&报价
- 【算法】LeetCode算法题-Remove Duplicates from Sorted Array
- (1)Python基础
- python3+scrapy 趣头条爬虫实例
- 【洛谷p2312】解方程
- Alpha课堂展示(麻瓜制造者)
- [python]接口签名
- 【CF700E】Cool Slogans 后缀自动机+线段树合并