Package com.sun.j3d.utils.geometry

Examples of com.sun.j3d.utils.geometry.Box


      //Half edge length of the cube that represents the platform.
      float platformSize = 0.1f;

      //Generate the platform in the form of a cube.
      Box platform = new Box(platformSize,platformSize,platformSize,redApp);

      //A transformation rotating the platform a little bit.
      Transform3D tfPlatform = new Transform3D();
      tfPlatform.rotY(Math.PI/6);

      //The transformation group of the platform.
      TransformGroup tgPlatform = new TransformGroup(tfPlatform);
      tgPlatform.addChild(platform);


//*** The cockpit of the helicopter. ****

      //An Appearance to make the cockpit green.
      Appearance greenApp = new Appearance();
      setToMyDefaultAppearance(greenApp,new Color3f(0.0f,0.7f,0.0f));

      //Radius of the cockpit.
      float cabinRadius = 0.1f;

      //Generate the cockpit in the form of a sphere.
      Sphere cabin = new Sphere(cabinRadius,greenApp);

      //The transformation group for the cockpit.
      //The cockpit first remains in the origin. Later on, the whole
      //helicopter is shifted onto the platform.
      TransformGroup tgCabin = new TransformGroup();
      tgCabin.addChild(cabin);




//*** The rotor blade of the helicopter with its rotation ***

    //An Appearance to make the rotor blade blue.
    Appearance blueApp = new Appearance();
    setToMyDefaultAppearance(blueApp,new Color3f(0.0f,0.0f,1.0f));

    //Generate the rotor blade in the form of a (very thin and long) box.
    Box rotor = new Box(0.4f,0.0001f,0.01f,blueApp);

    //The transformation group for then rotor blade in which also the
    //animated rotation is implemented.
    TransformGroup tgmRotor = new TransformGroup();
    tgmRotor.addChild(rotor);

    //The slow rotation at the beginning.
    Transform3D bladeRotationAxis = new Transform3D();
    int timeStartRotor = 2000; //The rotor blade should start to turn after 2 seconds.
    int noStartRotations = 2//First, two slow rotations are carried out.
    int timeSlowRotation = 1500;//A slow rotation takes 1.5 seconds.

    //The Alpha for the slow rotation.
    Alpha bladeRotationStartAlpha = new Alpha(noStartRotations,
                                              Alpha.INCREASING_ENABLE,
                                              timeStartRotor,
                                              0,timeSlowRotation,0,0,0,0,0);



    //The slow rotation.
    RotationInterpolator bladeRotationStart = new RotationInterpolator(
                                             bladeRotationStartAlpha,tgmRotor,
                                             bladeRotationAxis,0.0f,(float) Math.PI*2);

    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE);
    bladeRotationStart.setSchedulingBounds(bounds);



    int timeFastRotation = 500; //A fast rotation takes 0.5 seconds.
    int timeOneWayFlight = 2000;//The helicopter rises within 2 seconds.
    int timeHovering = 1000;//It shall hover for one second.
    int timeStartWait = 1000;//The helicopter should start its flight when the rotor
                             //blade has been rotating fast for one second.

    //The overall time when the helicopter should start its flight.
    int timeFlightStart = timeStartRotor+timeSlowRotation*noStartRotations+timeStartWait;
    //Number of fast rotations.
    int noFastRotations = 1+ ((timeStartWait+2*timeOneWayFlight+timeHovering)/timeFastRotation);

    //The Alpha for the fast rotations.
    Alpha bladeRotationAlpha = new Alpha(noFastRotations,Alpha.INCREASING_ENABLE,
                                         timeStartRotor+timeSlowRotation*noStartRotations,
                                         0,timeFastRotation,0,0,0,0,0);


    //The fast rotation.
    RotationInterpolator bladeRotation = new RotationInterpolator(
                                             bladeRotationAlpha,tgmRotor,
                                             bladeRotationAxis,0.0f,(float) Math.PI*2);
    bladeRotation.setSchedulingBounds(bounds);


    //The slow and the fast rotation are assigned to the transformation group
    //of the rotor blade. These rotations are carried out in the origin so far.
    //The later transformations will place everything correctly.
    tgmRotor.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tgmRotor.addChild(bladeRotationStart);
    tgmRotor.addChild(bladeRotation);


//*** The transformation group to position the rotor blade on top of the cockpit. ***
    //The rotation of the rotor blade will therefore also take place om top
    //of the cockpit.
    Transform3D tfRotor = new Transform3D();
    tfRotor.setTranslation(new Vector3f(0.0f,cabinRadius,0.0f));
    TransformGroup tgRotor = new TransformGroup(tfRotor);
    tgRotor.addChild(tgmRotor);



//*** The tail of the helicopter. ***

    //Length of the tail.
    float halfTailLength = 0.2f;

    //Generate the tail in form of a green box.
    Box tail = new Box(halfTailLength,0.02f,0.02f,greenApp);

    //A transformation placing the tail at the end of the cockpit.
    Transform3D tfTail = new Transform3D();
    tfTail.setTranslation(new Vector3f(cabinRadius+halfTailLength,0.0f,0.0f));

View Full Code Here


                .doubleValue() / 2.0);

        float width = (float) (((DoubleToken) zWidth.getToken()).doubleValue() / 2.0);

        if (_changesAllowedNow) {
            Box box = new Box(1.0f, 1.0f, 1.0f, primitiveFlags, _appearance);

            TransformGroup scaler = new TransformGroup();
            scaler.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
            _scaleTransform = new Transform3D();
            _scaleTransform.setScale(new Vector3d(length, height, width));
            scaler.setTransform(_scaleTransform);
            scaler.addChild(box);
            _containedNode = scaler;
        } else {
            _containedNode = new Box(length, height, width, primitiveFlags,
                    _appearance);
            _scaleTransform = null;
        }
    }
View Full Code Here

        float len = (float)((Value * 0.89999997615814209D) / (maxValue + (double)LittleFloat) + (double)LittleFloat);
        float y = len;
        float z = ((2.0F / (float)pCount) * (float)j - 1.0F) + 1.0F / (float)pCount;
        t3dSelf.setTranslation(new Vector3d(x, y, z));
        objTransSelf.setTransform(t3dSelf);
        Box newBox = new Box(0.3F / (float)pCount, len, 0.3F / (float)pCount, BoxApp);
        objTransSelf.addChild(newBox);
        objTransSelf.setCapability(12);
        objTransSelf.setCapability(14);
        objTransSelf.setCapability(13);
        return objTransSelf;
View Full Code Here

        objRoot.setCapability(13);
        TransformGroup objTrans = new TransformGroup();
        objTrans.setCapability(18);
        objTrans.setCapability(17);
        objScale.addChild(objTrans);
        objTrans.addChild(new Box(1.0F, 0.005F, 1.0F, new Appearance()));
        if(surfaceMode)
        {
            Shape3D surface = new Shape3D();
            TriangleArray surfTriang = new TriangleArray((FData.getProcCount() - 1) * (FData.getProcCount() - 1) * 18, 7);
            int tNext = 0;
View Full Code Here

    material.setDiffuseColor(orange);
    material.setSpecularColor(orange);
    material.setEmissiveColor(orange);
    appear.setMaterial(material);

    final Box box = new Box();
    box.setAppearance(appear);

    final Appearance appear2 = new Appearance();

    final PointAttributes pointAttr2 = new PointAttributes();
    pointAttr2.setPointAntialiasingEnable(true);
    appear2.setPointAttributes(pointAttr2);

    final LineAttributes lineAttr2 = new LineAttributes();
    lineAttr2.setLineAntialiasingEnable(true);
    appear2.setLineAttributes(lineAttr2);

    final PolygonAttributes polyAttr2 = new PolygonAttributes();
    polyAttr2.setPolygonMode(PolygonAttributes.POLYGON_LINE);
    appear2.setPolygonAttributes(polyAttr2);

    final ColoringAttributes colorAttr2 = new ColoringAttributes();
    colorAttr2.setColor(new Color3f(1f, 0.5f, 0f));
    colorAttr2.setShadeModel(ColoringAttributes.NICEST);
    appear2.setColoringAttributes(colorAttr2);

    appear2.setMaterial(material);

    final Box box2 = new Box();
    box2.setAppearance(appear2);

    final PointLight pointLight1 = new PointLight();
    pointLight1.setPosition(2, 2, 2);
    pointLight1.setColor(new Color3f(1f, 1f, 1f));
    pointLight1.setInfluencingBounds(new BoundingSphere(new Point3d(0, 0, 0),
View Full Code Here

        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();
View Full Code Here

         Cylinder.ENABLE_GEOMETRY_PICKING,
         26, 26, lightGrayLook);
        final Sphere sphere = new Sphere(10,
            Sphere.GENERATE_NORMALS |
            Sphere.ENABLE_GEOMETRY_PICKING, redLook);
        final Box box = new Box(10,10,10,
            Box.GENERATE_NORMALS |
            Box.ENABLE_GEOMETRY_PICKING,
            redLook);

    this.edgeAppearanceTransformer = new ConstantTransformer(lightGrayLook);
View Full Code Here

  objRot.addChild(objTrans3);
    //end
 
 
    //Create a box
    Box BoxObj = new Box(0.8f, 0.8f, 0.8f, ap);
    objTrans3.addChild(BoxObj);


    // Let Java 3D perform optimizations on this scene graph.
    objRoot.compile();
View Full Code Here

/*     */
/* 129 */     super.buildGraph();
/*     */   }
/*     */
/*     */   public SceneGraphObject createNode(Class j3dClass) {
/* 133 */     Box box = (Box)super.createNode(j3dClass, new Class[] { Float.TYPE, Float.TYPE, Float.TYPE, Integer.TYPE, Appearance.class }, new Object[] { new Float(this.xdim), new Float(this.ydim), new Float(this.zdim), new Integer(this.primflags), null });
/*     */
/* 143 */     return box;
/*     */   }
View Full Code Here

/*     */
/* 143 */     return box;
/*     */   }
/*     */
/*     */   protected SceneGraphObject createNode() {
/* 147 */     return new Box(this.xdim, this.ydim, this.zdim, this.primflags, null);
/*     */   }
View Full Code Here

TOP

Related Classes of com.sun.j3d.utils.geometry.Box

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.