How to show regular 3d shape in pyqtgraph

1,758 views
Skip to first unread message

Caleb Crome

unread,
Mar 5, 2014, 11:47:52 AM3/5/14
to pyqt...@googlegroups.com
Hi there, 
  I have to say, pyqtgraph is *awesome*.  I've been playing with it for a while, and I'm amazed how good it is. 

the one thing I can't figure out is how to plot a solid 3d object.  You know, the kind made up of triangles with surface normals.  Seems like GLVolumeItem might kind of work if I set the A to 100%, but it has the limitation of dtype=ubyte, and it just doesn't seem to be the right format.

I have a list of traingles that describe a surface.

I see this post: http://www.linux.com/community/blogs/133-general-linux/291889 shows how to display an STL file, which is pretty much what I'm doing.  Is there some easy way to use PyQtGraph for this?


Any pointers would be appreciated.

Thanks,
  -Caleb

Mathew Schwartz

unread,
Mar 5, 2014, 10:20:05 PM3/5/14
to pyqt...@googlegroups.com


--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/3622b0bc-2a28-4fad-808a-6395c19c8e10%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Luke Campagnola

unread,
Mar 5, 2014, 10:44:16 PM3/5/14
to pyqt...@googlegroups.com
On Wed, Mar 5, 2014 at 11:47 AM, Caleb Crome <ca...@crome.org> wrote:
the one thing I can't figure out is how to plot a solid 3d object.  You know, the kind made up of triangles with surface normals.  Seems like GLVolumeItem might kind of work if I set the A to 100%, but it has the limitation of dtype=ubyte, and it just doesn't seem to be the right format.

GLMeshItem is the one. There is a corresponding script in the examples/ directory as well. As Matthew pointed out, MeshData is used to encapsulate triangle data including vertexes, faces, normals, colors, etc. 

There is also GLSurfacePlotItem, but that is only useful of your vertexes are on a regular grid. 
 

Caleb Crome

unread,
Mar 6, 2014, 7:43:43 AM3/6/14
to pyqt...@googlegroups.com
Boy, I feel silly.  I'm not sure how I missed that one.  I was looking at the '3D Graphics' docs and for some reason 3DMeshItem just didn't enter my consciousness.  It was right in front of my nose.  I'll give ti a try.

Thanks,
  -Caleb
  


--
You received this message because you are subscribed to a topic in the Google Groups "pyqtgraph" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyqtgraph/7idY_egfic8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/CACZXET8wE1zQJO27jQRu4H1hotTAp%3DFRejRcBYxwDi_zyQ65fw%40mail.gmail.com.

Caleb Crome

unread,
Mar 6, 2014, 5:43:01 PM3/6/14
to pyqt...@googlegroups.com
Hi again,
   got my object plotting just fine (Thanks for the MeshItem), but now I need to get more light on the subject.  For reference, I put the 'shaded' example object in my code, next to the object I want to display.  My code looks like this:

[code]
# the Egg object form the demo
m4 = gl.GLMeshItem(meshdata=md, smooth=True, shader='shaded', glOptions='opaque')                          
m4.translate(x[3], 0, 0)                                                                                    
m4.scale(.5, .5, 1)                                                                                        

# My widget
faces = [array of (20480, 3, 3) triangle verticies]
meshData = gl.MeshData(vertexes=faces)
meshPlot = gl.GLMeshItem(meshdata = meshData, smooth=True, shader='shaded', glOptions='opaque')       
[/code]

You can see from the attached image, that I don't have enough light on the subject, and that the light I do have seems to come from different directions.

How do I get more light on the scene?

Thanks so much,
  -Caleb


egg.png

Luke Campagnola

unread,
Mar 6, 2014, 5:47:29 PM3/6/14
to pyqt...@googlegroups.com
On Thu, Mar 6, 2014 at 5:43 PM, Caleb Crome <ca...@crome.org> wrote:


You can see from the attached image, that I don't have enough light on the subject, and that the light I do have seems to come from different directions.

How do I get more light on the scene?

  
For the mesh on the right--is it possible that your normals need to be inverted?

 

Caleb Crome

unread,
Mar 6, 2014, 6:05:33 PM3/6/14
to pyqt...@googlegroups.com
I tried that by reversing the first and third coordinates of each triangle, but the results were the same.
-C


--
You received this message because you are subscribed to a topic in the Google Groups "pyqtgraph" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyqtgraph/7idY_egfic8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyqtgraph+...@googlegroups.com.

Caleb Crome

unread,
Mar 6, 2014, 6:12:19 PM3/6/14
to pyqt...@googlegroups.com
Oopsie, I spoke too soon.  I forgot that I had the mesh stored in a persistent cache.  (wow, I love the shelve module -- just discovered it!).

I (actually) reversed the normals, et voila!  It looks much better.

Thanks again,
  -Caleb

oopsie.png
Reply all
Reply to author
Forward
0 new messages