/** * LoadSceneOrig * * @param filename * @return int */ private int LoadSceneOrig () { String instr = Constants.INPUT; char[] spt = new char[1]; spt [0] = '\n'; sceneLines = instr.Split (spt); MainCL.logger.InfoFormat ("number of lines: {0}", sceneLines.Length); scenePos = 0; int numObj = 0, ObjID = 0; camera = null; lights = null; objects = null; materials = null; MaxX = MinX = MaxY = MinY = MaxZ = MinZ = 0.0f; String input; input = readString (); while (input != null) { if (input.Equals ("camera {")) { ReadCamera (); } else if (input.Equals ("point_light {")) { ReadLight (); } else if (input.Equals ("sphere {")) { numObj += ReadSphere (ObjID); } else if (input.Equals ("poly_set {")) { numObj += ReadPoly (ObjID); } else { ; } input = readString (); } return (numObj); }
/** * ReadMaterial * * @param infile * @return Material */ private Material ReadMaterial () { String temp; double[] input = new double[3]; Color[] colors = new Color[4]; int i, j; double shininess, ktran; temp = readString (); for (i = 0; i < 4; i++) { temp = readString (); if (i != 1) { temp = temp.Substring (14); } else { temp = temp.Substring (13); } for (j = 0; j < 2; j++) { input [j] = (double)Double.Parse (temp.Substring (0, temp.IndexOf (' '))); temp = temp.Substring (temp.IndexOf (' ') + 1); } input [2] = (double)Double.Parse (temp); colors [i] = new Color (input [0], input [1], input [2]); } temp = readString (); shininess = (double)Double.Parse (temp.Substring (14)); temp = readString (); ktran = (double)Double.Parse (temp.Substring (10)); temp = readString (); Material newmaterial = new Material (colors [0], colors [1], colors [2], colors [3], shininess, ktran); MaterialNode newnode = new MaterialNode (newmaterial, materials); materials = newnode; return (newmaterial); }