Esempio n. 1
0
int main (int argc, char *argv[])
{
#ifdef WIN32
    if (__argv[0]) {
        applicationPath = __argv[0];
        applicationPath.erase (applicationPath.find_last_of ('\\')+1, applicationPath.size());
    }
#else
    if (argv[0]) {
        applicationPath = argv[0];
        applicationPath.erase (applicationPath.find_last_of ('/')+1, applicationPath.size());
    }
#endif

    // Setup logger callback, so error messages are reported with fltk::message
    logger.AddCallback (LogCallbackProc, 0);
#ifdef _DEBUG
    logger.SetDebugMode (true);
#endif

//	math_test();

    // Initialize the class system
    creg::ClassBinder::InitializeClasses ();

    int r = 0;
    if (ParseCmdLine(argc, argv, r))
    {
        // Bring up the main editor dialog
        EditorUI editor;
        editorUI = &editor;
        editor.Show(true);
        editor.LoadToolWindowSettings();

//		luaBinder.Init();
        lua_State *L = lua_open();
        luaL_openlibs(L);
        luaopen_upspring(L);

        editor.luaState = L;

        if (luaL_dostring(L, "require(\"jit.opt\").start()") != 0)
        {
            const char *err = lua_tostring(L, -1);
            fltk::message("Unable to start Lua JIT: %s", err);
        }

        if (luaL_dofile(L, "scripts/init.lua") != 0)
        {
            const char *err = lua_tostring(L, -1);
            fltk::message("Error while executing init.lua: %s", err);
        }
        fltk::run();
    }

    // Shutdown scripting system and class system
    creg::ClassBinder::FreeClasses ();

    return r;
}
Esempio n. 2
0
	void start(){
		//resource
		String rspath = Application::instance()->appResourcesDirectory();
		//init renders
		Vec4 viewport(0, 0, 1280, 720);
		getRender().setViewportState(viewport);
        getRender().setClearColorState({64,64,64,255});
		getRender().setZBufferState(true);
		getRender().setBlendState(BlendState(BLEND::ONE, BLEND::ZERO));
		getRender().setCullFaceState(CullFace::DISABLE);
		//materials
		matTrackball.init();
		matPoints.init();
		matGeometry.init();
		matGeometry.setColor({1.0,1.0,1.0,1.0});
		//init trackball
		trackball.init(&matTrackball);
        //init track area
        //left
        trackAreaLeft.init(&matGeometry, &matPoints);
        trackAreaLeft.setTrackball(trackball);
        //right
        trackAreaRight.init(&matGeometry, &matPoints);
        trackAreaRight.setTrackball(trackball);
        //init ui
        ui.setSizeLeft(UI_SIZE);
        ui.setCallBackLoad([this](const String& path)
                           {
                               loadModel(path);
                           });
        ui.setCallBackSave([this](const String& path)
                           {
                               saveModels(path);
                           });
        ui.setCallBackSVD([this]()
                         {
                             mergeMesh();
                         });
		#if 0
		Mesh m1;
		m1.addMeshOFF(modelRight, {
			1, 0, 0, 0,
			0, 0.5, 0, 0,
			0, 0, 1, 0,
			0, 0, 0, 1
		});
		m1.saveOFF(rspath + "/meshs/faccia045.off");
		#endif
		
	}
Esempio n. 3
0
	void run(float dt){
		//clear
		getRender().doClear();
		//draw left
        drawModels();
        //draw ui
        ui.draw();
	}
Esempio n. 4
0
    void saveModels(const String& path)
    {
		if (lstate == NO_LOAD || !lastMesh)
		{
			ui.showWrongMessage("can't save mesh");
			return;
		}
        //screen size
        Vec2 ssize=getScreen().getSize();
        //add mesh to area
        if(!trackAreaLeft.saveMeshs(path))
        {
            ui.showWrongMessage("can't save mesh");
            return;
        }
        //viewport
        trackAreaLeft.setViewport(Vec4(UI_SIZE, 0,  ssize.x-UI_SIZE, ssize.y) );
        //new state
        lstate=ONE_LOAD;
    }
Esempio n. 5
0
    void mergeMesh()
    {
		if (lstate != ALL_LOAD || !lastMesh)
		{
			ui.showWrongMessage("can't merge mesh");
			return;
		}
        //screen size
        Vec2 ssize=getScreen().getSize();
        //add mesh to area
        if(!trackAreaLeft.addMeshsSVD(trackAreaRight))
        {
            ui.showWrongMessage("can't merge mesh");
            return;
        }
        //viewport
        trackAreaLeft.setViewport(Vec4(UI_SIZE, 0,  ssize.x-UI_SIZE, ssize.y) );
        //new state
        lstate=ONE_LOAD;
    }
Esempio n. 6
0
int main (int argc, char *argv[])
{
#ifdef WIN32
	if (__argv[0]) {
		applicationPath = __argv[0];
		applicationPath.erase (applicationPath.find_last_of ('\\')+1, applicationPath.size());
	}
#else
	if (argv[0]) {
		applicationPath = argv[0];
		applicationPath.erase (applicationPath.find_last_of ('/')+1, applicationPath.size());
	}
#endif

	// Setup logger callback, so error messages are reported with fltk::message
	logger.AddCallback (LogCallbackProc, 0);
#ifdef _DEBUG
	logger.SetDebugMode (true);
#endif

//	math_test();

	// Initialize the class system
	creg::System::InitializeClasses ();

	int r = 0;
	if (ParseCmdLine(argc, argv, r))
	{
		// Bring up the main editor dialog
		EditorUI editor;
		editorUI = &editor;
		editor.Show(true);
		editor.LoadToolWindowSettings();

//		luaBinder.Init();
		lua_State *L = lua_open();
		luaL_openlibs(L);
		luaopen_upspring(L);

		editor.luaState = L;

		if (luaL_dostring(L, "require(\"jit.opt\").start()") != 0) {
			const char *err = lua_tostring(L, -1);
			fltk::message("Unable to start Lua JIT: %s", err);
		}
		
		if (luaL_dofile(L, "scripts/init.lua") != 0) {
			const char *err = lua_tostring(L, -1);
			fltk::message("Error while executing init.lua: %s", err);
		}

		// NOTE: the "scripts/plugins" literal was changed to "scripts/plugins/"
		std::list<std::string>* luaFiles = FindFiles("*.lua", false,
#ifdef WIN32
			"scripts\\plugins");
#else
			"scripts/plugins/");
#endif

		for (std::list<std::string>::iterator i = luaFiles->begin(); i != luaFiles->end(); ++i) {
			if (luaL_dofile(L, i->c_str()) != 0) {
				const char *err = lua_tostring(L, -1);
				fltk::message("Error while executing \'%s\': %s", i->c_str(), err);
			}
		}

		fltk::run();
	}

	// Shutdown scripting system and class system
	creg::System::FreeClasses ();

	return r;
}