/** * Sets the world drawn by this view. * Then repaints this view. * @param world the world. */ public void setWorld(World world) { if (_world!=null) _world.removeView(this); _world = world; if (_world!=null) _world.addView(this); updateTransforms(); repaint(); }
/** * Marks dirty the drawing of this world. Calling this method causes * a repaint of all view canvases in which this world may be drawn. */ public void dirtyDraw() { repaint(); }
/** * Adds an image panel group to a simple frame from a given image panel * group. * @param ipg an image panel group. * @return the attached image panel group. */ public ImagePanelGroup addImagePanels(ImagePanelGroup ipg) { _world.addChild(ipg); return ipg; }
if (world==null) world = new World(); if (ao==null) ao = AxesOrientation.XRIGHT_YOUT_ZDOWN; _world = world;
_world.clearSelectedExcept(_selectable); _selectable.setSelected(true); } else { if (_world!=null) _world.clearSelected();
private PickResult pick(MouseEvent event) { ViewCanvas canvas = (ViewCanvas)event.getSource(); //canvas.addMouseMotionListener(_mml); ?? View view = canvas.getView(); if (view==null) return null; World world = view.getWorld(); if (world==null) return null; PickContext pc = new PickContext(event); world.pickApply(pc); PickResult pickResult = pc.getClosest(); if (pickResult!=null) { Point3 pointLocal = pickResult.getPointLocal(); Point3 pointWorld = pickResult.getPointWorld(); System.out.println("Pick"); System.out.println(" local="+pointLocal); System.out.println(" world="+pointWorld); } else { System.out.println("Pick nothing"); } return pickResult; } }
if (world!=null) { if (_worldSphere==null) _worldSphere = world.getBoundingSphere(true); BoundingSphere ws = _worldSphere; Point3 c = (!ws.isEmpty())?ws.getCenter():new Point3();
world.cullApply(cc); DrawList dl = cc.getDrawList(); DrawContext dc = new DrawContext(canvas);
/** * Adds a triangle group to a simple frame from a given triangle group. * @param tg a triangle group. * @return the attached triangle group. */ public TriangleGroup addTriangles(TriangleGroup tg) { _world.addChild(tg); return tg; }
/** * Demos the default behavior. */ private static void demo0() { Sphere sphere = new Sphere(); StateSet states = StateSet.forTwoSidedShinySurface(Color.WHITE); sphere.setStates(states); World world = new World(); world.addChild(sphere); SimpleFrame sf = new SimpleFrame(world); sf.setTitle("OrbitViewLighting Demo: Default lighting"); }
/** * Demos re-positioning the light source to the top-right corner. */ private static void demo1() { Sphere sphere = new Sphere(); StateSet states = StateSet.forTwoSidedShinySurface(Color.WHITE); sphere.setStates(states); World world = new World(); world.addChild(sphere); SimpleFrame sf = new SimpleFrame(world); OrbitViewLighting ovl = new OrbitViewLighting(); ovl.setPosition(0,1.0f,1.0f,0.0f); ovl.setLightSourceType(LightSourceType.DIRECTIONAL); sf.getOrbitView().setOrbitViewLighting(ovl); sf.setTitle("OrbitViewLighting Demo: Re-positioned primary light"); }
public static void main(String[] args) { int n1 = 101; int n2 = 121; int n3 = 141; double d1 = 1.0/(n1-1); double d2 = d1; double d3 = d1; double f1 = 0.0; double f2 = 0.0; double f3 = 0.0; Sampling s1 = new Sampling(n1,d1,f1); Sampling s2 = new Sampling(n2,d2,f2); Sampling s3 = new Sampling(n3,d3,f3); float k1 = 4.0f*FLT_PI*(float)d1; float k2 = 4.0f*FLT_PI*(float)d2; float k3 = 4.0f*FLT_PI*(float)d3; float[][][] fb = rampfloat(0.0f,k1,k2,k3,n1,n2,n3); float[][][] fa = sin(fb); ImagePanelGroup2 ipg = new ImagePanelGroup2(s1,s2,s3,fa,fb); ipg.setPercentiles1(1,99); World world = new World(); world.addChild(ipg); DemoFrame frame = new DemoFrame(world); frame.setVisible(true); } }
public static void main(String[] args) { StateSet states = new StateSet(); MaterialState ms = new MaterialState(); ms.setColorMaterialFront(GL_AMBIENT_AND_DIFFUSE); ms.setSpecularFront(Color.white); ms.setShininessFront(100.0f); states.add(ms); ColorCubeDemo cc1 = new ColorCubeDemo(); ColorCubeDemo cc2 = new ColorCubeDemo(); cc1.setStates(states); cc2.setStates(states); TransformGroup tg1 = new TransformGroup(Matrix44.translate(-2,0,0)); TransformGroup tg2 = new TransformGroup(Matrix44.translate( 2,0,0)); tg1.addChild(cc1); tg2.addChild(cc2); World world = new World(); world.addChild(tg1); world.addChild(tg2); DemoFrame frame = new DemoFrame(world); frame.setVisible(true); } }
public static void main(String[] args) { float[] xyz = makeSineWave(); xyz = addBulge(xyz); xyz = addTear(xyz); float[] rgb = makeColors(xyz); System.out.println("Making QuadGroup ..."); QuadGroup tg = new QuadGroup(true,xyz,rgb); System.out.println("QuadGroup bounding sphere =\n" + tg.getBoundingSphere(true)); StateSet states = new StateSet(); ColorState cs = new ColorState(); cs.setColor(Color.CYAN); states.add(cs); LightModelState lms = new LightModelState(); lms.setTwoSide(true); states.add(lms); MaterialState ms = new MaterialState(); ms.setColorMaterial(GL_AMBIENT_AND_DIFFUSE); ms.setSpecular(Color.white); ms.setShininess(100.0f); states.add(ms); tg.setStates(states); World world = new World(); world.addChild(tg); DemoFrame frame = new DemoFrame(world); OrbitView view = frame.getOrbitView(); view.setWorldSphere(new BoundingSphere(5,5,5,5)); frame.setSize(new Dimension(800,600)); frame.setVisible(true); }
public static void go() { float[] xyz = makeSineWave(); xyz = addBulge(xyz); xyz = addTear(xyz); float[] rgb = makeColors(xyz); TriangleGroup tg = new TriangleGroup(true,xyz,rgb); System.out.println("TriangleGroup bounding sphere =\n" + tg.getBoundingSphere(true)); StateSet states = new StateSet(); ColorState cs = new ColorState(); cs.setColor(Color.CYAN); states.add(cs); LightModelState lms = new LightModelState(); lms.setTwoSide(true); states.add(lms); MaterialState ms = new MaterialState(); ms.setColorMaterial(GL_AMBIENT_AND_DIFFUSE); ms.setSpecular(Color.WHITE); ms.setShininess(100.0f); states.add(ms); tg.setStates(states); World world = new World(); world.addChild(tg); DemoFrame frame = new DemoFrame(world); OrbitView view = frame.getOrbitView(); view.setWorldSphere(new BoundingSphere(5,5,5,5)); frame.setSize(new Dimension(800,600)); frame.setVisible(true); }