Package javax.media.j3d

Examples of javax.media.j3d.BoundingBox


    backgroundBranch.addChild(halfSphere);
   
    final Background background = new Background(backgroundBranch);
    updateBackgroundColorAndTexture(backgroundAppearance, this.home, waitForLoading);
    background.setImageScaleMode(Background.SCALE_FIT_ALL);
    background.setApplicationBounds(new BoundingBox(
        new Point3d(-1E6, -1E6, -1E6),
        new Point3d(1E6, 1E6, 1E6)));   
   
    if (listenToHomeUpdates) {
      // Add a listener on sky color and texture properties change
View Full Code Here


      model = (BranchGroup)ModelManager.getInstance().cloneNode(model);
      model.setCapability(BranchGroup.ALLOW_DETACH);
      setNodeCapabilities(model);
     
      if (model.numChildren() > 0) {
        BoundingBox bounds = null;
        try {
          bounds = ModelManager.getInstance().getBounds(model);
        } catch (IllegalArgumentException ex) {
          // Model is empty
        }
        if (bounds != null) {
          Point3d lower = new Point3d();
          bounds.getLower(lower);
          Point3d upper = new Point3d();
          bounds.getUpper(upper);
         
          // Translate model to center
          Transform3D translation = new Transform3D ();
          translation.setTranslation(
              new Vector3d(-lower.x - (upper.x - lower.x) / 2,
View Full Code Here

   * The model is shown at its default size.
   */
  protected void setModelRotation(float [][] modelRotation) {
    BranchGroup model = getModel();
    if (model != null && model.numChildren() > 0) {
      BoundingBox bounds = ModelManager.getInstance().getBounds(model);
      Point3d lower = new Point3d();
      bounds.getLower(lower);
      Point3d upper = new Point3d();
      bounds.getUpper(upper);
   
      // Translate model to center
      Transform3D translation = new Transform3D ();
      translation.setTranslation(
          new Vector3d(-lower.x - (upper.x - lower.x) / 2,
View Full Code Here

   */
  protected void setModelRotationAndSize(float [][] modelRotation,
                                         float width, float depth, float height) {
    BranchGroup model = getModel();
    if (model != null && model.numChildren() > 0) {
      BoundingBox bounds = ModelManager.getInstance().getBounds(model);
      Point3d lower = new Point3d();
      bounds.getLower(lower);
      Point3d upper = new Point3d();
      bounds.getUpper(upper);
     
      // Translate model to center
      Transform3D translation = new Transform3D ();
      translation.setTranslation(
          new Vector3d(-lower.x - (upper.x - lower.x) / 2,
View Full Code Here

   * This method computes the exact box that contains all the shapes,
   * contrary to <code>node.getBounds()</code> that returns a bounding
   * sphere for a scene.
   */
  public Vector3f getSize(Node node) {
    BoundingBox bounds = getBounds(node);
    Point3d lower = new Point3d();
    bounds.getLower(lower);
    Point3d upper = new Point3d();
    bounds.getUpper(upper);
    return new Vector3f(Math.max(MINIMUM_SIZE, (float)(upper.x - lower.x)),
        Math.max(MINIMUM_SIZE, (float)(upper.y - lower.y)),
        Math.max(MINIMUM_SIZE, (float)(upper.z - lower.z)));
  }
View Full Code Here

   * This method computes the exact box that contains all the shapes,
   * contrary to <code>node.getBounds()</code> that returns a bounding
   * sphere for a scene.
   */
  public BoundingBox getBounds(Node node) {
    BoundingBox objectBounds = new BoundingBox(
        new Point3d(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY),
        new Point3d(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY));
    computeBounds(node, objectBounds, new Transform3D());
    Point3d lower = new Point3d();
    objectBounds.getLower(lower);
    if (lower.x == Double.POSITIVE_INFINITY) {
      throw new IllegalArgumentException("Node has no bounds");
    }
    return objectBounds;
  }
View Full Code Here

   *                 or <code>null</code> if no transformation should be applied to node.
   * @param width    the width of the box
   */
  public TransformGroup getNormalizedTransformGroup(Node node, float [][] modelRotation, float width) {
    // Get model bounding box size
    BoundingBox modelBounds = getBounds(node);
    Point3d lower = new Point3d();
    modelBounds.getLower(lower);
    Point3d upper = new Point3d();
    modelBounds.getUpper(upper);
   
    // Translate model to its center
    Transform3D translation = new Transform3D();
    translation.setTranslation(
        new Vector3d(-lower.x - (upper.x - lower.x) / 2,
View Full Code Here

            superTrans.setPickable(false);
            addChild(superTrans);
        }

        setBounds(new BoundingBox(
            new Point3d(-BoardModel.HEX_SIDE_LENGTH, -BoardModel.HEX_DIAMETER/2, BoardModel.HEX_HEIGHT*hex.floor()),
            new Point3d(BoardModel.HEX_SIDE_LENGTH, BoardModel.HEX_DIAMETER/2, height)
        ));

        if (hex.getElevation() != 0) addText(Messages.getString("BoardView1.LEVEL") + hex.getElevation(), col);
View Full Code Here

    public static final Font3D BIGBOLD = new Font3D(new Font("sans-serif", Font.BOLD, 3), tolerance, null);
   

    public LabelModel(String text, Color3f fg, Color3f bg, Font3D font) {
        Text3D geom = new Text3D(font, text, new Point3f(0.0f, 0.0f, 0.0f), Text3D.ALIGN_CENTER, Text3D.PATH_RIGHT);
        BoundingBox b = new BoundingBox();
        geom.getBoundingBox(b);
        Point3d upper = new Point3d(), lower = new Point3d();
        b.getLower(lower);
        b.getUpper(upper);
       
        // Workaround for a bounding box bug -- assumes that M and ( have same ascent
        GlyphVector fix = font.getFont().createGlyphVector(new FontRenderContext(null, false, false), "M(");
        Point3d fixu = new Point3d(), fixl = new Point3d();
        font.getBoundingBox(fix.getGlyphCode(0), b);
        b.getUpper(fixu);
        b.getLower(fixl);
        double h1 = fixu.y-fixl.y;
        font.getBoundingBox(fix.getGlyphCode(1), b);
        b.getUpper(fixu);
        b.getLower(fixl);
        double h2 = fixu.y-fixl.y;
        upper.y = h1;
        lower.y = h1-h2;

        Switch sw = new Switch(Switch.CHILD_MASK);
View Full Code Here

        for (GeometryArray geom : geoms) {
            addGeometry(geom);
        }
        double p = .5;
        if (scale) p *= MODEL_SIZE_CORRECTION;
        this.setBounds(new BoundingBox(new Point3d(-p, -p, -p), new Point3d(p, p, p)));
    }
View Full Code Here

TOP

Related Classes of javax.media.j3d.BoundingBox

Copyright © 2018 www.massapicom. 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.