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.

Similar Messages

  • Is This Even Possible? eDirectory syncing passwords with external RADIUS servers.

    We are currently have a solution that allows us to use a campus RADIUS
    server as the authentication mechanism for accessing the Internet. We want
    to integrate this so users can authenticate with their campus IDs but gain
    access to the Novell server (home directory and printing) using the same
    information.
    Is this even possible?
    So, essentially, we would like the external RADIUS' user/password data to
    be synced with the eDirectory data, but have the eDirectory receive updates
    from the RADIUS (or LDAP, Kerberos or whatever system is necessary). Or is
    an all-Novell solution the only possible way to use RADIUS authentication?
    Any input would be greatly appreciated.
    -=Bryan

    Hi Bryan,
    As jim said, you can use idm to do this, but another option for you
    might be to use somthing like freeradius and point it back to
    edirectory as its authentication source.
    Cheers,
    Steve
    On Thu, 23 Feb 2006 15:50:11 GMT, [email protected] wrote:
    >Michael,
    >
    >Thanks for the info. I really wasn't sure where to post this question. I
    >really wasn't sure if I needed to be using Novell's RADIUS server or not to
    >do this. Reading the online docs didn't really help me to know which
    >solution or solutions to choose.
    >
    >-=Bryan
    >
    >> [email protected] wrote:
    >>
    >> > Is this even possible?
    >> >
    >> > So, essentially, we would like the external RADIUS' user/password data to
    >> > be synced with the eDirectory data, but have the eDirectory receive updates
    >> > from the RADIUS (or LDAP, Kerberos or whatever system is necessary). Or is
    >> > an all-Novell solution the only possible way to use RADIUS authentication?
    >>
    >> What you want should be possible with Novell Identity Manager (formerly
    >> DirXML) product. This particular forum is for help with the NetWare
    >> Radius server, which would not factor into what you are trying to
    >> accomplish... you have a non-Novell Radius server that you want to sync
    >> eDirectory information with, and that is the realm of identity manager.
    >>
    >> As to the "hows", you might as in the nsure-identity-manager group here.
    >>
    >> --
    >> Jim
    >> NSC SYsop

  • How is this even possible? Folders out of sync. Backlog command says in sync.

    Two 2008 R2 servers.  Been running DFS-R for about a year now.  Generally no problems.
    If I run the DFSRdiag backlog command on either server, for one particular folder, it says there is no backlog.  The only problem with that is;  on one server there are 11 files in that folder, on the other server, in the same folder, there are
    15 files.  How is this even possible!

    Hi,
    Please check if DFS Replication filter some special file from replication. For more detailed information, please refer to the article below:
    Exclude files or subfolders from replication
    http://technet.microsoft.com/en-us/library/cc758048(v=ws.10).aspx
    If the issue still exists, please create a Diagnostic Report to see if there is any error message.
    Create a Diagnostic Report for DFS Replication
    http://technet.microsoft.com/en-us/library/cc754227.aspx
    Best Regards,
    Mandy
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • I would like to share my photo's titles and descriptions in the photo streams into which I place these carefully labeled photos. I do this so clients can see the names of the things they're swiping through. Is this even possible?

    I would like to share my photo's titles and descriptions in the photo streams into which I place these carefully labeled photos. I do this so clients can see the names of the things they're swiping through. Is this even possible?

    No.  Send a feature request to Apple via http://www.apple.com/feedback/iphoto.html.
    OT

  • I'm no lab geek but I thought I had a 1st gen IPad. Was having difficulty downloading. Went out bought a new ipad3. Took my gen 1 to Apple store and it's running IOS7. Is this even possible.

    I'm no lab geek but I thought I had a 1st gen IPad. Was having difficulty downloading. Went out bought a new ipad3. Took my gen 1 to Apple store and it's running IOS7. Is this even possible???

    http://en.wikipedia.org/wiki/IPad
    Dope, I deleted link as I pressed  add reply.

  • I recently bought a new iMac as well as a wireless time capsule and have it connected how can I use this external drive as the location to store all my files for iTunes, or is this even possible?

    New iMac user here, I recently bought a new iMac and Time capsule and have the whole network up and running now. I have connected another external HD to the time capsule as well and have a total of 3 TB of storage connected wireless to my new iMac. My question is can I use this location as the default location for iTunes?  I doubt I am gonna run out of room considering the iMac has 1 TB of storage already, but I'd prefer to keep my movies and music off the Mac to keep it running smoothly. If this is possibly, I'd like to do this with iPhoto as well. 

    I would advise against placing your iTunes library on a Time Capsule.
    The Time Capsule is designed as a backup device and not for wireless streaming of video.
    Before you do anything more, can I suggest you put into place a reliable, redundant backup strategy.
    Unless you are prepared to risk loss of your iTunes library due to a hard drive failure, I would not put iTunes on the Time Capsule.
    Leave your iTunes library on your iMac until such time as your internal drive is full. Backup to Time Capsule using Time Machine and create a clone of your internal iMac HD to your external drive.
    That's my 2 cents worth. Others may have a different opinion.

  • Is this even possible with a Linksys product?

    I am doing an installation at a laundrymat and heres the situation:
    This gentleman currently has 1 DSL line coming into a Meraki wireless hub.  If you arent familiar with these, they have no out ports for hardwiring.  This hub takes his one DSL line and splits it on the out to two independent static IP addresses.  He uses one for personal that is secured, and one for wifi for customers to use.  He wants to add a DVR to the system that needs to be hardwired in to a network connection, which as I stated before, would be impossible (I believe) due to the fact there are no out ports on this router.  My question is this, is there a Linksys product that will maintain two seperate static IP addresses so that he can still maintain the 2 virtual lines coming out and also enable me to hook up the DVR?  
    Thank you in advance,
    Kevin

    I would say that you would have a device at the dsl first then connect everything else up that is needed. It would have to be wired to the dsl.

  • Computer crashed, need to get music off my ipod onto new harddrive. Is this even possible anymore?

    My computer crashed and I got a new hardrive. I need to get my music off my Ipod Touch 4th gen onto my new computer...is it even possible anymore?

    For iTunes purchases:
    iTunes Store: Transferring purchases from your iPhone, iPad, or iPod to a computer
    For other music you need a third-pary program like one of those discussed here:
    Copy music from Ipod to new computer...: Apple Support Communities

  • Is this even possible... newbie link/photo question

    I know that I can link one thing to an entire photo. Is there any way at all to have little links that are on various spots of one photo? Someone is asking me to do this for our site but I just can't figure it out. I've only dabbled in Dreamweaver and I just don't even know where to look in the various help pages! If anyone can point me in the right direction, it would be great. If it helps, here is the page they want me to make work in this way....http://www.hartleynature.org/ecology/1918.html

    Worked like a charm! you are my new hero. Thanks for the help cause I'm sure it will get put to use throughout the site.

  • Want to use an iPAD with my Pismo, is this even possible

    Ok, here come the chuckles...
    I have a Pismo set to dual boot in either 9.2.2 or 10.4.1with the aid of firewire which houses OSX basically because I'm still using Photoshop 5.5 which runs faster in 9 than using 9 classic from OSX. I want to do Fingerpainting on a mobile device like an iPOD or iPAD and I am told my processor (400) won't support 10.5. Apple sales just said what did I expect, I was using a 10 year old computer.
    Can I upgrade the processor on the Pismo to accomplish this or has my Pismo had it's day. I love it and it has been dual booting and doing just fine now for 2 years.
    I do have one more problem... none of my IOMEGA devices, my JAZ and my ZIP will not run from my old system 9 since I made the change over to dual boot and I have a lot of paintings stored on them that I would like to transfer to CDs. I know too many questions in one post but maybe someone, somewhere is as broke as I am and needs to hang on and upgrade the impossible like I do. I'd like to address these issues to those of you who can't just go out and buy a new computer and all new software. My finances are so bad right now, I'm having a hard time paying attention, so please bear with me. Any thoughts?
    sharon

    Here's the spec page on your G3 Pismo - http://www.everymac.com/systems/apple/powerbookg3/stats/powerbook_g3_400fw.html
    The max OS on the Pismo is Tiger 10.4.x Even if the Pismo could run Leopard 10.5, it would be slow. Snow Leopard 10.6 requires an Intel processor.
     Cheers, Tom

  • Is this even possible with Bridge?

    I do alot of work with Photoshop and some other products but am new to Bridge.  I've been tasked to use Bridge to find a specific type of TIFF file that is being generated by one of our legacy patient record systems.  It isn't in a standard TIFF format but some type of 8BPP format.
    Is it possible to use Bridge to find these type of files in a directory and search all subdirectories (about 500)?
    Any help would be really appreciated as I don't even know where to start.
    Thanks!

    It depends if that information is entered as a metadata point.  Click on picture and see if that has specific data in the metadata tab.  Also check the metadata in preferences to see if you have checked this data to be displayed.
    If so I believe you can search the "all metadata" in Find.  Type in the appropriate fields in search boxes.

  • Is this even possible with a selectManyCheckbox???

    I know I can do one of two layouts with a selectManyCheckbox, line or page. I would like to have the checkboxes go horizontally i.e. line, but after x number of them, say 5, I would like to start a new row rather than scrolling off to the right... I see that a selectManyCheckbox actually renders an HTML table so I tried to use the pass-through attribute "cols" to set it but no dice. Anyone have any idea how to do this or even if it is possible?

    I would say that you would have a device at the dsl first then connect everything else up that is needed. It would have to be wired to the dsl.

  • Is this even possible...if so advice??

    Hi Everyone,
    So I need to tap into the great knowledge of others on here and see if anyone has either some advice or maybe recommended resources to check on this question.
    I am setting up a small business with a Mac Mini Server and my client asked me if there was anyway to set it up to have basically a redundant server going that would take over for the main one should it go down to something that required repair, like a logic board issue.
    I know in large enterprise situations they have server farms setup and you can configure a setup that monitors the other units and will setup to the plate if that unit goes down automatically.
    I know Snow Leopard Server doesn't have anything built-in (to my knowledge) that makes this happen, but does anyone have an idea of if/or how I could accomplish this? Say if I had one Mac Mini Server as the main unit and the second one waiting in the wings so to speak. I figured an easy way just to have a cloned unit sitting there, but it is the whole automatic aspect.
    If anyone has any suggestions, advice or resources I can dig into I would really appreciate it. I would also appreciate if your response is they are bat sh*t crazy and there is no way to do this without stepping up to Xserve-land.
    Thanks!

    I know Snow Leopard Server doesn't have anything built-in (to my knowledge) that makes this happen
    Fortunately, you're mis-informed.
    Mac OS X Server has had automatic failover abilities for some time now.
    You'd need two machines and each one listens for a heartbeat from its partner system. If the heartbeat fails it's assumed that the other system is offline and the failover daemon starts up whatever services you have configured to failover.
    The three main issues are:
    1) implementing a heartbeat network between the two machines (ideally on a separate network link, which could be FireWire)
    2) determining which services should failover (it's unlikely that you need/want all services to failover since there is a cost of failover (and an even bigger cost of fallback))
    3) Managing common storage elements - how to make sure both machines have the same content. For example, if you determine that you want to failover your web server you need to make sure that both machines have access to the same web content, otherwise your site will look different in a failover situation. This grows exponentially if you have a dynamic, database-driven web site since you need to consider database replication as well.
    Note that 3 may be partly solved via network storage that's accessible to both machines, however you need to consider the case where the network storage fails...

  • I'm looking into the possibility of using Photoshop CS2 on Imac with Mavericks OS. Is this even possible, and if not, what would I need to do?

    Is it possible to download and use Photoshop CS2 on Imac with Mavericks OS?

    This is not a photography question.  It is an application specific question,  Please post in the Photoshop forum.
    Photoshop General Discussion
    Remember, you are not addressing Adobe here in the user forums.  You are requesting help from volunteers users just like you who give their time free of charge. No one has any obligation to answer your questions.

  • HT4864 Does anyone know how to setup iCloud to automatically compose an email when a "mailto" link is clicked? Is this even possible on a Windows 8.1 PC? It seems near impossible to find a yes or no answer to.

    Any answers with explanations would be greatly appreciated at this time.

    Jneklason wrote:
    ~snip~
    I know this email is confusing and really hard to understand...perhaps now you will know how i've been feeling--lost and confused with all the mis-information, with a hit and miss phone, and out of time with all the 1 1/2 hr to 2 hrs EACH wasted on this issue.
    On top of all this, I can't even find out how to file a complaint with anyone higher up than Customer Service.
    I hate to tell you this, but you didn't write an email. You wrote a discussion post on the Verizon Wireless Community forum which is a public peer to peer forum. Unfortunately since you didn't mark your post as a question, the VZW reps that roam this community won't ever see your post. Before you re-post it, don't. Duplicate posts get removed from the community.
    I see there were several missteps both by the reps and yourself in your post. First you should have insisted on returning the phone within the 14 day return policy period. Second which Samsung Galaxy mini model did you purchase? The S3 mini or the S4 mini? Did you do any research prior to deciding on this device. The reps at that time deflected the easiest course of action, by trying to get you to replace the phone under insurance instead of returning the phone. The Early Edge payment option requires the current phone on the line using the early Edge must be returned to Verizon Wireless. Did you once considered going to a third party site like Swappa to purchase a gently used device for your daughter?

Maybe you are looking for

  • [SOLVED]Java error running a .jar file

    Hi. I'm running Arch 64 and I keep getting this error when trying to run java -jar TwinkEdit-0.6.9.jar (from twinkle.sourceforge.net -- a flashcard program for palm. This .jar is the desktop editor for the flashcards. It's worked before on Linux ...

  • Blue Screen Error Please Help.

    Hello ... i m getting this error when ever i start my pc Multiprocessor_configuration_not_supported... this error came when my system finished booting then eventually this blue screen error occured and i needed to restart my computer .. after restart

  • My ipod shuffle will connect to itunes on computer but will not fully charge and will not play songs

    My Ipod shuffle was washed in a washing machine but dried completely. Now it will connect to my itunes on my computer but will not completely charge or play songs. Can anyone tell me if this is a lost cause and I should buy a new one or is there hope

  • Help required in ALE configuration

    Hello All, I am working on SAP Demo version. I have created a logical system and saved it. After defining logical system i tried to create a distribution model but i don't see any logical system in the distribution model? Can anyone help me in this i

  • Learning Java in Public Facilities, e.g., libraries.

    I am determined to learn and master Java applications and applets. At this time I do not own a computer and am not enrolled in any classes, but I need access to compile and run Java. Does anyone know how this can be done in the library? I have tried