void Builder::build() {

			engine3D->setDisabled(true);


			Rendering::OpenGLRenderer renderTarget(engine3D);
			renderTarget.begin(); // we clear before parsing...

			Preprocessor pp;
			QString out = pp.Process(loadedSystem);
			Tokenizer tokenizer(out);
			EisenParser e(&tokenizer);
			RuleSet* rs = e.parseRuleset();
			rs->resolveNames();
			Model::Builder b(&renderTarget, rs, false);
			b.build();
			if (b.wasCancelled()) throw Exception("User cancelled");

			renderTarget.end();
			engine3D->setRaytracerCommands(b.getRaytracerCommands());
			//INFO(QString("Setting %1 raytracer commands.").arg(raytracerCommands.count()));
			delete(rs);
			rs = 0;

			engine3D->setDisabled(false);
			engine3D->requireRedraw();

		}
Ejemplo n.º 2
0
 QString FilterSSynth::ssynth(QString grammar,int maxdepth,int seed,CallBackPos *cb){
    QString path("");
                 if (cb != NULL)		(*cb)(0, "Loading...");
            Template templ(this->renderTemplate);
            MyTrenderer renderer(templ);
            renderer.begin();
            Preprocessor pp;
            QString out = pp.Process(grammar);
            Tokenizer token(out);
            EisenParser parser(&token);
                        try
                        {
            RuleSet* rs=parser.parseRuleset();
            rs->resolveNames();
            rs->dumpInfo();
                        if(maxdepth>0)rs->setRulesMaxDepth(maxdepth);
            RandomStreams::SetSeed(seed);
            Builder b(&renderer,rs,false);
            b.build();
            renderer.end();
            QString output=renderer.getOutput();
			(*cb)(0, "Temp");
			QFile file(QDir::tempPath() + "/output.x3d");
            if(!file.open(QFile::WriteOnly | QFile::Text)){(*cb)(0, "File has not been opened"); return QString("");}
            QTextStream outp(&file);
            outp << output;
            file.close();
            path=file.fileName();
                        if (cb != NULL){	(*cb)(99, "Done");}
                        }
                        catch(Exception& ex){
                                return ex.getMessage();
                        }
                        catch(ParseError& ex){
                                return ex.getMessage();
                        }
    return path;
}