<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 12/20/2017 11:16 AM, Andreas Plesch
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAKdk67sEDk6=xX+FMEyd46dSEBv_fD9GAfDOKwGqtCkFR9US7g@mail.gmail.com">
      <pre wrap="">Hi Michalis,

yes, that is how DEF/USE should be implemented. The point I am trying
to understand is if there is absolutely no distinction between the
original DEF node and a USE node which references the DEF node, how
can the USE node be identified, for example during picking ? The USE
node still needs to have at least a distinct ID, right ?</pre>
    </blockquote>
    <br>
    Andreas,<br>
    <br>
    There is no distinction as it is not a separate node. For example:<br>
    <br>
    <Transform position='5 0 0'><br>
      <Shape DEF='PickShape'><br>
        <Box DEF='PickGeometry'/><br>
        <Appearance><br>
          <Material diffuseColor='1 0 0'/><br>
        </Appearance><br>
      </Shape><br>
    </Transform><br>
    <br>
    <Transform position='0 5 0'><br>
      <Shape USE='PickShape'/><br>
    </Transform><br>
    <br>
    <Transform position='0 0 5'><br>
      <Shape DEF='PickShape2'><br>
        <Box USE='PickGeometry'/><br>
        <Appearance><br>
          <Material diffuseColor='0 1 0'/><br>
        </Appearance><br>
      </Shape><br>
    </Transform><br>
    <br>
    <br>
    Will display a scene with 3 boxes, one at 5 units from the origin on
    each coordinate axis. The X & Y boxes are colored red, the Z box
    is colored green. Picking (from the X3D scene) will generate an
    event on either PickShape or PickGeometry node, no matter which one
    is picked. If internally OpenGL identifies the boxes as different,
    it is reduced to the single instance when the picked objected is
    returned.<br>
    <br>
    [I know the code above won't exactly work for picking (assuming
    TouchSensor or equivalent), but it should be clear enough to get the
    point across.]<br>
    <br>
    <br>
    Leonard Daly<br>
    <br>
    <br>
    <blockquote type="cite"
cite="mid:CAKdk67sEDk6=xX+FMEyd46dSEBv_fD9GAfDOKwGqtCkFR9US7g@mail.gmail.com">
      <pre wrap="">

A conceptual scene graph structure may look like this:

group1
  node 1: DEF "original"
group2
  node 2: USE "original"

There are still two nodes. node 2 is not a copy of node 1 but is still
a separate node which happens to reference node 1.

Or

group1
 node 1: DEF "orginal"
group2
 node 1 (inserted a second time during scene graph construction)

Closer to spec. but makes it hard (impossible?) to distinguish the two
node 1 instances from each other.

So I was thinking something like an additional ID may have to exist:

1. group1
2.  node 1: DEF "orginal"
3. group2
4.  node 1 (inserted during scene graph construction)

?

-Andreas




On Wed, Dec 20, 2017 at 11:03 AM, Michalis Kamburelis
<a class="moz-txt-link-rfc2396E" href="mailto:michalis.kambi@gmail.com"><michalis.kambi@gmail.com></a> wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">2017-12-20 15:51 GMT+01:00 Andreas Plesch <a class="moz-txt-link-rfc2396E" href="mailto:andreasplesch@gmail.com"><andreasplesch@gmail.com></a>:
</pre>
        <blockquote type="cite">
          <pre wrap="">(DEF/USE in x3dom: There are a several x3dom issues about picking a
USE Shape. Since x3dom literally places the referenced DEF Shape in
the scene graph, the picking actually reports the node of the
referenced DEF Shape when the USE Shape is picked. This is because
x3dom actually does not keep a distinct representation of the USE node
at all. Except for the fact that the DEF node now has two parents.
This may be too literal an interpretation of the DEF/USE concept, and
I wonder if in the spec. there is a section which explains how the
node which has a USE reference is still a distinct node. I suspect
that keeping such a distinct node around is how most x3d browsers work
?
</pre>
        </blockquote>
        <pre wrap="">
This DEF / USE (in x3dom) treatment is required by the X3D
specification, and it (should) be the same in all VRML / X3D browsers.
I know it is the same in view3dscene and Castle Game Engine. When we
encounter a "USE Xxx" then internally we *do not* make a copy of the
"Xxx" node, instead we make an additional link to the "Xxx" node that
in effect has 2 parents. This implementation is most natural and
practically required by the X3D specification:

<a class="moz-txt-link-freetext" href="http://www.web3d.org/documents/specifications/19775-1/V3.2/Part01/concepts.html#DEFL_USESemantics">http://www.web3d.org/documents/specifications/19775-1/V3.2/Part01/concepts.html#DEFL_USESemantics</a>

"""
The USE statement does not create a copy of the node. Instead, the
same node is inserted into the scene graph a second time, resulting in
the node having multiple parents (see 4.3.5 Transformation hierarchy,
for restrictions on self-referential nodes).
"""

And that's a very good concept, in my opinion: it allows to use DEF /
USE mechanism for various optimizations. Since you have only one copy
of the node, you should also be able to have only one copy of various
internal things (like OpenGL VBO data) associated e.g. with Shape that
is USEd multiple times. This is really powerful, you can construct a
large scene by USEing the same shapes multiple times, and it will
still render fast and not eat too much memory:)

In contrast, expanding the PROTOtypes makes a copy on the contents.

Regards,
Michalis
</pre>
      </blockquote>
      <pre wrap="">


</pre>
    </blockquote>
    <p><br>
    </p>
    <div class="moz-signature">-- <br>
      <font class="tahoma,arial,helvetica san serif" color="#333366">
        <font size="+1"><b>Leonard Daly</b></font><br>
        3D Systems & Cloud Consultant<br>
        LA ACM SIGGRAPH Past Chair<br>
        President, Daly Realism - <i>Creating the Future</i>
      </font></div>
  </body>
</html>