示例#1
0
文件: scene5.c 项目: vchaillo/rtv1
void			load_scene5_lights(t_scene *scene)
{
	scene->amb_intensity = 0.3;
	scene->amb_color = new_color(BLUE);
	add_light(scene, new_light(SPOT, 1, new_vector(-20, 15, 10),
		new_color(WHITE)));
	add_light(scene, new_light(DIR, 0.5, new_vector(0, -1, -1),
		new_color(WHITE)));
}
示例#2
0
int	handle_input(t_env* env, char* line)
{
	char**	input;
	int	nb_args;

	input = id_strwordtab(line, " \t", &nb_args);
	if (input == NULL)
		return (-1);
	if (id_strcmp(input[0], "c") == 0)
		return (fill_camera(env, input, nb_args));
	else if (id_strcmp(input[0], "S") == 0)
		return (new_sphere(env, input, nb_args));
	else if (id_strcmp(input[0], "P") == 0)
		return (new_plane(env, input, nb_args));
	else if (id_strcmp(input[0], "C") == 0)
		return (new_cylinder(env, input, nb_args));
	else if (id_strcmp(input[0], "Li") == 0)
		return (new_light(env, input, nb_args));
	id_wordtabfree(input);
	return (0);
}
示例#3
0
文件: vt_lua.c 项目: elionne/lutopia
int main()
{
    lua_State *L = luaL_newstate();
    int err;

    struct sockaddr_in send_to;

    luaL_openlibs(L);

    dmx = socket(AF_INET, SOCK_DGRAM, 0);

    send_to.sin_port = htons(21812);
    send_to.sin_family = AF_INET;

    if( inet_aton("127.0.0.1", &send_to.sin_addr) == 0 ){
        printf("invalid address\n");
        return EXIT_FAILURE;
    }

    if( connect(dmx, (struct sockaddr*)&send_to, sizeof(struct sockaddr_in)) < 0){
        printf("couldn’t not connect socket\n");
        return EXIT_FAILURE;
    }

    /*new_global_table(L, LIGHT); */

    register_lt_functions(L);

    new_universe(L, "u");
    new_group(L, "u", "group1");

    err = luaL_loadfile(L, "lights.lua");
    dbg_lua(L, err, "lights.lua");
    err = lua_pcall(L, 0, LUA_MULTRET, 0);
    dbg_lua(L, err, "lights.lua");

    new_light(L, 30, "u", "parled", "test1");
    new_light(L, 5, "u", "parled", "test2");
    new_light(L, 1, "u", "lspot", "spot1");
    new_light(L, 2, "u", "lspot", "spot2");
    new_light(L, 3, "u", "lspot", "spot3");
    new_light(L, 4, "u", "lspot", "spot4");


    link_into_group(L, "u", "group1", "test1");
    link_into_group(L, "u", "group1", "test2");

    err = luaL_loadfile(L, "test.lua");
    dbg_lua(L, err, "test.lua");
    err = lua_pcall(L, 0, LUA_MULTRET, 0);
    dbg_lua(L, err, "test.lua");

    double p = 0;

    lua_getglobal(L, "main");
    if( !lua_isfunction(L, -1) ){
        printf("\"main\" function, is not defined\n");
        return -1;
    }
    lua_pushnumber(L, p);
    err = lua_pcall(L, 1, 0, 0);
    dbg_lua(L, err, "main");

    //update_lights(L, "u", cue);

    //printf("%g\r", p);
    //fflush(stdout);

    do{
        lua_getglobal(L, "rt_time");
        if( !lua_isfunction(L, -1) ){
            printf("\"rt_time\" function, is not defined\n");
            break;
        }

        err = lua_pcall(L, 0, 0, 0);
        dbg_lua(L, err, "rt_time");

    }while(1);

    lua_close(L);
    close(dmx);
    return 0;
}