This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Oct 17th, 2011  |  syntax: Java  |  size: 1.26 KB  |  views: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import javax.media.j3d.Appearance;
  2. import javax.media.j3d.BoundingSphere;
  3. import javax.media.j3d.Bounds;
  4. import javax.media.j3d.Material;
  5. import javax.media.j3d.Transform3D;
  6. import javax.media.j3d.TransformGroup;
  7. import javax.vecmath.Point3d;
  8. import javax.vecmath.Vector3f;
  9.  
  10. import com.sun.j3d.utils.geometry.Sphere;
  11.  
  12.  
  13. public class CelestialBody extends TransformGroup {
  14.        
  15.         public Transform3D movement = null;
  16.        
  17.         public final double timeScale = 0.0001f;
  18.         public final double gravitationalConstant = 6.67384e-11; // m^3 / (kg * s^2)
  19.        
  20.         public double mass = 1.0f; // kg. Mass should never be 0!!!
  21.        
  22.         CelestialBody(float posX, float posY, float posZ) {
  23.                 // This is set for the dynamic behaviour.
  24.                 setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
  25.                
  26.                 Transform3D t3d = new Transform3D();
  27.                 t3d.setTranslation(new Vector3f(posX, posY, posZ));
  28.                 setTransform(t3d);
  29.                 setBounds(new BoundingSphere(new Point3d(0.0f, 0.0f, 0.0f), 10000.0f));
  30.                
  31.                 Sphere sphere = new Sphere(1.0f, Sphere.GENERATE_NORMALS, 100, createAppearance());
  32.                
  33.                 addChild(sphere);
  34.         }
  35.        
  36.         private Appearance createAppearance() {
  37.                 Appearance appear = new Appearance();
  38.                 Material mat = new Material();
  39.                 mat.setShininess(100.0f);
  40.                 appear.setMaterial(mat);
  41.                
  42.                 return appear;
  43.         }
  44. }
  45.  
  46.  
clone this paste RAW Paste Data