java - Java3D: I can't see my triangle -
i'm new java3d , try show triangle, not show up, frame black. if add
bg.addchild(new colorcube(0.3));
it shows red square in middle (so showing shapes should work, shouldn't it?)
i don't know if problem construction of triangle or other part of view, e.g. triangle not in focus, small, not lit, etc. polygons trianglearray have lit source, or appear matt objects?
here code:
import com.sun.j3d.utils.geometry.colorcube; import com.sun.j3d.utils.geometry.geometryinfo; import com.sun.j3d.utils.geometry.normalgenerator; import com.sun.j3d.utils.geometry.sphere; import com.sun.j3d.utils.universe.simpleuniverse; import java.awt.borderlayout; import java.awt.color; import java.awt.frame; import java.awt.graphicsconfiguration; import javax.swing.jframe; import javax.media.j3d.*; import javax.vecmath.color3f; import javax.vecmath.color4f; import javax.vecmath.point3d; import javax.vecmath.point3f; import javax.vecmath.vector3f; public class simulator extends frame { point3f[] testtrianglepoints = { new point3f(0.0f ,0.0f, 1.0f), new point3f(0.0f, 0.0f, 1.2f), new point3f(0.2f, 0.2f, 1.2f)}; simulator() { system.out.println("simulator window initiated"); } public void run() { simpleuniverse u = new simpleuniverse(); branchgroup bg = new branchgroup(); //bg.addchild(new colorcube(0.3)); trianglearray t_geo = new trianglearray(9, trianglearray.coordinates); t_geo.setcoordinates(0,testtrianglepoints); geometryarray t_geoarray = (new geometryinfo(t_geo)).getgeometryarray(); shape3d t_shape = new shape3d(t_geoarray,new appearance()); bg.addchild(t_shape); u.addbranchgraph(bg); u.getviewingplatform().setnominalviewingtransform(); } } `
Comments
Post a Comment