List of usage examples for javax.media.j3d Alpha Alpha
public Alpha(int loopCount, long increasingAlphaDuration)
From source file:HelloWorld.java
private static BranchGroup createSceneGraph() { // Make a scene graph branch BranchGroup branch = new BranchGroup(); // Make a changeable 3D transform TransformGroup trans = new TransformGroup(); trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); branch.addChild(trans);/*w ww . j a va2 s . c o m*/ // Make a shape ColorCube demo = new ColorCube(0.4); trans.addChild(demo); // Make a behavor to spin the shape Alpha spinAlpha = new Alpha(-1, 4000); RotationInterpolator spinner = new RotationInterpolator(spinAlpha, trans); spinner.setSchedulingBounds(new BoundingSphere(new Point3d(), 1000.0)); trans.addChild(spinner); return branch; }
From source file:Rotation.java
/** * Erstellt den Szenegraphen/*from ww w . j a v a 2 s . c o m*/ * * @return BranchGroup */ public BranchGroup macheSzene() { BranchGroup objWurzel = new BranchGroup(); // Transformation, 2 Rotationen: Transform3D drehung = new Transform3D(); Transform3D drehung2 = new Transform3D(); drehung.rotX(Math.PI / 4.0d); drehung2.rotY(Math.PI / 5.0d); drehung.mul(drehung2); TransformGroup objDreh = new TransformGroup(drehung); TransformGroup spin = new TransformGroup(); spin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); spin.addChild(new ColorCube(0.4)); objDreh.addChild(spin); objWurzel.addChild(objDreh); // Drehung Alpha spinAlpha = new Alpha(-1, 5000); RotationInterpolator dreher = new RotationInterpolator(spinAlpha, spin); BoundingSphere zone = new BoundingSphere(); dreher.setSchedulingBounds(zone); spin.addChild(dreher); return objWurzel; }
From source file:HelloJava3Dc.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // Create the transform group node and initialize it to the // identity. Add it to the root of the subgraph. TransformGroup objSpin = new TransformGroup(); objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objSpin);/* w w w.jav a 2 s .c o m*/ // Create a simple shape leaf node, add it to the scene graph. // ColorCube is a Convenience Utility class objSpin.addChild(new ColorCube(0.4)); // Create a new Behavior object that will perform the desired // operation on the specified transform object and add it into // the scene graph. Alpha rotationAlpha = new Alpha(-1, 4000); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objSpin); // a bounding sphere specifies a region a behavior is active // create a sphere centered at the origin with radius of 100 BoundingSphere bounds = new BoundingSphere(); rotator.setSchedulingBounds(bounds); objSpin.addChild(rotator); return objRoot; }
From source file:HelloUniverse1.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // Create the TransformGroup node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at run time. Add it to // the root of the subgraph. TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objTrans);// ww w . ja va 2 s . co m // Create a simple Shape3D node; add it to the scene graph. objTrans.addChild(new ColorCube(0.4)); // Create a new Behavior object that will perform the // desired operation on the specified transform and add // it into the scene graph. Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, 4000); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); rotator.setSchedulingBounds(bounds); objRoot.addChild(rotator); // Have Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:AxisClassDemoApp.java
public BranchGroup createSceneGraph() { BranchGroup objRoot = new BranchGroup(); objRoot.addChild(new Axis()); // Create the transform group node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. Add it to the // root of the subgraph. TransformGroup objSpin = new TransformGroup(); objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); // Create a new Behavior object that will perform the desired // operation on the specified transform object and add it into // the scene graph. Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, 4000); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objSpin); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); rotator.setSchedulingBounds(bounds); Transform3D trans = new Transform3D(); trans.set(new Vector3f(0.5f, 0.0f, 0.0f)); TransformGroup objTrans = new TransformGroup(trans); objRoot.addChild(objSpin);/* w w w.j a va 2 s .c o m*/ objSpin.addChild(objTrans); objSpin.addChild(rotator); objTrans.addChild(new ColorCube(0.1)); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:Text3DApp.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); Transform3D t3D = new Transform3D(); t3D.setTranslation(new Vector3f(0.0f, 0.0f, -3.0f)); TransformGroup objMove = new TransformGroup(t3D); objRoot.addChild(objMove);//from w ww. ja v a 2 s . c o m // Create the transform group node and initialize it to the // identity. Add it to the root of the subgraph. TransformGroup objSpin = new TransformGroup(); objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objMove.addChild(objSpin); Appearance textAppear = new Appearance(); ColoringAttributes textColor = new ColoringAttributes(); textColor.setColor(1.0f, 0.0f, 0.0f); textAppear.setColoringAttributes(textColor); textAppear.setMaterial(new Material()); // Create a simple shape leaf node, add it to the scene graph. Font3D font3D = new Font3D(new Font("Helvetica", Font.PLAIN, 1), new FontExtrusion()); Text3D textGeom = new Text3D(font3D, new String("3DText")); textGeom.setAlignment(Text3D.ALIGN_CENTER); Shape3D textShape = new Shape3D(); textShape.setGeometry(textGeom); textShape.setAppearance(textAppear); objSpin.addChild(textShape); // Create a new Behavior object that will perform the desired // operation on the specified transform object and add it into // the scene graph. Alpha rotationAlpha = new Alpha(-1, 10000); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objSpin); // a bounding sphere specifies a region a behavior is active // create a sphere centered at the origin with radius of 100 BoundingSphere bounds = new BoundingSphere(); rotator.setSchedulingBounds(bounds); objSpin.addChild(rotator); DirectionalLight lightD = new DirectionalLight(); lightD.setInfluencingBounds(bounds); lightD.setDirection(new Vector3f(0.0f, 0.0f, -1.0f)); lightD.setColor(new Color3f(1.0f, 0.0f, 1.0f)); objMove.addChild(lightD); AmbientLight lightA = new AmbientLight(); lightA.setInfluencingBounds(bounds); objMove.addChild(lightA); return objRoot; }
From source file:FPSCounterDemo.java
BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // Create the TransformGroup node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at run time. Add it to // the root of the subgraph. TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objTrans);/*from w ww. ja v a 2s . com*/ // Create a simple Shape3D node; add it to the scene graph. objTrans.addChild(new ColorCube(0.4)); // Create a new Behavior object that will perform the // desired operation on the specified transform and add // it into the scene graph. Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, 4000); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); rotator.setSchedulingBounds(bounds); objRoot.addChild(rotator); // Create the Framecounter behavior fpsCounter.setSchedulingBounds(bounds); objRoot.addChild(fpsCounter); return objRoot; }
From source file:Text2DApp.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // Create the transform group node and initialize it to the // identity. Add it to the root of the subgraph. TransformGroup objSpin = new TransformGroup(); objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objSpin);/*ww w . ja v a 2s . c o m*/ // Create a simple Text2D leaf node, add it to the scene graph. Text2D text2d = new Text2D("2D text in Java 3D", new Color3f(0.9f, 1.0f, 1.0f), "Helvetica", 24, Font.ITALIC); objSpin.addChild(text2d); Appearance textAppear = text2d.getAppearance(); // The following 4 lines of code (commented out) make the Text2D object // 2-sided. // This code depends on the line of code above that sets TextAppear. // PolygonAttributes polyAttrib = new PolygonAttributes(); // polyAttrib.setCullFace(PolygonAttributes.CULL_NONE); // polyAttrib.setBackFaceNormalFlip(true); // textAppear.setPolygonAttributes(polyAttrib); // The following 12 lines of code (commented out) use the texture from // the previous Text2D object on another object. // This code depends on the line of code above that sets TextAppear. // QuadArray qa = new QuadArray(4, QuadArray.COORDINATES | // QuadArray.TEXTURE_COORDINATE_2); // qa.setCoordinate(0, new Point3f(-10.0f, 1.0f, -5.0f)); // qa.setCoordinate(1, new Point3f(-10.0f, -1.0f, -5.0f)); // qa.setCoordinate(2, new Point3f(10.0f, -1.0f, -5.0f)); // qa.setCoordinate(3, new Point3f(10.0f, 1.0f, -5.0f)); // qa.setTextureCoordinate(0, new Point2f(0.0f, 1.0f)); // qa.setTextureCoordinate(1, new Point2f(0.0f, 0.0f)); // qa.setTextureCoordinate(2, new Point2f(1.0f, 0.0f)); // qa.setTextureCoordinate(3, new Point2f(1.0f, 1.0f)); // // objRoot.addChild(new Shape3D(qa, textAppear)); // Create a new Behavior object that will perform the desired // operation on the specified transform object and add it into // the scene graph. Alpha rotationAlpha = new Alpha(-1, 8000); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objSpin); // a bounding sphere specifies a region a behavior is active // create a sphere centered at the origin with radius of 100 BoundingSphere bounds = new BoundingSphere(); rotator.setSchedulingBounds(bounds); objSpin.addChild(rotator); Background backg = new Background(); backg.setColor(0.4f, 0.4f, 1.0f); backg.setApplicationBounds(new BoundingSphere()); objRoot.addChild(backg); return objRoot; }
From source file:BooksDemo.java
public void createScene() { BufferedImage image = new BufferedImage(xpanel.getWidth(), xpanel.getHeight(), BufferedImage.TYPE_INT_RGB); getContentPane().paint(image.getGraphics()); BufferedImage subImage = new BufferedImage(CANVAS3D_WIDTH, CANVAS3D_HEIGHT, BufferedImage.TYPE_INT_RGB); ((Graphics2D) subImage.getGraphics()).drawImage(image, null, -c3d.getX(), -c3d.getY()); Background bg = new Background(new ImageComponent2D(ImageComponent2D.FORMAT_RGB, subImage)); BoundingSphere bounds = new BoundingSphere(); bounds.setRadius(100.0);//from ww w .j a v a2 s. co m bg.setApplicationBounds(bounds); BranchGroup objRoot = new BranchGroup(); objRoot.addChild(bg); TransformGroup objTg = new TransformGroup(); objTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Transform3D yAxis = new Transform3D(); rotor1Alpha = new Alpha(1, 400); rotator1 = new RotationInterpolator(rotor1Alpha, objTg, yAxis, (float) Math.PI * 1.0f, (float) Math.PI * 2.0f); rotator1.setSchedulingBounds(bounds); textures.put("pages_top", createTexture("pages_top.jpg")); textures.put("pages", createTexture("amazon.jpg")); textures.put("amazon", createTexture("amazon.jpg")); textures.put("cover1", createTexture("cover1.jpg")); textures.put("cover2", createTexture("cover2.jpg")); textures.put("cover3", createTexture("cover3.jpg")); book = new com.sun.j3d.utils.geometry.Box(0.5f, 0.7f, 0.15f, com.sun.j3d.utils.geometry.Box.GENERATE_TEXTURE_COORDS, new Appearance()); book.getShape(book.TOP).setAppearance((Appearance) textures.get("pages_top")); book.getShape(book.RIGHT).setAppearance((Appearance) textures.get("pages")); book.getShape(book.LEFT).setAppearance((Appearance) textures.get("amazon")); book.getShape(book.FRONT).setAppearance((Appearance) textures.get("cover1")); book.getShape(book.BACK).setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); book.getShape(book.FRONT).setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); // book.getShape(book.LEFT).setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); // book.getShape(book.RIGHT).setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); objTg.addChild(book); objTg.addChild(rotator1); Transform3D spin = new Transform3D(); Transform3D tempspin = new Transform3D(); spin.rotX(Math.PI / 8.0d); tempspin.rotY(Math.PI / 7.0d); spin.mul(tempspin); TransformGroup objTrans = new TransformGroup(spin); objTrans.addChild(objTg); objRoot.addChild(objTrans); SimpleUniverse u = new SimpleUniverse(c3d); u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(objRoot); View view = u.getViewer().getView(); view.setSceneAntialiasingEnable(true); }
From source file:ConeYoyoApp.java
public BranchGroup createSceneGraph() { BranchGroup objRoot = new BranchGroup(); // Create the transform group node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. Add it to the // root of the subgraph. TransformGroup objSpin = new TransformGroup(); objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objSpin);//w w w .j a v a 2 s . co m objSpin.addChild(new ConeYoyo().getBG()); // Create a new Behavior object that will perform the desired // operation on the specified transform object and add it into // the scene graph. Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, 4000); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objSpin); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); rotator.setSchedulingBounds(bounds); objSpin.addChild(rotator); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }