So, I've got a problem.  Well, my girlfriend tells me I have several, but
that's for another list.

We have a nice 4 view applet running with a bunch of manipulation and 
picking behaviors going on.  We've always noticed a bit of flashing
sometimes (not predictable, but forcible if transparency values are
tweaked on the fly).  It wasn't a big problem, just one of those things
to fix someday.  This was with 1 view.

Now that we have 4 views things have become a little more serious given that
some of our models are complicated.  I dug in and found that each view was
rendering 4 times.  That means that anytime some action happens there are
16(!!!) renders.  I don't know if it does a full render, but I do know that
postSwap is called 16 times for any change.  I have a few problems with this.

  1. It should only render once for any change and then only in one
     window if I'm only modifying the view of one window.  If I manipulate
     an object, it should do 4 renders.

  2. Not all the rendered images swapped in are the same.  Sometimes we
     get flashing geometry (that isn't supposed to).  Sometimes Transform
     nodes don't seem to be respected resulting in dancing geometry or
     sometimes blipping monster geometry (an object flashes between tiny
     and huge 2 times (each).  While it's sort of cool to see, it's not
     a great thing for demos...

  So, #1 on my nice fast machine is passable (NT: P2 450, 256M, ATI...) 
a more compute bound machine (W95: P1 266 80MB, ???) is painful to use or watch.

  #2 is right out.

  I started stripping stuff out of our code, disabling this and that and
came up with the appended test program.  Behaves the same on NT, W95, or
Solaris:  four postSwaps (preRenders & postRenders too) for any major
event.  Click the window, click another window, click the window again...

Any ideas?  Is this part of the design or ???

-- John



import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.event.*;
import java.awt.GraphicsConfiguration;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;

public class MyHello extends Applet {


  public BranchGroup createSceneGraph () {

    BranchGroup objRoot = new BranchGroup ();
    objRoot.addChild (new ColorCube (0.4));
    objRoot.compile ();

    return objRoot;
  }

  public MyHello () {
    setLayout (new BorderLayout ());

    MyCanvas3D c = new MyCanvas3D ();
    add  ("Center", c);

    BranchGroup scene = createSceneGraph ();
    SimpleUniverse u = new SimpleUniverse (c);

    u.getViewingPlatform ().setNominalViewingTransform ();

    u.addBranchGraph (scene);
  }

  public static void main (String[] args) {
    new MainFrame (new MyHello (), 256, 256);
  }


  public class MyCanvas3D extends Canvas3D {

    public MyCanvas3D () {
      super (null);
    }

    public void postSwap () {
      System.out.println ("MyCanvas3D: postSwap "+ 
                                 ((System.currentTimeMillis () / 1000)%1000));
    }
  }
}
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/

Reply via email to