osgEarth设置模型旋转角度
#include<windows.h>
#include <osgViewer/Viewer>
#include <osgEarthDrivers/gdal/GDALOptions>
#include <osg/ShapeDrawable>
#include <osgEarthUtil/EarthManipulator>
#include <osg/MatrixTransform>
#include <osgEarthFeatures/ConvertTypeFilter>
#include <osgEarthDrivers/model_simple/SimpleModelOptions>
#include <osgViewer/ViewerEventHandlers>
#include <osgGA/StateSetManipulator> #ifdef _DEBUG
#pragma comment(lib, "osgd.lib")
//#pragma comment(lib, "osgDBd.lib")
#pragma comment(lib, "osgViewerd.lib")
#pragma comment(lib, "osgGAd.lib")
#pragma comment(lib, "osgEarthd.lib")
#pragma comment(lib, "osgEarthUtild.lib")
#else
#pragma comment(lib, "osg.lib")
#pragma comment(lib, "osgDB.lib")
#pragma comment(lib, "osgViewer.lib")
#pragma comment(lib, "osgGA.lib")
#endif // DEBUG // lonlat1:雷达波圆锥顶点
// lonlat2:轨迹点
void rotateCone(osg::MatrixTransform* mt, const osgEarth::SpatialReference* sr, osg::Vec3d lonlat1, osg::Vec3d lonlat2)
{
// 雷达波模型所在位置
osgEarth::GeoPoint geoPoint1(
sr,
lonlat1.x(),
lonlat1.y(),
lonlat1.z(),
osgEarth::ALTMODE_ABSOLUTE);
osg::Matrixd matrix1;
// 获取雷达波模型从原点变换到lonlat1位置的变换矩阵
geoPoint1.createLocalToWorld(matrix1);
// 经纬度高程到xyz的变换
osg::Vec3d world1, world2;
// geoPoint1.toWorld(world1);//等同于 sr->transformToWorld(lonlat1,world1);
sr->transformToWorld(lonlat2, world2);
// 计算轨迹点在雷达波模型坐标系下的位置
osg::Vec3 point2InRadarCoordinateSystem = world2*osg::Matrix::inverse(matrix1);
// 在雷达波模型坐标系下,对Z轴进行旋转,与连接原点指向轨迹点方向的矢量重合,计算出此旋转矩阵
osg::Matrixd rotMat = osg::Matrixd::rotate(osg::Z_AXIS, point2InRadarCoordinateSystem-osg::Vec3(,,));
// 将计算出的旋转矩阵赋给雷达波模型所在的mt
mt->setMatrix(rotMat);
}
int main(int argc, char** argv)
{
osgViewer::Viewer viewer;
std::string world_tif = "data/world.tif";
osgEarth::Map* map = new osgEarth::Map();
// Start with a basemap imagery layer; we'll be using the GDAL driver
// to load a local GeoTIFF file:
osgEarth::Drivers::GDALOptions basemapOpt;
basemapOpt.url() = world_tif;
map->addImageLayer(new osgEarth::ImageLayer(osgEarth::ImageLayerOptions("basemap", basemapOpt))); osgEarth::MapNodeOptions mapNodeOptions;
mapNodeOptions.enableLighting() = false;
osgEarth::MapNode* mapNode = new osgEarth::MapNode(map, mapNodeOptions); osgEarth::Drivers::SimpleModelOptions opt;
opt.location() = osg::Vec3(, , );
//opt.url() = "cow.osg.1000,1000,1000.scale";
osg::Geode* geode = new osg::Geode;
osg::ShapeDrawable* cone = new osg::ShapeDrawable(new osg::Cone(osg::Vec3(), , ));
//osg::ShapeDrawable* cone = new osg::ShapeDrawable(new osg::Box(osg::Vec3(), 50000));
geode->addDrawable(cone);
osg::MatrixTransform* mtCone = new osg::MatrixTransform;
mtCone->addChild(geode);
opt.node() = mtCone;
map->addModelLayer(new osgEarth::ModelLayer("", opt)); rotateCone(mtCone, map->getProfile()->getSRS(), osg::Vec3(, , ), osg::Vec3(, , )); osg::Group* root = new osg::Group();
root->addChild(mapNode);
viewer.setSceneData(root);
viewer.setCameraManipulator(new osgEarth::Util::EarthManipulator()); // Process cmdline args
//MapNodeHelper().parse(mapNode, arguments, &viewer, root, new LabelControl("Features Demo")); //视点定位模型所在位置
osgEarth::Viewpoint vp("", , , 1000.0, -2.50, -90.0, 1.5e6);
(dynamic_cast<osgEarth::Util::EarthManipulator*>(viewer.getCameraManipulator()))->setViewpoint(vp); // add some stock OSG handlers:
viewer.addEventHandler(new osgViewer::StatsHandler());
viewer.addEventHandler(new osgViewer::WindowSizeHandler());
viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));
viewer.setUpViewInWindow(, , , );
return viewer.run();
}
osgEarth设置模型旋转角度的更多相关文章
- xBIM WeXplorer 设置模型颜色
目录 基础 xBIM WeXplorer 简要介绍 xBIM WeXplorer xViewer 基本应用 xBIM WeXplorer xViewer 浏览器检查 xBIM WeXplorer xV ...
- xBIM 基础13 WeXplorer 设置模型颜色
系列目录 [已更新最新开发文章,点击查看详细] 默认情况下模型具有合理的图形表示.这是从IFC模型中获取的,它应该在所有工具中看起来相同,它应该与您或您的用户的创作环境中的相同.但有时候能够改 ...
- [原][osgearth]设置OE的高程,高度场的数据。修改设置高度值
; row < hf->getNumRows(); ++row ) { ; col < hf->getNumColumns(); ++col ) { float val = h ...
- fluent批量处理——模型参数的设置
对于常见的工程应用来说,计算的工况很多,尤其优化工作,少则几百,多则上千,面对如此之多的case文件要写,假如按照一个一个的读写的话,相信你一定会为这么机械的工作烦躁,甚至影响今后好几天的心情,那么有 ...
- WebGL或OpenGL关于模型视图投影变换的设置技巧
目录 1. 具体实例 2. 解决方案 1) Cube.html 2) Cube.js 3) 运行结果 3. 详细讲解 1) 模型变换 2) 视图变换 3) 投影变换 4) 模型视图投影矩阵 4. 存在 ...
- xBIM 实战02 在浏览器中加载IFC模型文件并设置特效
系列目录 [已更新最新开发文章,点击查看详细] 在模型浏览器中加载模型后,可以对模型做一些特殊操作.下图是常用的设置. 都是通过 xbim-viewer.js 中的 API 来设置以达到一定的 ...
- [源码解析] 模型并行分布式训练 Megatron (4) --- 如何设置各种并行
[源码解析] 模型并行分布式训练 Megatron (4) --- 如何设置各种并行 目录 [源码解析] 模型并行分布式训练 Megatron (4) --- 如何设置各种并行 0x00 摘要 0x0 ...
- WebGL three.js学习笔记 加载外部模型以及Tween.js动画
WebGL three.js学习笔记 加载外部模型以及Tween.js动画 本文的程序实现了加载外部stl格式的模型,以及学习了如何把加载的模型变为一个粒子系统,并使用Tween.js对该粒子系统进行 ...
- MVC4做网站六后台管理:6.2网站信息设置
用来实现网站标题.名称.关键字.描述.版权等信息的设置. 模型字段: 网站的设置信息前后台都要用到,所以要把模型方式Ninesky/Models文件夹中,代码如下: ///////////////// ...
随机推荐
- 安卓程序代写 网上程序代写[原]BluetoothServerSocket详解
一. BluetoorhServerSocket简介 1. 继承关系 public final class BluetoothServerSocket extends Object implement ...
- 25个顶级的jQuery表格插件
jQuery 表格插件可以让你创建各种各样的表格布局,表格布局是报纸和杂志中最常见的布局,现在的网站中也很常见,在这篇文章中,我向大家推荐25个jQuery 的表格插件,你可以任意控制表格的行和列,用 ...
- C++ 结构体初始化
#include <stdio.h> int main(int argc, const char * argv[]) { //定义结构体类型 struct Person { char *n ...
- Qt之QLocalServer
简述 QLocalServer提供了一个基于本地socket的server. QLocalServer可以接受来自本地socket的连接.通过调用listen(),让server监听来自特定key的连 ...
- 【转】android如何实现开机自动启动Service或app
1.今天我们主要来探讨android怎么让一个service开机自动启动功能的实现.Android手机在启动的过程中会触发一个Standard Broadcast Action,名字叫android. ...
- SpringCloud微服务部署
https://blog.csdn.net/weixin_36397925/article/details/79496657 https://blog.csdn.net/forezp/article/ ...
- mxnet与tensorflow的卷积实现细节比较
mxnet的卷积 kernel = 3 pad=1边界补充0后,不管stride是否1还是2,imgw = 奇数或者偶数, 都是从图像位置(0,0)开始卷积 tensorlfow的卷积 kernel ...
- ajax实现模糊查询完成列表信息显示
之前遗留一个老问题:列表模糊查询,用的直接是form提交,点击搜索按扭后,页面刷新,搜索框中关键词就没了,这鸡肋的体验,我发誓一定要搞定它 但是鉴于自己写代码是纯粹玩票,我写代码没有目标,只有在当前工 ...
- 使 Finder 显示 文件夹路径
显示路径: cd ~ defaults write com.apple.finder _FXShowPosixPathInTitle -bool TRUE killall Finder 不显示路径: ...
- Numpy存字符串
# -*- coding: utf-8 -*- import numpy as np student = np.dtype({'names':['name', 'age', 'weight'], 'f ...