Hi guys Thanks for the replies, I admittedly do feel better now, but only because someone out there cares. My overlay still flikers.
In the small universe of the j3d "overlay" i have made a significant breakthrough, though, by getting the 3D stuff *not* to flicker. Im either on the right path, or this was the last step to the end of the road. If I were Pascal...and I had to wager... Anyhow, it's also now also becoming a personal thing, because in our office, I'm the only guy doing this, on risk. On Monday, it's *Monday*. ----------------------------------------------------------------------- /* cw-e (compile without expectations) creditations and thanks to many contributors won't run without modifications You need to add a few things (like a shape3d and some g2d drawings) */ //not all imports are necessary - choose import java.applet.Applet; import java.awt.*; import java.awt.event.*; import com.sun.j3d.utils.applet.MainFrame; import com.sun.j3d.utils.geometry.*; import com.sun.j3d.utils.universe.*; import javax.media.j3d.*; import javax.vecmath.*; import com.sun.j3d.utils.behaviors.vp.OrbitBehavior; import com.mnstarfire.loaders3d.Inspector3DS; import java.util.*; import com.sun.j3d.utils.picking.*; import java.awt.image.BufferedImage; //import org.j3d.geom.overlay.ImageOverlay; //import org.j3d.geom.overlay.OverlayBase; import javax.media.j3d.*; import java.util.Enumeration; public class AH-MFD-3D extends Applet implements getInput { private double sceneScale = 0.4; private TransformGroup xformgrpScale = new TransformGroup(); private TransformGroup xgrpView = new TransformGroup(); private BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 200.0); private BranchGroup bgrpRoot = new BranchGroup(); private ViewingPlatform vp = new ViewingPlatform(); private GraphicsContext3D gc3d; private J3DGraphics2D j3dg2d; private SimpleUniverse su = null; public BranchGroup createSceneGraph (SimpleUniverse su) { Transform3D xform3DMain; Transform3D xform3D = new Transform3D(); xform3D.setScale(sceneScale); xformgrpScale.setTransform(xform3D); bgrpRoot.addChild(xformgrpScale); Color3f bgCol = new Color3f(0.0f, 0.0f, 0.0f); Background bgMain = new Background(bgCol); bgMain.setApplicationBounds(bounds); xformgrpScale.addChild(bgMain); bgrpRoot.compile(); return bgrpRoot; } /* I know that some people have wondered how to use Starfire's 3DS loader, so here's a snippet of code to show you how I've done it. I use the terrain in a branchgroup of its own so that I can use pickray to get intersection coords for terrain following...and it works! :) public BranchGroup createTerrainGraph (SimpleUniverse su) { BranchGroup terrainBG = new BranchGroup(); Transform3D xform3Dterrain = new Transform3D(); TransformGroup xformgrpScaleTerrain = new TransformGroup(); xform3Dterrain.setScale(sceneScale); xformgrpScaleTerrain.setTransform(xform3Dterrain); terrainBG.addChild(xformgrpScaleTerrain); Inspector3DS terrain = new Inspector3DS(modelPath[pathToUse] + "terrain_latest.3ds");//<--String path + filename //terrain.setTextureLightingOn(); //<-- when commented out, the geometry becomes "self illuminating" terrain.parseIt(); TransformGroup xformTerrain = terrain.getModel(); xformgrpScaleTerrain.addChild(xformTerrain); terrainBG.compile(); return terrainBG; } */ public void init() { setLayout(new BorderLayout()); GraphicsConfiguration gConfig = SimpleUniverse.getPreferredConfiguration(); DrawOnCanvas3D canvas3D = new DrawOnCanvas3D(gConfig); add ("Center", canvas3D); su = new SimpleUniverse(canvas3D); su.getViewingPlatform().setNominalViewingTransform(); su.getViewer().getView().setBackClipDistance(500.0); su.getViewer().getView().setFieldOfView(Math.toRadians(60)); //xgrpView = su.getViewingPlatform().getViewPlatformTransform(); BranchGroup mainScene = createSceneGraph(su); su.addBranchGraph(mainScene); //see public BranchGroup createTerrainGraph (SimpleUniverse su) above //terrainScene = createTerrainGraph(su); //su.addBranchGraph(terrainScene); OrbitBehavior orbit = new OrbitBehavior(canvas3D); orbit.setSchedulingBounds(new BoundingSphere(new Point3d(0.0, 1.0, 0.0), Double.POSITIVE_INFINITY)); su.getViewingPlatform().setViewPlatformBehavior(orbit); } public void destroy() { su.cleanup(); } public static void main(String[] args) { new MainFrame(new AH-MFD-3D(), width, height); } public void say(Object o) { System.out.println(o); } } // this class overrides canvas3d so that I can draw on the canvas3d by making use // of the postSwap() callback. // I used to do it using a behavior, but I took that out in favour of this method. // The way I've done it here, I've managed to get rid of the flickering of the // entire scene. Now only the bufferedimage that gets drawn onto the canvas, // i.e. my overlay stuff, flickers. why, i dunno... class DrawOnCanvas3D extends Canvas3D { private GraphicsContext3D gc3d; private J3DGraphics2D j3dg2d; private int width = 512, height = width; private BufferedImage bufim; private Graphics2D g2d; public DrawOnCanvas3D(GraphicsConfiguration gc) { super(gc); bufim = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR); g2d = bufim.createGraphics(); j3dg2d = this.getGraphics2D(); gc3d = this.getGraphicsContext3D(); } public void postSwap() { //I tried using the following commented line, but to no avail. //I've had it in many different places, same result (nothing). What does it do, btw? //Toolkit.getDefaultToolkit().sync(); gc3d.setBufferOverride(false); this.setDoubleBufferEnable(false); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f)); g2d.setColor(Color.BLACK); g2d.fillRect(0,0,width,height); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f)); g2d.setColor(Color.WHITE); /*----> g2d.drawingStuffHappensHere(...) <----*/ j3dg2d.flush(true);//<--with or without, makes no diff j3dg2d.drawAndFlushImage(bufim, 0, 0, this); this.setDoubleBufferEnable(true); } } =========================================================================== 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".