Creating a 3D sphere in AI

Hi All,
I'm pretty new to Illustrator, and I'm having a challeng with creating the look I want using 3D Revolve. The sphere is part of a logo, and needs to essentially match the color of part of the logo, but I also want it to have a smooth 3D quality. Hard to explain in writing.
To start, here's the color I want to be predominant in the sphere:
Here's what I've come up with thus far:
This is as close as I've been able to get to the original color, but there's no gradation between the shades. Here are the 3D Revolve settings:
Surface: Plastic Shading
Light Intensity: 50%
Ambient Light: 70%
Highlight Intensity: 95%
Highlight Size: 95%
Blend Steps: 256
Shading Color: Black
And here's another experiment:
This has the blend from dark to light I'm looking for, but the base color has become much more purple, and doesn't really match the original. Here are the settings for this version:
Surface: Plastic Shading
Light Intensity: 40%
Ambient Light: 0%
Highlight Intensity: 100%
Highlight Size: 100%
Blend Steps: 50
Shading Color: None
I've played around with diffuse shading, but haven't even come as close as these two samples. So basically, what I'm looking for is the base color of the first sample (maybe a little lighter), with the blend from dark to light of the second.
Thanks for any input or suggestions, and I'll be happy to provide more info if needed.
Sam

Icon,
To achieve a look like the one in the second image with the right colour (transition), you may:
1) Create the circle with fill/nostroke,
2) Create a horizontal line from the centre to the right edge, and a vertical line one half of the way (or where it fits your final look, maybe one third of the way) on top of the circle,
3) Select the circle and drag horizontally with the Gradient Tool from the crossing to the edge and switch to a Radial Gradient,
4) Apply white to the centre and #0000CC to the edge (left and right) and keep the Slider over the gradient at 50%,
5) Hide the lines and rotate the circle by 45 dregrees (or whichever rotation suits the purpose).
You may Undo and adjust 2), 3), and 5), until you are satisfied, and maybe delete the lines when done.
For quicker trying with less control, you may skip 2) and 5) and just drag from somewhere to the edge (or to somewhere else) in 3).
You can also define the colour as RGB 0/0/204.
Edit: Hi Monika.

Similar Messages

  • How to create a colored sphere?

    I am writing an application SQL database that has a staus bar. The program can connect to mySQL, winSQL, oracle, MS access, and postgreSQL database files. When the user clicks New Connection from the main menu, and selects database to connect to. I would like to have in the status bar, connection: and in another field a red or green sphere depending on whether the connection was successful.
    I have got it to draw a green/red circle, but I would like it to look like a green/red 3D sphere if possible.
    This is the code I am using below.
         /* JFRAME STATUS BAR */
         // Each JTextField is given it's own name so it's easy to write to each
         // in different stages throughout the program.
         private Box statusBar()
              Box sBar = Box.createHorizontalBox();
              linePosField = new JTextField(15);
              linePosField.setBackground(Color.LIGHT_GRAY);
              linePosField.setEditable(false);
              linePosField.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
              connectionField = new JTextField(40);
              connectionField.setBackground(Color.LIGHT_GRAY);
              connectionField.setEditable(false);
              connectionField.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
              //circleField = new JTextField(4);
              //circleField.setBackground(Color.LIGHT_GRAY);
              //circleField.setEditable(false);
              //circleField.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
              //circleField.add(paint(Graphics g));
              CirclePanel cp = new CirclePanel();
              cp.setColor(Color.GREEN);
              cp.setPreferredSize(new Dimension(20,10));
              cp.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
              blankField1 = new JTextField(15);
              blankField1.setBackground(Color.LIGHT_GRAY);
              blankField1.setEditable(false);
              blankField1.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
              blankField2 = new JTextField(40);
              blankField2.setBackground(Color.LIGHT_GRAY);
              blankField2.setEditable(false);
              blankField2.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
              sBar.add(linePosField);
              sBar.add(connectionField);
              sBar.add(cp);
              sBar.add(blankField1);
              sBar.add(blankField2);
              return sBar;
         private class CirclePanel extends JPanel
              private static final long serialVersionUID = 1L;
              private Color c;
              private static final int DIAMETER = 10;
              public void setColor(Color c)
                   this.c = c;
              private Color getColor()
                   return c;
              public void paintComponent(Graphics g)
                   super.paintComponent(g);
                   super.setBackground(Color.LIGHT_GRAY);
                   g.setColor(c);
                   g.fillOval(DIAMETER/4, DIAMETER/4, DIAMETER, DIAMETER);
                   //g.fill3DRect(4, 4, DIAMETER, DIAMETER, true);
         } // End private Class CirclePanel

    YAY fixed.
    It took me forever to figure out why there was a 5*5 gap (invisible border) around the icon, which caused the status bar to get extended height and look really ugly.
    But I finally did something to make it work (not sure what). took 2 hours >.< of writing / re-writing things, and playing with difference components/Layouts
    Now I just need to figure out how to add Line numbers to my JTextArea's, every example I can find on the net is either terribad, or adds 4-6 different panes to a JFrame all doing slightly different line numbers, and is so complex I can't work out what's going on.
    Edited by: G-Unit on Oct 14, 2010 11:22 PM

  • Adding a 3D sphere onto a 3D cube

    Hi, currently i have created a 3D cube and was thinking to create a 3D sphere so that the sphere can stay onto the cube. And so when the cube is being rotated, the sphere that is on the cube will move according too. Can any1 show me the code to create the sphere and add it to the existing Universe. I will paste my code of creating the 3D cube below. Hope you all can use my existing code and add the code for the sphere and show me. Thank you Very Much for your help.
    * IconGlassPanel3D.java
    * Created on October 30, 2006, 2:57 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package Pas3DGUI;
    import CobraNet.Zone;
    import DbConnection.DAOFactory;
    import DbConnection.ZoneDAO;
    import Pas2DGUI.ZoneIcons;
    import com.sun.j3d.utils.geometry.Sphere;
    import java.applet.Applet;
    import java.awt.BorderLayout;
    import java.awt.Frame;
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.utils.geometry.ColorCube;
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.behaviors.mouse.*;
    import java.awt.Graphics;
    import java.awt.Point;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import java.awt.Image;
    import java.awt.Toolkit;
    import java.awt.event.*;
    import java.util.Enumeration;
    * @author 042255f
    public class IconGlassPanel3D extends Applet {
    /** Creates a new instance of IconGlassPanel3D */
    public BranchGroup createSceneGraph() {
    // Create the root of the branch graph
    BranchGroup objRoot = new BranchGroup();
    TransformGroup objTransform = new TransformGroup();
    objTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    objRoot.addChild(objTransform);
    objTransform.addChild(new ColorCube(0.4));
    MouseRotate myMouseRotate = new MouseRotate();
    myMouseRotate.setTransformGroup(objTransform);
    myMouseRotate.setSchedulingBounds(new BoundingSphere());
    objRoot.addChild(myMouseRotate);
    MouseTranslate myMouseTranslate = new MouseTranslate();
    myMouseTranslate.setTransformGroup(objTransform);
    myMouseTranslate.setSchedulingBounds(new BoundingSphere());
    objRoot.addChild(myMouseTranslate);
    MouseZoom myMouseZoom = new MouseZoom();
    myMouseZoom.setTransformGroup(objTransform);
    myMouseZoom.setSchedulingBounds(new BoundingSphere());
    objRoot.addChild(myMouseZoom);
    // Let Java 3D perform optimizations on this scene graph.
    objRoot.compile();
    return objRoot;
    } // end of CreateSceneGraph method of MouseBehaviorApp
    // Create a simple scene and attach it to the virtual universe
    public IconGlassPanel3D() {
    setLayout(new BorderLayout());
    Canvas3D canvas3D = new Canvas3D(null);
    add("Center", canvas3D);
    BranchGroup scene = createSceneGraph();
    // SimpleUniverse is a Convenience Utility class
    SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
    // This will move the ViewPlatform back a bit so the
    // objects in the scene can be viewed.
    simpleU.getViewingPlatform().setNominalViewingTransform();
    simpleU.addBranchGraph(scene);
    } // end of IconGlassPanel (constructor)
    // The following allows this to be run as an application
    // as well as an applet
    public static void main(String[] args) {
    System.out.println("Hold the mouse button while moving the mouse to make the cube move.");
    System.out.println(" left mouse button - rotate cube");
    System.out.println(" right mouse button - translate cube");
    System.out.println(" Alt+left mouse button - zoom cube");
    Frame frame = new MainFrame(new IconGlassPanel3D(), 256, 256);
    } // end of main (method of IconGlassPanel)
    }

    What I figured out was that the model MUST be saved in one of the file formats acrobat recognizes - it won't come in straight from AutoCAD's native .dwg format.  So I save it as a .SAT file and then it works as advertised.
    Thanks for your response.

  • Help Zooming the 3D Sphere

    Hello Friends ...
    am pretty much new to Java 3D... my objective is to come up with a Sphere, add Mouse events to it & then wrap a texture around it....
    with help from this forum, i have a SPhere in place, which rotates just fine.. am unable to add the zooming behaviour... i am posting the code here. .will be great if someone can help.
    regards.,
    krishnan
    import javax.swing.JFrame;
    import javax.media.j3d.Canvas3D;
    import java.awt.*;
    import javax.swing.* ;
    import javax.media.j3d.*;
    import com.sun.j3d.utils.universe.SimpleUniverse;
    import com.sun.j3d.utils.universe.ViewingPlatform;
    import javax.media.j3d.BranchGroup;
    import javax.media.j3d.TransformGroup;
    import com.sun.j3d.utils.behaviors.mouse.*;
    import javax.media.j3d.Appearance;
    import javax.media.j3d.Material;
    import javax.media.j3d.BoundingSphere;
    import javax.media.j3d.DirectionalLight;
    import javax.vecmath.*;
    import com.sun.j3d.utils.geometry.Sphere;
    public class SphericalSpecimen extends JFrame
         private SimpleUniverse universe ;
         private BranchGroup rootBG ;
         public SphericalSpecimen ()
              super ("Sphere") ;
              setSize (300,300) ;
              initialise () ;
              addMomentsToSphereSpecimen () ;
              finialise () ;
         public void initialise ()
              /* Create a universe .place a canavas within that universe */
              GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
              Canvas3D canvas = new Canvas3D (config);
              universe = new SimpleUniverse (canvas) ;
              /* set layout manager to "BORDER" layout */
              getContentPane().setLayout(new BorderLayout());
              getContentPane().add("Center", canvas);
              /*Create a Branch Group to hold the Sphere **/
              rootBG = new BranchGroup () ;
              /* Create a transform Group to allow sphere rotation via mouse */
              TransformGroup RSTG = new RotSphereTransformGroup () ;
              * Add light (certain color)to the whole scene
              * (in a certain direction) to have the visual
              * objects within the "dark" universe become visible
              addDirectionalLight (new Vector3f(0f, 0f, -1) ,
                                       new Color3f(1f, 1f, 0f)) ;
         } /*end of initialize */
         private void addMomentsToSphereSpecimen ()
              ParticleParameters pp = new ParticleParameters (0f,1f);
              TransformGroup momentsTG = pp.addTG () ;
         private void finialise ()
              universe.addBranchGraph(rootBG);
              universe.getViewingPlatform().setNominalViewingTransform();
         public void addDirectionalLight(Vector3f direction, Color3f color)
              /* Create a bounding sphere for the lights */
              BoundingSphere bounds =     new BoundingSphere ();
              * create a directional light with the given
              * direction and color and set its influencing
              * bounds to "bounds" .
              DirectionalLight lightD = new DirectionalLight(color, direction);
    lightD.setInfluencingBounds(bounds);
              /* add the light to the root BranchGroup */
    rootBG.addChild(lightD);
         } /* end of addDirectionalLight */
         public class RotSphereTransformGroup extends TransformGroup
              /* Constructor */
              public RotSphereTransformGroup ()
                   * Add transform group to root branch group.
                   * This will make transform group a "live" object.
                   rootBG.addChild (this ) ;
                   * The behavior and properties of a "live" object
                   * like "this" transform group object cannot be
                   * manipulated or changed unless their capabilities
                   * are set prior to any change
                   setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
              setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
              * Add a behavior -- which allows any object
              * attached to this transfrom group to rotate
              * by mouse interaction.
              MouseRotate mouseRotate = new MouseRotate();
              mouseRotate.setTransformGroup(this);
              mouseRotate.setSchedulingBounds(new BoundingSphere());
              rootBG.addChild(mouseRotate);
              MouseZoom zoom =
              new MouseZoom(MouseZoom.INVERT_INPUT);
              zoom.setTransformGroup(this);
              zoom.setSchedulingBounds(new BoundingSphere());
              rootBG.addChild(zoom);
              * Now, we wish to add a sphere to the transform
              * group but, prior to this, we would like to .
              * customize the sphere's appearance
              Appearance app = new Appearance ();
              Material mat = new Material () ;
                   mat.setAmbientColor (new Color3f(1,0,0));
         mat.setDiffuseColor (new Color3f(1,0,0));
         mat.setSpecularColor(new Color3f(1,0,0));
              app.setMaterial (mat);
              /* create a 0.5-meter diameter sphere */
              Sphere mainSphere = new Sphere (0.5f,app);
              /* attach the sphere to the rotating transform group */
              addChild (mainSphere) ;
              } /* end of constructor */
         } /* end of class "RotSphereTransformGroup" */
         public class ParticleParameters
              private final ColoringAttributes BLACK =
              new ColoringAttributes(0,0,0,
              ColoringAttributes.FASTEST );
              private float theta ;
              private float phi ;
              public ParticleParameters ( float theta, float phi)
                   this.theta = theta ;
                   this.phi = phi ;
              public TransformGroup addTG ()
                   Transform3D t3d = new Transform3D () ;
                   float x = (float)(0.5f * Math.cos(theta)* Math.sin(phi)) ;
                   float y = (float)(0.5f * Math.sin(theta)* Math.sin(phi)) ;
                   float z = (float)(0.5f * Math.cos (phi)) ;
                   t3d.set (new Vector3d (y,z,x));
                   Appearance mApp = new Appearance () ;
                   mApp.setColoringAttributes(BLACK) ;
                   Sphere s1 = new Sphere ((float)(0.5/2.0),mApp);
                   TransformGroup mtg = new TransformGroup (t3d) ;
                   mtg.addChild(s1) ;
                   return (mtg);               
         public static void main ( String args [])
              SphericalSpecimen a = new SphericalSpecimen () ;
              a.setVisible(true) ;
    thanks in advacnce...
    Message was edited by:
    krishnan82

    Hi can you suggest how do i Controll mouse for obj clip.
    I want to move inside house.obj and not collide with walls. I am able to load the obj file
    I want to move inside and rotate side movement not Up and down and Prevent Collosion with walls and objects
    import java.applet.Applet;
    import java.awt.BorderLayout;
    import java.awt.GraphicsConfiguration;
    import java.io.FileNotFoundException;
    import java.net.MalformedURLException;
    import java.net.URL;
    import javax.media.j3d.Alpha;
    import javax.media.j3d.AmbientLight;
    import javax.media.j3d.Background;
    import javax.media.j3d.BoundingSphere;
    import javax.media.j3d.BranchGroup;
    import javax.media.j3d.Canvas3D;
    import javax.media.j3d.DirectionalLight;
    import javax.media.j3d.RotationInterpolator;
    import javax.media.j3d.Transform3D;
    import javax.media.j3d.TransformGroup;
    import javax.vecmath.Color3f;
    import javax.vecmath.Point3d;
    import javax.vecmath.Vector3d;
    import javax.vecmath.Vector3f;
    import com.mnstarfire.loaders3d.Inspector3DS;
    import com.sun.j3d.loaders.IncorrectFormatException;
    import com.sun.j3d.loaders.ParsingErrorException;
    import com.sun.j3d.loaders.Scene;
    import com.sun.j3d.loaders.objectfile.ObjectFile;
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
    import com.sun.j3d.utils.universe.PlatformGeometry;
    import com.sun.j3d.utils.universe.SimpleUniverse;
    import com.sun.j3d.utils.universe.ViewingPlatform;
    public class ObjLoad extends Applet {
    private boolean spin = false;
    private boolean noTriangulate = false;
    private boolean noStripify = false;
    private double creaseAngle = 0.0;
    private URL filename = null;
    private SimpleUniverse u;
    private BoundingSphere bounds;
    public BranchGroup createSceneGraph() {
    // Create the root of the branch graph
    BranchGroup branchGroupObject = new BranchGroup();
    // Create a Transformgroup to scale all objects so they
    // appear in the scene.
    TransformGroup transformGroup1 = new TransformGroup();
    Transform3D transform3DObject1 = new Transform3D();
    transform3DObject1.setScale(0.5);
    transformGroup1.setTransform(transform3DObject1);
    branchGroupObject.addChild(transformGroup1);
    // Create the transform group node and initialize it to the
    // identity. Enable the TRANSFORM_WRITE capability so that
    // our behavior code can modify it at runtime. Add it to the
    // root of the subgraph.
    TransformGroup transformGroup2 = new TransformGroup();
    transformGroup2.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    transformGroup2.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    transformGroup1.addChild(transformGroup2);
    int flags = ObjectFile.RESIZE;
    // int flags = ObjectFile.REVERSE;
    if (!noTriangulate)
    flags |= ObjectFile.TRIANGULATE;
    if (!noStripify)
    flags |= ObjectFile.STRIPIFY;
    ObjectFile f = new ObjectFile(flags,
    (float) (creaseAngle * Math.PI / 180.0));
    Scene s = null;
    try {
    s = f.load(filename);
    } catch (FileNotFoundException e) {
    System.err.println(e);
    System.exit(1);
    } catch (ParsingErrorException e) {
    System.err.println(e);
    System.exit(1);
    } catch (IncorrectFormatException e) {
    System.err.println(e);
    System.exit(1);
    transformGroup1.addChild(s.getSceneGroup());
    bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
    /*if (spin) {
    Transform3D yAxis = new Transform3D();
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0,
    4000, 0, 0, 0, 0, 0);
    RotationInterpolator rotator = new RotationInterpolator(
    rotationAlpha, objTrans, yAxis, 0.0f,
    (float) Math.PI * 2.0f);
    rotator.setSchedulingBounds(bounds);
    objTrans.addChild(rotator);
    // Set up the background
    Color3f bgColor = new Color3f(0.05f, 0.05f, 0.5f);
    Background bgNode = new Background(bgColor);
    bgNode.setApplicationBounds(bounds);
    branchGroupObject.addChild(bgNode);
    return branchGroupObject;
    private void usage() {
    System.out.println("Usage: java ObjLoad [-s] [-n] [-t] [-c degrees] <.obj file>");
    System.out.println(" -s Spin (no user interaction)");
    System.out.println(" -n No triangulation");
    System.out.println(" -t No stripification");
    System.out
    .println(" -c Set crease angle for normal generation (default is 60 without");
    System.out
    .println(" smoothing group info, otherwise 180 within smoothing groups)");
    System.exit(0);
    } // End of usage
    public void init() {
    if (filename == null) {
    // Applet
    try {
    URL path = getCodeBase();
    filename = new URL(path.toString() + "./house.obj");
    } catch (MalformedURLException e) {
    System.err.println(e);
    System.exit(1);
    setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse
    .getPreferredConfiguration();
    Canvas3D c = new Canvas3D(config);
    add("Center", c);
    // Create a simple scene and attach it to the virtual universe
    BranchGroup scene = createSceneGraph();
    u = new SimpleUniverse(c);
    // add mouse behaviors to the ViewingPlatform
    ViewingPlatform viewingPlatform = u.getViewingPlatform();
    PlatformGeometry pg = new PlatformGeometry();
    // Set up the ambient light
    Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f);
    AmbientLight ambientLightNode = new AmbientLight(ambientColor);
    ambientLightNode.setInfluencingBounds(bounds);
    pg.addChild(ambientLightNode);
    // Set up the directional lights
    Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f);
    Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f);
    Color3f light2Color = new Color3f(1.0f, 1.0f, 1.0f);
    // Color3f light2Color = new Color3f(1.1f, 1.5f, 2.2f);
    Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
    // Vector3f light2Direction = new Vector3f(15.0f, 5.0f, 5.0f);
    DirectionalLight light1 = new DirectionalLight(light1Color,
    light1Direction);
    light1.setInfluencingBounds(bounds);
    pg.addChild(light1);
    DirectionalLight light2 = new DirectionalLight(light2Color,
    light2Direction);
    light2.setInfluencingBounds(bounds);
    pg.addChild(light2);
    viewingPlatform.setPlatformGeometry(pg);
    // This will move the ViewPlatform back a bit so the
    // objects in the scene can be viewed.
    viewingPlatform.setNominalViewingTransform();
    if (!spin ) {
    OrbitBehavior orbit = new OrbitBehavior(c,
    OrbitBehavior.REVERSE_ALL);
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0,
    0.0), 100.0);
    orbit.setSchedulingBounds(bounds);
    viewingPlatform.setViewPlatformBehavior(orbit);
    u.addBranchGraph(scene);
    // Caled if running as a program
    public ObjLoad(String[] args) {
    if (args.length != 0) {
    for (int i = 0; i < args.length; i++) {
    if (args.startsWith("-")) {
    if (args[i].equals("-s")) {
    spin = true;
    } else if (args[i].equals("-n")) {
    noTriangulate = true;
    } else if (args[i].equals("-t")) {
    noStripify = true;
    } else if (args[i].equals("-c")) {
    if (i < args.length - 1) {
    creaseAngle = (new Double(args[++i])).doubleValue();
    } else
    usage();
    } else {
    usage();
    } else {
    try {
    if ((args[i].indexOf("file:") == 0)
    || (args[i].indexOf("http") == 0)) {
    filename = new URL(args[i]);
    } else if (args[i].charAt(0) != '/') {
    filename = new URL("file:./" + args[i]);
    } else {
    filename = new URL("file:" + args[i]);
    } catch (MalformedURLException e) {
    System.err.println(e);
    System.exit(1);
    // Running as an applet
    public ObjLoad() {
    public void destroy() {
    u.cleanup();
    // The following allows ObjLoad to be run as an application
    // as well as an applet
    public static void main(String[] args) {
    new MainFrame(new ObjLoad(args), 700, 700);
    Can any one help me to for me Collision Class for this program
    Thank you
    Santosh
    [email protected]

  • Specific need: to generate a cylindrical projection NOT from a sphere, but from a flat image

    Specific need: to generate a cylindrical projection NOT from a sphere, but from a flat image, like a person's face, etc., such that the cylindrical projection can be used to wrap a sphere (via other software such as the DX I use), where the face could be positioned arbitrarily at the equator (where a cylindrical projection image created FROM a sphere appears most normal), a pole (where a cylindrical projection image created FROM a sphere appears most stretched out), or anywhere else on the resultant sphere's surface. This would allow creation of a, say, a cylindrical projection of a sphere that represents a numbered billiard ball from a flat representation of the number design. Is there an Adobe or Photoshop product that will provide this? Thanks for any help!

    Thanks, Noel. Here's the crux: the image sphincters at the poles, natch. I've been looking for an algorithm or feature in a graphics app that would assume that the flat image of joetalker's entry would be spread proportionately at the poles so that the size of print would be uniform (or the shape of face photo, etc).
    Using such a feature would dictate that type, lets say, would be distributed on the flat image something like this in order not to lose too much at the edges (where the sphere mesh meets at 0-longitude), and sphincters as latitude approaches the poles:
    ++++++++Hello+++++++++
    +++++How are you &+++++
    ++What can I do for you+++
    +++++How are you &+++++
    ++++++++Hello+++++++++
    Yes, over-simplified. Here with a photo, where the original photo is "X" signs, and the empty space is "+" signs, along with the desired created cylindrical projection ready for a sphere mesh:
    Example 1 at equator:
    original:
    ++++++++++++++++++++++++
    ++++++++++++++++++++++++
    ++++++++++XXXXX++++++++++
    +++++++++XXXXX++++++++++
    +++++++++++XXXX+++++++++
    ++++++++++XXX++++++++++
    +++++++++++++++++++++++++
    ++++++++++++++++++++++++
    created cylindrcal projection:
    ++++++++++++++++++++++++
    ++++++++++++++++++++++++
    ++++++++XXXXXXXXX++++++++
    +++++++++XXXXX++++++++++
    +++++++++XXXXXXXX+++++++
    +++++++XXXXXXXXX+++++++
    +++++++++++++++++++++++++
    +++++++++++++++++++++++
    -very similar, with a widening at top and bottom of "photo", right?
    Example 2 at poles:
    original:
    +++++++++++XXXX+++++++++    (bottom of photo)
    ++++++++++XXX++++++++++
    +++++++++++++++++++++++++
    +++++++++++++++++++++++++
    ++++++++++++++++++++++++
    ++++++++++++++++++++++++
    ++++++++++XXXXX++++++++++   (top of photo)
    +++++++++XXXXX++++++++++
    created cylindrcal projection:
    +++XXXXXXXXXXXXXXXXXXXX+++
    ++++++XXXXXXXXXXXXX++++++
    +++++++++++++++++++++++++
    +++++++++++++++++++++++++
    ++++++++++++++++++++++++
    ++++++++++++++++++++++++
    +++++XXXXXXXXXXXXXXX++++++
    ++XXXXXXXXXXXXXXXXXXXXXX+++
    -now with an even more widening toward the poles to compensate for the pole sphinctering.
    If starting with a true globe already spatially correct, creating a cylindrical projection is commonplace. I'm attempting to find an app that will create a cylindrical projection-like graphic ready for a sphere mesh from a flat photo or graphic. The above example would place the photo in correct proportion over the pole of the sphere, discarding information at the ever decreasing edges as the image projects to the poles.
    Hope this is clear, and thanks again!
    -Johnny

  • Can ya...draw a sphere  ...  with lat. and long.  lines

    Is there a way to draw a sphere with it's wire frame?
    Can I create such a sphere and map a texture underneath the wire frame?
    thanks, --guy without a clue on this

    Sorry. The batch of scripts I meant to direct to is here:
    http://www.IllustrationETC.com/AIbuds/JETPathScriptsShared.zip
    Bill,
    Assuming you are using AICS or CS2, the 3D Effect with Symbol mapping as Gary suggested is fine. I sometimes use both; using the 3D image mapping for the sphere surface, but overlaying it with the grid made by the script. (It so happened I was working on such a thing right when you posted this thread.) Reasons are: It's easy to do "stroke things" (Art Brushes, dashes, etc.) with the grid made by the script, because the paths are all simple ellipses with 4 points...:
    ...; whereas the 3D mapping route tapers the lat/long lines, and when expanded all the strokes are outlined, even if the Symbol contained simple strokes.
    Also, the script results in ellipses spaced as if they were mechanically constructed in an axonometric projection (isometric, dimetric, trimetric), which makes them useful to me for other things, such as sperical "protractors".
    For those using AI10, a version of the script without the prompts is here:
    http://www.IllustrationETC.com/AIbuds/LatLongSphere/JETSphereAI10.js
    A PDF explaining how to edit the number of lines in AI10 and showing some other experiments with it is here:
    http://www.IllustrationETC.com/AIbuds/LatLongSphere/JETSphereNotes.pdf
    JET

  • 3D transparent sphere with text

    I want to create a 3d sphere with 3D text around that shere. I can actualy do it with simple text applying black/withe in the transparency menu over a pre-defined texture. It looks good, but i would like to put 3d text over a transparent sphere so i would see that text around.

    Hi Jean,
    There's no quick way to achieve this in Ps. With CS5 and Repoussé you can get the 3D text creation but it will not align to 3D shapes. What you can do manually is rotate and move each 3D letter to a guide so that it appears to wrap on a shape. Here's an example of wrapping it to a cylinder ( I used a circle for a guide and set camera view to 'Top'). I used a mesh for the ground plane, which is why the p's descender is not viewable.
    Is this along the lines of what your were looking to do?
    regards,
    steve

  • Rotating sphere

    Hi
    Been using Motion 5 for about a week, teaching myself as I go.
    I've been able to create a rotating sphere and this seems to work great. My only problem is that as it rotates, it also moves the sphere across the screen. What I would like is for it to rotate on its axis (like it does now) but for it to be stationary on the screen.
    At present, to get my "rotation" to work, the sphere's X pixel value goes from -350px (at 0:00) to 175px (at 5:00). But of course this is moving my sphere across the screen. The Y pixel value remains constant throughout.
    I haven't had any prior animation experience, so maybe I've approached this all wrong? Any help would be greatly appreciated.
    Thanks.
    Joe.

    Animating a sphere isn't terribly intuitive.
    You have your image/object that you want to make look like a spheroid, and you want it to spin on an axis without moving across the screen. The trick is to use a 3D group (there's a small icon on the right side of the layers column across from the group — if it looks like 3 parallel cards, then the group is 3D — clicking on that icon toggles the group from 2D to 3D.) You want to add the Sphere distortion filter to the Group. You want to animate the X position of the image/object inside the group.
    I guess you can think of it as adding a lens over the object. You're not animating the lens -- just what the lens looks at. (And it has to be 3D so that there is a separation of the two.)
    HTH

  • The dreaded "could not find the Main Class, Program will exit", how?

    Hello all,
    I am trying to run my .jar file and I get this error message.
    I want to mention I googled and searched for it, without success: There is so many different explanations!
    I tried this:
    Adding some lines in a manifest.fm file...
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.0
    Created-By: 10.0-b19 (Sun Microsystems Inc.)
    X-COMMENT: Main-Class will be added automatically by build
    I have Netbeans 5.5.
    Also I noticed my "build.xml" file is empty" and my "manifest.fm" nearly empty. I have also added "project, main class" in the options...
    Here is my "build":
    {code}<?xml version="1.0" encoding="UTF-8"?>
    <!-- You may freely edit this file. See commented blocks below for -->
    <!-- some examples of how to customize the build. -->
    <!-- (If you delete it and reopen the project it will be recreated.) -->
    <project name="BetaCourseworkJava3d_Final" default="default" basedir=".">
    <description>Builds, tests, and runs the project BetaCourseworkJava3d_Final.</description>
    <import file="nbproject/build-impl.xml"/>
    <!--
    There exist several targets which are by default empty and which can be
    used for execution of your tasks. These targets are usually executed
    before and after some main targets. They are:
    -pre-init: called before initialization of project properties
    -post-init: called after initialization of project properties
    -pre-compile: called before javac compilation
    -post-compile: called after javac compilation
    -pre-compile-single: called before javac compilation of single file
    -post-compile-single: called after javac compilation of single file
    -pre-compile-test: called before javac compilation of JUnit tests
    -post-compile-test: called after javac compilation of JUnit tests
    -pre-compile-test-single: called before javac compilation of single JUnit test
    -post-compile-test-single: called after javac compilation of single JUunit test
    -pre-jar: called before JAR building
    -post-jar: called after JAR building
    -post-clean: called after cleaning build products
    (Targets beginning with '-' are not intended to be called on their own.)
    Example of inserting an obfuscator after compilation could look like this:
    <target name="-post-compile">
    <obfuscate>
    <fileset dir="${build.classes.dir}"/>
    </obfuscate>
    </target>
    For list of available properties check the imported
    nbproject/build-impl.xml file.
    Another way to customize the build is by overriding existing main targets.
    The targets of interest are:
    -init-macrodef-javac: defines macro for javac compilation
    -init-macrodef-junit: defines macro for junit execution
    -init-macrodef-debug: defines macro for class debugging
    -init-macrodef-java: defines macro for class execution
    -do-jar-with-manifest: JAR building (if you are using a manifest)
    -do-jar-without-manifest: JAR building (if you are not using a manifest)
    run: execution of project
    -javadoc-build: Javadoc generation
    test-report: JUnit report generation
    An example of overriding the target for project execution could look like this:
    <target name="run" depends="BetaCourseworkJava3d_TestsBACKUPSUNDAY05April-impl.jar">
    <exec dir="bin" executable="launcher.exe">
    <arg file="${dist.jar}"/>
    </exec>
    </target>
    Notice that the overridden target depends on the jar target and not only on
    the compile target as the regular run target does. Again, for a list of available
    properties which you can use, check the target you are overriding in the
    nbproject/build-impl.xml file.
    -->
    </project>
    {code}
    my Manifest:
    {code}Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.0
    Created-By: 10.0-b19 (Sun Microsystems Inc.)
    X-COMMENT: Main-Class will be added automatically by build
    {code}
    And my whole code (although I have like 4 .JAVA files in my project):
    {code}
    package courseworkjava3d;
    import java.awt.*;
    import java.awt.event.*;
    import com.sun.j3d.utils.geometry.*;
    import com.sun.j3d.utils.universe.*;
    import javax.swing.*;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import javax.media.j3d.PositionPathInterpolator;
    import javax.media.j3d.Alpha;
    import javax.media.j3d.BoundingSphere;
    import com.sun.j3d.utils.applet.MainFrame;
    import java.applet.Applet;
    import java.awt.event.WindowAdapter;
    import javax.swing.Timer;
    import com.sun.j3d.utils.image.*;
    public class Simple3D extends JFrame implements ActionListener, KeyListener
    private TransformGroup objTransxx;
    private Button go = new Button("Press to start the Bouncing Ball. Press A and S to move the ball Left and Right once it started!");
    private Transform3D transxx = new Transform3D();
    private float height=0.0f;
    private float sign = 1.0f; // aller vers le haut ou vers le bas
    private Timer timer;
    private float xloc=-2.25f;
    public Simple3D()
    setSize(800, 800);
    GraphicsConfiguration graphicsConfig = SimpleUniverse.getPreferredConfiguration();
    Canvas3D canvas = new Canvas3D(graphicsConfig);
    getContentPane().add("Center", canvas);
    BasicUniverse universe = new BasicUniverse(canvas, 8.0f);
    // Rotate the view platform by PI/4 radians about X in the BasicUniverse
    TransformGroup viewTransform = universe.getViewPlatformTransform();
    Transform3D transform = new Transform3D();
    transform.rotX(-Math.PI / 4.0);
    Transform3D currentTransform = new Transform3D();
    viewTransform.getTransform(currentTransform);
    transform.mul(currentTransform);
    viewTransform.setTransform(transform);
    // Add something to display
    BranchGroup scene = createCubeGraph();
    universe.addBranchGraph(scene);
    /* //ultra important! comment theses lines otherwise it bugs!
    //Merde
    setLayout(new BorderLayout());
    GraphicsConfiguration config =
    SimpleUniverse.getPreferredConfiguration();
    Canvas3D c = new Canvas3D(config); */
    add("Center", canvas);
    //i messed up te code, i replaced canvas c by "canvas" as i already had one!
    canvas.addKeyListener(this);
    timer = new Timer(75,this);
    //timer.start();
    Panel p =new Panel();
    p.add(go);
    add("North",p);
    go.addActionListener(this);
    go.addKeyListener(this);
    // Cr�er une sc�ne simple et l�ajouetr � l�univers
    //BranchGroup scene2 = createCubeGraph();
    //SimpleUniverse u = new SimpleUniverse(c);
    //u.getViewingPlatform().setNominalViewingTransform();
    //u.addBranchGraph(scene2);
    //End Merde
    public BranchGroup createCubeGraph() {
    BranchGroup Humanoid = new BranchGroup();
    //Debut Ball REBOUND
    // Create the root of the branch graph
    //BranchGroup objRoot = new BranchGroup();
    objTransxx = new TransformGroup();
    objTransxx.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    Humanoid.addChild(objTransxx);
    // Cr�er une forme simple et l�ajouter au graph de sc�ne
    Sphere spherex = new Sphere(0.85f);
    objTransxx = new TransformGroup();
    objTransxx.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    Transform3D pos1 = new Transform3D();
    pos1.setTranslation(new Vector3f(-2.0f,0.0f,-2.0f));
    objTransxx.setTransform(pos1);
    objTransxx.addChild(spherex);
    Humanoid.addChild(objTransxx);
    BoundingSphere boundsx =
    new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
    // I messed up the colors: I have applied 2 times some colorslights to the same BranchGroup
    Color3f light1Colorx = new Color3f(1.0f, 1.0f, 1.0f);
    Vector3f light1Directionx = new Vector3f(4.0f, -7.0f, -12.0f);
    DirectionalLight light1x
    = new DirectionalLight(light1Colorx, light1Directionx);
    light1x.setInfluencingBounds(boundsx);
    Humanoid.addChild(light1x);
    // R�gler la lumi�re ambiante
    Color3f ambientColorx = new Color3f(1.0f, 1.0f, 1.0f);
    AmbientLight ambientLightNodex = new AmbientLight(ambientColorx);
    ambientLightNodex.setInfluencingBounds(boundsx);
    Humanoid.addChild(ambientLightNodex);
    // END BallRebound
    // Apparence BODY
    // Configurer les couleurs
    Color3f blackbody = new Color3f(0.0f, 0.0f, 0.0f);
    Color3f whitebody = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f redbody = new Color3f(0.8f, .85f, .85f);
    // Configurer la texture
    //if I want it in Black and white i need to replace RGB by LUMINANCE
    TextureLoader loaderbody = new TextureLoader("C:\\java3d\\body.jpg", "RGB", new Container());
    Texture texturebody = loaderbody.getTexture();
    texturebody.setBoundaryModeS(Texture.WRAP);
    texturebody.setBoundaryModeT(Texture.WRAP);
    texturebody.setBoundaryColor( new Color4f( 1.0f, 1.0f, 0.0f, 0.0f ) );
    // Configurer les attributs de la texture
    // Param�tres possibles : REPLACE, BLEND ou DECAL (ici, MODULATE)
    TextureAttributes texAttrbody = new TextureAttributes();
    texAttrbody.setTextureMode(TextureAttributes.MODULATE);
    Appearance apbody = new Appearance();
    apbody.setTexture(texturebody);
    apbody.setTextureAttributes(texAttrbody);
    //Configurer le mat�riau
    apbody.setMaterial(new Material(redbody, blackbody, redbody, blackbody, 1.0f));
    // Cr�er une sph�re pour y appliquer les textures
    int primflagsbody = Primitive.GENERATE_NORMALS + Primitive.GENERATE_TEXTURE_COORDS;
    // End Apparence BODY
    // Apparence BODYHEAD
    // Configurer les couleurs
    Color3f blackbodyH = new Color3f(0.0f, 0.0f, 0.0f);
    Color3f whitebodyH = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f redbodyH = new Color3f(0.8f, .85f, .85f);
    // Configurer la texture
    //if I want it in Black and white i need to replace RGB by LUMINANCE
    TextureLoader loaderbodyH = new TextureLoader("C:\\java3d\\head.jpg", "RGB", new Container());
    Texture texturebodyH = loaderbodyH.getTexture();
    texturebodyH.setBoundaryModeS(Texture.WRAP);
    texturebodyH.setBoundaryModeT(Texture.WRAP);
    texturebodyH.setBoundaryColor( new Color4f( 1.0f, 1.0f, 0.0f, 0.0f ) );
    // Configurer les attributs de la texture
    // Param�tres possibles : REPLACE, BLEND ou DECAL (ici, MODULATE)
    TextureAttributes texAttrbodyH = new TextureAttributes();
    texAttrbodyH.setTextureMode(TextureAttributes.MODULATE);
    Appearance apbodyH = new Appearance();
    apbodyH.setTexture(texturebodyH);
    apbodyH.setTextureAttributes(texAttrbodyH);
    //Configurer le mat�riau
    apbodyH.setMaterial(new Material(redbodyH, blackbodyH, redbodyH, blackbodyH, 1.0f));
    // Cr�er une sph�re pour y appliquer les textures
    int primflagsbodyH = Primitive.GENERATE_NORMALS + Primitive.GENERATE_TEXTURE_COORDS;
    // End Apparence BODY HEAD
    //for the trunk c le corps
    TransformGroup fortheTrunk = new TransformGroup();
    //will allow to modify object wgile executing
    fortheTrunk.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    //alpha rotation time related
    Alpha rotationAlpha2=new Alpha(-1,9000);
    //behviour for our rotation
    RotationInterpolator rotator2= new RotationInterpolator(rotationAlpha2,fortheTrunk);
    // area where rotation will be
    BoundingSphere bounds2=new BoundingSphere();
    rotator2.setSchedulingBounds(bounds2);
    fortheTrunk.addChild(rotator2);
    //end of rtotation
    Alpha transAlphahuman=new Alpha(-1,600);
    //transform 3d trans for the interpolatipon HUMANOID
    Transform3D transhumanoid=new Transform3D();
    //matrix for 2positions
    Point3f[] cheminhuman=new Point3f[3];
    cheminhuman[0]=new Point3f(0.8f,0.0f,0.0f);
    cheminhuman[1]=new Point3f(-0.8f,0.0f,0.0f);
    cheminhuman[2]=new Point3f(0.8f,0.0f,0.0f);
    //matrix of floats to make the dots match with timeline
    float[] timePositionhuman={0.0f,0.50f,1.0f};
    PositionPathInterpolator interpolhuman=new PositionPathInterpolator(transAlphahuman,fortheTrunk,transhumanoid,timePositionhuman,cheminhuman);
    BoundingSphere bounds4=new BoundingSphere();
    interpolhuman.setSchedulingBounds(bounds4);
    fortheTrunk.addChild(interpolhuman);
    //add the trunk to the branchgroup
    Humanoid.addChild(fortheTrunk);
    TransformGroup zeTrunk = new TransformGroup();
    zeTrunk.addChild(new com.sun.j3d.utils.geometry.Box(.55f,.80f,.50f,
    primflagsbody,apbody));
    //t3D for the head= bouge up
    Transform3D T3DHead = new Transform3D();
    T3DHead.set(new Vector3f(0f,1.1f,0f));
    //create a tranform group for this t3Dhead
    TransformGroup fortheHead = new TransformGroup();
    fortheHead.setTransform(T3DHead);
    //add the box head
    //fortheHead.addChild(new com.sun.j3d.utils.geometry.Box(.20f,.20f,.10f, primflagsbody,apbody));
    fortheHead.addChild(new com.sun.j3d.utils.geometry.Sphere(0.35f,primflagsbodyH,apbodyH));
    /* I dont need that anymore it was for putting a flat texture on a face. I chose a sphere instead!
    //transform 3D for the face
    Transform3D T3DFace = new Transform3D();
    T3DFace.set(new Vector3f(0f,0f,.14f));
    //create a TransformGroup for this Face
    TransformGroup Face = new TransformGroup();
    Face.setTransform(T3DFace);
    //add the child box to the face;
    Face.addChild(new com.sun.j3d.utils.geometry.Box(.20f,.20f,.2f,
    primflagsbodyH,apbodyH));
    //add this face to the head as a child
    fortheHead.addChild(Face);
    //tranform3d left arm
    Transform3D T3DArmL = new Transform3D();
    T3DArmL.set(new Vector3f(-0.79f,0.73f,0f));
    //create Tranform Group for the leftarm
    TransformGroup fortheArmL = new TransformGroup();
    fortheArmL.setTransform(T3DArmL);
    //add the group for upperarm
    TransformGroup ArmL = new TransformGroup();
    ArmL.addChild(new com.sun.j3d.utils.geometry.Box(.25f,.14f,.10f,
    primflagsbody,apbody));
    fortheArmL.addChild(ArmL);
    //create a transform3D for the forearmleft
    Transform3D T3DForearmL = new Transform3D();
    T3DForearmL.set(new Vector3f(-.51f,0f,0f));
    //create the tranformgroup for the forearmleft
    TransformGroup ForearmL = new TransformGroup();
    ForearmL.setTransform(T3DForearmL);
    //add the child box to forearm
    ForearmL.addChild(new com.sun.j3d.utils.geometry.Box(.20f,.14f,.10f,
    primflagsbody,apbody));
    ArmL.addChild(ForearmL);
    //create transform 3d for the lefthand
    Transform3D T3DHandL = new Transform3D();
    T3DHandL.set(new Vector3f(-.42f,0f,0f));
    //create the child tranform group for the box of the hand
    TransformGroup HandL= new TransformGroup();
    HandL.setTransform(T3DHandL);
    //add the child hand to the forearm
    ForearmL.addChild(HandL);
    //create the box for the handLeft
    HandL.addChild(new com.sun.j3d.utils.geometry.Box(.10f,.140f,.10f,
    primflagsbody,apbody));
    //Right Arm
    //tranform3d right arm
    Transform3D T3DArmR = new Transform3D();
    T3DArmR.set(new Vector3f(0.79f,0.73f,0f));
    //create Tranform Group for the right arm
    TransformGroup fortheArmR = new TransformGroup();
    fortheArmR.setTransform(T3DArmR);
    //add the group for upperarm right
    TransformGroup ArmR = new TransformGroup();
    ArmR.addChild(new com.sun.j3d.utils.geometry.Box(.25f,.14f,.10f, primflagsbody,apbody));
    //com.sun.j3d.utils.geometry.Box.GENERATE_NORMALS,new Appearance()));
    fortheArmR.addChild(ArmR);
    //create a transform3D for the forearmright
    Transform3D T3DForearmR = new Transform3D();
    T3DForearmR.set(new Vector3f(.51f,0f,0f));
    //create the tranformgroup for the forearmright
    TransformGroup ForearmR = new TransformGroup();
    ForearmR.setTransform(T3DForearmR);
    //add the child box to forearmright
    ForearmR.addChild(new com.sun.j3d.utils.geometry.Box(.20f,.14f,.10f, primflagsbody,apbody));
    ArmR.addChild(ForearmR);
    //create transform 3d for the righthand
    Transform3D T3DHandR = new Transform3D();
    T3DHandR.set(new Vector3f(.42f,0f,0f));
    //create the child tranform group for the box of the hand
    TransformGroup HandR= new TransformGroup();
    HandR.setTransform(T3DHandR);
    //add the child hand to the forearmright
    ForearmR.addChild(HandR);
    //create the box for the handright
    HandR.addChild(new com.sun.j3d.utils.geometry.Box(.10f,.14f,.10f, primflagsbody,apbody));
    //Left Leg
    //tranform3d left leg
    Transform3D T3DLegL = new Transform3D();
    T3DLegL.set(new Vector3f(0.43f,-1.23f,0f));
    //create Tranform Group for the leftleg
    TransformGroup fortheLegL = new TransformGroup();
    fortheLegL.setTransform(T3DLegL);
    //add the group for uppeleg
    TransformGroup LegL = new TransformGroup();
    LegL.addChild(new com.sun.j3d.utils.geometry.Box(.16f,.35f,.10f, primflagsbody,apbody));
    fortheLegL.addChild(LegL);
    //create a transform3D for the downlegleft
    Transform3D T3DDownLegL = new Transform3D();
    T3DDownLegL.set(new Vector3f(0f,-.70f,0f));
    //create the tranformgroup for the downegleft
    TransformGroup DownLegL = new TransformGroup();
    DownLegL.setTransform(T3DDownLegL);
    //add the child box to downlegm
    DownLegL.addChild(new com.sun.j3d.utils.geometry.Box(.16f,.25f,.10f, primflagsbody,apbody));
    LegL.addChild(DownLegL);
    //create transform 3d for the leftfeet
    Transform3D T3DFeetL = new Transform3D();
    T3DFeetL.set(new Vector3f(.0f,-.45f,0f));
    //create the child tranform group for the box of thefeet
    TransformGroup FeetL= new TransformGroup();
    FeetL.setTransform(T3DFeetL);
    //add the child hand to the downleg
    DownLegL.addChild(FeetL);
    //create the box for the feetLeft
    FeetL.addChild(new com.sun.j3d.utils.geometry.Box(.16f,.10f,.15f, primflagsbody,apbody));
    //Right Leg
    //tranform3dright leg
    Transform3D T3DLegR = new Transform3D();
    T3DLegR.set(new Vector3f(-0.43f,-1.23f,0f));
    //create Tranform Group for the righttleg
    TransformGroup fortheLegR = new TransformGroup();
    fortheLegR.setTransform(T3DLegR);
    //add the group for uppelegR
    TransformGroup LegR = new TransformGroup();
    LegR.addChild(new com.sun.j3d.utils.geometry.Box(.16f,.35f,.10f, primflagsbody,apbody));
    fortheLegR.addChild(LegR);
    //create a transform3D for the downlegright
    Transform3D T3DDownLegR = new Transform3D();
    T3DDownLegR.set(new Vector3f(0f,-.70f,0f));
    //create the tranformgroup for the downegright
    TransformGroup DownLegR = new TransformGroup();
    DownLegR.setTransform(T3DDownLegR);
    //add the child box to downlegRight
    DownLegR.addChild(new com.sun.j3d.utils.geometry.Box(.16f,.25f,.10f, primflagsbody,apbody));
    LegR.addChild(DownLegR);
    //create transform 3d for the rightfeet
    Transform3D T3DFeetR = new Transform3D();
    T3DFeetR.set(new Vector3f(.0f,-.45f,0f));
    //create the child tranform group for the box of thefeetright
    TransformGroup FeetR= new TransformGroup();
    FeetR.setTransform(T3DFeetR);
    //add the child feet right to the downleg
    DownLegR.addChild(FeetR);
    //create the box for the feetright
    FeetR.addChild(new com.sun.j3d.utils.geometry.Box(.16f,.10f,.15f, primflagsbody,apbody));
    //rajoute la box zetrunk et des fils
    fortheTrunk.addChild(zeTrunk);
    fortheTrunk.addChild(fortheHead);
    fortheTrunk.addChild(fortheArmL);
    fortheTrunk.addChild(fortheArmR);
    fortheTrunk.addChild(fortheLegL);
    fortheTrunk.addChild(fortheLegR);
    //DEBUT CUBE
    //beginning of rotation
    TransformGroup objSpin=new TransformGroup();
    //create transform 3d for box which spin
    Transform3D T3DobjSpin = new Transform3D();
    T3DobjSpin.set(new Vector3f(-2.50f,.45f,0f));
    //create the child tranform group for the box which spin
    objSpin.setTransform(T3DobjSpin);
    //will allow to modify object while executing
    objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    //alpha rotation time related
    Alpha rotationAlpha=new Alpha(-1,900);
    Alpha transAlpha=new Alpha(-1,900);
    //transform 3d trans for the interpolatipon
    Transform3D trans=new Transform3D();
    //matrix for 2positions
    Point3f[] chemin=new Point3f[3];
    chemin[0]=new Point3f(-2.8f,0.40f,1.0f);
    chemin[1]=new Point3f(-0.8f,0.40f,1.0f);
    chemin[2]=new Point3f(-2.8f,0.40f,1.0f);
    //matrix of floats to make the dots match with timeline
    float[] timePosition={0.0f,0.50f,1.0f};
    PositionPathInterpolator interpol=new PositionPathInterpolator(transAlpha,objSpin,trans,timePosition,chemin);
    BoundingSphere bounds3=new BoundingSphere();
    interpol.setSchedulingBounds(bounds3);
    objSpin.addChild(interpol);
    //behviour for our rotation
    RotationInterpolator rotator= new RotationInterpolator(rotationAlpha,objSpin);
    // area where rotation will be
    BoundingSphere bounds=new BoundingSphere();
    rotator.setSchedulingBounds(bounds);
    objSpin.addChild(rotator);
    //end of rtotation
    //add transform group objspin to branchgroup humanoid
    Humanoid.addChild(objSpin);
    //test a cube which heritate of this rotation?
    objSpin.addChild(new ColorCube(0.25));
    //test
    //module cube + transparency
    // create an ALPHA transparency apparence (invisible)
    Appearance app0x=new Appearance();
    app0x.setColoringAttributes(new ColoringAttributes(new Color3f(0.3f,0.2f,1.0f),ColoringAttributes.SHADE_GOURAUD));
    app0x.setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.NICEST,0.5f));//0.5f represente 50% de transparence
    // create the blue sphere which rotate
    Transform3D transsphere=new Transform3D();
    transsphere.set(new Vector3f(0.0f, -0.1f, 0.3f));
    TransformGroup TGsphere=new TransformGroup(transsphere);
    TGsphere.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objSpin.addChild(TGsphere);
    //objRotatecube.addChild(TGsphere);
    TGsphere.addChild( new Sphere(0.3f,app0x) );
    //End Module Cube + Transparency
    //END CUBE
    //DEBUT WHOLE BIRD
    //beginning of Rotation for Bird
    TransformGroup Bird=new TransformGroup();
    //will allow to modify object while executing
    Bird.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    //alpha rotation time related
    Alpha rotationAlphaBird=new Alpha(-1,400);
    Alpha transAlphaBird=new Alpha(-1,5990);
    //transform 3d trans for the interpolatipon
    Transform3D transBird=new Transform3D();
    //create transform 3d for the Bird
    transBird.set(new Vector3f(1.90f,-.45f,0.9f));
    //create the child tranform group for the Bird Box
    Bird.setTransform(transBird);
    //matrix for 2positions
    Point3f[] cheminBird=new Point3f[3];
    cheminBird[0]=new Point3f(1.95f,0.0f,-6.8f);
    cheminBird[1]=new Point3f(1.95f,0.90f,-0.8f);
    cheminBird[2]=new Point3f(1.95f,0.0f,5.8f);
    //matrix of floats to make the dots match with timeline
    float[] timePositionBird={0.00f,0.50f,1.0f};
    PositionPathInterpolator interpolBird=new PositionPathInterpolator(transAlphaBird,Bird,transBird,timePosition,cheminBird);
    BoundingSphere bounds3Bird=new BoundingSphere();
    //BoundingSphere bounds3Bird= new BoundingSphere(new Point3d(0.0, 0.0, -50.0), 0.5);
    interpolBird.setSchedulingBounds(bounds3Bird);
    Bird.addChild(interpolBird);
    //behviour for our rotation
    RotationInterpolator rotatorBird= new RotationInterpolator(rotationAlphaBird,Bird);
    // area where rotation will be
    BoundingSphere boundsBird=new BoundingSphere();
    rotatorBird.setSchedulingBounds(boundsBird);
    Bird.addChild(rotatorBird);
    //end of rotation For Bird
    //add transform group objspin to branchgroup humanoid
    Humanoid.addChild(Bird);
    //debut test APPARENCE Wing Left
    //test textures
    // Configurer les couleurs
    Color3f blackx = new Color3f(0.0f, 0.0f, 0.0f);
    Color3f whitex = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f redx = new Color3f(0.7f, .75f, .75f);
    // Configurer la texture
    TextureLoader loaderx = new TextureLoader("C:\\java3d\\pois.jpg", "RGB", new Container());
    Texture texturex = loaderx.getTexture();
    texturex.setBoundaryModeS(Texture.WRAP);
    texturex.setBoundaryModeT(Texture.WRAP);
    texturex.setBoundaryColor( new Color4f( 0.0f, 1.0f, 0.0f, 0.0f ) );
    // Configurer les attributs de la texture
    // Param�tres possibles : REPLACE, BLEND ou DECAL (ici, MODULATE)
    TextureAttributes texAttrx = new TextureAttributes();
    texAttrx.setTextureMode(TextureAttributes.REPLACE);
    Appearance apx = new Appearance();
    apx.setTexture(texturex);
    apx.setTextureAttributes(texAttrx);
    //Configurer le mat�riau
    apx.setMaterial(new Material(redx, blackx, redx, blackx, 1.0f));
    int primflagsx = Primitive.GENERATE_NORMALS + Primitive.GENERATE_TEXTURE_COORDS;
    //End test APPARENCE Wing Left
    //test a cube which heritate of this rotation?
    // Bird.addChild(new ColorCube(0.8));
    //test bird body
    // Bird.addChild(new com.sun.j3d.utils.geometry.Box(.25f,.22f,.45f,
    // com.sun.j3d.utils.geometry.Box.GENERATE_NORMALS,new Appearance()));
    Bird.addChild(new com.sun.j3d.utils.geometry.Box(.25f,.22f,.45f, primflagsx,apx));
    //test WingRightBird
    //create a transform3D for the BirdWIngR
    Transform3D T3DBirdWingR = new Transform3D();
    T3DBirdWingR.set(new Vector3f(0.45f,.0f,-0.35f));
    //create the tranformgroup for the BirdWIngR
    TransformGroup BirdWingR = new TransformGroup();
    BirdWingR.setTransform(T3DBirdWingR);
    //add the child box to BirdWIngR
    // BirdWingR.addChild(new com.sun.j3d.utils.geometry.Box(.43f,.07f,.22f,
    // com.sun.j3d.utils.geometry.Box.GENERATE_NORMALS,new Appearance()));
    //End test WingRightBird
    ////////comments/////////
    //beginning of Rotating WINR
    //----------------------d�but de la cr�ation de la rotation--------------------------------
    TransformGroup WinRSpin=new TransformGroup();
    // permet de modifier l'objet pendant l'execution
    WinRSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    // on cr�e un fonction de rotation au cours du temps
    Alpha rotationAlphaWinRSpin=new Alpha(-1,1000);
    Transform3D rot = new Transform3D();
    rot.rotX((float)Math.PI/- 2.0f);
    //rot.rotX(-45);
    //rot.rotX((-Math.PI / 4.0)+30);
    //rot.rotZ((-Math.PI / 4.0));
    //rot.rotX(-Math.PI / 4.0);
    //rot.rotY(-Math.PI / 4.0);
    // rot.rotZ(-Math.PI / 4.0);
    // rot.rotY(00);
    //rot.rotZ(45);
    // on cr�e un comportement qui va appliquer la rotation � l'objet voulu
    // on d�finit la zone sur laquelle va s'appliquer la rotation
    //RotationInterpolator rotatorWinRSpin=new RotationInterpolator(rotationAlphaWinRSpin,WinRSpin, rot, 0.50f,(float)(2.0*Math.PI));
    RotationInterpolator rotatorWinRSpin=new RotationInterpolator(rotationAlphaWinRSpin,WinRSpin, rot, 25,26);
    BoundingSphere boundsWinRSpin=new BoundingSphere(new Point3d((Math.PI / 4.0), 0.0, 0.0), 0.5);
    // boundsWinRSpin.setCenter(new Point3d((Math.PI / 4.0),0,0));
    boundsWinRSpin.setCenter(new Point3d(-10,0,0));
    //boundsWinRSpin.setCenter();
    //test put a t3d to a boundingsphere??
    //Transform3D T3Dbounding = new Transform3D();
    // T3Dbounding.set(new Vector3f(5.00f,0.0f,0.00f));
    //WinRSpin.setTransform(T3Dbounding);
    //end test put a t3d to a boundingsphere, not working
    rotatorWinRSpin.setSchedulingBounds(boundsWinRSpin);
    // test BoundingSphere of BODY BIRD rotatorWinRSpin.setSchedulingBounds(boundsBird);
    WinRSpin.addChild(rotatorWinRSpin);
    //----------------------End de la cr�ation de la rotation--------------------------------
    BirdWingR.addChild(WinRSpin);
    // on cree un cube qui h�rite de la rotation
    //WinRSpin.addChild(new ColorCube(0.5));// de rayon 50 cm
    WinRSpin.addChild(new com.sun.j3d.utils.geometry.Box(.43f,.07f,.22f, primflagsx,apx));
    //End of Rotating WINR
    //////// END comments/////////
    //I commented the following, that was the TEST sinusoidal, rotation which help me understood how to rotate wingR
    // -----------d�but de cr�ation de la rotation--------------------------------------------------
    TransformGroup objSpinxx=new TransformGroup();
    // permet de modifier l'objet pendant l'execution
    objSpinxx.setCapability(TransformGroup.ALL

    Thank you very much!
    I cant believe this little comment has been so helpful!
    But yes it is:
    I explain, despite my efforts to find, googled it, forums, faqs, etc...
    no where it mentionned the manifest.fm file is... INSIDE the .jar!
    Your comment "a zip" made me attempt to open it with winrar, and I found a manifest.fm file inside!
    So far I was editing the one at the "source" of my project and rebuilding it with netbeans.
    I am going to try that now.
    Actually.... :( no its mentionning my main class!
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.0
    Created-By: 10.0-b19 (Sun Microsystems Inc.)
    Main-class: courseworkjava3d.Simple3D
    Class-Path:
    X-COMMENT: Main-Class will be added automatically by buildWell I have no problems uploading you the .jar, it is for a coursework it is not a private project or whatever:
    http://www.uploading.com/files/CM2LKWYU/BetaCourseworkJava3d_Final.jar.html
    Oh and I felt on your comment "dont ask us" as if I was suppose to know... i'm a beginner, I did not know that! And I tried to give you so many infos so you dont lose your time if you want to help, especially as after my own research I found many, many results for this "main class" and I tried a few solutions!
    Edited by: CupofTea on Apr 13, 2008 3:28 AM

  • Need help with finding picture size

    ok here is  my problem i have this sphere and it works great except when you click the thumbnails to display the picture, depending on the size of the picture, the pictures can get pushed to far over, and i understand why. the x and y coord never change. now my idea is to get the size of picture and use that to adjust the x-coord accordingly. my question is. how do i get the picture size? if i can. do the pictures have to be in the fla?
    heres code:
    The radius of the sphere, 'rad'. You can change it if you wish
    especially if you use thumbnails of a different size than our thumbnails.
    var rad:Number=380;
    The position of 'board' that will be defined later. 'board' is the main
    container containing the sphere and the black background
    that reponds to mouse actions.
    var posX:Number=stage.stageWidth/2;
    var posY:Number=stage.stageHeight/2;
    The size of thumbnails. Change the values to reflect the size of your
    images.
    var thumbWidth:Number=70;
    var thumbHeight:Number=53;
    The thumbnail images have been imported to the Library and linked to AS3
    under the names 'Small1', 'Small2',....,'Small46'. The corresponding
    Bitmap objects will be stored in the array 'thumbsArray'.
    var thumbsArray:Array=[];
    The addresses of the images corresponding to the thumbnails are stored
    in 'picsArray'. The images will be loaded at runtime when the user
    clicks on each thumbnail.
    var picsArray:Array=[];
    The Bitmap object corresponding to each thumbnail will be placed
    in a Sprite, holdersArray[i][j], as its child. We have to do this
    to make thumbnails responsive to mouse clicks.
    var holdersArray:Array=[];
    In order to depth-sort images on the sphere, we will need to keep
    track of their midpoints and the position of each midpoint in 3D.
    The midpoints will be stored in 'midsArray'.
    var midsArray:Array=[];
    The only part of our spherical menu that is hard-wired (and a bit harder
    to customize) is the number of thumbnails and their placement on the sphere.
    We have 46 thumbnails placed along 7 horizontal 'circles' on the sphere.
    The 'jLen' vector describes the number of thumbnails on each circle.
    The first 'circle' is the north pole and contains 1 image; the second
    is the circle corresponding to the vertical angle of 30 degrees
    from the negative y axis. That circle contains 6 images. The next one,
    at 60 degree of vertical displacement contains 10 images;
    the one after that, at 90 degrees from the negative y axis, is the equador
    of the sphere and contains 12 images. Past that, we go symmetrically:
    10, 6, and 1 image at the south pole.
    All our arrays are organized to reflect that placement of thumbnails.
    For example, thumbsArray is an array of arrays, thumbsArray[i], where
    i corresponds to the number of each circle. thumbsArray[i][j] is the
    j-th image on the i-th of the seven circles.
    var jLen:Vector.<Number>=new Vector.<Number>();
    jLen=Vector.<Number>([1,6,10,12,10,6,1]);
    We use the almost standard parametrization of a sphere:
    phi is the vertical angle measured from the vertical axis
    pointing upwards (in Flash's coordinate system this is the negative
    y-axis), theta is the horizontal angle measured from the
    horizontal axis pointing away from the screen; that is,
    the negative z-axis. phi changes from 0 to 90 degrees,
    theta from 0 to 360 degrees. For each circle, phi is constant:
    0, 30, 60, 90, 120, 150, 180. 'thetaStep' contains the angular
    distances between thumbnails on each circle. Except
    for the north and the south pole, for each circle
    the angular distance between thumbnails equals to 360 divided
    by the number of thumbnails on the circle.
    var thetaStep:Vector.<Number>=new Vector.<Number>();
    thetaStep=Vector.<Number>([0,60,36,30,36,60,0]);
    //The vertical angle between circles.
    var phiStep:Number=30;
    To make images tangent to the sphere, we need to tilt them
    vertically and horizontally. Horizontal tilt is always
    equal to the theta angle of the midpoint
    of the image and changes along each circle;
    the vertical tilt is based on the values
    of phi and is constant for each circle of thumbnails.
    var phiTilt:Vector.<Number>=new Vector.<Number>();
    phiTilt=Vector.<Number>([-90,-60,-30,0,30,60,90]);
    //The next four variables are related to auto-rotation
    //and rotation by the user.
    var autoOn:Boolean=true;
    var manualOn:Boolean=false;
    var prevX:Number;
    var prevY:Number;
    //The amount of perpective distortion. Higher values give more distortion.
    //Values have to be between 0 and 180 as they correspond to the view angle.
    this.transform.perspectiveProjection.fieldOfView=70;
    //We define and position the container 'board'.
    var board:Sprite=new Sprite();
    this.addChild(board);
    board.x=posX;
    board.y=posY;
    //We call the function that draws the border and the background
    //of 'board'.
    drawBoard();
    //Settings for our dynamic text boxes present on the Stage.
    infoBox.mouseEnabled=false;
    infoBox.wordWrap=true;
    infoBox.text="";
    loadBox.mouseEnabled=false;
    loadBox.wordWrap=true;
    loadBox.text="";
    loadBox.visible=false;
    When the user double-clicks on a thumbnail, the corresponding image
    will be loaded into 'loader' - an instance of the Loader class.
    'loader' is a child of the Sprite, 'photoHolder', which is a child
    of the MainTimeline.
    var photoHolder:Sprite=new Sprite();
    this.addChild(photoHolder);
    photoHolder.x=200;
    photoHolder.y=100;
    var loader:Loader=new Loader();
    photoHolder.addChild(loader);
    photoHolder.visible=false;
    We will literally 'build' a shere of thumbnails by positioning
    them in a Sprite called 'spSphere'. The moment we assign
    any of the 3D properties to 'spSphere', for example a value for the z coordinate,
    spSphere becomes a 3D container. That means we can place elements in it
    in 3D. We will also be able to apply 3D methods to 'spSphere', e.g. rotations.
    When 'spSphere' becomes a 3D display object, it has transfrom.matrix3D property.
    The latter property holds all the information about the current 3D state
    of 'spSphere'.
    var spSphere:Sprite=new Sprite();
    board.addChild(spSphere);
    spSphere.x=0;
    spSphere.y=0;
    //We move 'spSphere' backwards to avoid distortion of the front thumbnails.
    //You can experiment with different values for the z coordinate.
    spSphere.z=rad;
    //We call several functions defined later in the script.
    //They names tell it all.
    setUpPics();
    buildSphere();
    spSphere.rotationY=0;
    spSphere.rotationX=0;
    spSphere.rotationZ=0;
    spSphere.filters=[new GlowFilter(0x666666,1.0,6.0,6.0,2)];
    rotateSphere(0,0,0);
    setUpListeners();
    //The function that draws the black rectangle behind our sphere.
    //You can change the values below to change the size and the color
    //of the background. Those values do not affect the sphere itself.
    function drawBoard():void {
          board.graphics.clear();
          board.graphics.lineStyle(0,0x333333);
          board.graphics.beginFill(0x000000, 0);
          board.graphics.drawRect(-640,-490,1180,1080);
          board.graphics.endFill();
    //We add all the necassary listeners. They are self-explanatory.
    //Note that holdersArray[i][j] is the Sprite that contains the
    //j-th thumbnail on the i-th circle.
    function setUpListeners():void {
              var i:int;
              var j:int;
              this.addEventListener(Event.ENTER_FRAME,autoRotate);
              board.addEventListener(MouseEvent.ROLL_OUT,boardOut);
              board.addEventListener(MouseEvent.MOUSE_MOVE,boardMove);
              board.addEventListener(MouseEvent.MOUSE_DOWN,boardDown);
              board.addEventListener(MouseEvent.MOUSE_UP,boardUp);
              loader.contentLoaderInfo.addEventListener(Event.COMPLETE,doneLoad);
              loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,loadingError);
              photoHolder.addEventListener(MouseEvent.CLICK,holderClicked);
             for(i=0;i<7;i++){
                for(j=0;j<jLen[i];j++){
                    holdersArray[i][j].doubleClickEnabled=true;
                    holdersArray[i][j].addEventListener(MouseEvent.DOUBLE_CLICK,picClicked);
    The functions that are executed in response to events to which we listen.
    The next one runs when a loaded picture is clicked.
    function holderClicked(e:MouseEvent):void {
        board.visible=true;
        photoHolder.visible=false;
        infoBox.text="";
        manualOn=false;
        autoOn=true;
    'picClicked' is executed when any of the thumbnails is double-clicked.
    Note that in the function 'buildSphere' below, we assigned names to
    all holders, holderArray[i][j]. We need those names now to know
    which thumbnail was clicked and which image to load.
    function picClicked(e:MouseEvent):void {
        var targName:String="Double Click Image To View";
        var i:int;
        var j:int;
        targName=e.currentTarget.name;
        i=int(targName.charAt(3));
        j=int(targName.substring(5,targName.length));
        board.visible=false;
        loader.load(new URLRequest(picsArray[i][j]));
        infoBox.text="";
        loadBox.text="Loading...";
        loadBox.visible=true;
    function loadingError(e:IOErrorEvent):void {
        loadBox.text="There has been an error loading the image. The server may be busy. Refresh the page and try again.";
    function doneLoad(e:Event):void {
        infoBox.text="Click the image to close it.";
        photoHolder.visible=true;
        loadBox.text="";
        loadBox.visible=false;
    //Listeners responsible for mouse rotations and auto-rotation.
    function autoRotate(e:Event):void {
             if(autoOn && !manualOn){
                 spSphere.transform.matrix3D.prependRotation(-0.5,Vector3D.Y_AXIS);
                 zSortPics();
    function boardOut(e:MouseEvent):void {
                autoOn=true;
                manualOn=false;
    function boardDown(e:MouseEvent):void {           
                prevX=board.mouseX;
                prevY=board.mouseY;
                autoOn=false;
                manualOn=true;
    function boardUp(e:MouseEvent):void {
                manualOn=false;
         function boardMove(e:MouseEvent):void {
                    var locX:Number=prevX;
                    var locY:Number=prevY;
                    if(!autoOn && manualOn){
                    prevX=board.mouseX;
                    prevY=board.mouseY;
                    rotateSphere(prevY-locY,-(prevX-locX),0);
                    e.updateAfterEvent();
    The function setUpPics populates the arrays thumbsArray and picsArray.
    Note the organization of thumbnails by circles on which they reside:
    thumbsArray[0] - the north pole, thumbsArray[1] thumbnails of the first circle
    down from the north pole, etc. 'picsArray' is organized similarly.
    You can, of course, subsitute your own images, use thumbnails of
    dimensions different from ours. Changing the number of thumbnails and their organization
    would, however, require rewritting the script a bit.
    function setUpPics():void {
        thumbsArray[0]=[new Bitmap(new Small1(70,46))];
        picsArray[0]=["pic1.jpg"];
        thumbsArray[1]=[new Bitmap(new Small2(70,105)),new Bitmap(new Small3(70,105)),new Bitmap(new Small4(70,53)),new Bitmap(new Small5(70,53)),new Bitmap(new Small6(70,53)),new Bitmap(new Small7(70,53))];
        picsArray[1]=["pic2.jpg","pic3.jpg","pic4.jpg","pic5.jpg","pic6.jpg","pic7.jpg"];
        thumbsArray[2]=[new Bitmap(new Small8(70,53)),new Bitmap(new Small9(70,53)),new Bitmap(new Small10(70,53)),new Bitmap(new Small11(70,53)),new Bitmap(new Small12(70,53)),new Bitmap(new Small13(70,53)),new Bitmap(new Small14(70,53)),new Bitmap(new Small15(70,53)),new Bitmap(new Small16(70,53)),new Bitmap(new Small17(70,53))];
        picsArray[2]=["pic8.jpg","pic9.jpg","pic10.jpg","pic11.jpg","pic12.jpg","pic13.jpg","pic1 4.jpg","pic15.jpg","pic16.jpg","pic17.jpg"];
        thumbsArray[3]=[new Bitmap(new Small18(70,53)),new Bitmap(new Small19(70,53)),new Bitmap(new Small20(70,53)),new Bitmap(new Small21(70,53)),new Bitmap(new Small22(70,53)),new Bitmap(new Small23(70,53)),new Bitmap(new Small24(70,53)),new Bitmap(new Small25(70,53)),new Bitmap(new Small26(70,53)),new Bitmap(new Small27(70,53)),new Bitmap(new Small28(70,53)),new Bitmap(new Small29(70,53))];
        picsArray[3]=["pic18.jpg","pic19.jpg","pic20.jpg","pic21.jpg","pic22.jpg","pic23.jpg","pi c24.jpg","pic25.jpg","pic26.jpg","pic27.jpg","pic28.jpg","pic29.jpg"];
        thumbsArray[4]=[new Bitmap(new Small30(70,53)),new Bitmap(new Small31(70,53)),new Bitmap(new Small32(70,53)),new Bitmap(new Small33(70,53)),new Bitmap(new Small34(70,53)),new Bitmap(new Small35(70,53)),new Bitmap(new Small36(70,53)),new Bitmap(new Small37(70,53)),new Bitmap(new Small38(70,53)),new Bitmap(new Small39(70,53))];
        picsArray[4]=["pic30.jpg","pic31.jpg","pic32.jpg","pic33.jpg","pic34.jpg","pic35.jpg","pi c36.jpg","pic37.jpg","pic38.jpg","pic39.jpg"];
        thumbsArray[5]=[new Bitmap(new Small40(70,53)),new Bitmap(new Small41(70,53)),new Bitmap(new Small42(70,53)),new Bitmap(new Small43(70,53)),new Bitmap(new Small44(70,53)),new Bitmap(new Small45(70,53))];
        picsArray[5]=["pic40.jpg","pic41.jpg","pic42.jpg","pic43.jpg","pic44.jpg","pic45.jpg"];
        thumbsArray[6]=[new Bitmap(new Small46(70,53))];
        picsArray[6]=["pic46.jpg"];
    In the next function we actually create a 3D sphere of thumbnails by positioning
    them in 3D within spSphere. Note the center of the sphere is at (0,0,0) of
    spSphere. It might be worth recalling that with our interpretation of
    phi and theta each point P=(x,y,z) on the sphere corresponding to given values
    of phi and theta is given by:
    x = rad * sin(phi) * sin(theta),
    y = -rad * cos(phi),
    z = -rad * sin(phi) * cos(theta).
    Within the function, we populate 'holdersArray' and 'midsArray'. We assign thumbnails
    to holdersArray elements, position holdersArray elements, tilt them, give them names.
    We literally build our sphere.
    function buildSphere():void {
        var i:int;
        var j:int;
        var tStep:Number;
        var pStep:Number=phiStep*Math.PI/180;
        for(i=0;i<7;i++){
            holdersArray[i]=[];
            midsArray[i]=[];
            tStep=thetaStep[i]*Math.PI/180;
            for(j=0;j<jLen[i];j++){
                midsArray[i][j]=new Vector3D(rad*Math.sin(i*pStep)*Math.sin(j*tStep),-rad*Math.cos(i*pStep),-rad*Math.sin(i*p Step)*Math.cos(j*tStep));
                holdersArray[i][j]=new Sprite();
                holdersArray[i][j].name="pic"+String(i)+"_"+String(j);
                holdersArray[i][j].addChild(thumbsArray[i][j]);
                thumbsArray[i][j].x=-thumbWidth/2;
                thumbsArray[i][j].y=-thumbHeight/2;
                spSphere.addChild(holdersArray[i][j]);
                holdersArray[i][j].x=midsArray[i][j].x;
                holdersArray[i][j].y=midsArray[i][j].y;
                holdersArray[i][j].z=midsArray[i][j].z;
                holdersArray[i][j].rotationX=phiTilt[i];
                holdersArray[i][j].rotationY=-j*thetaStep[i];
          zSortPics();
    'zSortPics' depth-sorts all thumbnails corresponding to each view of
    the sphere. It sorts thumbnails by removing them (or more precisely
    their holders, holdersArray[i][j], as children of spSphere and then reassigning
    them based on the z-coordinates of their midpoints.
    function zSortPics():void {
        var distArray:Array=[];
        var dist:Number;
        var i:int;
        var j:int;
        var k:int;
        var curMatrix:Matrix3D;
        var curMid:Vector3D;
        curMatrix=spSphere.transform.matrix3D.clone();
        while(spSphere.numChildren>0){
            spSphere.removeChildAt(0);
            for(i=0;i<7;i++){
                for(j=0;j<jLen[i];j++){
                curMid=curMatrix.deltaTransformVector(midsArray[i][j]);
                dist=curMid.z;
                distArray.push([dist,i,j]);
          distArray.sort(byDist);
          for(k=0;k<distArray.length;k++){
              spSphere.addChild(holdersArray[distArray[k][1]][distArray[k][2]]);
              holdersArray[distArray[k][1]][distArray[k][2]].alpha=Math.max(k/(distArray.length-1),0.5) ;
    function byDist(v:Array,w:Array):Number {
         if (v[0]>w[0]){
            return -1;
          } else if (v[0]<w[0]){
            return 1;
           } else {
            return 0;
    The function that rotates the sphere in response to the user moving the mouse.
    Note we are setting the z coordinate to 0 before rotation. Otherwise,
    the non-zero translation coefficients produce undesirable effects.
    Note also that we do not use this function in 'autoRotate'. That is because
    when the sphere auto-rotates we want it to revolve about is pole-to-pole
    axis. That means prepending rather than appending rotation.
    See the function 'autoRotate' above.
    function rotateSphere(rotx:Number,roty:Number,rotz:Number):void {
          spSphere.z=0;
          spSphere.transform.matrix3D.appendRotation(rotx,Vector3D.X_AXIS);
          spSphere.transform.matrix3D.appendRotation(roty,Vector3D.Y_AXIS);
          spSphere.transform.matrix3D.appendRotation(rotz,Vector3D.Z_AXIS);
          spSphere.z=rad;
          zSortPics();

    I won't be searching thru all that code to try to find something relevant to your post, but if you are using a Loader to load the images, you can get the width and height as soon as the loading is complete using the loader object (loader.width, loader.height).  You just need to wait until loading is complete, so you'll need a listener for that if you don't have one already.

  • Changing position at runtime

    I have an object in my java application, and I would like it to move to x,y, and z coordinates that are constantly changed. The problem is that createSceneGraph seems to be called only once, it isn't a constantly updating thing. Here is the code I have so far, does anyone have any ideas on how I could implement this?
    The HeliListener interface calls onUpdate(Heli) whenever the position is changed.
    import java.awt.GraphicsConfiguration;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.net.MalformedURLException;
    import java.net.URL;
    import javax.media.j3d.AmbientLight;
    import javax.media.j3d.Background;
    import javax.media.j3d.BoundingSphere;
    import javax.media.j3d.BranchGroup;
    import javax.media.j3d.Canvas3D;
    import javax.media.j3d.DirectionalLight;
    import javax.media.j3d.Transform3D;
    import javax.media.j3d.TransformGroup;
    import javax.vecmath.Color3f;
    import javax.vecmath.Point3d;
    import javax.vecmath.Vector3f;
    import org.Heli;
    import org.HeliListener;
    import com.sun.j3d.loaders.IncorrectFormatException;
    import com.sun.j3d.loaders.ParsingErrorException;
    import com.sun.j3d.loaders.Scene;
    import com.sun.j3d.loaders.objectfile.ObjectFile;
    import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
    import com.sun.j3d.utils.behaviors.mouse.MouseTranslate;
    import com.sun.j3d.utils.behaviors.mouse.MouseZoom;
    import com.sun.j3d.utils.geometry.ColorCube;
    import com.sun.j3d.utils.geometry.Sphere;
    import com.sun.j3d.utils.universe.PlatformGeometry;
    import com.sun.j3d.utils.universe.SimpleUniverse;
    import com.sun.j3d.utils.universe.ViewingPlatform;
    public class ObjLoad implements HeliListener {
        private double creaseAngle = 60.0;
        private URL filename = null;
        private SimpleUniverse u;
        private BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 600.0);
        TransformGroup objTrans;
        BranchGroup objRoot;
        protected Canvas3D c;
        //x, y, and z coordinates of Helicopter
        private float   x=0,
                            y=0,
                            z=1;
        private static boolean isFreeLook = true;
        public BranchGroup createSceneGraph()
              // Create the root of the branch graph
              objRoot = new BranchGroup();
            // Create a Transformgroup to scale all objects so they
            // appear in the scene.
            TransformGroup objScale = new TransformGroup();
            Transform3D t3d = new Transform3D();
            t3d.setScale(0.7);
            objScale.setTransform(t3d);
            objRoot.addChild(objScale);
              // Create the transform group node and initialize it to the
              // identity.  Enable the TRANSFORM_WRITE capability so that
              // our behavior code can modify it at runtime.  Add it to the
              // root of the subgraph.
              objTrans = new TransformGroup();
              objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
              objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
              objScale.addChild(objTrans);
              int flags = ObjectFile.RESIZE;
              flags |= ObjectFile.TRIANGULATE;
              //flags |= ObjectFile.STRIPIFY;
              ObjectFile f = new ObjectFile(flags, (float)(creaseAngle * Math.PI / 180.0));
              Scene s = null;
              //Try to load the model
              try {
                s = f.load(filename);
              catch (FileNotFoundException e) {
                System.err.println(e);
                System.exit(1);
              catch (ParsingErrorException e) {
                System.err.println(e);
                System.exit(1);
              catch (IncorrectFormatException e) {
                System.err.println(e);
                System.exit(1);
              //Add the model
              objTrans.addChild(s.getSceneGroup());
              //Get the black and green grid and add it.
              MapGrid grid = new MapGrid();
              objRoot.addChild(grid.getGrid());
            //Create the background sphere that contains everything. default color is black
            Background bg = new Background();
            bg.setApplicationBounds(bounds);
            BranchGroup backGeoBranch = new BranchGroup();
            Sphere sphereObj = new Sphere(1.0f, Sphere.GENERATE_NORMALS |
                             Sphere.GENERATE_NORMALS_INWARD |
                          Sphere.GENERATE_TEXTURE_COORDS, 45);
            backGeoBranch.addChild(sphereObj);
            bg.setGeometry(backGeoBranch);
            objTrans.addChild(bg);
            //Sets a transform3D so we can modify the placement of the helicopter
              Transform3D yAxis = new Transform3D();
              objTrans.getTransform(yAxis);
              Vector3f v3f = new Vector3f(x,z,y);
              yAxis.set(v3f);
              objTrans.setTransform(yAxis);
              objRoot.compile();
              return objRoot;
        public ObjLoad(Heli heli)
             heli.addListener(this);
             //Try to get the full filename
              if (filename == null)
                  try
                      String path = new File("").getAbsolutePath();
                      filename = new URL("file://" + path + "/models/Helicopter.obj");
                  catch (MalformedURLException e)
                       System.err.println(e);
                       System.exit(1);
             GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
             c = new Canvas3D(config);
              // Create a simple scene and attach it to the virtual universe
              BranchGroup scene = createSceneGraph();
              u = new SimpleUniverse(c);
            // This will move the ViewPlatform back a bit so the
            // objects in the scene can be viewed.
              ViewingPlatform viewingPlatform = u.getViewingPlatform();
              viewingPlatform.setNominalViewingTransform();
            TransformGroup viewTrans = viewingPlatform.getViewPlatformTransform();
               * The following code sets up the scene lighting
                        //Setup the scene geometry for the lights
                        PlatformGeometry pg = new PlatformGeometry();
                        // Set up the ambient light
                        Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f);
                        AmbientLight ambientLightNode = new AmbientLight(ambientColor);
                        ambientLightNode.setInfluencingBounds(bounds);
                        pg.addChild(ambientLightNode);
                        ambientLightNode.setInfluencingBounds(bounds);
                        // Set up the direction and color of directional lights
                        Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f);
                        Vector3f light1Direction  = new Vector3f(1.0f, 1.0f, 1.0f);
                        Color3f light2Color = new Color3f(1.0f, 1.0f, 1.0f);
                        Vector3f light2Direction  = new Vector3f(-1.0f, -1.0f, -1.0f);
                        //Make the first light
                        DirectionalLight light1
                            = new DirectionalLight(light1Color, light1Direction);
                        light1.setInfluencingBounds(bounds);
                        pg.addChild(light1);
                        //Make the second light
                        DirectionalLight light2
                            = new DirectionalLight(light2Color, light2Direction);
                        light2.setInfluencingBounds(bounds);
                        pg.addChild(light2);
              //Add the Platform geometry (containing the lights) to the viewing platform
              viewingPlatform.setPlatformGeometry( pg );
              // This will move the ViewPlatform back a bit so the
              // objects in the scene can be viewed.
              viewingPlatform.setNominalViewingTransform();
              //Create a branchgroup for the mouse movement
              BranchGroup mouseGroup = new BranchGroup();
              if(isFreeLook){
                   //Create the rotate behavior node
                 MouseRotate behavior1 = new MouseRotate(viewTrans);
                 behavior1.setSchedulingBounds(bounds);
                 System.out.println(behavior1.getXFactor() + "  "+behavior1.getYFactor());
                 //Mouse becomes hard to control with default factor, so we scale it down a little, default is .03
                 behavior1.setFactor(.001,.001);
                 mouseGroup.addChild(behavior1);
                 // Create the zoom behavior node
                 MouseZoom behavior2 = new MouseZoom(viewTrans);
                 behavior2.setSchedulingBounds(bounds);
                 mouseGroup.addChild(behavior2);
                 // Create the translate behavior node
                 MouseTranslate behavior3 = new MouseTranslate(viewTrans);
                 behavior3.setSchedulingBounds(bounds);
                 mouseGroup.addChild(behavior3);
              else //(is Centered view)
            mouseGroup.compile();
            scene.compile();
            u.addBranchGraph(scene);
            u.addBranchGraph(mouseGroup);
         public Canvas3D getCanvas() {
              return c;
         public void onUpdate(Heli heli)
            x = heli.getState().x;
            y = heli.getState().y;
            z = heli.getState().z;
            update(9,9,3);
            System.out.println("Entered...");
         public void update(float x, float y, float z){
              objRoot.removeChild(objTrans);
              objTrans = null;
              Transform3D yAxis = new Transform3D();
              objTrans.getTransform(yAxis);
              Vector3f v3f = new Vector3f(x, z, y);
              yAxis.set(v3f);
              objTrans.setTransform(yAxis);
              objRoot.addChild(objTrans);
    }Thanks for any help!

    and I would like it to move to x,y, and z coordinates that are constantly changedYou need to implement a Behavior and attach it to a Node that is a parent to the objects you want to animate. The Behavior framework is really easy to implement and for your implementation you might like to try a WakeupCriterion Object, ie WakeupOnElapsedFrames(0), and keep track of the position in a Transform.
    The Behavior leaf node provides a framework for adding user-defined actions into the scene graph. Behavior is an abstract class that defines two methods that must be overridden by a subclass: An initialization method, called once when the behavior becomes "live," and a processStimulus method called whenever appropriate by the Java 3D behavior scheduler. The Behavior node also contains an enable flag, a scheduling region, a scheduling interval, and a wakeup condition.
    See the javadoc for javax.media.j3d.Behavior. You might like to look at Alpha as well.
    Hope that helps you out.
    regards

  • Texture in a box - problem(wrong colours)

    hello guys I want to create a box with a texture of chess board on top of it, but the problem is that it loads just a dark blue colour surface instead of blue and white squares surface,feel free to check what I mean, here is what the program shows
    http://img97.imageshack.us/i/checkes.png/
    and here the original texture I want to put in the box
    http://img266.imageshack.us/i/arizonae.jpg/
    here also is my code
    import com.sun.j3d.utils.behaviors.keyboard.KeyNavigatorBehavior;
    import javax.media.j3d.Transform3D;
    import javax.swing.JFrame;
    import java.awt.*;
    import javax.swing.*;
    import javax.media.j3d.Canvas3D;
    import com.sun.j3d.utils.universe.SimpleUniverse;
    import javax.media.j3d.BranchGroup;
    import com.sun.j3d.utils.geometry.Box;
    import com.sun.j3d.utils.image.TextureLoader;
    import javax.vecmath.*;
    import javax.media.j3d.DirectionalLight;
    import javax.media.j3d.BoundingSphere;
    import javax.media.j3d.Appearance;
    import javax.media.j3d.ImageComponent2D;
    import javax.media.j3d.Material;
    import javax.media.j3d.Texture;
    import javax.media.j3d.Texture2D;
    import javax.media.j3d.TransformGroup;
    import com.sun.j3d.utils.behaviors.mouse.*;
    public class vrlm extends JFrame {
    * The SimpleUniverse object
    protected SimpleUniverse simpleU;
    * The root BranchGroup Object.
    protected BranchGroup rootBranchGroup;
    * Constructor that consturcts the window with the given name.
    * @param name
    * The name of the window, in String format
    public vrlm(String name) {
    // The next line will construct the window and name it
    // with the given name
    super(name);
    // Perform the initial setup, just once
    initial_setup();
    * Perform the essential setups for the Java3D
    protected void initial_setup() {
    // A JFrame is a Container -- something that can hold
    // other things, e.g a button, a textfield, etc..
    // however, for a container to hold something, you need
    // to specify the layout of the storage. For our
    // example, we would like to use a BorderLayout.
    // The next line does just this:
    getContentPane().setLayout(new BorderLayout());
    // The next step is to setup graphics configuration
    // for Java3D. Since different machines/OS have differnt
    // configuration for displaying stuff, therefore, for
    // java3D to work, it is important to obtain the correct
    // graphics configuration first.
    GraphicsConfiguration config = SimpleUniverse
    .getPreferredConfiguration();
    // construct the canvas.
    Canvas3D canvas3D = new Canvas3D(config);
    // And we need to add the "canvas to the centre of our
    // window..
    getContentPane().add("Center", canvas3D);
    // Creates the universe
    simpleU = new SimpleUniverse(canvas3D);
    // First create the BranchGroup object
    rootBranchGroup = new BranchGroup();
    * Adds a light source to the universe
    * @param direction
    * The inverse direction of the light
    * @param color
    * The color of the light
    public void addDirectionalLight(Vector3f direction, Color3f color) {
    // Creates a bounding sphere for the lights
    BoundingSphere bounds = new BoundingSphere();
    bounds.setRadius(1000d);
    // Then create a directional light with the given
    // direction and color
    DirectionalLight lightD = new DirectionalLight(color, direction);
    lightD.setInfluencingBounds(bounds);
    // Then add it to the root BranchGroup
    rootBranchGroup.addChild(lightD);
    * Adds a box to the universe
    * @param x
    * x dimension of the box
    * @param y
    * y dimension of the box
    * @param z
    * z dimension of the box
    Appearance vasixrwma(){
         Appearance vasixrwmaa = new Appearance();
    //load the texture
         String filename = "C:/Documents and Settings/Andy/Desktop/Arizona.jpg";
         TextureLoader loader = new TextureLoader(filename, this);
    ImageComponent2D image = loader.getImage();
    if(image == null) {
    System.out.println("load failed for texture: "+filename);
    Texture2D texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA,
    image.getWidth(), image.getHeight());
    texture.setEnable(true);
    texture.setImage(0, image);
    texture.setMagFilter(Texture.BASE_LEVEL_LINEAR);
    texture.setMinFilter(Texture.BASE_LEVEL_LINEAR);
    vasixrwmaa.setTexture(texture);
         return vasixrwmaa;
    public void addBox(float x, float y, float z, Color3f diffuse, Color3f spec, float a, float b, float c) {
    // Add a box with the given dimension
    // First setup an appearance for the box
    Appearance app = new Appearance();
    Material mat = new Material();
    mat.setDiffuseColor(diffuse);
    mat.setSpecularColor(spec);
    mat.setShininess(5.0f);
    app.setMaterial(mat);
    Box box = new Box(x, y, z, app);
    // Create a TransformGroup and make it the parent of the box
    Transform3D meros = new Transform3D();
    meros.setTranslation(new Vector3d(a, b, c));
    TransformGroup tg = new TransformGroup(meros);
    Appearance appear = vasixrwma();
    box.getShape(Box.TOP).setAppearance(appear);
    tg.addChild(box);
    // Then add it to the rootBranchGroup
    rootBranchGroup.addChild(tg);
    //code for mouse navigation
    tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    MouseRotate myMouseRotate = new MouseRotate();
    myMouseRotate.setTransformGroup(tg);
    myMouseRotate.setSchedulingBounds(new BoundingSphere());
    rootBranchGroup.addChild(myMouseRotate);
    MouseTranslate myMouseTranslate = new MouseTranslate();
    myMouseTranslate.setTransformGroup(tg);
    myMouseTranslate.setSchedulingBounds(new BoundingSphere());
    rootBranchGroup.addChild(myMouseTranslate);
    MouseZoom myMouseZoom = new MouseZoom();
    myMouseZoom.setTransformGroup(tg);
    myMouseZoom.setSchedulingBounds(new BoundingSphere());
    rootBranchGroup.addChild(myMouseZoom);
    // new code for key navigation
    KeyNavigatorBehavior keyNavBeh = new KeyNavigatorBehavior(tg);
    keyNavBeh.setSchedulingBounds(new BoundingSphere(new Point3d(),1000.0));
    rootBranchGroup.addChild(keyNavBeh);
    * Finalise everything to get ready
    public void finalise() {
    // Then add the branch group into the Universe
    simpleU.addBranchGraph(rootBranchGroup);
    // And set up the camera position
    simpleU.getViewingPlatform().setNominalViewingTransform();
    public static void main(String[] argv) {
    vrlm bc = new vrlm("checkers");
    bc.setSize(250, 250);
    bc.addBox(10f, 10f, 10f, new Color3f(0.8f, 0.52f, 0.25f), new Color3f(0.8f, 0.52f, 0.25f), 0.7f, -0.0415f, 0.7f);
    bc.addDirectionalLight(new Vector3f(0f, 0f, -1),
    new Color3f(4f, 4f, 0f));
    bc.finalise();
    bc.show();
    return;
    please everyone's help is appreciated, because its urgent, thank you very much!!!!

    Dave,
    You won't need that hovering window next time!
    Jerry

  • Is this even possible? (Rotation question)

    Hi! I'm new to Java 3D... What I am trying to do is to rotate one transform group around another transform group. i.e. get a moon spinning the earth does anyone know how to do this? I am posting my code below.... I've searched the forums already and alas found no answer :( I've tried everything as you can see from the bottom of the code where all the "garbage" is. The actual earth has been commented out so that I can see the moon. Any help would be greatly appreiciated!! Thank you in advance! -JET
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.JFrame;
    import java.awt.GraphicsConfiguration;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.geometry.*;
    import com.sun.j3d.utils.image.TextureLoader;
    class System2 extends JFrame // implements ActionListener
         //a SimpleUniverse is used for this program
         System2() //constructor executes Program
              JFrame view = new JFrame("Program");
              view.setSize(800,600);
              GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
              Canvas3D c = new Canvas3D(config);
              Container cp = view.getContentPane();
              cp.add(c);
              SimpleUniverse u = new SimpleUniverse(c);          
              BranchGroup run = createSceneGraph();
              u.addBranchGraph(run);
              u.getViewingPlatform( ).setNominalViewingTransform( );
              view.setVisible(true);
         public BranchGroup createSceneGraph()
              //define Colors
              Color3f yellow = new Color3f(0.9f, 0.8f, 0.0f);
              Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f);
              Color3f white      = new Color3f(1.0f,1.0f,1.0f);     
              Color3f nullCol = new Color3f(0.0f,0.0f,0.0f);
              Color3f earthDiff = new Color3f(0.49f,0.34f,0);
              Color3f earthSpec = new Color3f(0.89f,0.79f,0);
              // Create a bounds for the background and lights
              BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
              //create BranchGroup
              BranchGroup root = new BranchGroup();
              // Set up the background
              Background bg = new Background(bgColor);
              bg.setApplicationBounds(bounds);
              //root.addChild(bg);
              //add first TransformGroup
              TransformGroup earthTrans = new TransformGroup();
              Transform3D earth3d = new Transform3D();
              earthTrans.setTransform(earth3d);
              earthTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
              root.addChild(earthTrans);
              //Creating a Sphere for the Earth          
              //sets the appearance of the earth adds a texture image
              Appearance earthApp = new Appearance();
              earthApp.setColoringAttributes(new ColoringAttributes( yellow,ColoringAttributes.NICEST));
              PolygonAttributes polyAt=new PolygonAttributes(PolygonAttributes.POLYGON_FILL,
                                            PolygonAttributes.CULL_NONE,0f);
              earthApp.setPolygonAttributes(polyAt);
              Material earthMat = new Material(new Color3f(1f,1f,1f)
              ,new Color3f(0.25f,0.25f,0.25f)//Shadows color
              ,new Color3f(1.0f,1.0f,0.8f)//Sun's light
              ,new Color3f(1f,1f,1f)
              ,128);
              //earthMat.setAmbientColor(0,0,0.5f);
              //earthMat.setDiffuseColor(1,1,1);
              //earthMat.setShininess(1000);
              //Material(white,white,earthDiff,earthSpec,100f);
              earthMat.setLightingEnable(true);
              TextureLoader picload = new TextureLoader("earth.jpg",this);
              Texture earthpic = picload.getTexture();
              earthpic.setMagFilter(Texture.BASE_LEVEL_LINEAR | Texture.NICEST);
              earthpic.setMinFilter(Texture.BASE_LEVEL_LINEAR | Texture.NICEST);
              earthApp.setMaterial(earthMat);
              earthApp.setTexture(earthpic);
              TextureAttributes texAttr = new TextureAttributes();
              texAttr.setTextureMode(TextureAttributes.MODULATE);
              earthApp.setTextureAttributes(texAttr);
              //adding lights to the sphere
              System.out.println("directional lights");
              Vector3f direction = new Vector3f(-1.0f,-0.5f,0.1f);
              DirectionalLight dirLight = new DirectionalLight(true,white,direction);
              dirLight.setInfluencingBounds(bounds);
              root.addChild(dirLight);     
              //creates the earth
              Sphere earth = new Sphere(0.5f,Sphere.GENERATE_TEXTURE_COORDS | Sphere.GENERATE_NORMALS,100,earthApp);
              earthTrans.addChild(earth);
              System.out.println("doing rotation");     
              //Setting rotation of Earth
              Alpha rotEarth = new Alpha(-1, 10000);
              Transform3D yAxis = new Transform3D();
              //Setting the rotation in a clock wise direction (could have used default constructor)
              RotationInterpolator rotator = new RotationInterpolator(rotEarth, earthTrans, yAxis,
                        0.0f,(float) Math.PI*2.0f);
              rotator.setSchedulingBounds(bounds);          
              earthTrans.addChild(rotator);
              //end Earth
              //Start Moon
              TransformGroup moonTrans = new TransformGroup();
              Transform3D moon3d = new Transform3D();     
              moonTrans.setTransform(moon3d);
              moonTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
              root.addChild(moonTrans);
              Appearance moonApp = new Appearance();
              Material moonMat = new Material(new Color3f(1f,1f,1f)
              ,new Color3f(0.25f,0.25f,0.25f)//Shadows color
              ,new Color3f(1.0f,1.0f,0.8f)//Sun's light
              ,new Color3f(1f,1f,1f)
              ,128);
              moonApp.setMaterial(moonMat);
              moonApp.setColoringAttributes(new ColoringAttributes( white,ColoringAttributes.NICEST));
              Sphere moon = new Sphere(0.2f,Sphere.GENERATE_NORMALS,moonApp);
              moonTrans.addChild(moon);
              Alpha rotMoon = new Alpha(-1, 4000);
              yAxis = new Transform3D();
              //Setting the rotation in a clock wise direction (could have used default constructor)
              RotationInterpolator moonSpin = new RotationInterpolator(rotMoon, moonTrans, yAxis,
                        0.0f,(float) Math.PI*2.0f);
              moonSpin.setSchedulingBounds(bounds);
              Transform3D axisOfTranslation = new Transform3D();
              Alpha transAlpha = new Alpha(-1,
                        Alpha.INCREASING_ENABLE |
                        Alpha.DECREASING_ENABLE,
                        0, 0,
                        5000, 0, 0,
                        5000, 0, 0);
              axisOfTranslation.rotY(-Math.PI/2.0);
              PositionInterpolator translator =
                             new PositionInterpolator(transAlpha,
                             moonTrans,
                             axisOfTranslation,
                             2.0f, 3.5f);
              translator.setSchedulingBounds(bounds);
              moonTrans.addChild(translator);               
              moonTrans.addChild(moonSpin);
              root.compile();
              return root;
         public static void main (String [] args)
              System2 sys = new System2();
              TransformGroup moonTrans = new TransformGroup();
              Transform3D moon3d = new Transform3D();     
              moonTrans.setTransform(moon3d);
              moonTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
              root.addChild(moonTrans);
              TransformGroup sunTrans = new TransformGroup();
              Transform3D sun3d = new Transform3D();     
              sunTrans.setTransform(sun3d);
              sunTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
              root.addChild(sunTrans);
              //creates the Sun that is used for Directional lighting
              Appearance sunApp = new Appearance();
              sunApp.setColoringAttributes(new ColoringAttributes( yellow,ColoringAttributes.NICEST));
              Sphere sun = new Sphere(0.2f,sunApp);
              sunTrans.addChild(sun);
              //positions the sun
              Alpha posSun = new Alpha(-1,Alpha.INCREASING_ENABLE |
                        Alpha.DECREASING_ENABLE,
                        0, 0,
                        5000, 0, 0,
                        5000, 0, 0);
              PositionInterpolator sunPos = new PositionInterpolator(posSun, sunTrans);
              sunPos.setSchedulingBounds(bounds);
              sunTrans.addChild(sunPos);
              //root.addChild(aLgt);
              AmbientLight a = new AmbientLight(white);     
              a.setInfluencingBounds(bounds);
              root.addChild(a);
              System.out.println("point light");
              PointLight pl = new PointLight(true, white,new Point3f(1f,0f,1f),new Point3f(1.0f,0f,0f));
              pl.setInfluencingBounds(bounds);
              root.addChild(pl);
    Transform3D Trafo_1 = new Transform3D();
              Transform3D Trafo_2 = new Transform3D();
              Trafo_1.rotX(0.5);
              Trafo_2.rotY(0.5);
              Trafo_2.mul(Trafo_1);
              RotationInterpolator moonEarth = new RotationInterpolator(rotMoon, moonTrans, Trafo_2,
                        0.0f,(float) Math.PI*2.0f);
              //Billboard moonEarth = new Billboard(moonTrans, Billboard.ROTATE_ABOUT_POINT, new Point3f(0f,0f,0f));

    Yes it is possible. Build a scene graph where the TransformGroup of the moon is a child of the TransformGroup of the earth.
    TG1 __________ Earth Shape3D
    |
    |____ TG2 ___ Moon Shape3D
    In this way the overal transformation for the moon is the concatenation of TG2 and TG1. The transformation for the moon TG2 has to be given relative to the earth (i.e. the middle of the earth is the center of the local coordinate system for the moon).
    If you want the earth spinning then build the following graph:
    TG1___ TG3 ___ Earth
    |
    |____ TG2 ___ Moon
    Put the transformation of the earth position in TG1. Put the spinning transformation of the earth in TG3 and the position transformation of the moon relative to the earth in TG2. Thus the spinning of the earth will not interfere with the position of the moon.

  • Converting a 2D image to 3D image

    Can any one help on Face Recogniton .....

    Mylenium,
    Trying to set the Render Setting to Final and then exporting the animation never allowed the images to be exported. It just hung there, forever. So I unchecked Open GL then created the 3D sphere and it didn't lose any resolution. So your advice helped, in a roundabout way. Thanks.

  • Adding objects to the scenegraph

    Hi,
    I am tryin to add a simple sphere primitive to my program. If i call the method createASphere (see below)in the createScenegraph method, the sphere is added with no problems. However, when i comment out createASphere(), and try calling the method from my Java Swing GUI it causes an error:
    javax.media.j3d.CapabilityNotSetException: Group: no capability to append children
    I have tried using all of the possible capabilties for BranchGroup, but nothing seems to work. Does anyone have any ideas? thanks very much.
    This is just a small code extract
        public BranchGroup createSceneGraph(SimpleUniverse su)
             // Create the root of the branch graph
            BranchGroup objRoot = new BranchGroup();
            createASphere();   // this is the method which creates a simple sphere primitive,
                                              // however, i need it to work from my GUI, not from the createSceneGraph method!
            // Let Java 3D perform optimizations on this scene graph.
            objRoot.compile();
            return objRoot;

    you know something?...I HAD ALREADY GOT THAT, but it was on the wrong BranchGroup! DOH!! :-/
    thanks very much neways! ;-)
    -Ricky

Maybe you are looking for

  • How many times can you clean install leopard on the same computer?

    How many times can you clean install leopard on the same computer? Will the leopard dvd run out of installations and not let you install anymore?

  • Is there a way to view current playlist during airplay to apple TV and perhaps search and add to queue? So there are no interruptions between videos?

    We are having a karaoke night and have all the songs as videos in iTunes, would be great to select the  item and edit the current playlist. so we have a seamless transition to the next abba video Is this possible? Perhaps there are other products / a

  • User Exit for PGI

    Dear All, I have a requirement where client wants del. qty. & pick qty. should be uneditable i.e. not changeable before PGI. The net wt. i.e. del. qty. & pick qty. is updated in VL02N through weigh bridge system by internally run BDC. Users are creat

  • Flattening a JTreeTable to a JTable

    Has anybody done something along the following lines... Taking a JTreeTable that looks like this: Parent 1                 Child 1                 Child 2                 Child 3 Parent 2                 Child 4                 Child 5 and converting

  • Marquee does not wrk when given under h:panelgrid

    Hi, I tried to give a marquee tag under a panel grid and it does not wrk. without a grid it wrks. <h:panelGrid id="gridformarquee" columns="1" width="80%">                     <f:verbatim>                          <marquee id="marquee1" scrollAmount=