Esempio n. 1
0
int Vip::req_vip_receive_world_tree(uint32_t id) {
	World_Tree_Flock_Map::iterator iter = vip_detail_->world_tree_val.find(id);
	const World_Tree_Config *conf =  CONFIG_CACHE_VIP->get_world_tree_config(id);
	if(iter == vip_detail_->world_tree_val.end() || !conf) {
		return ERROR_CLIENT_PARAM;
	}
	World_Tree_Flock &wtf = (iter->second);
	uint32_t addition = 0;
	if(conf->addition.size() > player_self()->vip()) {
		addition = conf->addition[player_self()->vip()];
	}
	if(addition == 0) {
		return 0;
	}
	Money_Add_List money_add_list;
	int32_t copper_num = (wtf.copper * addition) / 100 - wtf.receive_copper;
	int32_t souls_num = (wtf.souls * addition) / 100 - wtf.receive_souls;
	int32_t dragon_soul_num = (wtf.dragon_soul * addition) / 100 - wtf.receive_dragon_soul;
	{
		money_add_list.clear();
		//金币
		if(copper_num > 0) {
			Money_Add_Info copper(Money_Type(COPPER), copper_num, MONEY_ADD_VIP_WORLD_TREE);
			money_add_list.push_back(copper);
		}
		//英灵
		if(souls_num > 0) {
			Money_Add_Info souls(Money_Type(SOULS), souls_num, MONEY_ADD_VIP_WORLD_TREE);
			money_add_list.push_back(souls);
		}
		//龙魂
		if(dragon_soul_num > 0) {
			Money_Add_Info dragon_soul(Money_Type(DRAGON_SOUL), dragon_soul_num, MONEY_ADD_VIP_WORLD_TREE);
			money_add_list.push_back(dragon_soul);
		}
	}
	if(money_add_list.size() <= 0) {
		return ERROR_VIP_TREE_NOT_RECEIVE;
	}
	int return_status = player_self()->pack_add_money(money_add_list);
	if(return_status != 0) {
		return return_status;
	}
	wtf.receive_copper += copper_num;
	wtf.receive_souls += souls_num;
	wtf.receive_dragon_soul += dragon_soul_num;
	vip_detail_->detail_change();
	MSG_50106202 msg;
	msg.reset();
	msg.id = id;
	msg.tree_info = wtf;
	THIS_SEND_TO_CLIENT(msg);
	send_world_tree_icon_status(1);//需要统计是否还有可领
	{ // 背包获得客户端特效
		MSG_81000102 acv_msg;
		if (copper_num > 0) {
			acv_msg.property.push_back(Property(COPPER, copper_num));
		}
		if (souls_num > 0) {
			acv_msg.property.push_back(Property(SOULS, souls_num));
		}
		if (dragon_soul_num > 0) {
			acv_msg.property.push_back(Property(DRAGON_SOUL, dragon_soul_num));
		}
		if (!acv_msg.property.empty()) {
			THIS_SEND_TO_CLIENT(acv_msg);
		}
	}
	return 0;
}
Esempio n. 2
0
int main(int argc, char* argv[])
{
    // Build your scene and setup your camera here, by calling
    // functions from Raytracer.  The code here sets up an example
    // scene and renders it from two different view points, DO NOT
    // change this if you're just implementing part one of the
    // assignment.
    Raytracer raytracer;
    int width = 320;
    int height = 240;
    int aa = 2;
    int sceneNum = 0;

    double toRadian = 2*M_PI/360.0;

    fprintf(stderr, "Using options:\n");

#ifdef USE_EXTENDEDLIGHTS
    fprintf(stderr, "\tExtended light sources\n");
#else
    fprintf(stderr, "\tPoint light sources\n");
#endif

#ifdef USE_REFRACTIONS
    fprintf(stderr, "\tRefractions\n");
#else
    fprintf(stderr, "\tNo refractions\n");
#endif

#ifdef USE_REFLECTIONS
    fprintf(stderr, "\tReflections\n");
#else
    fprintf(stderr, "\tNo reflections\n");
#endif

#ifdef IGNORE_SHADOWS
    fprintf(stderr, "\tNo shadows\n");
#else
    {
#ifdef USE_TRANSMISSIONSHADOWS
        fprintf(stderr, "\tTransmission-based shadows\n");
#else
        fprintf(stderr, "\tSimple shadows\n");
#endif
    }
#endif

#ifdef USE_FINERFLUX
    fprintf(stderr, "\tFiner numerical flux intergrations\n");
#else
    fprintf(stderr, "\tCoarser numerical flux intergrations\n");
#endif


    if (argc == 3) {
        width = atoi(argv[1]);
        height = atoi(argv[2]);
    } else if (argc == 4) {
        width = atoi(argv[1]);
        height = atoi(argv[2]);
        aa = atoi(argv[3]);
    } else if (argc == 5) {
        width = atoi(argv[1]);
        height = atoi(argv[2]);
        aa = atoi(argv[3]);
        sceneNum = atoi(argv[4]);
    }
    // SceneNum should not exceed total scenes
    if ((sceneNum > 3)|| (sceneNum <0)) {
        sceneNum = 0;
    }
    // Camera parameters.
    Point3D eye(0, 0, 1);
    Vector3D view(0, 0, -1);
    Vector3D up(0, 1, 0);
    double fov = 60;


    // Defines materials for shading.
    Material gold( Colour(0.3, 0.3, 0.3), Colour(0.75164, 0.60648, 0.22648),
                   Colour(0.628281, 0.555802, 0.366065),
                   51.2, 0.001, 0.0, 1/2.4 );
    Material jade( Colour(0.22, 0.38, 0.33), Colour(0.52, 0.73, 0.57),
                   Colour(0.316228, 0.316228, 0.316228),
                   12.8, 0.2 , 0.0, 0.0 );
    Material polishedGold( Colour(0.24725, 0.2245, 0.0645), Colour(0.34615, 0.3143, 0.0903),
                           Colour(0.797357, 0.723991, 0.208006), 83.2, 0.01,0.0,0.0);

    Material glass( Colour(0.15, 0.15, 0.15), Colour(0.08, 0.08, 0.08),
                    Colour(0.2, 0.2, 0.2), 50.1,0.08,0.9,0.6667 );

    Material glass1( Colour(0.2, 0.2, 0.2), Colour(0.2, 0.2, 0.2),
                     Colour(0.7, 0.7, 0.7), 10.1,0.03,0.9,0.6667 );


    Material steel( Colour(0.1, 0.1, 0.1), Colour(0.1, 0.1, 0.1),
                    Colour(0.8, 0.8, 0.8), 80, 0.03, 0.0, 1.0 );

    Material blueSolid( Colour(0, 0, 1), Colour(0, 0, 1),
                        Colour(0, 0, 0), 0, 0.0, 0.0, 1.0 );

    Material redSolid( Colour(1, 0, 0), Colour(1, 0, 0),
                       Colour(0, 0, 0), 0, 0.0, 0.0, 1.0 );

    Material chrome( Colour(0.25, 0.25, 0.25), Colour(0.4,0.4,0.4),
                     Colour(0.7746, 0.7746, 0.7746), 77, 0.42, 0.0, 1.0);

    Material ruby( Colour(0.1745, 0.01175, 0.01175), Colour(0.61424, 0.04136, 0.04136),
                   Colour(0.727811, 0.626959, 0.626959) , 76.8, 0.01, 0.0, 0.565);

    Material pearl( Colour(0.25, 0.20725, 0.20725), Colour(1, 0.829, 0.829),
                    Colour(0.296648, 0.296648, 0.296648), 11.264, 0.1,0.0,1.0 );

    Material silver(Colour(0.23125, 0.23125, 0.23125), Colour(0.2775, 0.2775, 0.2775),
                    Colour(0.773911, 0.773911, 0.773911), 89.6, 0.4,0.0, 1.0);

    Material emerald(Colour(0.0215, 0.1745, 0.0215),Colour(0.07568, 0.61424, 0.07568),
                     Colour(0.633, 0.727811, 0.633), 76.8, 0.1, 0.25, 0.637);

    Material brass(Colour(0.329412, 0.223529,  0.027451),Colour(0.780392, 0.568627, 0.113725),
                   Colour(0.992157, 0.941176, 0.807843),27.8974, 0.3, 0.0, 1.0 );

    Material bronze(Colour(0.2125, 0.1275, 0.054), Colour(0.714, 0.4284, 0.18144),
                    Colour(0.393548, 0.271906, 0.166721), 25.6, 0.1, 0.0, 1.0 );

    Material bronzeShiny(Colour(0.25, 0.148, 0.06475), Colour(0.4, 0.2368, 0.1036),
                         Colour(0.774597, 0.458561, 0.200621), 76.86, 0.15, 0.0, 1.0 );

    Material turquoise(Colour(0.1, 0.18725, 0.1745), Colour(0.396, 0.74151, 0.69102),
                       Colour(0.297254, 0.30829, 0.306678), 12.8, 0.01, 0.2, 0.9);

    Material obsidian(Colour(0.05375, 0.05, 0.06625), Colour(0.18275, 0.17, 0.22525),
                      Colour(0.332741, 0.328634, 0.346435), 38.4, 0.05, 0.18, 0.413);

    Material copper(Colour(0.19125, 0.0735, 0.0225), Colour(0.7038, 0.27048, 0.0828),
                    Colour(0.256777, 0.137622, 0.086014), 12.8, 0.1, 0.0, 1.0 );

    Material copperPolished(Colour(0.2295, 0.08825, 0.0275), Colour(0.5508, 0.2118, 0.066),
                            Colour(0.580594, 0.223257, 0.0695701), 51.2, 0.15, 0.0, 1.0 );

    Material pewter(Colour(0.105882, 0.058824, 0.113725), Colour(0.427451, 0.470588, 0.541176),
                    Colour(0.333333, 0.333333, 0.521569), 9.84615, 0.0, 0.0, 1.0 );


    // Light Sources
    //=====================
    //raytracer.addLightSource( new PointLight(Point3D(1, 1, 2),Colour(0.5, 0.5, 0.5)) );

#ifdef USE_EXTENDEDLIGHTS
    // Defines a ball light source
    raytracer.addLightSource( new BallLight(Point3D(-1, 1, 1),
                                            2.0, Colour(0.9, 0.9, 0.9), 4) );
#else
    // Defines a point light source.
    raytracer.addLightSource( new PointLight(Point3D(0, 0, 5),
                              Colour(0.9, 0.9,0.9) ) );
#endif


    if (sceneNum==0) {

        // Defines a point light source.
        //raytracer.addLightSource( new PointLight(Point3D(0, 0, 5),
        //			Colour(0.9, 0.9, 0.9) ) );

        // Add a unit square into the scene with material mat.
        SceneDagNode* sphere = raytracer.addObject( new UnitSphere(), &gold);
        SceneDagNode* plane = raytracer.addObject( new UnitSquare(), &jade );

        // Apply some transformations to the unit square.
        double factor1[3] = { 1.0, 2.0, 1.0 };
        double factor2[3] = { 6.0, 6.0, 1.0 };
        double factor3[3] = { 4.0, 4.0, 4.0 };
        double factor4[3] = { 3.7, 3.7, 3.7 };
        raytracer.translate(sphere, Vector3D(0, 0, -5));
        raytracer.rotate(sphere, 'x', -45);
        raytracer.rotate(sphere, 'z', 45);
        raytracer.scale(sphere, Point3D(0, 0, 0), factor1);

        raytracer.translate(plane, Vector3D(0, 0, -7));
        raytracer.rotate(plane, 'z', 45);
        raytracer.scale(plane, Point3D(0, 0, 0), factor2);
        /*
        SceneDagNode* bigSphere = raytracer.addObject( new UnitSphere(), &glass1);
        raytracer.scale(bigSphere, Point3D(0, 0, 0), factor3);
        raytracer.translate(bigSphere, Vector3D(0, 0, -7));

        SceneDagNode* bigSphere2 = raytracer.addObject( new UnitSphere(), &glass1);
        raytracer.scale(bigSphere2, Point3D(0, 0, 0), factor4);
        raytracer.translate(bigSphere2, Vector3D(0, 0, -7));
        */

    }// end of scene 0

    if (sceneNum==1) {
        /*
        raytracer.addLightSource( new BallLight(Point3D(-1, 1, 1),
        	5.0, Colour(0.9, 0.9, 0.9), 0.888) );
        raytracer.addLightSource( new PointLight(Point3D(0, 0, 2),Colour(0.5, 0.5, 0.5)) );
        */

        // Add a unit square into the scene with material mat.
        SceneDagNode* sphere = raytracer.addObject( new UnitSphere(), &glass);
        SceneDagNode* sphere1 = raytracer.addObject( new UnitSphere(), &brass);
        SceneDagNode* plane = raytracer.addObject( new UnitSquare(), &jade);
        SceneDagNode* cylinder = raytracer.addObject( new UnitCylinder(), &brass);


        // Apply some transformations to the unit square.
        double factor1[3] = { 1.0, 2.0, 1.0 };
        double factor2[3] = { 6.0, 6.0, 1.0 };
        double factor3[3] = { 0.5, 0.5, 2.0 };
        raytracer.translate(sphere, Vector3D(0, 0, -5));
        raytracer.rotate(sphere, 'x', -45);
        raytracer.rotate(sphere, 'z', 45);
        raytracer.scale(sphere, Point3D(0, 0, 0), factor1);

        raytracer.translate(sphere1, Vector3D(-2.5, 0, -5));

        raytracer.translate(plane, Vector3D(0, 0, -7));
        raytracer.rotate(plane, 'z', 45);
        raytracer.scale(plane, Point3D(0, 0, 0), factor2);


        raytracer.translate(cylinder, Vector3D(3, 0, -5));
        //raytracer.rotate(cylinder, 'y', -20);
        raytracer.rotate(cylinder, 'z', 45);
        raytracer.rotate(cylinder, 'x', -75);
        raytracer.scale(cylinder, Point3D(0, 0, 0), factor3);

    }// end of scene1


    //=============== Scene 2 ==============================
    //=====================================================

    if(sceneNum == 2) {
        /*
        raytracer.addLightSource( new BallLight(Point3D(-1, 1, 1),
        	5.0, Colour(0.9, 0.9, 0.9), 0.888) );*/
        //raytracer.addLightSource( new PointLight(Point3D(0, 0, 2),Colour(0.5, 0.5, 0.5)) );

        //Set up walls
        //========================================================

        SceneDagNode* planeBack = raytracer.addObject( new UnitSquare(), &brass);
        SceneDagNode* planeBottom = raytracer.addObject( new UnitSquare(), &chrome);
        SceneDagNode* planeTop = raytracer.addObject( new UnitSquare(), &copperPolished);
        SceneDagNode* planeLeft = raytracer.addObject( new UnitSquare(), &bronzeShiny);
        SceneDagNode* planeRight = raytracer.addObject( new UnitSquare(), &brass);
        SceneDagNode* planeRear = raytracer.addObject( new UnitSquare(), &brass);

        double scaleFactor[3] = {8.0,8.0,1.0};
        double scaleFactor1[3] = {20.01,20.01,1.0};

        raytracer.translate(planeBottom, Vector3D(0, -10, 0));
        raytracer.translate(planeTop, Vector3D(0, 10, 0));
        raytracer.translate(planeLeft, Vector3D(-10, 0, 0));

        raytracer.translate(planeRight, Vector3D(10, 0, 0));

        raytracer.translate(planeBack, Vector3D(0, 0, -19.9));
        raytracer.translate(planeBottom, Vector3D(0, 0, -10));
        raytracer.translate(planeTop, Vector3D(0, 0, -10));
        raytracer.translate(planeLeft, Vector3D(0, 0, -10));
        raytracer.translate(planeRight, Vector3D(0, 0, -10));
        raytracer.translate(planeRear, Vector3D(0, 0, 20));

        raytracer.rotate(planeTop, 'x', 90);
        raytracer.rotate(planeBottom, 'x',-90);
        raytracer.rotate(planeLeft, 'y', -90);
        raytracer.rotate(planeRight, 'y', 90);
        raytracer.rotate(planeRear, 'x', 180);

        raytracer.scale(planeBack, Point3D(0, 0, 0), scaleFactor1);
        raytracer.scale(planeBottom, Point3D(0, 0, 0), scaleFactor1);
        raytracer.scale(planeTop, Point3D(0, 0, 0), scaleFactor1);
        raytracer.scale(planeLeft, Point3D(0, 0, 0), scaleFactor1);
        raytracer.scale(planeRight, Point3D(0, 0, 0), scaleFactor1);
        raytracer.scale(planeRear, Point3D(0, 0, 0), scaleFactor1);
        //===========================================================

        double scaleEgg[3] = { 1.0, 1.5, 1.0 };
        double scaleBall[3] = {2,2,2};
        SceneDagNode* sphere = raytracer.addObject( new UnitSphere(), &glass1);
        SceneDagNode* sphere1 = raytracer.addObject( new UnitSphere(), &ruby);
        SceneDagNode* sphere2 = raytracer.addObject( new UnitSphere(), &chrome);

        //SceneDagNode* cone = raytracer.addObject(sphere, new UnitCone(), &emerald);

        //raytracer.translate(cone, Vector3D(0,0,-2));
        raytracer.translate(sphere, Vector3D(-1,-1,-11));
        raytracer.scale(sphere, Point3D(0,0,0), scaleBall);

        raytracer.translate(sphere1, Vector3D(2.5,-1,-11));
        raytracer.translate(sphere2, Vector3D(2,3,-11));
        //raytracer.translate(cone, Vector3D(-1,-1,-12));
        raytracer.rotate(sphere1, 'z', -45);
        raytracer.scale(sphere1, Point3D(0,0,0), scaleEgg);
        //raytracer.rotate(cone, 'x', 90);

    }//end of scene 2


    //==================== Scene 3 =================
    //===============================================


    if(sceneNum == 3) {

#ifdef USE_EXTENDEDLIGHTS
        raytracer.addLightSource( new BallLight(Point3D(-5, 5, -3),
                                                2.0, Colour(0.4, 0.4, 0.4), 2) );
        raytracer.addLightSource( new BallLight(Point3D(5, 5, -3),
                                                2.0, Colour(0.4, 0.4, 0.4), 2) );
#else
        raytracer.addLightSource( new PointLight(Point3D(-5, 5, 0),
                                  Colour(0.5, 0.0, 0.0) ) );
        raytracer.addLightSource( new PointLight(Point3D(5, 5, 0),
                                  Colour(0.0, 0.5, 0.0) ) );
        raytracer.addLightSource( new PointLight(Point3D(0, -5, 0),
                                  Colour(0.0, 0.0, 0.5) ) );
#endif

        double planeScale[3] = {10.0, 10.0, 1.0};
        double sphereScale[3]= {1.5,1.5,1.5};
        double coneScale[3] = {1.5,1.5,5};

        SceneDagNode* plane = raytracer.addObject( new UnitSquare(), &pearl);
        SceneDagNode* sphere1 = raytracer.addObject( new UnitSphere(), &chrome);
        SceneDagNode* sphere2 = raytracer.addObject( new UnitSphere(), &brass);
        //SceneDagNode* cone = raytracer.addObject( new UnitCone(), &turquoise);

        raytracer.translate(sphere1, Vector3D(1, 1.5, -6.5));
        raytracer.translate(sphere2, Vector3D(-1, -1.5, -6.5));
        raytracer.scale(sphere2, Point3D(0,0,0), sphereScale);
        raytracer.scale(sphere1, Point3D(0,0,0), sphereScale);

        raytracer.rotate(plane, 'z', 45);
        raytracer.scale(plane, Point3D(0,0,0), planeScale);
        raytracer.translate(plane, Vector3D(0, 0, -8));
        /*
        		raytracer.translate(cone, Vector3D(2.0,-1.0,-3));
        		raytracer.rotate(cone, 'x', 180);
        		raytracer.scale(cone, Point3D(0,0,0), coneScale); */
    }

    // Render the scene, feel free to make the image smaller for
    // testing purposes.

    raytracer.render(width, height, eye, view, up, fov, aa,  "sig1.bmp", 's');
    //raytracer.render(width, height, eye, view, up, fov, aa, "diffuse1.bmp",'d');
    //raytracer.render(width, height, eye, view, up, fov, aa, "view1.bmp",'p');





    // Render it from a different point of view.
    Point3D eye2(4, 2, 1);
    Vector3D view2(-4, -2, -6);

    raytracer.render(width, height, eye2, view2, up, fov, aa, "sig2.bmp", 's');
    //raytracer.render(width, height, eye2, view2, up, fov, aa, "diffuse2.bmp",'d');
    //raytracer.render(width, height, eye2, view2, up, fov, aa, "view2.bmp",'p');



    Point3D eye3(-4, -2, 1);
    Vector3D view3(4, 2, -6);

    raytracer.render(width, height, eye3, view3, up, fov, aa, "sig3.bmp", 's');
    //raytracer.render(width, height, eye3, view3, up, fov, aa, "diffuse3.bmp",'d');
    raytracer.render(width, height, eye3, view3, up, fov, aa, "view3.bmp",'p');




    return 0;
}
Esempio n. 3
0
int main(int argc, char** argv)
{
    // initialize guacamole
    gua::init(argc, argv);

    // setup scene
    gua::SceneGraph graph("main_scenegraph");

    gua::math::vec4 iron(0.560, 0.570, 0.580, 1);
    gua::math::vec4 silver(0.972, 0.960, 0.915, 1);
    gua::math::vec4 aluminium(0.913, 0.921, 0.925, 1);
    gua::math::vec4 gold(1.000, 0.766, 0.336, 1);
    gua::math::vec4 copper(0.955, 0.637, 0.538, 1);
    gua::math::vec4 chromium(0.550, 0.556, 0.554, 1);
    gua::math::vec4 nickel(0.660, 0.609, 0.526, 1);
    gua::math::vec4 titanium(0.542, 0.497, 0.449, 1);
    gua::math::vec4 cobalt(0.662, 0.655, 0.634, 1);
    gua::math::vec4 platinum(0.672, 0.637, 0.585, 1);

    auto pbrMat(gua::MaterialShaderDatabase::instance()->lookup("gua_default_material")->make_new_material());
    // pbrMat.set_uniform("Color", chromium);
    // pbrMat.set_uniform("Roughness", 0.2f);
    // pbrMat.set_uniform("Metalness", 1.0f);

    std::string directory("/opt/3d_models/Cerberus_by_Andrew_Maximov/Textures/");
    pbrMat->set_uniform("ColorMap", directory + "Cerberus_A.tga");
    pbrMat->set_uniform("MetalnessMap", directory + "Cerberus_M.tga");
    pbrMat->set_uniform("RoughnessMap", directory + "Cerberus_R.tga");
    pbrMat->set_uniform("NormalMap", directory + "Cerberus_N.negated_green.tga");

    gua::TriMeshLoader loader;

    auto transform = graph.add_node<gua::node::TransformNode>("/", "transform");
    auto cerberus(loader.create_geometry_from_file(
        "cerberus", "/opt/3d_models/Cerberus_by_Andrew_Maximov/Cerberus_LP.3ds", pbrMat, gua::TriMeshLoader::NORMALIZE_POSITION | gua::TriMeshLoader::NORMALIZE_SCALE));
    graph.add_node("/transform", cerberus);
    cerberus->set_draw_bounding_box(true);
    cerberus->rotate(90, 0.f, 1.f, 0.f);
    cerberus->rotate(90, 0.f, 0.f, 1.f);

    auto pointLight = graph.add_node<gua::node::LightNode>("/", "pointLight");
    pointLight->data.set_type(gua::node::LightNode::Type::POINT);
    pointLight->data.color = gua::utils::Color3f(1.0f, 1.0f, 1.0f);
    pointLight->data.brightness = 150.0f; // lm
    pointLight->scale(9.f);
    pointLight->translate(-2.f, 3.f, 5.f);

    auto screen = graph.add_node<gua::node::ScreenNode>("/", "screen");
    screen->data.set_size(gua::math::vec2(1.92f, 1.08f));
    screen->translate(0, 0, 1.0);

    // add mouse interaction
    gua::utils::Trackball trackball(0.01, 0.002, 0.2);

    // setup rendering pipeline and window
    // auto resolution = gua::math::vec2ui(1920, 1080);
    auto resolution = gua::math::vec2ui(2560, 1440);

    std::string skymaps_dir("/opt/guacamole/resources/skymaps/");

    for(auto const& file : {std::string(directory + "Cerberus_A.tga"),
                            std::string(directory + "Cerberus_M.tga"),
                            std::string(directory + "Cerberus_R.tga"),
                            std::string(directory + "Cerberus_N.negated_green.tga"),
                            std::string(skymaps_dir + "skymap.jpg")})
    {
        gua::TextureDatabase::instance()->load(file);
    }

    auto tiledPipe(std::make_shared<gua::PipelineDescription>());
    tiledPipe->add_pass(std::make_shared<gua::TriMeshPassDescription>());
    tiledPipe->add_pass(std::make_shared<gua::LightVisibilityPassDescription>());
    tiledPipe->add_pass(std::make_shared<gua::ResolvePassDescription>());

    auto camera = graph.add_node<gua::node::CameraNode>("/screen", "cam");
    camera->translate(0, 0, 2.0);
    camera->config.set_resolution(resolution);
    camera->config.set_screen_path("/screen");
    camera->config.set_scene_graph_name("main_scenegraph");
    camera->config.set_output_window_name("main_window");
    camera->config.set_enable_stereo(false);
    camera->set_pipeline_description(tiledPipe);

    auto window = std::make_shared<gua::GlfwWindow>();
    gua::WindowDatabase::instance()->add("main_window", window);
    window->config.set_enable_vsync(false);
    window->config.set_size(resolution);
    window->config.set_resolution(resolution);
    window->config.set_stereo_mode(gua::StereoMode::MONO);
    window->on_resize.connect([&](gua::math::vec2ui const& new_size) {
        window->config.set_resolution(new_size);
        camera->config.set_resolution(new_size);
        screen->data.set_size(gua::math::vec2(0.001 * new_size.x, 0.001 * new_size.y));
    });
    window->on_move_cursor.connect([&](gua::math::vec2 const& pos) { trackball.motion(pos.x, pos.y); });
    window->on_button_press.connect(std::bind(mouse_button, std::ref(trackball), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
    window->open();

    gua::Renderer renderer;

    // application loop
    gua::events::MainLoop loop;
    gua::events::Ticker ticker(loop, 1.0 / 500.0);

    size_t ctr{};
    ticker.on_tick.connect([&]() {
        // apply trackball matrix to object
        gua::math::mat4 modelmatrix = scm::math::make_translation(gua::math::float_t(trackball.shiftx()), gua::math::float_t(trackball.shifty()), gua::math::float_t(trackball.distance())) *
                                      gua::math::mat4(trackball.rotation());

        transform->set_transform(modelmatrix);

        if(ctr++ % 150 == 0)
            gua::Logger::LOG_WARNING << "Frame time: " << 1000.f / window->get_rendering_fps() << " ms, fps: " << window->get_rendering_fps() << std::endl;

        window->process_events();
        if(window->should_close())
        {
            renderer.stop();
            window->close();
            loop.stop();
        }
        else
        {
            renderer.queue_draw({&graph});
        }
    });

    loop.start();

    return 0;
}