Here are some precisions about my purpose
I want to represent one by one all
platonic solidsSo I took some inspiration from
this sample program (BTW the cube is one of the platonic solids but fortunately the box is a native object in vpython)
So from my first experiments with vpython I understood that it is a real 3D library and dealing with 'flat' objects can be uneasy. In another program about conic sections I use a thin box to materialize a plane. So I understood that flat things are built in the xy reference plane, then send to space by transformations as rotations, changes of position, etc. etc..
My idea was to start from the patterns, for example as shown on this picture
and to fold by rotating along edges with angles given for example in the wiki.
For three of them it's possible to work with simple triangles, but I wanted to build my own polygon object for general purpose, which I did.
My final solid is a compound of polygons which are themselves compounds of triangles mostly rotated from initial position.
So we can say that such object can be considered as complex.
I want to show any of these solids in slow rotation, the example gives the solution.
To stop and restart again motion following the example was enough.
My next problem was to change color.
The ideal was a drop list with choices to get an 'on the fly' color change.
See my test program
here with a dummy setcolor doing now nothing after all my failing attempts.
For commodity and communication between functions I use global variables which is not necessary, they will disappear in the final release.
For example the init_scene function uses the global couleur, to color vertices, which in turn give their color to triangles, which give their color to polygons, which give their color to solids, but of course I understand that there is nothing like the color of a compound.
The way the program is written it is not too difficult to begin with an input from console and to color the tetrahedron according the user's initial wish, but what about changing color dynamically from a drop list ?
My simple idea was to change the value of the global couleur and to call init_scene that would start from the beginning all over again.. Alas! it doesn't work. No error message but the scene canvas simply disappears and only the two widgets stay visible.
My second idea was to work in depth accessing the polygons individually, then the triangles, then the vertices which have a color attribute and to alter this attribute, but this I don't know how to do it and it seems that my new friend GROK (I was introduced by John) doesn't know either.