Package horcher.visual

Source Code of horcher.visual.Achse

/**27.07.2008
* Jan Gunnar Gleixner
* Horcher
*
*
*/
package horcher.visual;

import javax.media.j3d.Appearance;
import javax.media.j3d.ColoringAttributes;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Vector3f;

import com.sun.j3d.utils.geometry.Box;
import com.sun.j3d.utils.geometry.Cone;

public class Achse extends TransformGroup {
  public static final float LENGTH = 8;
  public static final float WIDTH = 0.02f;
  public static final int ALING_X = 0;
  public static final int ALING_Y = 1;
  public static final int ALING_Z = 2;
  AntiAliased<Box> achse;
  AntiAliased<Cone> spitze;
  Appearance appear, appearR;
  ColoringAttributes farb;

  public Achse(final int aling) {
    super();
    this.appear = new Appearance();
    this.farb = new ColoringAttributes(0.4f, 0.4f, 0.4f,
        ColoringAttributes.NICEST);
    this.appear.setColoringAttributes(this.farb);
    // Material mat = new Material();
    // appear.setMaterial(mat);

    final AntiAliased<Box> achse = new AntiAliased<Box>(new Box(Achse.WIDTH,
        Achse.LENGTH, Achse.WIDTH, this.appear));
    final AntiAliased<Cone> spitze = new AntiAliased<Cone>(new Cone(
        Achse.WIDTH * 2, Achse.WIDTH * 2, this.appear));

    final Transform3D transform3d = new Transform3D();
    if (aling == Achse.ALING_X)
      transform3d.rotZ(-Math.PI / 2);
    if (aling == Achse.ALING_Z)
      transform3d.rotX(Math.PI / 2);
    this.setTransform(transform3d);
    this.addChild(achse);

    final Transform3D transformSp = new Transform3D();
    transformSp.setTranslation(new Vector3f(0, Achse.LENGTH + Achse.WIDTH, 0));
    final TransformGroup trgSP = new TransformGroup(transformSp);
    trgSP.addChild(spitze);
    this.addChild(trgSP);
  }
}
TOP

Related Classes of horcher.visual.Achse

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.