资源简介
基于glut,读取点云文件 并进行绘制 包括用鼠标加键盘进行旋转、缩放、平移操作
使用VS2012编写
代码片段和文件信息
// OpenglDrawPoints.cpp : Defines the entry point for the console application.
//
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef struct tagPoint3D
{
GLfloat x;
GLfloat y;
GLfloat z;
}Point3D;
const float PI = 3.141592543f;
std::vector vec_pts;
GLfloat eyeZ;
GLfloat centerX centerY centerZ;
GLfloat fWidth fHeight;
GLfloat halfWidth halfHeight;
GLfloat translateX translateY;
GLfloat rotX rotY;
GLfloat downPtX downPtY;
bool leftBtnDown; GLfloat tempEyeZ;
GLuint arb;
GLuint pt3DNum;
PFNGLGENBUFFERSARBPROC glGenBuffersARB = 0;
PFNGLBINDBUFFERARBPROC glBindBufferARB = 0;
PFNGLBUFFERDATAARBPROC glBufferDataARB = 0;
PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = 0;
bool readFile()
{
string filePath;
cout << “input the poing cloud file: “ << endl;
cin >> filePath;
if (-1 == filePath.find(‘\\‘))
{
char path[256];
GetModuleFileName(NULL path 256);
int length = strlen(path);
char* temp = path + length;
while (temp[0] != ‘\\‘)
{
temp--;
}
temp[0] = 0;
filePath.insert(0 “\\“);
filePath.insert(0 path);
filePath += “.txt“;
//ifstream in(strcat(path “\\PointsXYZ_201506151741.txt“));
}
ifstream in(filePath.c_str());
if (!in)
{
printf(“读取文件失败!“);
return false;
}
//FILE* file = fopen(filePath.c_str() “r“);
//if (file == NULL)
//{
// printf(“读取文件失败!“);
// return false;
//}
char buf[80];
float a b c;
float minX = 0.0f maxX = 0.0f minY = 0.0f maxY = 0.0f minZ = 0.0f maxZ = 0.0f;
int index = 0;
while (!in.eof())
//while (!feof(file))
{
//fscanf(file “%f %f %f“ &a &b &c);
in.getline(buf 80 ‘\n‘);
sscanf(buf “%f %f %f“ &a &b &c);
Point3D pt;
pt.x = a;
pt.y = b;
pt.z = c;
if(eyeZ eyeZ=fabs(pt.z);
if (pt.x < minX)
minX = pt.x;
if (pt.x > maxX)
maxX = pt.x;
if (pt.y < minY)
minY = pt.y;
if (pt.y > maxY)
maxY = pt.y;
//if (pt.z < minZ)
// minZ = pt.z;
//if (pt.z > maxZ)
// maxZ = pt.z;
//minX += pt.x;
//minY += pt.y;
minZ += pt.z;
vec_pts.push_back(pt);
index = 0;
}
in.close();
//fclose(file);
centerX = (maxX + minX)/2;
centerY = (maxY + minY)/2;
//centerZ = (maxZ + minZ)/2;
//centerX = minX/vec_pts.size();
//centerY = minY/vec_pts.size();
centerZ = minZ/vec_pts.size();
halfWidth = fabs(maxX) > fabs(minX) ? fabs(maxX) : fabs(minX);
halfHeight = fabs(maxY) > fabs(minY) ? fabs(maxY) : fabs(minY);
pt3DNum = vec_pts.size();
Point3D* pData = new Point3D[pt3DNum];
for (int i=0; i {
pData[i].x = vec_pts[i].x;
pData[i].y = vec_pts[i].y;
pData[i].z = vec_pts[i].z;
}
glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)wglGetProcAddress(“glGenBuffersARB“);
glB
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 127488 2015-08-05 09:24 glDrawPointCloud\Debug\glDrawPointCloud.exe
文件 1131 2015-08-05 09:23 glDrawPointCloud\Debug\glDrawPointCloud.exp
文件 775852 2015-08-05 09:24 glDrawPointCloud\Debug\glDrawPointCloud.ilk
文件 2466 2015-08-05 09:23 glDrawPointCloud\Debug\glDrawPointCloud.lib
文件 1362944 2015-08-05 09:24 glDrawPointCloud\Debug\glDrawPointCloud.pdb
文件 1155165 2015-07-08 11:39 glDrawPointCloud\Debug\rabbit.txt
文件 3607 2015-08-05 09:28 glDrawPointCloud\glDrawPointCloud\glDrawPointCloud.vcxproj
文件 11864 2015-08-05 11:22 glDrawPointCloud\glDrawPointCloud\main.cpp
文件 37683200 2015-08-05 11:23 glDrawPointCloud\glDrawPointCloud.sdf
文件 915 2015-08-03 15:00 glDrawPointCloud\glDrawPointCloud.sln
..A..H. 37376 2015-08-05 11:23 glDrawPointCloud\glDrawPointCloud.v11.suo
文件 22528 2015-08-05 11:23 glDrawPointCloud\Release\glDrawPointCloud.exe
文件 1133 2015-08-05 11:23 glDrawPointCloud\Release\glDrawPointCloud.exp
文件 2466 2015-08-05 11:23 glDrawPointCloud\Release\glDrawPointCloud.lib
文件 625664 2015-08-05 11:23 glDrawPointCloud\Release\glDrawPointCloud.pdb
目录 0 2015-08-05 11:24 glDrawPointCloud\Debug
目录 0 2015-08-05 11:23 glDrawPointCloud\glDrawPointCloud
目录 0 2015-08-05 11:24 glDrawPointCloud\Release
目录 0 2015-08-05 11:23 glDrawPointCloud
----------- --------- ---------- ----- ----
41813799 19
- 上一篇:计算机基础综合408真题2009-2017
- 下一篇:开博进销存_7.55版()
相关资源
- 计算机图形学大作业
- OpenCV与OpenGL实现增强现实
- 3d opengl 飞行射击游戏源码和论文
- 20个可读的obj模型文件
- opengl实现模型读取以及光照,移动等
- 常用点云数据
- Opengl实现旗帜飘扬效果
- OpenGL星星公转自转
- OpenGL显示三维点云图像
- opengl绘制太阳、地球、月球
- Qt通过控件控制立方体旋转
- OpenGL编程指南 第九版英文版 OpenGL P
- 三维游戏设计师宝典(经典!)——学
- OpenGL课程设计
- OpenGL飘动的雏菊画布
- isprs点云数据
- OpenGL-篮球场.rar
- PCL1.7.2+Kinect V 2.0获取并保存点云PCD数
- opengl显示兔子程序
- learnopengl-cn-2018年5月更新.pdf
- OpenGL超级宝典完整源码(第五版)
- OpenGL游戏程序设计+源码
- 点云库pcl中的pcd文件
- cloudcompare数据
- opengl编程指南第七版
- 基于OpenGL实现的各种粒子特效
- 3D模型obj文件导入渲染光照贴图
- 常用的点云源数据.ply格式等斯坦福兔
- OpenGL配置库与教程实现一个.
- Lidar点云原始数据
评论
共有 条评论