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

Similar Messages

  • 3D Problems in AE CS3 Mac OSX 10.5

    I am having a lot of trouble with 3D in After Effects. I cannot get my layers to be 3D, even when I have the 3D option checked on in the timeline. For instance, I'm trying to create a rotating Earth, but instead of it rotating and being a sphere, it's just a flat layer that twists. I don't know what to do. I can't find any good info about this type of thing.
    Also, I don't have a 3D axis (you know--the three-dimensional X,Y,Z axis). I don't know if it's my video card or the program itself. I don't know what to do and I'm getting close to scrapping the whole program and trying to find a version for Mac online.
    Can anyone help?

    You can do a rotating sphere using any one of several 3rd party apps. To create the effect using the built in effects take an image you want to use for the
    globe surface and apply the CC Sphere Effect. You'll find that under Effects>Perspective>CCSphere.
    Apply the CC Sphere to the layer, make the layer 3D, change the Transform properties to Auto Orient towards Camera, then apply the followint expressions:
    To CC Sphere X rotation:
    r = lookAt(position, thisComp.layer("Camera 1").transform.position);
    x = r[0] - 180;
    value + x
    To CC Sphere Y rotation:
    r = lookAt(position, thisComp.layer("Camera 1").transform.position);
    y = - r[1];
    value + y
    To CC Sphere Z rotation:
    r = lookAt(position, thisComp.layer("Camera 1").transform.position);
    z = r[2] +180;
    value + z
    If you really want to get fancy you can add expressions to light height and direction using a variation of the basic lookAt(position1, position2) language.
    Hope this helps. You might want to take a look at
    this sample project using one of the images picked from the google link above.

  • Adding multiple objects

    Hi.
    I'm trying to add multiple objects to my universe, but i'm not sure how to do it. What i was thinking was to create a for loop and create the object within it.The z value refers to the z vector point.The code is below.I'm new to java 3D so if anyone could help me, that would be great.
    Thanks
    Sharon.      
    for (float z = 0f; z < 20f; z = z + 2){
              Cylinder cylinder = new Cylinder( 0.8f,10f );
              Color3f col = new Color3f(8f, .15f, .15f);
              ColoringAttributes ca = new ColoringAttributes (col,ColoringAttributes.NICEST);
              app.setColoringAttributes(ca);
              cylinder.setAppearance(app);
              Transform3D transform = new Transform3D();
              Vector3f vector = new Vector3f(0f, 0f, z);
              transform.setTranslation(vector);
              tg.setTransform(transform);
              tg.addChild( cylinder );
              bg.addChild( tg );
    }

    Hi.
    I have two programs, BGroup.java, which creates a rotating sphere and coloring attributes etc. and some1Canvas3D.java which creates a canvas and simple universe and panel with buttons and works on the BGroup.java program by adding it as a branchgraph to the simple universe "simpleU.addBranchGraph(new BGroup());". what i'd like to do is that if one of the buttons in some1Canvas3D.java is pressed then i want to decrease/increase the radius size of the sphere in BGroup.java. and see this within the canvas.
    I'm not sure how this will work.
    If anyone has any ideas how to do this, that'd be great.
    The code for the two programs is below . i'm quite new to Java3D so i hope it makes sense.
    Thanks for you help.
    Sharon
    /********BGroup.java****************
    import com.sun.j3d.utils.geometry.*;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import com.sun.j3d.utils.image.TextureLoader;
    public class BGroup extends BranchGroup
    public BGroup()
    /*create the transformGroup and set the capability to write.needed for rotation*/
    TransformGroup someGroup = new TransformGroup();
    someGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    //add the transform group to the branchgroup
    this.addChild(someGroup);
    //create the sphere and add it to the scene
    Sphere mysphere = new Sphere(0.5f);
    someGroup.addChild(mysphere);
    // Create a light that shines for 100m from the origin
    Color3f light1Color = new Color3f(7f, 2.6f, 4.1f);
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
    Vector3f light1Direction = new Vector3f(9.0f, -7.0f, 5.0f);
    DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
    light1.setInfluencingBounds(bounds);
    someGroup.addChild(light1);
    Transform3D yAxis = new Transform3D();
         Alpha rotationAlpha = new Alpha(-1, 4000);
         RotationInterpolator rotator =
         new RotationInterpolator(rotationAlpha, someGroup, yAxis,
                        0.0f, (float) Math.PI*2.0f);
         rotator.setSchedulingBounds(bounds);
         someGroup.addChild(rotator);
    this.compile();
    *********************some1Canvas3D.java******************/
    import java.awt.*;
    import java.awt.GraphicsConfiguration;
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.geometry.*;
    import javax.media.j3d.*;
    import java.applet.*;
    import java.awt.event.*;
    import java.awt.event.WindowAdapter;
    public class some1Canvas3D extends Applet {
    private Button go = new Button ("Forward");
    private Button go2 = new Button ("Left");
    private Button go3 = new Button ("Right");
    private Button go4 = new Button ("Back");
    private Button go5 = new Button ("Do it for me !!!");
    public void init()
    setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
    Canvas3D c1 = new Canvas3D(config);
    c1.setSize(256,256);
    add("Center", c1);
    SimpleUniverse simpleU = new SimpleUniverse(c1);
    simpleU.getViewingPlatform().setNominalViewingTransform();
    simpleU.addBranchGraph(new BGroup());
    Panel p = new Panel();
    p.add(go);
    p.add(go2);
    p.add(go3);
    p.add(go4);
    p.setBackground(Color.blue);
    p.setForeground(Color.red);
    add("North",p);
    Panel p2 = new Panel();
    p2.add(go5);
    p2.setBackground(Color.blue);
    p2.setForeground(Color.red);
    add("South",p2);
    public void start() {
    public void destroy() {
    public void run() {
    //Explains what happens when the Mouse is clicked on the Applet
    public void actionPerformed(ActionEvent e) {
         if (e.getSource()==go ) {
    /*when this button is pressed i want to be able to decrease the radius size of the sphere in BGroup.java*/
    public static void main(String []args)
    System.out.println("Program Started");
    new MainFrame(new some1Canvas3D(), 750,500);
    Thanks again.
    Sharon.

  • Java_chic needs help please!!!!!!

    Hi.
    I have two programs, BGroup.java, which creates a rotating sphere and coloring attributes etc. and some1Canvas3D.java which creates a canvas and simple universe and panel with buttons and works on the BGroup.java program by adding it as a branchgraph to the simple universe "simpleU.addBranchGraph(new BGroup());". what i'd like to do is that if one of the buttons in some1Canvas3D.java is pressed then i want to decrease/increase the radius size of the sphere in BGroup.java. and see this within the canvas.
    I'm not Interested in what the program does but only how interaction between two programs work.
    If anyone has any ideas how to do this, that'd be great.
    The code for the two programs is below . i'm quite new to Java3D so i hope it makes sense.
    Thanks for you help.
    Sharon
    /********BGroup.java****************
    import com.sun.j3d.utils.geometry.*;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import com.sun.j3d.utils.image.TextureLoader;
    public class BGroup extends BranchGroup
    public BGroup()
    /*create the transformGroup and set the capability to write.needed for rotation*/
    TransformGroup someGroup = new TransformGroup();
    someGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    //add the transform group to the branchgroup
    this.addChild(someGroup);
    //create the sphere and add it to the scene
    Sphere mysphere = new Sphere(0.5f);
    someGroup.addChild(mysphere);
    // Create a light that shines for 100m from the origin
    Color3f light1Color = new Color3f(7f, 2.6f, 4.1f);
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
    Vector3f light1Direction = new Vector3f(9.0f, -7.0f, 5.0f);
    DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
    light1.setInfluencingBounds(bounds);
    someGroup.addChild(light1);
    Transform3D yAxis = new Transform3D();
    Alpha rotationAlpha = new Alpha(-1, 4000);
    RotationInterpolator rotator =
    new RotationInterpolator(rotationAlpha, someGroup, yAxis,
    0.0f, (float) Math.PI*2.0f);
    rotator.setSchedulingBounds(bounds);
    someGroup.addChild(rotator);
    this.compile();
    *********************some1Canvas3D.java******************/
    import java.awt.*;
    import java.awt.GraphicsConfiguration;
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.geometry.*;
    import javax.media.j3d.*;
    import java.applet.*;
    import java.awt.event.*;
    import java.awt.event.WindowAdapter;
    public class some1Canvas3D extends Applet {
    private Button go = new Button ("Forward");
    private Button go2 = new Button ("Left");
    private Button go3 = new Button ("Right");
    private Button go4 = new Button ("Back");
    private Button go5 = new Button ("Do it for me !!!");
    public void init()
    setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
    Canvas3D c1 = new Canvas3D(config);
    c1.setSize(256,256);
    add("Center", c1);
    SimpleUniverse simpleU = new SimpleUniverse(c1);
    simpleU.getViewingPlatform().setNominalViewingTransform();
    simpleU.addBranchGraph(new BGroup());
    Panel p = new Panel();
    p.add(go);
    p.add(go2);
    p.add(go3);
    p.add(go4);
    p.setBackground(Color.blue);
    p.setForeground(Color.red);
    add("North",p);
    Panel p2 = new Panel();
    p2.add(go5);
    p2.setBackground(Color.blue);
    p2.setForeground(Color.red);
    add("South",p2);
    public void start() {
    public void destroy() {
    public void run() {
    //Explains what happens when the Mouse is clicked on the Applet
    public void actionPerformed(ActionEvent e) {
    if (e.getSource()==go ) {
    /*when this button is pressed i want to be able to decrease the radius size of the sphere in BGroup.java*/
    public static void main(String []args)
    System.out.println("Program Started");
    new MainFrame(new some1Canvas3D(), 750,500);
    *************************/

    One of the approach you might take regarding this program is : taking off the previous sphere whenever decrease or increase button is hit, then replace it with a new sphere with appropriate size "bigger or smaller".
    I don't know how to do it yet as I'm still in my 2nd or third week of Java3d learning "I'd call it fooling around :D", but if I get a chance, I might give it a shot :)

  • How can I make a 2-D sphere rotate in Flash with 3D effect

    Hi I have an image of sphere that I need to make rotate as if it were a globe rotating on it's axis.  Can I do this without having to recreate the shpere as a 3D image?
    I have attached the file.

    flash can't make 3d objects.  cs5 can make 2d objects that move in apparent 3d space but that's the limit of flash'es capabilities.
    however, there are other programs that can be used to make 3d objects and then animate those objects in flash.

  • Java 3D: making a sphere rotate like a planet.

    Hey guys, could anyone possible show me to make a spher rotate on its axis, like a plant? I'm fairly new to java 3d.
         Sphere sp = new Sphere(.4f, Sphere.GENERATE_TEXTURE_COORDS, earthApp);
         t.set(1.0, new Vector3d(0f, 0f, 0f));
         TransformGroup tg1 = new TransformGroup(t);
         tg1.addChild(sp);
         mainTG.addChild(tg1);
    That basically puts a sphere in the middle of the screen, earthApp references a file called earth.JPG which colours the sphere to make it look like the earth.
    But i need help rotating it guys!

    I'm pretty new to Java3D as well, but:
    If you look under %JAVA_HOME%\demo\java3d\index.html there are several very clear examples (with source). The ConicWorld example looks similar to what you want to do. Check out the createObject method in %JAVA_HOME%\demo\java3d\ConicWorld\ConicWorld.java. It's slightly more complicated than it has to be because they're using arrays of objects, but the general spin idea is there.

  • How can I create a rotating basketball image in Motion?

    I need to have a basketball rotate and do a full 360 degree. I took an image from Google Images and dragged into Motion and applied the sphere filter. Is that the best 3D looking basketball I can get from a 2D image? Thanks!
    Message was edited by: Host <to correct typo in title, change it to clarify>

    You need an unrolled basketball image and wrap that around a sphere...
    Like this:
    Patrick

  • Problem with 3D sphere in Photoshop Extended CS6

    Here is a still from what will be a trade show video. The problem is that the longitudinal lines are a bit wobbly, especially near the poles, for instance in the top right quadrant, between the orange and yellow earplugs.
    http://www.flickr.com/photos/carolgunn/7544861696/in/photostream
    I created a new 3D object with the preset sphere from a layer that is a grid of my client's products.  As the sphere rotates, the black edges of the grid straighten out as they come around to the front, and then get wobbly again as they approach the edge of the sphere. At first, I made the black part of the grid from a bitmap mask (which had caused a problem in an earlier 3D file) but no, same problem when I made the grid from a vector mask.
    Pretty sure it is not a hardware issue as I have gone thru all the optimization steps for using the Mercury Graphics Engine on my quad-core iMac 27" with a supported video card, and the latest version of OSX.
    Can anyone tell me what I might be doing wrong?
    Thanks!
    --Carol Gunn
    Gunn Graphics
    Austin, TX 78741
    www.gunngraphics.biz

    That looks like a possible "scalloping" bug that could be related to the one being discussed here:  http://forums.adobe.com/message/4460728
    It seemed to me that with relatively large objects curved lines between mesh points were being curved the wrong way, as though someone got a sign backwards in the software.  Adobe is working on it, but there's no sign of a 13.0.1 update so far.
    Not sure if this is the same issue at all, but it did trigger my memory of talking about it about a month ago.
    -Noel

  • How do I make a 3-d rotating text in Flash cs4?

    Hi, Thunder BoomCat PowWow here.
    I'm a student in this Virtual Enterprise class and am in charge of learning flash and making a kick-butt commercial for our firm: Uncommon Ground.
    I was wanted to make some text rotate AROUND a sphere in flash (the sphere is going to be a picture of the earth).
    I want the text to go in one direction, wrapping around the sphere, and appearing on the other side like it went all the way around.
    Can anyone tell me how to do that using Flash?
    Thanks in advanced,
    TBCPW
    Sole employee of the media department

    flash can't make 3d objects.  cs5 can make 2d objects that move in apparent 3d space but that's the limit of flash'es capabilities.
    however, there are other programs that can be used to make 3d objects and then animate those objects in flash.

  • 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.

  • 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.

  • Can anyone tell me how to click the sphere and display a messege???

    /* Goal: Want to create a bunch of spheres, and when a sphere is clicked:
    * 1) display a message in the textfield
    * 2) transform the position of the sphere to (0,0,0)
    * (if (0,0.0) is occupied by another sphere, move that sphere somewhere.
    * Achieved : create the spheres,can transform,rotate and zoome the spheres.
    * Problem: having trouble to click it and display text and change location (problem with picking)
    * Thanks!!!!!!
    public class node extends Applet{
    public static void main(String[] args){
    new MainFrame(new node(),1000,800);
    Sphere sphere;
    PickCanvas pc;
    TextField text;
    public void init(){
    setLayout(new BorderLayout());
    GraphicsConfiguration gc=
    SimpleUniverse.getPreferredConfiguration();
    Canvas3D cv=new Canvas3D(gc);
    add(cv,BorderLayout.CENTER);
    //add mouseListener
    //add mouseListener for click
    cv.addMouseListener(new MouseAdapter(){
    public void mouseClicked
    (java.awt.event.MouseEvent mouseEvent){
    pick(mouseEvent);
    //create textfield down below
    text=new TextField();
    add(text,BorderLayout.SOUTH);
    BranchGroup bg=createSceneGraph(cv);
    bg.compile();
    SimpleUniverse su= new SimpleUniverse(cv);
    su.getViewingPlatform().setNominalViewingTransform();
    su.addBranchGraph(bg);
    private BranchGroup createSceneGraph(Canvas3D cv){
         BranchGroup root= new BranchGroup();
    TransformGroup spin= new TransformGroup();
    spin.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    spin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    root.addChild(spin);
    //appearance
    Appearance ap=new Appearance();
              ap.setMaterial(new Material());
              //create ten spheres
              for(int i=0;i<10;i++){
                   double x=0.1*i;
                   double y=-0.05*i;
                   //<transform sphere>
                   Transform3D tr=new Transform3D();
                   tr.setTranslation(new Vector3d(x,y,0));
                   tr.setScale(0.03);
                   //<transform sphere>
                   //<objects>
                   sphere=new Sphere();
                   sphere.setAppearance(ap);
                   TransformGroup Tg= new TransformGroup(tr);
                   Tg.addChild(sphere);
                   spin.addChild(Tg);
                   //<objects>
              //rotation
    MouseRotate rotator=new MouseRotate(spin);
    BoundingSphere bounds= new BoundingSphere();
    rotator.setSchedulingBounds(bounds);
    spin.addChild(rotator);
    //translation
    MouseTranslate translator=new MouseTranslate(spin);
    translator.setSchedulingBounds(bounds);
    spin.addChild(translator);
    //zoom
    MouseZoom zoom=new MouseZoom(spin);
    zoom.setSchedulingBounds(bounds);
    spin.addChild(zoom);
              // <picking>
              BranchGroup bg=new BranchGroup();
    spin.addChild(bg);
    pc=new PickCanvas(cv,bg);
    pc.setTolerance(5);
    pc.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
    //</picking>
    // <background and light>
              BoundingSphere bound=new BoundingSphere();
              Background background=new Background(1.0f,1.0f,1.0f);
              background.setApplicationBounds(bound);
              root.addChild(background);
              AmbientLight light=new AmbientLight(true, new Color3f(Color.cyan));
              light.setInfluencingBounds(bound);
              root.addChild(light);
              PointLight ptlight=new PointLight(new Color3f(Color.green),
                        new Point3f(3f,3f,3f),new Point3f(1f,0f,0f));
              ptlight.setInfluencingBounds(bound);
              root.addChild(ptlight);
              PointLight ptlight2=new PointLight(new Color3f(Color.yellow),
                        new Point3f(3f,3f,3f),new Point3f(1f,0f,0f));
              ptlight2.setInfluencingBounds(bound);
              root.addChild(ptlight2);
         // </background and light>
    return root;
    //mouse event
    public void pick(MouseEvent mouseEvent){
    pc.setShapeLocation(mouseEvent);
    PickResult[] results= pc.pickAll();
    //when a sphere is clicked, display Node #
    for(int i=0;(results !=null) && (i<results.length);i++){
    PickIntersection inter= results.getIntersection(0);
    int[] ind=inter.getPrimitiveCoordinateIndices();
    text.setText("Node"+ind[0]);
    //When a sphere is clicked, i want to change its position
    //how to relocate the clicked sphere to position (0,0,0)?
    //(if there is a sphere already in(0,0,0),change that sphere to
    //somewhere else)
    (I import this )
    import javax.media.j3d.AmbientLight;
    import javax.media.j3d.Appearance;
    import javax.media.j3d.Background;
    import javax.media.j3d.BoundingSphere;
    import javax.media.j3d.BranchGroup;
    import javax.media.j3d.Canvas3D;
    import javax.media.j3d.Material;
    import javax.media.j3d.PointAttributes;
    import javax.media.j3d.PointLight;
    import javax.media.j3d.Shape3D;
    import javax.media.j3d.Transform3D;
    import javax.media.j3d.TransformGroup;
    import com.sun.j3d.utils.behaviors.mouse.*;
    import com.sun.j3d.utils.picking.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.media.j3d.*;
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.geometry.*;
    import java.applet.*;
    import com.sun.j3d.utils.applet.MainFrame;
    import javax.vecmath.*;

    never mind. I got it to work.

  • 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]

  • Motion path on rotated ellipse?

    Hi, I'm an experienced animator (with Flash) but relative newbie to Motion, and so finding some things very frustrating but also empowering. I've got a series of ellipses kind of like an atomic symbol which I'm trying to rotate small objects (spheres) around in 2D - pretty basic - just three orbits. At first I tried drawing a path and then attaching to the sphere graphic (as in Flash) but then found Add Behaviour > Basic Motion > Motion path which was actually much easier and powerful than Flash. But now I have an 'angled' ellipse (45 degrees) but I can find no way to rotate the motion path to match the angle. I can adjust each of the circular path's axis, but no way to rotate about a central point. All I want is an angled elliptical path! Is there any easy (or difficult) way to do this? Thanks for any help.
    Chris

    You're going to love how easy this is:
    Add Behavior/Basic Motion/Motion Path to your sphere. In the behaviors tab, change the path shape to Geometry. Drag the elipse layer into the Shape Source well and make sure the Attach to Shape button is checked.
    Now the sphere will follow around the elipse no matter how it's positioned. And if you change the shape of the elipse, it'll update in the motion of the sphere.
    Also, in the behavior you'll see areas to change the interpolation of the motion, as well as a Looping parameter for multiple orbits.
    Hope this helps.
    Andy

  • Rotation around an arbitrary axis in Flex

    I am hoping to animate the rotation of an object around an arbitrary axis.  Is it possible to do this with the animation classes in Flex 4?  I can get it to work using the Rotate3D function, but only around the x-, y- or z-axis.  I'll explain...  I have objects that are subclasses of FilledElements, because I need them to be filled with bitmaps.  These elements are created using drawPath, because they can be any type of polygon in the xy plane.  I need to be able to "flip" an object, using any one of its sides as an axis.  The "flip" is a 3D rotation.  The flip works for a rectangle whose width is parallel to the x-axis or length is parallel to the y-axis.  But, if I have a triangle or other polygon whose sides are not parallel to any axes? How can I generate a 3D rotation on one of its sides?
    I tried setting different values using SimpleMotionPath on the transform property.  I tried using the animation class, but it needs a property, and I'm not sure what property maps to what I need.  I thought changing the transform property using SimpleMotionPath might work, but that doesn't do it.  I have tried using matrix.appendRotation on the object, but I'm not sure how to animate using that function.
    Thanks!  Any help would be appreciated.

    It is not the spheres I am worried about in this instance. I can move the spheres as I need to however, there are linking cylinders between those spheres. I easily find the midpoint for the cylinder to be located at but the cylinder needs to be aligned so it is pointing to the central sphere and the external sphere. That is what the above code is trying to generate, a matrix4d transform that rotates and aligns the cylinder along the direction required.
    Cheers
    Mark

Maybe you are looking for

  • Action with LiveTrace?

    I need to LiveTrace 36 frames of a video, and thought an Action might be the best approach to that. I am aware of the 'insert menu option' thing, which I did, but my problem is that it only traces with the default settings. Now I'd like to use the gr

  • NEW HEADER TEXT IN PO

    Dear Gurus, How to create OR Copy new header text type in PO. Actually i needed 3 or more new Header text type in PO. Please suggest Thanks

  • What does the S10e's serial number look like

    I just had the most frustrating time calling Lenovo service about my new IdeaPad S10e. They tell me the serial number is not that of an IdeaPad but a Thinkpad. I checked the S/N on the shipping box and on the bottom of the IdeaPad and they match. The

  • RUNTIME ERROR ON MEDIA MANAGER

    HAS ANYONE FIGURED A WAY AROUND THIS MEDIA MANAGER SO I CAN ACTUALLY USE THIS FEATURE.  I HAVE FOLDERS THAT I WOULD LIKE TO ORGANIZE ON MY PHONE.  THE MEDIA MANAGER WORKED FOR A FEW WEEKS BUT NOW ALL I GET IS A RUNTIME ERROR AND THE COMPUTER DOES NOT

  • Help! Can't get past grey apple screen after Time Machine restore

    Today I did a complete restoration of my HD using Time Machine. It seemed to successfully complete, prompting me to his <RESTART>, which I did. After the grey screen with the apple, I get this black and white pattern, almost like patchwork. Anyway, I