private void readPolygons(StreamTokenizer lex, Scene scene, List<Vector> vertices, Material shapeMaterial, Matrix shapeMatrix) { int startLevel = lex.BracketLevel; while (!lex.EndOfStream) { double i1 = 0; if (lex.TryReadDouble(out i1)) { // read polyline till -1 double iPreLast = lex.ReadDouble(); double iLast = lex.ReadDouble(); while (iLast != -1) { scene.addObject(new Triangle(shapeMaterial, shapeMatrix * vertices[(int)i1], shapeMatrix * vertices[(int)iPreLast], shapeMatrix * vertices[(int)iLast])); iPreLast = iLast; iLast = lex.ReadDouble(); } } if (lex.BracketLevel <= startLevel) return; } }
public void AddToSceneFrom(Scene scene, ScnFile scnFile, string modelPath) { foreach (Primitive primitive in scnFile.Primitives) { scene.addObject(primitive); } foreach (Light light in scnFile.Lights) { scene.addLight(light); } // use VRML loader to load external models Vrml2FormatLoader vrmlLoader = new Vrml2FormatLoader(); foreach (ModelFileInfo modelFile in scnFile.ModelFiles) { // assume model in same folder as xml file string modelFileName = Path.Combine(modelPath, modelFile.FileName); vrmlLoader.TransformMatrix = modelFile.TransformMatrix; vrmlLoader.AddToSceneFrom(scene, modelFileName); } }