7 Replies - 5044 Views - Last Post: 19 September 2010 - 08:28 PM Rate Topic: -----

#1 ghillieLEAD  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 208
  • Joined: 08-March 10

Java3D Applet Rotating Cube [SOLVED]

Posted 19 September 2010 - 01:44 PM

When I run my program from eclipse, the cube will rotate. When I run the applet in browser the cube does not rotate. Here is my code:

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


public class HelloUniverse extends Applet {
	
	public HelloUniverse() {
		setLayout( new BorderLayout() );
		GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
		Canvas3D canvas = new Canvas3D(config);
		add("Center", canvas);
		
		BranchGroup scene = createSceneGraph();
		scene.compile();
		
		SimpleUniverse universe = new SimpleUniverse(canvas);
		universe.getViewingPlatform().setNominalViewingTransform();
		
		universe.addBranchGraph(scene);
	}
	
	private BranchGroup createSceneGraph() {
		// Create the root of the branch graph
		BranchGroup root = new BranchGroup();
		
		// Create the TransformGroup node and initialize it to the identity.
		// Add it to the root of the graph
		TransformGroup objSpin = new TransformGroup();
		objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
		root.addChild(objSpin);
		
		// Add a leaf that contains the cube to the objSpin object
		objSpin.addChild(new ColorCube(0.4));
		
		// Create a time varying function to drive the animation
		Alpha rotAlpha = new Alpha(-1, 4000);
		
		// Create a new behavior object that performs the desired operation
		// on the specified transform object and add it to the scene graph
		RotationInterpolator rotator = new RotationInterpolator(rotAlpha, objSpin);
		
		// Set the region in which the behavior is active
		BoundingSphere bounds = new BoundingSphere();
		rotator.setSchedulingBounds(bounds);
		objSpin.addChild(rotator);
		
		return root;
	}
	
}



What is causing this? Thank you for your help.

This post has been edited by ghillieLEAD: 19 September 2010 - 08:07 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Java3D Applet Rotating Cube [SOLVED]

#2 ghillieLEAD  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 208
  • Joined: 08-March 10

Re: Java3D Applet Rotating Cube [SOLVED]

Posted 19 September 2010 - 06:14 PM

For the sake of clarity, when I run the program in the browser I see the cube (the red face), it is just not animated and spinning like it is in eclipse. I have tried setting the bounding sphere to be monstrous just in case that was affecting it. It didn't help. I'm stilling looking for help on this one. Thanks again.
Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8315
  • View blog
  • Posts: 31,836
  • Joined: 06-March 08

Re: Java3D Applet Rotating Cube [SOLVED]

Posted 19 September 2010 - 06:52 PM

When you use non standard API library .jar files please post a link to them in your post
Thanks
Was This Post Helpful? 0
  • +
  • -

#4 ghillieLEAD  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 208
  • Joined: 08-March 10

Re: Java3D Applet Rotating Cube [SOLVED]

Posted 19 September 2010 - 07:48 PM

Here is the Java3D page: https://java3d.dev.java.net/
Here is the download page: https://java3d.dev.j...ary-builds.html
Here are the tutorials I am following: http://java.sun.com/...raining/java3d/

Thanks for your reply.
Was This Post Helpful? 0
  • +
  • -

#5 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2857
  • View blog
  • Posts: 10,960
  • Joined: 15-July 08

Re: Java3D Applet Rotating Cube [SOLVED]

Posted 19 September 2010 - 07:58 PM

Would this have anything to do with the Internet Browser? I wouldn't think so, but if it works in Eclipse, then it makes me wonder...
Was This Post Helpful? 1
  • +
  • -

#6 ghillieLEAD  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 208
  • Joined: 08-March 10

Re: Java3D Applet Rotating Cube [SOLVED]

Posted 19 September 2010 - 08:05 PM

View PostDogstopper, on 19 September 2010 - 06:58 PM, said:

Would this have anything to do with the Internet Browser? I wouldn't think so, but if it works in Eclipse, then it makes me wonder...


That it would be! Thank you for your help. I was using chrome, which did NOT work. When I ran the applet in Firefox the program ran fine. Again, thanks so much for your help.
Was This Post Helpful? 0
  • +
  • -

#7 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2857
  • View blog
  • Posts: 10,960
  • Joined: 15-July 08

Re: Java3D Applet Rotating Cube [SOLVED]

Posted 19 September 2010 - 08:15 PM

Glad I could help. I had no idea, but I guess sometimes working with stuff long enough makes you a good guesser. :P

Yah, I can't wait until Chrome catches up completely, as it almost is, but not quite and is my browser of choice.
Was This Post Helpful? 0
  • +
  • -

#8 ghillieLEAD  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 208
  • Joined: 08-March 10

Re: Java3D Applet Rotating Cube [SOLVED]

Posted 19 September 2010 - 08:28 PM

It might have to do with the fact that .html files are set to open with the chrome developer version rather than the standard download due to some HTML5 experimentation a while back. I don't think I have the standard download to test that theory however. Oh well, I'm just so glad that it works in FF. It is so frustrating when your just trying to get the hello world style applications to run and and they just wont! At least it wasn't a mistake in the code on my part :D

This post has been edited by ghillieLEAD: 19 September 2010 - 08:28 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1