I wish some folks from Sun have commented on the performance and other
problems connected with Canvas3D. See my email and the email from
Young dedicated to the performance problems with Canvas3D. Doug, what do u
have to say about this? We all need your help and comments badly!
vladimir
-=V=-
>-------<=============>-------<
Join in Java community now!
http://JavaCafe.VirtualAve.net/
>-------<=============>-------<
In your previous letter u wrote:
--------------------------------
RP> Hello,
RP> I have a canvas 3D in a JPanel used as content pane for a JFrame. I use it
RP> to display a small scene... everything is ok. Then I remove it from the
RP> JPanel and create a new Canvas and as I try to show the same(or other) scene
RP> in the new canvas I get e Dr.Watson Message!!!
RP> If I don't remove the old one, but still use the new for display It
RP> works!!!!!!!
RP> I have a sample code, to show this problem, bellow. I you press the Button
RP> the old Canvas is removed and a new one is created.
RP> thankx
RP> Rui Prada
RP> ----------------------------------------------------------------------------
RP> -------------------
RP> import javax.swing.*;
RP> import java.awt.*;
RP> import java.awt.event.*;
RP> import javax.media.j3d.*;
RP> import javax.vecmath.*;
RP> import com.sun.j3d.utils.universe.*;
RP> import com.sun.j3d.utils.geometry.ColorCube;
RP> public class Test extends JFrame {
RP> JPanel contentPane;
RP> Canvas3D c;
RP> VirtualUniverse universe;
RP> Locale locale;
RP> View view;
RP> TransformGroup viewTransform;
RP> BranchGroup viewBG;
RP> Test() {
RP> setSize(800,600);
RP> createContentPane();
RP> createCanvas();
RP> createUniverse();
RP> loadScene();
RP> }
RP> public void createContentPane() {
RP> contentPane = new JPanel(null);
RP> setContentPane(contentPane);
RP> JButton b = new JButton("TEST");
RP> b.setBounds(600,450,100,50);
RP> b.addActionListener(new ActionListener1());
RP> contentPane.add(b);
RP> show();
RP> }
RP> public void createCanvas() {
RP> GraphicsConfiguration config =
RP> SimpleUniverse.getPreferredConfiguration();
RP> c = new Canvas3D(config);
RP> c.setBounds(50,50,500,400);
RP> contentPane.add(c);
RP> }
RP> public void createUniverse() {
RP> universe = new VirtualUniverse();
RP> locale = new Locale(universe);
RP> view = new View();
RP> view.setPhysicalBody(new PhysicalBody());
RP> view.setPhysicalEnvironment(new PhysicalEnvironment());
RP> ViewPlatform vp = new ViewPlatform();
RP> view.attachViewPlatform(vp);
RP> viewTransform = new TransformGroup();
RP> viewTransform.addChild(view.getViewPlatform());
RP> view.addCanvas3D(c);
RP> viewBG = new BranchGroup();
RP> viewBG.addChild(viewTransform);
RP> locale.addBranchGraph(viewBG);
RP> }
RP> public void loadScene() {
RP> BranchGroup bg = new BranchGroup();
RP> Transform3D t3d = new Transform3D();
RP> t3d.setTranslation(new Vector3f(0.0f,0.0f,-5.0f));
RP> TransformGroup tg = new TransformGroup(t3d);
RP> tg.addChild(new ColorCube(1.0));
RP> bg.addChild(tg);
RP> locale.addBranchGraph(bg);
RP> }
RP> public void close() {
RP> view.removeCanvas3D(c);
RP> view = null;
RP> universe = null;
RP> locale = null;
RP> viewTransform = null;
RP> // Hide this line and this starts working!!!
RP> contentPane.remove(c);
RP> c.setVisible(false);
RP> contentPane.repaint();
RP> }
RP> public static void main(String[] args) {
RP> new Test();
RP> }
RP> class ActionListener1 implements ActionListener {
RP> public void actionPerformed(ActionEvent ev) {
RP> close();
RP> createCanvas();
RP> contentPane.add(c);
RP> createUniverse();
RP> loadScene();
RP> }
RP> }
RP> }
RP> ===========================================================================
RP> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
RP> of the message "signoff JAVA3D-INTEREST". For general help, send email to
RP> [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".