How do you use compound objects?

427 views
Skip to first unread message

Bruce Sherwood

unread,
Sep 28, 2016, 1:25:52 AM9/28/16
to Glowscript Users
Some issues have arisen in the context of the relatively new extrusion and 3D text objects that suggest that there are aspects of the compound object that could be improved (extrusion and text objects are created as compounds) If you have used compound objects, please describe how you use them and if possible give a link to programs that illustrate those uses. And if you found something awkward to do in creating compound objects, do describe in what way it was awkward.

For those of you who haven't made a compound object, here's the description:

Murray Garth

unread,
Sep 28, 2016, 3:44:17 AM9/28/16
to glowscri...@googlegroups.com
Hi Bruce,

I have used compound objects in this program:
http://www.glowscript.org/#/user/murray.garth/folder/Public/program/Eyeballs

The idea is for the eyes to quickly follow the position of the mouse while the head tracked more slowly. Of course, I wanted the eyeball locations to be attached to the movement of the head, ie. for the head and eyeballs to be in a "parent-child" relationship.

This is awkward in Glowscript VPython.

The simplest solution I could find was to create "virtual eyeball" placeholders as part of a "head" compound object. These placeholders moved with the orientation of the head. I then programatically set the location of the real eyeballs to these placeholders each step, using

    world_pos = Head.compound_to_world( vRightEye.pos )
    ebRight.pos = world_pos

This approach works (quite well IMHO), but it is awkward. I think I am attempting something for which compound objects are not designed (or else, I misunderstand the intention).

Murray.


--

---
You received this message because you are subscribed to the Google Groups "Glowscript Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glowscript-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bruce Sherwood

unread,
Sep 28, 2016, 10:51:34 AM9/28/16
to Glowscript Users
That's lovely, Murray! Thanks much for sharing this.

I think what you're looking for is the "frame" object that is in Classic VPython and needs to be implemented in GlowScript VPython (and Jupyter VPython). You create a frame object, which doesn't display anything, and place visible objects in it, relative to the frame pos. As with a compound, you can move or rotate or resize all the objects associated with the frame by changing the pos or axis or size of the frame. You can also move individual objects within the frame, and their pos and axis attributes are relative to the frame. A frame can also contain child frames.

There are two differences between compound and frame. One is that you can't move one object in a compound relative to the others. The other is that the display of a compound object is FAST. When you create a compound, all of the triangles that make up all of the objects are agglomerated into a single "model", with the same rendering status as a box or a cylinder "model". Such models are displayed very fast by the GPU. In contrast, each object in a frame will have to be rendered individually.

Bruce Sherwood

unread,
Sep 28, 2016, 12:30:01 PM9/28/16
to Glowscript Users
I should point out that a good way to handle "virtual" objects is to set visible=False for them. You till have access to their locations, but they won't be displayed.

Murray Garth

unread,
Sep 29, 2016, 9:26:40 AM9/29/16
to glowscri...@googlegroups.com
Thanks Bruce,it seems like frames are exactly what I need. So, this raises the obvious question, when will frames be available in Glowscript VPython?

On 29 September 2016 at 02:29, Bruce Sherwood <bruce.s...@gmail.com> wrote:
I should point out that a good way to handle "virtual" objects is to set visible=False for them. You till have access to their locations, but they won't be displayed.

--

Bruce Sherwood

unread,
Sep 29, 2016, 2:05:56 PM9/29/16
to Glowscript Users
I can't offer an estimate, but frames are fairly high on the priority list, since it's just about the only significant capability of Classic VPython that is missing from GlowScript VPython.

After mentioning "visible" I saw that you made the virtual objects effectively invisible by setting opacity to zero. Using "visible" is a better choice, for two reasons. One is that an object with zero opacity will still be rendered, though uselessly, whereas objects with visible set to False don't take up any render time. Also, when the scene has any transparent objects, all rendering is slowed down due to the complex procedures involved, and "antialiasing" is necessarily turned off, which means that edges of objects are slightly jagged. See

Murray Garth

unread,
Sep 30, 2016, 3:19:00 AM9/30/16
to glowscri...@googlegroups.com
Thanks again, Bruce. Another very detailed response to a simple question!

I have made the change you suggested. I don't see any improvement in speed (because there are not many objects on the screen anyway) but the improvement caused by the antialiasing is quite noticeable.

Again, thanks for all your effort with Glowscript,
Murray.

--

jsc...@gmail.com

unread,
Jan 3, 2018, 11:10:19 AM1/3/18
to Glowscript Users
I want to liberate a compound's components  for further manipulate  after rotating the compound.

Is this possible?    (are we still waiting for Frames?)

Bruce Sherwood

unread,
Jan 3, 2018, 1:38:53 PM1/3/18
to Glowscript Users
If you mean that you want to extract a component from a rotated compound in its rotated state, the answer is no.

There is indeed no frame as yet.

Bruce

Reply all
Reply to author
Forward
0 new messages