Example #1
0
static void ImageMerger_blit_rect (LIScrArgs* args)
{
	LIImgAsyncMerger* self;
	LIImgImage* image;
	LIScrData* data;
	LIMatRectInt dst_rect;
	LIMatRectInt src_rect;

	/* Get arguments. */
	self = args->self;
	if (!liscr_args_geti_data (args, 0, LIEXT_SCRIPT_IMAGE, &data))
		return;
	image = liscr_data_get_data (data);
	if (!liscr_args_geti_int (args, 1, &dst_rect.x))
		return;
	if (!liscr_args_geti_int (args, 2, &dst_rect.y))
		return;
	if (!liscr_args_geti_int (args, 3, &dst_rect.width))
		return;
	if (!liscr_args_geti_int (args, 4, &dst_rect.height))
		return;
	if (!liscr_args_geti_int (args, 5, &src_rect.x))
		return;
	if (!liscr_args_geti_int (args, 6, &src_rect.y))
		return;
	src_rect.width = dst_rect.width;
	src_rect.height = dst_rect.height;

	/* Add the task. */
	liimg_async_merger_blit (self, image, &dst_rect, &src_rect);
}
Example #2
0
static void Animation_copy (LIScrArgs* args)
{
	LIMdlAnimation* self;
	LIMdlAnimation* copy;
	LIScrData* data;

	/* Get arguments. */
	if (!liscr_args_geti_data (args, 0, LIEXT_SCRIPT_ANIMATION, &data))
		return;
	copy = liscr_data_get_data (data);

	/* Allocate the animation. */
	self = limdl_animation_new_copy (copy);
	if (self == NULL)
		return;

	/* Allocate the userdata. */
	data = liscr_data_new (args->script, args->lua, self, LIEXT_SCRIPT_ANIMATION, limdl_animation_free);
	if (data == NULL)
	{
		limdl_animation_free (self);
		return;
	}
	liscr_args_seti_stack (args);
}
Example #3
0
static void ImageMerger_blit_hsv_add_weightv (LIScrArgs* args)
{
	float val_range;
	LIImgAsyncMerger* self;
	LIImgColorHSV hsv;
	LIImgImage* image;
	LIScrData* data;

	/* Get arguments. */
	self = args->self;
	if (!liscr_args_geti_data (args, 0, LIEXT_SCRIPT_IMAGE, &data))
		return;
	if (!liscr_args_geti_float (args, 1, &hsv.h))
		hsv.h = 0.0f;
	if (!liscr_args_geti_float (args, 2, &hsv.s))
		hsv.s = 0.0f;
	if (!liscr_args_geti_float (args, 3, &hsv.v))
		hsv.v = 0.0f;
	if (!liscr_args_geti_float (args, 4, &val_range))
		val_range = 0.2f;
	image = liscr_data_get_data (data);

	/* Add the task. */
	liimg_async_merger_blit_hsv_add_weightv (self, image, NULL, NULL, &hsv, val_range);
}
Example #4
0
static void Heightmap_new (LIScrArgs* args)
{
	int i;
	int size;
	float spacing;
	float scaling;
	LIExtHeightmap* heightmap;
	LIExtHeightmapModule* module;
	LIImgImage* image;
	LIMatVector position;
	LIScrData* data;

	/* Get arguments. */
	module = liscr_script_get_userdata (args->script, LIEXT_SCRIPT_HEIGHTMAP);
	if (!liscr_args_geti_vector (args, 0, &position))
		position = limat_vector_init (0.0f, 0.0f, 0.0f);
	if (!liscr_args_geti_int (args, 1, &size))
		size = 33;
	else if (size < 0)
		size = 0;
	if (!liscr_args_geti_float (args, 2, &spacing))
		spacing = 1.0f;
	else if (spacing <= 0.0f)
		spacing = 1.0f;
	if (!liscr_args_geti_float (args, 3, &scaling))
		scaling = 1.0f;
	else if (scaling <= 0.0f)
		scaling = 1.0f;
	if (liscr_args_geti_data (args, 4, LIEXT_SCRIPT_IMAGE, &data))
		image = liscr_data_get_data (data);
	else
		image = NULL;

	/* Ensure that the size is valid. */
	for (i = 32 ; i < 65536 ; i *= 2)
	{
		if (size == i + 1)
			break;
	}
	if (size != i + 1)
	{
		lisys_error_set (EINVAL, "invalid heightmap size");
		lisys_error_report ();
		return;
	}

	/* Allocate the heightmap. */
	heightmap = liext_heightmap_new (module, image, &position, size, spacing, scaling);
	if (heightmap == NULL)
		return;

	/* Allocate the userdata. */
	data = liscr_data_new (args->script, args->lua, heightmap, LIEXT_SCRIPT_HEIGHTMAP, liext_heightmap_free);
	if (data == NULL)
	{
		liext_heightmap_free (heightmap);
		return;
	}
	liscr_args_seti_stack (args);
}
Example #5
0
static void Thread_push_message (LIScrArgs* args)
{
	const char* name = "";
	const char* string = NULL;
	LIScrData* data;
	LIEngModel* emodel;
	LIExtThread* self;

	/* Read the name. */
	self = args->self;
	if (!liscr_args_geti_string (args, 0, &name))
		liscr_args_gets_string (args, "name", &name);

	/* Read and push the data. */
	if (liscr_args_geti_string (args, 1, &string) ||
	    liscr_args_gets_string (args, "string", &string))
	{
		if (limai_program_push_message (self->program, LIMAI_MESSAGE_QUEUE_THREAD, LIMAI_MESSAGE_TYPE_STRING, name, string))
			liscr_args_seti_bool (args, 1);
	}
	else if (liscr_args_geti_data (args, 1, LISCR_SCRIPT_MODEL, &data) ||
	         liscr_args_gets_data (args, "model", LISCR_SCRIPT_MODEL, &data))
	{
		emodel = liscr_data_get_data (data);
		if (limai_program_push_message (self->program, LIMAI_MESSAGE_QUEUE_THREAD, LIMAI_MESSAGE_TYPE_MODEL, name, emodel->model))
			liscr_args_seti_bool (args, 1);
	}
	else
	{
		if (limai_program_push_message (self->program, LIMAI_MESSAGE_QUEUE_THREAD, LIMAI_MESSAGE_TYPE_EMPTY, name, NULL))
			liscr_args_seti_bool (args, 1);
	}
}
Example #6
0
static void Widget_add_child (LIScrArgs* args)
{
	LIScrData* data;

	/* Append rows. */
	if (liscr_args_geti_data (args, 0, LIEXT_SCRIPT_WIDGET, &data))
	{
		liwdg_widget_detach (liscr_data_get_data (data));
		liwdg_widget_add_child (args->self, liscr_data_get_data (data));
	}
}
Example #7
0
static void ImageMerger_blit (LIScrArgs* args)
{
	LIImgAsyncMerger* self;
	LIImgImage* image;
	LIScrData* data;

	/* Get arguments. */
	self = args->self;
	if (!liscr_args_geti_data (args, 0, LIEXT_SCRIPT_IMAGE, &data))
		return;
	image = liscr_data_get_data (data);

	/* Add the task. */
	liimg_async_merger_blit (self, image, NULL, NULL);
}
Example #8
0
static void Model_merge (LIScrArgs* args)
{
	LIScrData* data;
	LIEngModel* model1;
	LIEngModel* model2;

	if (liscr_args_geti_data (args, 0, LISCR_SCRIPT_MODEL, &data) ||
	    liscr_args_gets_data (args, "model", LISCR_SCRIPT_MODEL, &data))
	{
		model1 = args->self;
		model2 = liscr_data_get_data (data);
		if (!limdl_model_merge (model1->model, model2->model))
			lisys_error_report ();
	}
}
Example #9
0
static void Widget_append_row (LIScrArgs* args)
{
	int i;
	int w;
	int h;
	LIScrData* data;

	/* Append row. */
	liwdg_widget_get_size (args->self, &w, &h);
	if (!liwdg_widget_append_row (args->self))
		return;

	/* Append columns. */
	for (i = 0 ; i < w && liscr_args_geti_data (args, i, LIEXT_SCRIPT_WIDGET, &data) ; i++)
	{
		liwdg_widget_detach (liscr_data_get_data (data));
		liwdg_widget_set_child (args->self, i, h, liscr_data_get_data (data));
	}
}
Example #10
0
static void ImageMerger_blit_rect_hsv_add_weightv (LIScrArgs* args)
{
	float val_range;
	LIImgAsyncMerger* self;
	LIImgColorHSV hsv;
	LIImgImage* image;
	LIScrData* data;
	LIMatRectInt dst_rect;
	LIMatRectInt src_rect;

	/* Get arguments. */
	self = args->self;
	if (!liscr_args_geti_data (args, 0, LIEXT_SCRIPT_IMAGE, &data))
		return;
	if (!liscr_args_geti_int (args, 1, &dst_rect.x))
		return;
	if (!liscr_args_geti_int (args, 2, &dst_rect.y))
		return;
	if (!liscr_args_geti_int (args, 3, &dst_rect.width))
		return;
	if (!liscr_args_geti_int (args, 4, &dst_rect.height))
		return;
	if (!liscr_args_geti_int (args, 5, &src_rect.x))
		return;
	if (!liscr_args_geti_int (args, 6, &src_rect.y))
		return;
	src_rect.width = dst_rect.width;
	src_rect.height = dst_rect.height;
	if (!liscr_args_geti_float (args, 7, &hsv.h))
		hsv.h = 0.0f;
	if (!liscr_args_geti_float (args, 8, &hsv.s))
		hsv.s = 0.0f;
	if (!liscr_args_geti_float (args, 9, &hsv.v))
		hsv.v = 0.0f;
	if (!liscr_args_geti_float (args, 10, &val_range))
		val_range = 0.2f;
	image = liscr_data_get_data (data);

	/* Add the task. */
	liimg_async_merger_blit_hsv_add_weightv (self, image, &dst_rect, &src_rect, &hsv, val_range);
}
Example #11
0
static void Model_morph (LIScrArgs* args)
{
	float value = 0.5f;
	const char* shape;
	LIEngModel* model;
	LIEngModel* ref = NULL;
	LIScrData* data;

	model = args->self;
	if (!liscr_args_geti_string (args, 0, &shape) &&
	    !liscr_args_gets_string (args, "shape", &shape))
		return;
	if (!liscr_args_geti_float (args, 1, &value))
		liscr_args_gets_float (args, "value", &value);
	if (!liscr_args_geti_data (args, 2, LISCR_SCRIPT_MODEL, &data))
		liscr_args_gets_data (args, "ref", LISCR_SCRIPT_MODEL, &data);
	if (data != NULL)
		ref = liscr_data_get_data (data);

	liscr_args_seti_bool (args, limdl_model_morph (model->model,
		(ref != NULL)? ref->model : NULL, shape, value));
}
Example #12
0
static void Terrain_set_chunk_data (LIScrArgs* args)
{
	int grid_x;
	int grid_z;
	LIArcPacket* packet;
	LIScrData* data;

	/* Get the arguments. */
	if (!liscr_args_geti_int (args, 0, &grid_x) || grid_x < 0)
		return;
	if (!liscr_args_geti_int (args, 1, &grid_z) || grid_z < 0)
		return;

	/* Get the packet reader. */
	if (!liscr_args_geti_data (args, 2, LISCR_SCRIPT_PACKET, &data))
		return;
	packet = liscr_data_get_data (data);

	/* Read the data. */
	if (packet->reader != NULL)
		liscr_args_seti_bool (args, liext_terrain_set_chunk_data (args->self, grid_x, grid_z, packet->reader));
}