Results 1 to 6 of 6
- 05-10-2009, 04:59 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 27
- Rep Power
- 0
-
Much luck with this. Please post the results of your program here when you've finished it so that we can check it out.
- 05-11-2009, 12:42 AM #3
Member
- Join Date
- Mar 2009
- Posts
- 27
- Rep Power
- 0
these are some codes...
andJava 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); } }
pls if you can do that: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); } }
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.
- 05-11-2009, 01:39 AM #4
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
- 05-11-2009, 07:34 AM #5
Member
- Join Date
- Mar 2009
- Posts
- 27
- Rep Power
- 0
But UNTIL now it is not solved, the code is just for reference
- 05-11-2009, 04:27 PM #6
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
-
Strange behavior with Thread.sleep()
By Steve11235 in forum Advanced JavaReplies: 16Last Post: 05-04-2009, 05:24 AM -
strange refreshing behavior
By diggitydoggz in forum New To JavaReplies: 4Last Post: 12-27-2008, 04:51 PM -
Memory-Mapped File-(MappedByteBuffer )
By lenah in forum Advanced JavaReplies: 3Last Post: 12-22-2008, 07:00 PM -
Object class's equals() method behavior????
By skyineyes in forum New To JavaReplies: 4Last Post: 07-19-2008, 11:58 PM -
Bean data not mapped to database
By kriskras in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 07-19-2008, 09:13 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks