Doug,

I appreciate your help.  I've spent the morning doing some rearranging
and setting up for this.  It's not quite working for me yet, but I'm
pretty sure I know why.

I have the transform from each Shape to virtual world coordinates.  But
I think I may be missing the part of the transform to go from virtual
world to eye coordinates.  Can you give me what you consider to be the
set of steps to do this?

For example:

     VW
      |
     Locale
       |
    ------------
    BG1       BG2
    |          |
    G1        TG3
    |          |
    TG1       ViewPlatform
    |
    TG2
    |
    S3D

Let's say I want to draw the shape S3D in immediate mode after hacking
it off under G1.  I compute the transform3D (xform1) for the shape that
includes TG1 and TG2, and I also get the transform from G1 to virtual
world coordinates.

Right now, my code looks something like:

      G1.getLocalToVworld(parentXform);  // G1 to virtual world
      tempxform.mul(parentXform, xform1); // make S3D to virtual world
      gc.setAppearance( S3D.getAppearance() );
      gc.setModelTransform( tempxform );
      gc.draw( shape );

I use TG3 to move the view around in the scene.  Am I missing TG3 in my
code?  Actually, I guess I'm asking exactly how the argument to
"setModelTransform" should be created.

I swear if I get this going I'll put it in the FAQ... ;)

-Lee

> -----Original Message-----
> From: Doug Twilleager [mailto:[EMAIL PROTECTED]]
> Sent: Monday, April 23, 2001 11:18 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [JAVA3D] Range ordering of transparent objects
>
>
> Well, it looks like you have found a performance trap in detach/attach
> of OrderedGroup.  Let's try this a different way.  If we examine the
> order of operations in the Renderer thread, it looks like this:
>
>         Canvas3D.preRender();
>         Render opaque objects
>         Render OrderedGroup objects
>         Canvas3D.renderField();
>         Rendertransparent objects
>         Canvas3D.postRender();
>         Swap buffers
>         Canvas3D.postSwap();
>
> Since you are trying to render a collection of objects in a specific
> order, and they fall into the OrderedGroup catagory, an alternative
> approach is to render your ordered objects using the GraphicsContext3D
> in the Canvas3D.renderField() callback.  This is pretty much the same
> place that OrderedGroup would have rendered them.  And since you have
> references to all the objects, and are sorting them, it would be easy
> to render them there.  As long as the geometry was pretty
> much a one to
> one relationship with OrderedGroup children, you won't loose any
> performance from state sorting.  This technique should work well.
>
> Doug Twilleager
> Sun Microsystems
>
> >To: "'Doug Twilleager'" <[EMAIL PROTECTED]>
> >Cc: "JAVA3D-INTEREST (E-mail)" <[EMAIL PROTECTED]>
> >Subject: RE: [JAVA3D] Range ordering of transparent objects
> >MIME-Version: 1.0
> >
> >Doug,
> >I turned off compiling of my scene and placed a BranchGroup above my
> >OrderedGroup.  Next, I changed all my child nodes to plain
> Group nodes.
> >Still was very slow.  Then I turned off all reordering and
> left *just*
> >the detach/attach of my OrderedGroup.  Still slow.  Finally,
> I did some
> >profiling....
> >
> >long time1 = System.currentTimeMillis();
> >for(i = 0; i < 5; i++)
> >{
> >  myBranch.detach();
> >  myParent.addChild( myBranch );
> >}
> >long time2 = System.currentTimeMillis();
> >System.out.println(" AVG TIME = " + ((float)(time2-time1) * 0.2f) );
> >
> >AVG TIME = 46.0
> >AVG TIME = 70.200005
> >AVG TIME = 50.0
> >AVG TIME = 74.200005
> >AVG TIME = 146.2
> >AVG TIME = 84.200005
> >AVG TIME = 66.200005
> >AVG TIME = 90.0
> >AVG TIME = 66.200005
> >AVG TIME = 264.4
> >AVG TIME = 76.200005
> >AVG TIME = 108.200005
> >AVG TIME = 86.0
> >
> >These times are in milliseconds. Actually, I even changed it to do a
> >single attach/detach timing:
> >
> >AVG TIME = 70.0
> >AVG TIME = 90.0
> >AVG TIME = 60.0
> >AVG TIME = 90.0
> >AVG TIME = 841.0
> >AVG TIME = 90.0
> >AVG TIME = 151.0
> >AVG TIME = 90.0
> >AVG TIME = 140.0
> >AVG TIME = 90.0
> >AVG TIME = 80.0
> >AVG TIME = 120.0
> >
> >I know that Win2k timing is only good for 10ms, but there's a couple
> >pretty big ones in there.  What can I do about this?  If
> there is no way
> >around this, then how can I *ever* do range-ordering??  If the new
> >capability in 1.3 won't be available until later this year,
> how about an
> >interim release that just allows for *quick* reordering of
> OrderedGroup
> >nodes as a workaround?  At least the problem would then be workable.
> >
> >Thx
> >-Lee
> >
> >> -----Original Message-----
> >> From: Doug Twilleager [mailto:[EMAIL PROTECTED]]
> >> Sent: Monday, April 23, 2001 3:17 PM
> >> To: [EMAIL PROTECTED]
> >> Subject: Re: [JAVA3D] Range ordering of transparent objects
> >>
> >>
> >> The only way to get the compile out of the way is to compile the
> >> scene without your OrderedGroup's, and then add them in after
> >> the compile.  Other than that, I don't see any other ways
> >> to do this in 1.2.*.
> >>
> >> Doug Twilleager
> >> Sun Microsystems
> >>
> >>
> >> >To: "'Doug Twilleager'" <[EMAIL PROTECTED]>,
> >> [EMAIL PROTECTED]
> >> >Subject: RE: [JAVA3D] Range ordering of transparent objects
> >> >MIME-Version: 1.0
> >> >
> >> >Doug,
> >> >The only way to rearrange the children of the
> OrderedGroup is to do
> >> >attaches and reattaches of BranchGroups since I get an
> >> exception if I do
> >> >a "setChild(Node, index)" without the child being a
> >> BranchGroup.  This
> >> >is from the Group.setChild() Javadoc:
> >> >
> >> >"RestrictedAccessException - if this group node is part of live or
> >> >compiled scene graph and the child node being set is not a
> >> BranchGroup
> >> >node"
> >> >
> >> >Since they are BranchGroups, I still get the overhead of doing
> >> >attach/detach with each child.  My code for swapping
> >> children looks like
> >> >this:
> >> >
> >> >  in constructor...
> >> >  {
> >> >    ...
> >> >    empty = new BranchGroup();
> >> >    empty.setCapability(BranchGroup.ALLOW_DETACH);
> >> >    ...
> >> >  }
> >> >
> >> >  private void doReordering()
> >> >  {
> >> >    myBranch.detach();  // detach OrderedGroup from scene
> >> >
> >> >    // Call "swapBranches" as necessary
> >> >
> >> >    myParent.addChild( myBranch );
> >> >  }
> >> >
> >> >  private void swapBranches(int a, int b)
> >> >  {
> >> >
> >> >    BranchGroup b1 = (BranchGroup)myOrderedGroup.getChild( a );
> >> >    BranchGroup b2 = (BranchGroup)myOrderedGroup.getChild( b );
> >> >    myOrderedGroup.setChild( empty, a );  // I think this calls
> >> >b1.detach()
> >> >    myOrderedGroup.setChild( b1, b );
> >> >    myOrderedGroup.setChild( b2, a );
> >> >  }
> >> >
> >> >What do you think I can do?  Is there a way to prevent my
> >> OrderedGroup
> >> >from being compiled so I don't have to use BranchGroups for the
> >> >children??
> >> >
> >> >Thx
> >> >-Lee
> >> >
> >> >> -----Original Message-----
> >> >> From: Doug Twilleager [mailto:[EMAIL PROTECTED]]
> >> >> Sent: Monday, April 23, 2001 1:23 PM
> >> >> To: [EMAIL PROTECTED]
> >> >> Subject: Re: [JAVA3D] Range ordering of transparent objects
> >> >
> >> ><snip...>
> >> >
> >> >> If you detach the branch graph which contains the
> >> >> OrderedGroup, rearrange
> >> >> the OrderedGroup, then reattach again, you will get better
> >> performance
> >> >> that attaching and reattaching the children of the
> >> >> OrderedGroup individually.
> >> >>
> >> >> Doug Twilleager
> >> >> Sun Microsystems
> >> >>
> >>
> >> ==============================================================
> >> =============
> >> To unsubscribe, send email to [EMAIL PROTECTED] and
> >> include in the body
> >> of the message "signoff JAVA3D-INTEREST".  For general help,
> >> send email to
> >> [EMAIL PROTECTED] and include in the body of the
> message "help".
> >>
>
> ==============================================================
> =============
> To unsubscribe, send email to [EMAIL PROTECTED] and
> include in the body
> of the message "signoff JAVA3D-INTEREST".  For general help,
> send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to