Here is my new script
-----------------import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;
import javax.media.j3d.BranchGroup;
import com.sun.j3d.utils.applet.MainFrame;
import javax.media.j3d.*;
import java.awt.*;
import javax.vecmath.*;
public class MyFirstSphere extends java.applet.Applet {
public MyFirstSphere()
{
SimpleUniverse universe = new SimpleUniverse();
GraphicsConfiguration config = universe.getPreferredConfiguration();
Canvas3D c = new Canvas3D(config);
add("Center", c);
BranchGroup group = new BranchGroup();
group.addChild(new Sphere(0.5f));
Color3f light1Color = new Color3f(0.0f, 1.0f, 0.0f);
Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);
DirectionalLight dl = new DirectionalLight(light1Color,light1Direction);
BoundingSphere bounds = new BoundingSphere();
bounds.setRadius(Double.POSITIVE_INFINITY);
dl.setInfluencingBounds(bounds);
group.addChild(dl);
universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(group);
}
public static void main( String[] args )
new MainFrame(new MyFirstSphere(), 500,500);
}
}
-------------------
The green sphere is being displayed properly but i cannot put it inside the
MainFrame, it opens everytime another window which consists of the
shape(sphere) and the MainFrame(vacant), why that?
----- Original Message -----
From: Ricardo Nakamura <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, June 07, 2003 5:33 PM
Subject: Re: [JAVA3D] My first Sphere!
> Hi,
>
> I see two problems with your code:
>
> 1) the reason why you don't see the sphere is because you didn't add any
> Lights to your scene. Doing something like the following code should
> suffice (at least for a test):
>
> DirectionalLight dl = new DirectionalLight();
> BoundingSphere bounds = new BoundingSphere();
> bounds.setRadius(Double.POSITIVE_INFINITY);
> dl.setInfluencingBounds(bounds);
> group.addChild(dl);
>
>
> 2) However, note that the SimpleUniverse constructor with no parameters
> (which you are using) will create its own Canvas3D and window; therefore,
> your code is not using the Canvas3D that you create. If it did, you would
> not see anything (not even a window) since you are not displaying your
> applet window.
>
>
> Another *potential* problem is that a sphere of radius 4 might be too big
> to see from the "nominal view transform" position. I haven't tested it but
> I guess it will be too close or even envelop the view platform.
>
>
> Hope this helps,
>
> Ricardo Nakamura
>
>
> At 11:13 7/6/2003, you wrote:
>
> >I read a turotial and i am trying to figure out the Java3d
> >
> >Here is my attempt to create a simple Sphere
> >
> >-----------------
> >import com.sun.j3d.utils.universe.*;
> >import com.sun.j3d.utils.geometry.Sphere;
> >import javax.media.j3d.BranchGroup;
> >import com.sun.j3d.utils.applet.MainFrame;
> >import javax.media.j3d.*;
> >import java.awt.*;
> >
> >
> >public class MyFirstSphere extends java.applet.Applet {
> >
> >public MyFirstSphere()
> >
> >{
> >
> > SimpleUniverse universe = new SimpleUniverse();
> >
> > GraphicsConfiguration config = universe.getPreferredConfiguration();
> >
> >
> > Canvas3D c = new Canvas3D(config);
> >
> > add("Center", c);
> >
> > BranchGroup group = new BranchGroup();
> >
> > group.addChild(new Sphere(4));
> >
> > universe.getViewingPlatform().setNominalViewingTransform();
> >
> > universe.addBranchGraph(group);
> >
> >}
> >
> >public static void main( String[] args ) {
> >
> > new MyFirstSphere();
> >
> >}
> >----------------------------
> >
> >The problem is that everything is being compiled coorectly but nothing is
> >being displayed when i run it
> >
>
----------------------------------------------------------------------------
----
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.486 / Virus Database: 284 - Release Date: 29/5/2003
>
===========================================================================
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".