3D Drawing / Rendering

Hi all,

I have some X,Y,Z coordinates (80,000 ish) representing a 3D real world object. I have managed to draw the object in a canvas and can click a button to switch between views, top, bottom, left, right etc. Its slooooowww. I would also rather be able to drag the 3D object around spin it, turn it, zoom and view it from any angle. Is the canvas the way to go? Is there a better rendering engine for speed etc.

Any tips/pointers much appreciated.

I’m curious: what type of object?

I’m writing a CNC mill controller application. Its the milling coordinates. 80,000 is just an example, i’ve imported some GCODE which would mill a piece of stock 100 x 300 mm with 10 holes in it and some text. The text and drill holes are pretty coordinate intensive as all the curves are generated using circular interpolation. My example is using fairly low resolution interpolation too so 80,000 points is not large in the scale of things.

Thanks Jean Paul, I did wonder about openGL. I’ll look into this.

If I ever find the time I want to try to display protein structures. Just a few thousand points thogh …

I’m having a read through it now, looks very in depth and very powerful too. Looks like what I am after though. I think in a couple of hours I should be able to render my points on an openGL surface. I’ll let you know how it goes Markus

Like this… :stuck_out_tongue_winking_eye:

project here, using my ezgl framework for easy opengl. Made this awhile ago just to see how fast I could code parsing and showing Protein Data Bank files. Slows down after a couple thousand atoms but that’s because it’s drawing with the slowest technique, a display list is much faster. Added that just now and it is. (Mouse drag to move camera, scroll up/down to zoom)

I’ve done dancing lines and get good response up to about 20-30k lines, again using the slow technique of sending all the verts each render. If the model is static put it in a display list and 80k should be no problem.

Wow, it is super fast, just run some tests now and got the following consistent results:

84,204 vertices : 0.03 seconds
166,744 vertices : 0.083 seconds
293,424 vertices : 0.15 seconds

This compared to my old method of drawing on a canvas is astounding. The last test with 293,000 took me 14 seconds just to generate the data.

Thanks Will, that’s fantastic!

Pretty impressive will

How would I rotate the molecule aka move the lighting with me? Currently the lighting is stationary and the viewer moves around the molecule (resulting in seeing an illuminated and a dark half). The standard is to have the molecule rotate, which would be equal to the light source moving with the viewer …

Will, this is fantastic!!

Mike, if you just want to implement 2D output to a H-bridge driver, use HPGL as it is way easier to get up and running. Having a ‘Z’ axis in the mix makes things way more difficult.

Hi Chris, I am writing a 3 axis controller. Thats not been to difficult. Once all the math was in place to control a 2D 2 axis setup, adding the third axis was not too bad. Once I get that sorted I intend to move on to 5 axis but lets not run before we can walk.

My biggest problem has been visualising the GCODE on screen. I started just drawing it on a canvas but its way too slow. Moved on to OpenGL and its fantastic and just what I needed.