예제 #1
0
int LuaPerlinNoiseMap::l_calc2dMap(lua_State *L)
{
    NO_MAP_LOCK_REQUIRED;

    LuaPerlinNoiseMap *o = checkobject(L, 1);
    v2f p                = check_v2f(L, 2);

    Noise *n = o->noise;
    n->perlinMap2D(p.X, p.Y);

    return 0;
}
예제 #2
0
int LuaPerlinNoiseMap::l_get2dMap_flat(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;

	LuaPerlinNoiseMap *o = checkobject(L, 1);
	v2f p = check_v2f(L, 2);

	Noise *n = o->noise;
	n->perlinMap2D(p.X, p.Y);

	size_t maplen = n->sx * n->sy;

	lua_newtable(L);
	for (size_t i = 0; i != maplen; i++) {
		lua_pushnumber(L, n->result[i]);
		lua_rawseti(L, -2, i + 1);
	}
	return 1;
}
예제 #3
0
파일: l_noise.cpp 프로젝트: 0151n/minetest
int LuaPerlinNoiseMap::l_get2dMap_flat(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;

	LuaPerlinNoiseMap *o = checkobject(L, 1);
	v2f p = read_v2f(L, 2);

	Noise *n = o->noise;
	n->perlinMap2D(p.X, p.Y);

	int maplen = n->sx * n->sy;
	
	lua_newtable(L);
	for (int i = 0; i != maplen; i++) {
		float noiseval = n->np->offset + n->np->scale * n->result[i];
		lua_pushnumber(L, noiseval);
		lua_rawseti(L, -2, i + 1);
	}
	return 1;
}
예제 #4
0
int LuaPerlinNoiseMap::l_get2dMap(lua_State *L)
{
    NO_MAP_LOCK_REQUIRED;
    size_t i = 0;

    LuaPerlinNoiseMap *o = checkobject(L, 1);
    v2f p = check_v2f(L, 2);

    Noise *n = o->noise;
    n->perlinMap2D(p.X, p.Y);

    lua_newtable(L);
    for (u32 y = 0; y != n->sy; y++) {
        lua_newtable(L);
        for (u32 x = 0; x != n->sx; x++) {
            lua_pushnumber(L, n->result[i++]);
            lua_rawseti(L, -2, x + 1);
        }
        lua_rawseti(L, -2, y + 1);
    }
    return 1;
}
예제 #5
0
int LuaPerlinNoiseMap::l_get2dMap(lua_State *L)
{
	int i = 0;

	LuaPerlinNoiseMap *o = checkobject(L, 1);
	v2f p = read_v2f(L, 2);

	Noise *n = o->noise;
	n->perlinMap2D(p.X, p.Y);

	lua_newtable(L);
	for (int y = 0; y != n->sy; y++) {
		lua_newtable(L);
		for (int x = 0; x != n->sx; x++) {
			float noiseval = n->np->offset + n->np->scale * n->result[i++];
			lua_pushnumber(L, noiseval);
			lua_rawseti(L, -2, x + 1);
		}
		lua_rawseti(L, -2, y + 1);
	}
	return 1;
}