andrei
Alessandro Borges wrote:
About learning Java3D: J3D.ORG (start here) www.j3d.orgTutorial : http://java.sun.com/products/java-media/3D/collateral/ Selman's books : http://www.manning.com/selman/ Barrileaux's book: http://www.manning.com/Barrilleaux/ Java3D API JumpStart (book website- nice demos): http://www.web3dbooks.com/java3d/jumpstart/welcome.html On Line: Gamming http://fivedots.coe.psu.ac.th/~ad/jg/ http://www.javagaming.org/cgi-bin/JGOForums/YaBB.cgi Alessandro ----- Original Message ----- From: "andrei" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, June 03, 2003 7:07 PM Subject: [JAVA3D] LineArrayhello List, some time ago, i made some VRML PROTO's that are the wireframe version of some basic geometric forms (spheres, boxes, cilinders, etc.). Now, I am trying to translate them to Java3D. I am studying the GeometryArray now, so I think it is a good exercise to learn it. But I am having some problems. The following code doesn't work. It tries do draw a circle :-) If you could help me, or send me some good links, I would thank you a lot. another question: if there is a list specific for beginners, please, send me the link :-) thank you for your time, andrei /* * CilindroWireframeTeste.java * * Created on 2 de Junho de 2003, 19:38 */ import java.applet.Applet; import java.awt.BorderLayout; import java.awt.Frame; import java.awt.event.*; import java.awt.GraphicsConfiguration; import com.sun.j3d.utils.applet.MainFrame; import com.sun.j3d.utils.universe.*; //import com.sun.j3d.utils.geometry.ColorCube; import javax.media.j3d.*; import javax.vecmath.*; public class CirculoWireframeTeste extends Applet { public CirculoWireframeTeste() { setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D canvas3D = new Canvas3D(config); add("Center", canvas3D); BranchGroup scene = createSceneGraph(); scene.compile(); // SimpleUniverse is a Convenience Utility class SimpleUniverse simpleU = new SimpleUniverse(canvas3D); // This moves the ViewPlatform back a bit so the // objects in the scene can be viewed. simpleU.getViewingPlatform().setNominalViewingTransform(); simpleU.addBranchGraph(scene); } // end of HelloJava3Da (constructor) public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); Transform3D rotate = new Transform3D(); rotate.rotX(Math.PI/4.0d); Transform3D rotate2 = new Transform3D(); rotate2.rotY(Math.PI/4.0d); // rotate object has composite transformation matrix rotate.mul(rotate2); TransformGroup objRotate = new TransformGroup(rotate); objRotate.addChild(criaCirculoWireframe(0.25f,16)); objRoot.addChild(objRotate); return objRoot; // no futuro, criar classe CilindroWireframe e usar // objRoot.addChild(new CilindroWireframe(0.4, 0.2)); } // end of createSceneGraph method of HelloJava3Da public Shape3D criaCirculoWireframe(float raio, int seg) { ColoringAttributes cor = new ColoringAttributes((float).7,0,0,ColoringAttributes.SHADE_FLAT); cor.setColor((float).1,0,0); Appearance appCilindro = new Appearance(); appCilindro.setColoringAttributes(cor); /*Material mat = new Material(); mat.setEmissiveColor(1f,0f,0f); mat.setAmbientColor(1f,1f,1f); appCilindro.setMaterial(mat); */ Shape3D circulo = new Shape3D(criaGeomCirculoWireframe(raio,seg));return circulo; } private Geometry criaGeomCirculoWireframe(float raio, int segmentos) { //private Geometry yoyoGeometry() { /* original VRML/_javascript_ code var p1 = new SFVec3f(); p1.x = radius; p1.y = 0; p1.z = 0; var _coord = new MFVec3f(); var _coordIndex = new MFInt32(); var angle = 2 * 3.14159 / segments; var rot = new SFRotation(0,1,0,angle); var p2; var iCoord = 0; var iCoordIndex = 0; for (i = 0; i <= segments; i++) { rot.angle = angle * i; p2 = rot.multVec(p1); _coordIndex[iCoordIndex++] = iCoord; _coord[iCoord++] = p2; } _coordIndex[iCoordIndex++] = -1; coord_changed = _coord; coordIndex_changed = _coordIndex; * * end of VRML code */ Point3f ponto = new Point3f(raio, 0f, 0f); Point3f ponto1 = new Point3f(ponto); Point3f ponto2 = new Point3f(); float angulo = 2f * 3.14159f / segmentos; float angulo_rot; //var rot = new SFRotation(0,1,0,); int i; Color3f cores[] = new Color3f[segmentos*2]; Point3f pontos[] = new Point3f[segmentos*2]; for (i = 0; i < segmentos; i++) { angulo_rot = angulo * i; ponto2.x = ponto.x * (float) Math.cos(angulo_rot) - ponto.z * (float)Math.sin(angulo_rot); ponto2.y = 0f; ponto2.z = ponto.x * (float) Math.sin(angulo_rot) - ponto.z * (float) Math.cos(angulo_rot); pontos[i*2] = new Point3f(ponto1); pontos[(i*2)+1] = new Point3f(ponto2); ponto1 = ponto2; } for (i=0; i < (segmentos*2); i++) cores[i] = new Color3f(1,1,1); LineArray linhas = new LineArray(segmentos*2, GeometryArray.COORDINATES | GeometryArray.COLOR_3); linhas.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE | GeometryArray.ALLOW_COLOR_WRITE ); linhas.setColors(0,cores); linhas.setCoordinates(0,pontos); return linhas; } // The following allows this to be run as an application // as well as an applet public static void main(String[] args) { Frame frame = new MainFrame(new CirculoWireframeTeste(), 256, 256); } // end of main (method of HelloJava3Da) } -- "First of all you can't be subversive without being subversive toyourself, that's very important. You miss something crucial if you think subversion means to have clearly defined enemies and act against them. The enemy always is always you, too and in the first place."http://www.koreawebart.org/0100101110101101org.html===========================================================================To unsubscribe, send email to [EMAIL PROTECTED] and include in thebodyof the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". .
-- "First of all you can't be subversive without being subversive to yourself, that's very important. You miss something crucial if you think subversion means to have clearly defined enemies and act against them. The enemy always is always you, too and in the first place." http://www.koreawebart.org/0100101110101101org.html
