2011/11/1 Thomas Paviot <[email protected]>

> Dear all,
>
> A while ago, I started working on a set of pythonocc/webgl demos (they are
> still available at http://webgl.pythonocc.org).
>
> From this experience, I implemented these last days a webgl backend for
> pythonocc. It is based upon a tesselator class, implemented at the C++
> level (this one was originally written by Fotis Sioutis) to be as fast as
> possible. I created a pull requets on github so that it is merged to master.
>
> Here is the current state of this work, and the way to get it work on your
> machine:
> - a C++ class, named Tesselator, was added to the Visualization module
> - this Tesselator class take any TopoDS_Shape, mesh it and generates a
> list of vertices/normals (the Tesselate method)
> - the ExportToJSON method export this list of vertices/normals to a  file
> named shape.js, a JSON object for the amazing Three.js library (see
> https://github.com/mrdoob/three.js/)
> - the python module webgl_renderer.py wraps this C++ code and generated an
> html file
> - this html_file is opened with the default web browser.
>
> It's very easy to use. For instance, creating a box and rendering in a
> webgl compliant browser can be achieved with the following code:
>
> from OCC.Display.WebGl import webgl_renderer
> from OCC.BRepPrimAPI import *
>
> sh = BRepPrimAPI_MakeTorus(50,10).Shape()
> my_renderer = webgl_renderer.WebGlRenderer()
> my_renderer.DisplayShape(sh)
>
> 3 examples were added to the folder src/examples/Level1/WebGl. If you run,
> for instance, the webgl_geomplate.py example, you should get an output
> similar to the attached screenshot.
>
> Of course you need a Webgl compliant webbrowser (FF, Chr, Safari), but I'm
> quite sure there's no IE user here ;-) From the web brwoser:
> * right arrow: pan right
> * left arrow: pan left
> * up arrow : pan up
> * down arrow: pan down
> * W: zoom +
> * S: zoom -
> You can also move the mouse to move the camera position.
>
> This implementation is very basic so far, but what I plan to do in a short
> term is:
> - being able to display more than one shape
> - render faces separately so that they can be picked
> - automatically adjust the camera position, direction etc. to fit the
> shape dimensions
> - render edges
> - test a few shaders
>
> At last, I tried to make this visualization workflow as fast as possible.
> On OSX, it's much quicker to render the shape in Chrome or FF than in a
> pyQt/X11 window (X11 and PyQt are very loooong to be launched). In order to
> build this branch, please use the cmake builder rather than the setup.py
> script which is not up to date and will soon be dropped.
>
> Please feel free to comment the pull request available at:
> https://github.com/tpaviot/pythonocc/pull/23
>
> Best Regards,
>
> Thomas
>
>
The pull request was accidentally merged without being tested. I reopened
it:
https://github.com/tpaviot/pythonocc/pull/24

Thomas
_______________________________________________
Pythonocc-users mailing list
[email protected]
https://mail.gna.org/listinfo/pythonocc-users

Reply via email to