Package javax.media.j3d

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


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

   * 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

  /**
   * 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

  /**
   * 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

      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

    groundHome.getEnvironment().setGroundColor(home.getEnvironment().getGroundColor());
    groundHome.getEnvironment().setGroundTexture(home.getEnvironment().getGroundTexture());
    Ground3D ground = new Ground3D(groundHome, -1E7f / 2, -1E7f / 2, 1E7f, 1E7f, true);
    Transform3D translation = new Transform3D();
    translation.setTranslation(new Vector3f(0, -0.1f, 0));
    TransformGroup groundTransformGroup = new TransformGroup(translation);
    groundTransformGroup.addChild(ground);
    exportNode(groundTransformGroup, true, true, silk);

    HomeTexture skyTexture = home.getEnvironment().getSkyTexture();
    this.useSunSky = skyTexture == null || !(home.getCamera() instanceof ObserverCamera);
    if (!this.useSunSky) {
View Full Code Here

            t.rotX(Math.PI/2);
            tl.z += BoardModel.HEX_DIAMETER;
        }
        t.setScale(new Vector3d(2*BoardModel.HEX_SIDE_LENGTH, BoardModel.HEX_DIAMETER, 1.0));
        t.setTranslation(tl);
        TransformGroup anim = new TransformGroup();
        anim.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        anim.addChild(tileManager.getArtilleryTarget(type));
        TransformGroup tg = new TransformGroup(t);
        tg.addChild(anim);
        addChild(tg);
       
        // FIXME: somehow, this looks weird. find mistake.
        //RotationInterpolator ri = new RotationInterpolator(C.defAlpha, anim);
        //ri.setSchedulingBounds(BoardModel.bounds);
View Full Code Here

        BranchGroup back = new BranchGroup();
        Appearance sapp = new Appearance();
        sapp.setColoringAttributes(new ColoringAttributes(SKY, ColoringAttributes.SHADE_FLAT));
        sapp.setPolygonAttributes(C.noCull);
        sapp.setTexture(tileManager.getTexture("data/images/misc/clouds.jpg"));
        TransformGroup tg = new TransformGroup(new Transform3D(C.mkquat(1, 0, 0, Math.PI/2), new Vector3d(), 1.0));
        tg.addChild(new Sphere(1f, Primitive.GENERATE_TEXTURE_COORDS, 100, sapp));
        back.addChild(tg);
        Background bg = new Background(back);
        bg.setApplicationBounds(bounds);
        addChild(bg);
    }
View Full Code Here

            Transform3D t = new Transform3D();

            t.rotX(pitch(entity));
            t.setScale(scale);

            mech = new TransformGroup(t);
            mech.addChild(sh);
        }
        mech.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

        Transform3D ftrans = new Transform3D();
        ftrans.rotZ(facing(dir));
        ftrans.setTranslation(location(hex, c, elevation, height(entity)));
        facing = new TransformGroup(ftrans);
        facing.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        facing.addChild(mech);

        if (entity.getECMRange() != Entity.NONE) {
            int range = entity.getECMRange();
            Appearance eapp = new Appearance();
            eapp.setColoringAttributes(new ColoringAttributes(c50, ColoringAttributes.SHADE_FLAT));
            TransparencyAttributes ta = new TransparencyAttributes(TransparencyAttributes.BLENDED, 0.90f);
            ta.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
            eapp.setTransparencyAttributes(ta);
            TransparencyInterpolator ti = new TransparencyInterpolator(C.halfAlpha, ta, .90f, .97f);
            ti.setSchedulingBounds(BoardModel.bounds);
            addChild(ti);
            eapp.setPolygonAttributes(C.noCull);
            Shape3D ecm = makeECMArea(range);
            ecm.setAppearance(eapp);
            ecm.setPickable(false);
            facing.addChild(ecm);
            ecm = makeECMBorder(range);
            ecm.setAppearance(eapp);
            ecm.setPickable(false);
            facing.addChild(ecm);
            eapp = new Appearance();
            eapp.setColoringAttributes(new ColoringAttributes(c50, ColoringAttributes.SHADE_FLAT));
            eapp.setLineAttributes(C.defLine);
            ecm = makeECMOutline(range);
            ecm.setAppearance(eapp);
            ecm.setPickable(false);
            facing.addChild(ecm);
        }
       
        Appearance sapp = new Appearance();
        sapp.setMaterial(new Material(new Color3f(tint), C.black, c50, C.white, 64.0f));

        Cone co = new Cone();
        co.setAppearance(sapp);

        if (dir != sdir) {
            TransformGroup fscale = new TransformGroup();
            fscale.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
            ScaleInterpolator si = new ScaleInterpolator(C.dblAlpha, fscale);
            si.setSchedulingBounds(BoardModel.bounds);
            si.setMinimumScale(.8f);
            si.setMaximumScale(1.25f);
            fscale.addChild(co);
            Transform3D sftrans = new Transform3D();
            sftrans.rotZ(facing(sdir-dir));
            Vector3d sv = new Vector3d(0.0, 5*BoardModel.HEX_DIAMETER/12, 0.0);
            sftrans.transform(sv);
            sftrans.setTranslation(sv);
            TransformGroup sfacing = new TransformGroup(sftrans);
            sfacing.addChild(fscale);
            sfacing.addChild(si);
            facing.addChild(sfacing);
        }

        label = new TransformGroup(new Transform3D(C.nullRot, labelLocation(hex, c, elevation), 1.0));
        label.addChild(view.makeViewRelative(new LabelModel(entity.getShortName(), C.white, c50, LabelModel.BOLD), BoardModel.HEX_DIAMETER*.45));
        label.setPickable(false);
        label.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

        addChild(facing);
View Full Code Here

TOP

Related Classes of javax.media.j3d.TransformGroup

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.