4

I am currently doing a project which needs to do handle ply file and display it. I want to use pyopengl to handle this problem. Can someone tell me is there a way for me to display 3-D model of this ply file using pyopengl? I searched google, but couldn't find some useful thing.

Actually, right now, I have a ply file, and I want to read this file to let it display 3D mesh, but I read through some tutorial online, and couldn't find some useful information. Thank you!

python3
  • 251
  • 4
  • 12
  • +Close as too broad. specify closer what is your problem exactly. You do not know how to load ply file or you do not know how to render 3D mesh? What exactly is failing to work and how ... it is a good idea to start from point you know not asking us to do all the stuff for you at once ... PLY is simple ASCII export an example file would be good idea to share so we see the content (mine got just vertex and face lists without any textures,normals or colors) – Spektre Jun 07 '17 at 07:48
  • Hi, Thanks for suggestion!!! Actually, right now, I have a ply file, and I want to read this file to let it display 3D mesh, but I read through some tutorial online, and couldn't find some useful information. Thank you! – python3 Jun 07 '17 at 15:19
  • 1
    look for examples on parsing text file ... you need to read the file line by line extract number of points and faces ... allocate enough space for them and then read the data ... one line is one point ... one line is one face (first number tells you how many points per polygon and then the indexes goes). When done you can render it in OpenGL either by converting your data to VBO or use the old GL 1.0 `glVertex` calls if VBO are too much for the start for you. I do not use python but in C++ I estimate around 50-100 lines of code for all this (setting up OpenGL context not included) – Spektre Jun 08 '17 at 06:48

2 Answers2

0

You can use this to draw and display your file ply https://github.com/rbmj/SimpleRender.

In this repository there is draw.py that use OpenGL to display a file .ply, you can try it with:

$ python draw.py file.ply

If you want to know how it works you can study the code in draw.py

Stefano Borzì
  • 1,019
  • 1
  • 15
  • 32
  • A link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](//meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted.](//stackoverflow.com/help/deleted-answers) – Petter Friberg Sep 19 '17 at 06:49
0

Pyrender is a pure Python (2.7, 3.4, 3.5, 3.6) library for physically-based rendering and visualization.

You can see the git repo here and the specific steps for dealing with your use-case (.ply files) here.

Replace 'examples/models/fuze.obj' with your filename in trimesh.load function call

Ronen Ness
  • 9,923
  • 4
  • 33
  • 50
Ambareesh
  • 324
  • 1
  • 4
  • 18