Results 1 to 6 of 6
  1. #1
    aRTx is offline Member
    Join Date
    Mar 2009
    Posts
    27
    Rep Power
    0

    Question 3D Texture-Mapped Rectangle with a Billboard behavior

    Write a Java 3D program that shows a texture-mapped rectangle with a Billboard behavior. Use an OrbitBehavior object to allow view manipulations through mouse operations.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Much luck with this. Please post the results of your program here when you've finished it so that we can check it out.

  3. #3
    aRTx is offline Member
    Join Date
    Mar 2009
    Posts
    27
    Rep Power
    0

    Lightbulb these are some codes...

    Java Code:
     import javax.vecmath.*;
     import java.awt.*;
     import java.awt.event.*;
     import java.net.URL;
     import javax.media.j3d.*;
     import com.sun.j3d.utils.universe.*;
     import com.sun.j3d.utils.geometry.*;
     import com.sun.j3d.utils.image.*;
     import com.sun.j3d.utils.behaviors.mouse.*;
     import com.sun.j3d.utils.behaviors.vp.*;
     import java.applet.*;
     import com.sun.j3d.utils.applet.MainFrame;
    
     public class TestBillboard extends Applet {
       public static void main(String[] args) {
         new MainFrame(new TestBillboard(), 480, 480);
       }
    
       public void init() {
         // create canvas
         GraphicsConfiguration gc =
           SimpleUniverse.getPreferredConfiguration();
         Canvas3D cv = new Canvas3D(gc);
         setLayout(new BorderLayout());
         add(cv, BorderLayout.CENTER);
         TextArea ta = new TextArea("",3,30,TextArea.SCROLLBARS_NONE);
         ta.setText("Rotation: Drag with left button\n");
         ta.append("Translation: Drag with right button\n");
         ta.append("Zoom: Hold Alt key and drag with left button");
         ta.setEditable(false);
         add(ta, BorderLayout.SOUTH);
         BranchGroup root = new BranchGroup();
         // axes
         Transform3D tr = new Transform3D();
         tr.setScale(0.5);
         // tr.setTranslation(new Vector3d(-0.8, -0.7, -0.5));
         TransformGroup tg = new TransformGroup(tr);
         root.addChild(tg);
         AxesBillboard axes = new AxesBillboard();
         tg.addChild(axes);
         BoundingSphere bounds = new BoundingSphere();
         // light
         AmbientLight light =
         new AmbientLight(true, new Color3f(Color.blue));
         light.setInfluencingBounds(bounds);
         root.addChild(light);
         PointLight ptlight = new PointLight(new Color3f(Color.white),
    		new Point3f(0f,0f,2f), new Point3f(1f,0f,0f));
         ptlight.setInfluencingBounds(bounds);
         root.addChild(ptlight);
         // background
         Background background = new Background(1.0f, 1.0f, 1.0f);
         background.setApplicationBounds(bounds);
         root.addChild(background);
         root.compile();
         SimpleUniverse su = new SimpleUniverse(cv);
         su.getViewingPlatform().setNominalViewingTransform();
         // viewplatform motion
         OrbitBehavior orbit = new OrbitBehavior(cv);
         orbit.setSchedulingBounds(new BoundingSphere());
         su.getViewingPlatform().setViewPlatformBehavior(orbit);
         su.addBranchGraph(root);
       }
     }
    and

    Java Code:
     import javax.vecmath.*;
     import java.awt.*;
     import java.awt.event.*;
     import javax.media.j3d.*;
     import com.sun.j3d.utils.universe.*;
     import com.sun.j3d.utils.geometry.*;
    
     public class AxesBillboard extends Group {
       public AxesBillboard() {
         Appearance ap = new Appearance();
         ap.setMaterial(new Material());
         Font3D font = new Font3D(new Font("SanSerif", Font.PLAIN, 1),
                                  new FontExtrusion());
         Text3D x = new Text3D(font, "x");
         Shape3D xShape = new Shape3D(x, ap);
         Text3D y = new Text3D(font, "y");
         Shape3D yShape = new Shape3D(y, ap);
         Text3D z = new Text3D(font, "z");
         Shape3D zShape = new Shape3D(z, ap);
         // transform for texts
         Transform3D tTr = new Transform3D();
         tTr.setTranslation(new Vector3d(-0.12, 0.6, -0.04));
         tTr.setScale(0.5);
         // transform for arrows
         Transform3D aTr = new Transform3D();
         aTr.setTranslation(new Vector3d(0, 0.5, 0));
         // bounds
         Bounds bounds = new BoundingSphere(new Point3d(0,0,0), 100);
         // x axis
         Cylinder xAxis = new Cylinder(0.05f, 1f);
         Transform3D xTr = new Transform3D();
         xTr.setRotation(new AxisAngle4d(0, 0, 1, -Math.PI/2));
         xTr.setTranslation(new Vector3d(0.5, 0, 0));
         TransformGroup xTg = new TransformGroup(xTr);
         xTg.addChild(xAxis);
         this.addChild(xTg);
    	 TransformGroup xTextTg = new TransformGroup(tTr);
         TransformGroup bbTg = new TransformGroup();
         bbTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
         xTextTg.addChild(bbTg);
         bbTg.addChild(xShape);
         Billboard bb = new Billboard(bbTg,
         Billboard.ROTATE_ABOUT_POINT, new Point3f(0,0,0));
         bb.setSchedulingBounds(bounds);
         xTextTg.addChild(bb);
         xTg.addChild(xTextTg);
         Cone xArrow = new Cone(0.1f, 0.2f);
         TransformGroup xArrowTg = new TransformGroup(aTr);
         xArrowTg.addChild(xArrow);
         xTg.addChild(xArrowTg);
         // y axis
         Cylinder yAxis = new Cylinder(0.05f, 1f);
         Transform3D yTr = new Transform3D();
         yTr.setTranslation(new Vector3d(0, 0.5, 0));
         TransformGroup yTg = new TransformGroup(yTr);
         yTg.addChild(yAxis);
         this.addChild(yTg);
         TransformGroup yTextTg = new TransformGroup(tTr);
         bbTg = new TransformGroup();
         bbTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
         yTextTg.addChild(bbTg);
         bbTg.addChild(yShape);
         bb = new Billboard(bbTg,
         Billboard.ROTATE_ABOUT_POINT, new Point3f(0,0,0));
         bb.setSchedulingBounds(bounds);
         yTextTg.addChild(bb);
         yTg.addChild(yTextTg);
         Cone yArrow = new Cone(0.1f, 0.2f);
         TransformGroup yArrowTg = new TransformGroup(aTr);
         yArrowTg.addChild(yArrow);
         yTg.addChild(yArrowTg);
         // z axis
         Cylinder zAxis = new Cylinder(0.05f, 1f);
         Transform3D zTr = new Transform3D();
         zTr.setRotation(new AxisAngle4d(1, 0, 0, Math.PI/2));
         zTr.setTranslation(new Vector3d(0, 0, 0.5));
         TransformGroup zTg = new TransformGroup(zTr);
         zTg.addChild(zAxis);
         this.addChild(zTg);
         TransformGroup zTextTg = new TransformGroup(tTr);
         bbTg = new TransformGroup();
         bbTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
         zTextTg.addChild(bbTg);
         bbTg.addChild(zShape);
         bb = new Billboard(bbTg,
         Billboard.ROTATE_ABOUT_POINT, new Point3f(0,0,0));
         bb.setSchedulingBounds(bounds);
         zTextTg.addChild(bb);
         zTg.addChild(zTextTg);
         Cone zArrow = new Cone(0.1f, 0.2f);
         TransformGroup zArrowTg = new TransformGroup(aTr);
         zArrowTg.addChild(zArrow);
         zTg.addChild(zArrowTg);
       }
     }
    pls if you can do that:
    Write a Java 3D program that shows a texture-mapped rectangle with a Billboard behavior. Use an OrbitBehavior object to allow view manipulations through mouse operations.

  4. #4
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Please don't shout in blue.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  5. #5
    aRTx is offline Member
    Join Date
    Mar 2009
    Posts
    27
    Rep Power
    0

    Default

    But UNTIL now it is not solved, the code is just for reference

  6. #6
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    I look forward to finding out what billboard behaviour is, in big friendly capitals.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

Similar Threads

  1. Strange behavior with Thread.sleep()
    By Steve11235 in forum Advanced Java
    Replies: 16
    Last Post: 05-04-2009, 05:24 AM
  2. strange refreshing behavior
    By diggitydoggz in forum New To Java
    Replies: 4
    Last Post: 12-27-2008, 04:51 PM
  3. Memory-Mapped File-(MappedByteBuffer )
    By lenah in forum Advanced Java
    Replies: 3
    Last Post: 12-22-2008, 07:00 PM
  4. Object class's equals() method behavior????
    By skyineyes in forum New To Java
    Replies: 4
    Last Post: 07-19-2008, 11:58 PM
  5. Bean data not mapped to database
    By kriskras in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 07-19-2008, 09:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •