OpenGL读取PLY模型文件并绘制 Read and draw ply model by OpenGL

这篇博客介绍了如何使用OpenGL读取由MeshLab生成的PLY模型文件,并进行绘制。文章提供了PLY文件的部分内容展示,以及涉及的源代码文件PlyLoader.h, PlyLoader.cpp, 和 Main.cpp。" 89417198,8389406,IT职业发展:成为优秀项目经理之路,"['项目管理', '职业发展', 'IT职业规划']
摘要由CSDN通过智能技术生成

Ply文件由MeshLab导出生成,格式可能和其他软件导出的有出入。

本来想把模型文件贴上来,但是找了一下好像不能上传,希望着可留言。

这里贴一下模型文件的开头部分。

-------------------------------------------------------

ply
format ascii 1.0
comment VCGLIB generated
element vertex 6479
property float x
property float y
property float z
property float nx
property float ny
property float nz
property int flags
property uchar red
property uchar green
property uchar blue
property uchar alpha
element face 12954
property list uchar int vertex_indices
property int flags
end_header
0.0363526 0.0894518 0.0166275 -2.58589 -5.26492 -2.22414 0 175 160 84 255 
0.0389934 0.088225 0.0166275 -2.52566 -5.33 -2.15753 0 170 156 88 255 
0.0389934 0.0894518 0.0138336 -2.41584 -5.1918 -2.5521 0 146 145 86 255 
0.0340731 0.0894518 0.0200012 -2.865 -5.39322 -1.43764 0 174 151 78 255 
0.0356197 0.0886338 0.0200012 -2.74755 -5.42387 -1.53245 0 168 145 74 255 
0.0356197 0.0894518 0.0175829 -2.64306 -5.36739 -1.90754 0 171 156 75 255 

......

-------------------------------------------------------

PlyLoader.h

 

#ifndef PLYREADER_H_
#define PLYREADER_H_

#include <GL/glut.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include <vector>
#include <iostream>
using namespace std;

struct SModelData
{
	vector <float> vecFaceTriangles; // = face * 9
	vector <float> vecFaceTriangleColors; // = face * 9
	vector <float> vecNormals; // = face * 9
	int iTotalConnectedTriangles;
};

class CPLYLoader 
{
public:
	CPLYLoader();
	int LoadModel(char *filename);
	void Draw();
	
private:
	float* mp_vertexXYZ;
	float* mp_vertexNorm;
	float* mp_vertexRGB;
	int m_totalConnectedQuads;	
	int m_totalConnectedPoints;
	int m_totalFaces;
	SModelData m
评论 32
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值