资源简介
利用直角坐标值完成了基本的地形绘制,实现了基本的漫游

代码片段和文件信息
#include “stdafx.h“
#include “South.h“
using namespace std;
CSouth::CSouth():m_fMoveSpeed(1.5)//初始速度设为1.5
m_bLeftButtonDown(false)//左键没有按下
m_fpushX(0)//左键点下时初始坐标为0
m_fAngle(2.5)//初始角速度是2.5
m_bpeng(false)//开始时碰撞检测关闭
m_fpushY(0)//右键点下时位置为0
{
m_vPosition = osg::Vec3(-22.0-227.0100.0);//出生点位0
m_vRotation = osg::Vec3(osg::PI_200);//初始角度
scale = 1.0;
}
CSouth::~CSouth()
{
}
void CSouth::setByMatrix (const osg::Matrixd& matrix )
{
}
void CSouth::setByInverseMatrix(const osg::Matrixd& matrix)
{
}
osg::Matrixd CSouth::getMatrix(void) const
{
osg::Matrixd mat;
mat.makeRotate(m_vRotation._v[0]osg::Vec3(0.00.00.0)m_vRotation._v[1]osg::Vec3(0.0f0.0f0.0f)m_vRotation._v[2]osg::Vec3(0.00.00.0));
// // std::cout< return mat * osg::Matrixd::translate(m_vPosition);
// return osg::Matrixd::inverse(mat * osg::Matrixd::translate(m_vPosition));
// return mat;
}
osg::Matrixd CSouth::getInverseMatrix(void) const
{
osg::Matrixd mat;
mat.makeRotate(m_vRotation._v[0]osg::Vec3(1.00.00.0)m_vRotation._v[1]osg::Vec3(0.0f1.0f0.0f)m_vRotation._v[2]osg::Vec3(0.00.01.0));
return osg::Matrixd::inverse(mat * osg::Matrixd::translate(m_vPosition));
// return mat * osg::Matrixd::translate(m_vPosition);
// return mat1;
}
bool CSouth::handle(const osgGA::GUIEventAdapter& eaosgGA::GUIActionAdapter& us)
{
float mouseX = ea.getX();
float mouseY = ea.getY();
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()==0x20)//如果是空格
{
//重绘
us.requestRedraw();
us.requestContinuousUpdate(false);
return true;
}
if (ea.getKey()==0xFF56)//如果是 home键
{
//视点向上移动
changePosition(osg::Vec3(00m_fMoveSpeed));
return true;
}
if (ea.getKey()==0xFF55) //如果是end键
{
//视点向下移动
changePosition(osg::Vec3(00-m_fMoveSpeed));
return true;
}
if (ea.getKey()==0x2B)//如果是加号键
{
//加速
m_fMoveSpeed += 1.0f;
return true;
}
if (ea.getKey()==0x2D)//如果是减号
{
//减速
m_fMoveSpeed -= 1.0f;
if (m_fMoveSpeed<1.0f)
{
m_fMoveSpeed = 1.0f;
}
return true;
}
if (ea.getKey()==0xFF52||ea.getKey()==0x57||ea.getKey()==0x77)//如果是w或者up键
{
// //向前走
changePosition(osg::Vec3(05*m_fMoveSpeed*sinf(osg::PI_2+m_vRotation._v[2])0));
changePosition(osg::Vec3(5*m_fMoveSpeed*cosf(osg::PI+m_vRotation._v[2])00));
// changePosition(osg::Vec3(0m_fMoveSpeed*50));
return true;
}
if (ea.getKey()==0xFF54||ea.getKey()==0x53||ea.getKey()==0x73)//如果是s或者down键
{
//向后退
// changePosition(osg::Vec3(0-m_fMoveSpeed*sinf(osg::PI_2+m_vRotation._v[2])*50));
// changePosition(osg::Vec3(0-5*m_fMoveSpeed*sinf(osg::PI_2+m_vRotation._v[2])0));
// changePosition(osg::Vec3(-5*m_fMoveSpeed*cosf(osg::PI_2+m_vRotation._v[2
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-06-09 11:38 terrian\
目录 0 2012-06-09 11:38 terrian\Debug\
文件 94208 2012-06-23 19:07 terrian\Debug\terrian.exe
文件 738712 2012-06-23 19:07 terrian\Debug\terrian.ilk
文件 4459520 2012-06-23 19:07 terrian\Debug\terrian.pdb
目录 0 2012-07-16 10:18 terrian\Release\
目录 0 2012-06-23 19:07 terrian\terrian\
目录 0 2012-06-23 19:07 terrian\terrian\Debug\
文件 7520 2012-06-23 19:07 terrian\terrian\Debug\BuildLog.htm
文件 65 2012-06-23 19:07 terrian\terrian\Debug\mt.dep
文件 561561 2012-06-09 11:30 terrian\terrian\Debug\south.obj
文件 11873 2012-06-09 11:30 terrian\terrian\Debug\stdafx.obj
文件 663 2012-06-09 11:31 terrian\terrian\Debug\terrian.exe.em
文件 728 2012-06-09 11:31 terrian\terrian\Debug\terrian.exe.em
文件 621 2012-06-23 19:07 terrian\terrian\Debug\terrian.exe.intermediate.manifest
文件 559263 2012-06-23 19:07 terrian\terrian\Debug\terrian.obj
文件 3211264 2012-06-09 11:30 terrian\terrian\Debug\terrian.pch
文件 1682432 2012-06-23 19:07 terrian\terrian\Debug\vc90.idb
文件 3829760 2012-06-23 19:07 terrian\terrian\Debug\vc90.pdb
文件 1183 2011-06-03 17:49 terrian\terrian\ReadMe.txt
目录 0 2012-06-09 11:38 terrian\terrian\Release\
文件 58098 2012-06-09 11:36 terrian\terrian\Release\BuildLog.htm
文件 7584103 2012-06-09 11:36 terrian\terrian\Release\south.obj
文件 36899 2012-06-09 11:36 terrian\terrian\Release\stdafx.obj
文件 7615196 2012-06-09 11:36 terrian\terrian\Release\terrian.obj
文件 3211264 2012-06-09 11:36 terrian\terrian\Release\terrian.pch
文件 502784 2012-06-09 11:36 terrian\terrian\Release\vc90.idb
文件 3731456 2012-06-09 11:36 terrian\terrian\Release\vc90.pdb
文件 7274 2011-06-05 19:57 terrian\terrian\south.cpp
文件 1607 2011-06-05 19:41 terrian\terrian\south.h
文件 212 2011-06-03 17:49 terrian\terrian\stdafx.cpp
............此处省略12个文件信息
- 上一篇:北航数值分析第三次大作业
- 下一篇:GT-POWER自学很有用哦
相关资源
- 三维地形的仿真显示实现了对地图的
- 中国地形图(大陆部分,不附岛屿)
- 基于GPS-RTK与全站仪的城市道路改扩建
- GPS-RTK、全站仪联合作业在化石沟铜矿
- 探讨GPS技术在地形复杂矿山变形监测
- cesium实现底图和地形动态切换及supe
- 1:10M全球地形高程光栅格图像
- osg爆炸仿真及火烟模拟
- OpenGL三维地形建模
- 论文研究 - 利用地形因子预测冲绳岛
- 基于多波束声纳数据与反射模型的水
- Terrain Assets.unitypackageUnity3d官方资源包
- 地形点云.pcd
- MultiGenCreator的地形建模技术研究.
- OpenSceneGraph 3.0 Beginner’s Guide.pdf
- 点云数据读取 使用osg 附带点云数据
- osg显示点云
- Unity 最新T4M地形插件,适用于5.6以上
- OSG入门书籍之一:OpenSceneGraph Quick S
- 北京市街道边界GIS图
- 百度联合清华大学发布《产业智能化
- 地形匹配导航程序
- 地形匹配导航
- osg3.0.0.rar
- 本人亲自编译的最全的64位osg3.4第三方
- 可以在osg3.4+osgEarth2.8中使用的64位VP
- 中国GIS数据---gis数据是中国的地形图
- osgi自定义控制台命令demo
- OSG与OSGB批量转化工具
- GBT+20257.2-2006+国家基本比例尺地图图式
评论
共有 条评论