List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D Vector3D
public Vector3D(double x, double y, double z)
From source file:jtrace.scenes.OneSphere.java
public static void main(String[] args) throws IOException { Camera camera = new Camera(new Vector3D(0, 0, 5), new Vector3D(0, 0, 0), Vector3D.PLUS_J, 1.0, 4.0 / 3.0); Scene scene = new Scene(); scene.setCamera(camera);/*from ww w . j a va2 s.co m*/ LightSource light = new LightSource(new Vector3D(-3, 3, 3), 4); scene.addLightSource(light); FlatTexture sphereTexture = (new FlatTexture(new SolidPigment(new Colour(1, 0, 0)))) .addFinish(new DiffuseFinish(1.0)).addFinish(new AmbientFinish(0.1)); Sphere sphere = new Sphere(new Vector3D(0, 0, 0), 0.4); sphere.addTexture(sphereTexture); scene.addObject(sphere); BufferedImage image = scene.render(640, 480, 10); ImageIO.write(image, "PNG", new File("out.png")); }
From source file:jtrace.scenes.GlassSphere.java
public static void main(String[] args) throws IOException { Camera camera = new Camera(new Vector3D(0, 0, 2.0), new Vector3D(0, 0, 0), Vector3D.PLUS_J, 1.0, 800.0 / 600.0);//from ww w .j a v a 2s . c o m Scene scene = new Scene(); scene.setCamera(camera); scene.addLightSource(new LightSource(new Vector3D(-1, 3, 1), 4)); FlatTexture sphereTexture = (new FlatTexture(new SolidPigment(new Colour(1, 1, 1)))) .addFinish(new TransparentFinish(1.1)); Sphere sphere = new Sphere(new Vector3D(0, 0, 0), 0.4); sphere.addTexture(sphereTexture); scene.addObject(sphere); FlatTexture floorTexture = (new FlatTexture( new CheckeredPigment(new Colour(.5, .5, .5), new Colour(1, 1, 1), 1))) .addFinish(new DiffuseFinish(1.0)).addFinish(new AmbientFinish(0.05)); Plane plane = new Plane(new Vector3D(0, -0.4, 0), Vector3D.PLUS_J, Vector3D.PLUS_K); plane.addTexture(floorTexture); scene.addObject(plane); BufferedImage image = scene.render(800, 600, 10); ImageIO.write(image, "PNG", new File("out.png")); }
From source file:jtrace.scenes.MirroredSphere.java
public static void main(String[] args) throws IOException { Camera camera = new Camera(new Vector3D(-1, 1, 3), new Vector3D(0, 0, 0), Vector3D.PLUS_J, 1.0, 1.6); Scene scene = new Scene(); scene.setCamera(camera);/*w w w. ja v a 2 s .com*/ scene.addLightSource(new LightSource(new Vector3D(-3, 3, 3), 4)); FlatTexture sphereTexture = (new FlatTexture(new SolidPigment(new Colour(0, 1, 0)))) .addFinish(new AmbientFinish(0.1)).addFinish(new MirrorFinish(0.2)) .addFinish(new DiffuseFinish(0.8)).addFinish(new SpecularFinish(1.0, 100)); Sphere sphere = new Sphere(new Vector3D(0, 0, 0), 0.4); sphere.addTexture(sphereTexture); scene.addObject(sphere); FlatTexture floorTexture = (new FlatTexture( new CheckeredPigment(new Colour(.5, .5, .5), new Colour(1, 1, 1), 1))) .addFinish(new DiffuseFinish(1.0)).addFinish(new AmbientFinish(0.1)); Plane plane = new Plane(new Vector3D(0, -0.4, 0), Vector3D.PLUS_J, Vector3D.PLUS_K); plane.addTexture(floorTexture); scene.addObject(plane); BufferedImage image = scene.render(1440, 900, 10); ImageIO.write(image, "PNG", new File("out.png")); }
From source file:jtrace.scenes.OneCubeAnimate.java
public static void main(String[] args) throws IOException { Scene scene = new Scene(); scene.addLightSource(new LightSource(new Vector3D(-3, 3, -3), 4)); scene.addLightSource(new LightSource(new Vector3D(6, 6, -3), 4)); FlatTexture cubeTexture = (new FlatTexture(new SolidPigment(new Colour(0, 0, 1)))); cubeTexture.addFinish(new DiffuseFinish(1.0)); cubeTexture.addFinish(new AmbientFinish(0.1)); cubeTexture.addFinish(new MirrorFinish(0.2)); Cube cube = new Cube(new Vector3D(0, 0, 0), 0.5); cube.addTexture(cubeTexture);/*from w w w .j ava 2 s . c om*/ scene.addObject(cube); // FlatTexture floorTexture = new FlatTexture(new CheckeredPigment( // new Colour(.5,.5,.5), new Colour(1,1,1), 1)); FlatTexture floorTexture = new FlatTexture(new ImagePigment(new File("wood.jpg"), 1.0)); floorTexture.addFinish(new DiffuseFinish(1.0)); Plane plane = new Plane(new Vector3D(0, -0.25, 0), Vector3D.PLUS_J, Vector3D.PLUS_K); plane.addTexture(floorTexture); scene.addObject(plane); Vector3D pointAt = new Vector3D(0, 0, 0); int steps = 100; for (int i = 0; i < steps; i++) { double R = 2.0; double x = R * Math.sin(i * 2 * Math.PI / steps); double z = -R * Math.cos(i * 2 * Math.PI / steps); Camera camera = new Camera(new Vector3D(x, 1, z), pointAt, Vector3D.PLUS_J, 1.0, 800.0 / 600.0); scene.setCamera(camera); BufferedImage image = scene.render(800, 600, 10); ImageIO.write(image, "PNG", new File(String.format("out_%02d.png", i))); } }
From source file:jtrace.scenes.FourSpheres.java
public static void main(String[] args) throws IOException { Camera camera = new Camera(new Vector3D(-1, 2, 5), new Vector3D(0, 0, 0), Vector3D.PLUS_J, 1.0, 1.6); Scene scene = new Scene(); scene.setCamera(camera);//from w ww . ja v a2 s . co m scene.addLightSource(new LightSource(new Vector3D(-3, 3, 3), 4)); FlatTexture glossRed = (new FlatTexture(new SolidPigment(new Colour(1, 0, 0)))) .addFinish(new DiffuseFinish(1.0)).addFinish(new AmbientFinish(0.1)) .addFinish(new SpecularFinish(1.0, 100)); FlatTexture glossGreen = (new FlatTexture(new SolidPigment(new Colour(0, 1, 0)))) .addFinish(new DiffuseFinish(1.0)).addFinish(new AmbientFinish(0.1)) .addFinish(new SpecularFinish(1.0, 100)); FlatTexture glossBlue = (new FlatTexture(new SolidPigment(new Colour(0, 0, 1)))) .addFinish(new DiffuseFinish(1.0)).addFinish(new AmbientFinish(0.1)) .addFinish(new SpecularFinish(1.0, 100)); FlatTexture glossYellow = (new FlatTexture(new SolidPigment(new Colour(1, 1, 0)))) .addFinish(new DiffuseFinish(1.0)).addFinish(new AmbientFinish(0.1)) .addFinish(new SpecularFinish(1.0, 100)); Sphere redSphere = new Sphere(new Vector3D(-1, 0, 0), 0.4); redSphere.addTexture(glossRed); scene.addObject(redSphere); Sphere greenSphere = new Sphere(new Vector3D(0, 0, 1), 0.4); greenSphere.addTexture(glossGreen); scene.addObject(greenSphere); Sphere blueSphere = new Sphere(new Vector3D(0, 0, -1), 0.4); blueSphere.addTexture(glossBlue); scene.addObject(blueSphere); Sphere yellowSphere = new Sphere(new Vector3D(1, 0, 0), 0.4); yellowSphere.addTexture(glossYellow); scene.addObject(yellowSphere); FlatTexture floorTexture = new FlatTexture( new CheckeredPigment(new Colour(.5, .5, .5), new Colour(1, 1, 1), 1)); floorTexture.addFinish(new DiffuseFinish(1.0)); floorTexture.addFinish(new AmbientFinish(0.05)); Plane plane = new Plane(new Vector3D(0, -0.4, 0), Vector3D.PLUS_J, Vector3D.PLUS_K); plane.addTexture(floorTexture); scene.addObject(plane); BufferedImage image = scene.render(1440, 900, 10); ImageIO.write(image, "PNG", new File("out.png")); }
From source file:jtrace.scenes.OneCube.java
public static void main(String[] args) throws IOException { Camera camera = new Camera(new Vector3D(0, -2, 1), new Vector3D(0, 0, 0), Vector3D.PLUS_K, 1.0, 1440.0 / 900.0);/*from ww w .j a v a 2 s . co m*/ Scene scene = new Scene(); scene.setCamera(camera); scene.addLightSource(new LightSource(new Vector3D(-3, 3, 3), 4)); scene.addLightSource(new LightSource(new Vector3D(3, -3, 1), 4)); FlatTexture cubeTexture = (new FlatTexture(new SolidPigment(new Colour(0, 0, 1)))); cubeTexture.addFinish(new DiffuseFinish(1.0)); cubeTexture.addFinish(new AmbientFinish(0.1)); //cubeTexture.addFinish(new MirrorFinish(0.2)); Cube cube = new Cube(); //cube.addTransformation(new Scale(0.5)); cube.addTexture(cubeTexture); scene.addObject(cube); FlatTexture floorTexture = new FlatTexture(new ImagePigment(new File("wood.jpg"), 1.0)); floorTexture.addFinish(new DiffuseFinish(1.0)); Plane plane = new Plane(); plane.addTransformation(new Translation(0, 0, -0.5)); plane.addTexture(floorTexture); scene.addObject(plane); BufferedImage image = scene.render(1440, 900, 10); ImageIO.write(image, "PNG", new File("out.png")); }
From source file:edu.mit.fss.tutorial.part3.Element1.java
/** * The main method./*from w ww . j av a 2s.c o m*/ * * @param args the arguments * @throws RTIexception the RTI exception */ public static void main(String[] args) throws RTIexception { // Configure the logger and set it to display info messages. BasicConfigurator.configure(); logger.setLevel(Level.INFO); // Create a MobileElement object instance. MobileElement element = new MobileElement("Element 1", new Vector3D(10, 0, 0)); // Create an OnlineTutorialFederate object instance. OnlineTutorialFederate fed = new OnlineTutorialFederate(element); // Execute the federate and exit when complete. fed.execute(0, 50000, 1000); fed.exit(); }
From source file:edu.mit.fss.tutorial.part3.Element2.java
/** * The main method./*from w ww. j ava 2 s. c om*/ * * @param args the arguments * @throws RTIexception the RTI exception */ public static void main(String[] args) throws RTIexception { // Configure the logger and set it to display info messages. BasicConfigurator.configure(); logger.setLevel(Level.INFO); // Create a MobileElement object instance. MobileElement element = new MobileElement("Element 2", new Vector3D(0, 5, 0)); // Create an OnlineTutorialFederate object instance. OnlineTutorialFederate fed = new OnlineTutorialFederate(element); // Execute the federate and exit when complete. fed.execute(0, 50000, 1000); fed.exit(); }
From source file:jtrace.scenes.JustAPlane.java
public static void main(String[] args) throws IOException { Scene scene = new Scene(); //scene.setBackground(Colour.cyan.mix(0.8, Colour.white)); Camera camera = new Camera(new Vector3D(0, -3, 1), new Vector3D(0, 0, 0), Vector3D.PLUS_K, 1.0, 1440.0 / 900.0);//from w w w. j a v a 2 s. co m scene.setCamera(camera); LightSource light = new LightSource(new Vector3D(-3, -3, 3), 4); scene.addLightSource(light); FlatTexture floorTexture = new FlatTexture(new ImagePigment(new File("wood.jpg"), 1.0)); floorTexture.addFinish(new DiffuseFinish(1.0)); floorTexture.addFinish(new AmbientFinish(0.1)); Plane plane = new Plane(); plane.addTexture(floorTexture); plane.addTransformation(new Scale(2, 1, 1)); // plane.addTransformation(new Rotation(Vector3D.PLUS_K, Math.PI/16)); plane.addTransformation(new Rotation(Vector3D.PLUS_J, Math.PI / 16)); // plane.addTransformation(new Translation(0,-0.5,0)); scene.addObject(plane); BufferedImage image = scene.renderWireFrame(1440, 900, 10); ImageIO.write(image, "PNG", new File("out.png")); }
From source file:edu.mit.fss.tutorial.part4.ElementGUI.java
/** * The main method.// w ww . j a va 2s . c o m * * @param args the arguments * @throws RTIexception the RTI exception */ public static void main(String[] args) throws RTIexception { // Configure the logger and set it to display info messages. BasicConfigurator.configure(); logger.setLevel(Level.INFO); // Use an input dialog to request the element's name. String name = null; while (name == null || name.isEmpty()) { name = JOptionPane.showInputDialog("Enter element name:"); } // Create a MobileElement object instance. The "final" keyword allows // it to be referenced in the GUI thread below. final MobileElement element = new MobileElement(name, new Vector3D(0, 0, 0)); // Create an OnlineTutorialFederate object instance. The "final" // keyword allows it to be referenced in the GUI thread below. final OnlineTutorialFederate fed = new OnlineTutorialFederate(element); // Create the graphical user interface using the Event Dispatch Thread. try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { // Create a new ControlPanel object instance. ControlPanel controlPanel = new ControlPanel(); // Bind it to the element above. controlPanel.setBoundElement(element); // Add the control panel as an object change listener. fed.addObjectChangeListener(controlPanel); // Create a new frame to display the panel. Add the panel // as the content, pack it, and make it visible. JFrame frame = new JFrame(); frame.setContentPane(controlPanel); frame.pack(); frame.setVisible(true); // Add a new WindowAdapter object instance to exit the // federate when the window is closing. frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { fed.exit(); } }); } }); } catch (InvocationTargetException | InterruptedException e) { logger.error(e); } // Execute the federate. fed.execute(0, Long.MAX_VALUE, 1000); }