// makering.java // // This program will generate a POV include file to make a particle ring like // the rings of Saturn. The user passes in the number of particles. // // Written by: Henry Wagner (henryw@panix.com) import java.io.*; import java.util.*; public class MakeRing { public static void CreateRing(String filename) throws IOException { File o = new File(filename); int c1, nParticles = 5000; Random myRand = new Random(); FileOutputStream os = new FileOutputStream(o); PrintStream ps = new PrintStream(os); ps.println( "// rings.inc" ); ps.println( "//" ); ps.println( "// Written by: Henry Wagner (henryw@panix.com)" ); ps.println( "#declare Saturn_Ring = union {" ); for( c1 = 0; c1 < nParticles; c1++ ) { ps.println( " object {" ); ps.println( " Particle" ); ps.println( " rotate < " + myRand.nextInt()%360 + ", 0, 0 >" ); ps.println( " rotate < 0, " + myRand.nextInt()%360 + ", 0 >"); ps.println( " rotate < 0, 0, " + myRand.nextInt()%360 + " >"); ps.println( " translate < " + myRand.nextInt()%20000 + ", 0, 0 >"); ps.println( " rotate < 0, " + myRand.nextFloat() * 360.0 + ", 0 >"); ps.println( " }" ); } ps.println( " texture { T_Brass_4C }" ); ps.println( "}" ); ps.close(); os.close(); } public static void main (String[] argv) { if (argv.length == 0) { System.out.println("ERROR: You didn't pass in the number of particles"); System.exit(0); } try { CreateRing("rings.inc"); } catch(IOException e) { System.err.println(e.getMessage()); } } }