Examples of TransformGroup


Examples of javax.media.j3d.TransformGroup

  /**
   * Sets the <code>model</code> displayed by this component.
   * The model is shown at its default orientation and in a box of 1 unit wide.
   */
  public void setModel(BranchGroup model) {
    TransformGroup modelTransformGroup = (TransformGroup)this.sceneTree.getChild(0);
    modelTransformGroup.removeAllChildren();
    if (model != null) {
      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,
                           -lower.y - (upper.y - lower.y) / 2,
                           -lower.z - (upper.z - lower.z) / 2));
          // Scale model to make it fit in a 1.8 unit wide box
          Transform3D modelTransform = new Transform3D();
          modelTransform.setScale (1.8 / Math.max (Math.max (upper.x -lower.x, upper.y - lower.y),
                                                   upper.z - lower.z));
          modelTransform.mul(translation);
         
          modelTransformGroup.setTransform(modelTransform);
          modelTransformGroup.addChild(model);
        }
      }
    }
  }
View Full Code Here

Examples of javax.media.j3d.TransformGroup

      // Scale model to make it fit in a 1.8 unit wide box     
      Transform3D modelTransform = new Transform3D();
      modelTransform.setScale(1.8 / Math.max(Math.max((upper.x -lower.x), (upper.z - lower.z)), (upper.y - lower.y)));
      modelTransform.mul(rotationTransform);
     
      TransformGroup modelTransformGroup = (TransformGroup)this.sceneTree.getChild(0);
      modelTransformGroup.setTransform(modelTransform);
    }
  }
View Full Code Here

Examples of javax.media.j3d.TransformGroup

      } else {
        modelTransform.setScale(1.8 / Math.max(Math.max((upper.x -lower.x), (upper.z - lower.z)), (upper.y - lower.y)));
      }
      modelTransform.mul(scaleTransform);
     
      TransformGroup modelTransformGroup = (TransformGroup)this.sceneTree.getChild(0);
      modelTransformGroup.setTransform(modelTransform);
    }
  }
View Full Code Here

Examples of javax.media.j3d.TransformGroup

          this.polygonsPrimitives.clear();
          this.polygonsHoles.clear();
          this.vcount = null;
        }
      } else if ("visual_scene".equals(name)) {
        TransformGroup visualSceneGroup = new TransformGroup();
        this.parentGroups.push(visualSceneGroup);
        this.visualScenes.put(attributes.getValue("id"), visualSceneGroup);
      } else if ("node".equals(name)) {
        TransformGroup nodeGroup = new TransformGroup();
        if (this.parentGroups.size() > 0) {
          // Add node to parent node only for children nodes
          this.parentGroups.peek().addChild(nodeGroup);
        }
        this.parentGroups.push(nodeGroup);
View Full Code Here

Examples of javax.media.j3d.TransformGroup

    /**
     * Multiplies the transform at top of the transform groups stack by the
     * given <code>transformMultiplier</code>.
     */
    private void mulTransformGroup(Transform3D transformMultiplier) {
      TransformGroup transformGroup = (TransformGroup)this.parentGroups.peek();
      Transform3D transform = new Transform3D();
      transformGroup.getTransform(transform);
      transform.mul(transformMultiplier);
      transformGroup.setTransform(transform);
    }
View Full Code Here

Examples of javax.media.j3d.TransformGroup

          modelRotation [2][0], modelRotation [2][1], modelRotation [2][2]);
      modelTransform.setRotation(modelRotationMatrix);
    }
    modelTransform.mul(scaleOneTransform);
   
    return new TransformGroup(modelTransform);
  }
View Full Code Here

Examples of javax.media.j3d.TransformGroup

   * Creates the piece node with its transform group and add it to the piece branch.
   */
  private void createPieceOfFurnitureNode(final HomePieceOfFurniture piece,
                                          final boolean ignoreDrawingMode,
                                          final boolean waitModelAndTextureLoadingEnd) {
    final TransformGroup pieceTransformGroup = new TransformGroup();
    // Allow the change of the transformation that sets piece size and position
    pieceTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    pieceTransformGroup.setCapability(Group.ALLOW_CHILDREN_READ);
    pieceTransformGroup.setCapability(Group.ALLOW_CHILDREN_WRITE);
    pieceTransformGroup.setCapability(Group.ALLOW_CHILDREN_EXTEND);
    addChild(pieceTransformGroup);
   
    // While loading model use a temporary node that displays a white box 
    final BranchGroup waitBranch = new BranchGroup();
    waitBranch.setCapability(BranchGroup.ALLOW_DETACH);
    waitBranch.addChild(getModelBox(Color.WHITE));     
    // Allow appearance change on all children
    setModelCapabilities(waitBranch);
   
    pieceTransformGroup.addChild(waitBranch);
   
    // Set piece model initial location, orientation and size     
    updatePieceOfFurnitureTransform();
   
    // Load piece real 3D model
    Content model = piece.getModel();
    ModelManager.getInstance().loadModel(model, waitModelAndTextureLoadingEnd,
        new ModelManager.ModelObserver() {
          public void modelUpdated(BranchGroup modelRoot) {
            float [][] modelRotation = piece.getModelRotation();
            // Add piece model scene to a normalized transform group
            TransformGroup modelTransformGroup =
                ModelManager.getInstance().getNormalizedTransformGroup(modelRoot, modelRotation, 1);
            updatePieceOfFurnitureModelNode(modelRoot, modelTransformGroup, ignoreDrawingMode, waitModelAndTextureLoadingEnd);           
          }
         
          public void modelError(Exception ex) {
            // In case of problem use a default red box
            updatePieceOfFurnitureModelNode(getModelBox(Color.RED), new TransformGroup(), ignoreDrawingMode, waitModelAndTextureLoadingEnd);           
          }
        });
  }
View Full Code Here

Examples of javax.media.j3d.TransformGroup

  /**
   * Returns the node of the filled model.
   */
  private Node getFilledModelNode() {
    TransformGroup transformGroup = (TransformGroup)getChild(0);
    BranchGroup branchGroup = (BranchGroup)transformGroup.getChild(0);
    return branchGroup.getChild(0);
  }
View Full Code Here

Examples of javax.media.j3d.TransformGroup

  /**
   * Returns the node of the outline model.
   */
  private Node getOutlineModelNode() {
    TransformGroup transformGroup = (TransformGroup)getChild(0);
    BranchGroup branchGroup = (BranchGroup)transformGroup.getChild(0);
    if (branchGroup.numChildren() > 1) {
      return branchGroup.getChild(1);
    } else {
      return null;
    }
View Full Code Here

Examples of javax.media.j3d.TransformGroup

      modelBranch.addChild(createOutlineModelNode(normalization));
    }

    setModelCapabilities(modelBranch);

    TransformGroup transformGroup = (TransformGroup)getChild(0);
    // Remove previous nodes   
    transformGroup.removeAllChildren();
    // Add model branch to live scene
    transformGroup.addChild(modelBranch);
   
    // Update piece color, visibility and model mirror in dispatch thread as
    // these attributes may be changed in that thread
    updatePieceOfFurnitureColorAndTexture(waitTextureLoadingEnd);     
    updatePieceOfFurnitureVisibility();
View Full Code Here
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.