Exemplo n.º 1
0
/**
 * Page in debris bitmaps at level load
 */
void debris_page_in()
{
	uint i;

	Debris_model = model_load( NOX("debris01.pof"), 0, NULL );
	if (Debris_model >= 0)	{
		polymodel * pm;
		pm = model_get(Debris_model);
		Debris_num_submodels = pm->n_models;
	}

	Debris_vaporize_model = model_load( NOX("debris02.pof"), 0, NULL );

	for (i=0; i<Species_info.size(); i++ )
	{
		species_info *species = &Species_info[i];

		nprintf(( "Paging", "Paging in debris texture '%s'\n", species->debris_texture.filename));

		species->debris_texture.bitmap_id = bm_load(species->debris_texture.filename);
		if (species->debris_texture.bitmap_id < 0)
		{
			Warning( LOCATION, "Couldn't load species %s debris\ntexture, '%s'\n", species->species_name, species->debris_texture.filename);
		}

		bm_page_in_texture(species->debris_texture.bitmap_id);
	}
	
}
Exemplo n.º 2
0
/**
 * Set jump node model to render
 *
 * @param model_name Name of model file to load
 * @param show_polys Whether to render wireframe or not
 */
void CJumpNode::SetModel(char *model_name, bool show_polys)
{
	Assert(model_name != NULL);
	
	//Try to load the new model; if we can't, then we can't set it
	int new_model = model_load(model_name, 0, NULL, 0);
	
	if(new_model == -1)
	{
		Warning(LOCATION, "Couldn't load model file %s for jump node %s", model_name, m_name);
		return;
	}
	
	//If there's an old model, unload it
	if(m_modelnum != -1)
		model_unload(m_modelnum);

	//Now actually set stuff
	m_modelnum = new_model;
	m_flags |= JN_SPECIAL_MODEL;
	m_radius = model_get_radius(m_modelnum);

	//Do we want to change poly showing?
	if(show_polys)
		m_flags |= JN_SHOW_POLYS;
	else
		m_flags &= ~JN_SHOW_POLYS;
}
Exemplo n.º 3
0
void techroom_select_new_entry()
{
	Assert(Current_list != NULL);
	if (Current_list == NULL || Current_list_size <= 0) {
		Cur_entry_index = Cur_entry = -1;
		techroom_init_desc(NULL,0);
		return;
	}

	Cur_entry_index = Current_list[Cur_entry].index;
	Assert( Cur_entry_index >= 0 );

	// if we are in the ships tab, load the ship model
	if (Tab == SHIPS_DATA_TAB) {
		ship_info *sip = &Ship_info[Cur_entry_index];

		// little memory management, kinda hacky but it should keep the techroom at around
		// 100meg rather than the 700+ it can get to with all ships loaded - taylor
		for (int i=0; i<Current_list_size; i++) {
			if ((Current_list[i].model_num > -1) && (Current_list[i].textures_loaded)) {
				// don't unload any spot within 5 of current
				if ( (i < Cur_entry + 5) && (i > Cur_entry - 5) )
					continue;

				mprintf(("TECH ROOM: Dumping excess ship textures...\n"));

				model_page_out_textures(Current_list[i].model_num);

				Current_list[i].textures_loaded = 0;
			}
		}

		Techroom_ship_modelnum = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]);

		Current_list[Cur_entry].model_num = Techroom_ship_modelnum;

		// page in ship textures properly (takes care of nondimming pixels)
		model_page_in_textures(Techroom_ship_modelnum, Cur_entry_index);

		Current_list[Cur_entry].textures_loaded = 1;
	} else {
		Techroom_ship_modelnum = -1;
		Trackball_mode = 0;

		// load animation here, we now only have one loaded
		int stream_result = generic_anim_init_and_stream(&Current_list[Cur_entry].animation, Current_list[Cur_entry].tech_anim_filename, bm_get_type(Tech_background_bitmap), true);

		if (stream_result >= 0) {
			Current_list[Cur_entry].has_anim = 1;
		} else {
			// we've failed to load any animation
			// load an image and treat it like a 1 frame animation
			Current_list[Cur_entry].bitmap = bm_load(Current_list[Cur_entry].tech_anim_filename);
		}
	}

	techroom_init_desc(Current_list[Cur_entry].desc, Tech_desc_coords[gr_screen.res][SHIP_W_COORD]);
	fsspeech_play(FSSPEECH_FROM_TECHROOM, Current_list[Cur_entry].desc);
}
Exemplo n.º 4
0
// ------------------------------------------------------------------------------------
// shockwave_load()
//
// Call to load a shockwave, or add it and then load it
//
int shockwave_load(char *s_name, bool shock_3D)
{
	uint i;
	int s_index = -1;
	shockwave_info *si = NULL;

	Assert( s_name );

	// make sure that this is, or should be, valid
	if ( !VALID_FNAME(s_name) )
		return -1;

	for (i = 0; i < Shockwave_info.size(); i++) {
		if ( !stricmp(Shockwave_info[i].filename, s_name) ) {
			s_index = i;
			break;
		}
	}

	if (s_index < 0) {
		shockwave_info si_tmp;
	
		strcpy(si_tmp.filename, s_name);

		Shockwave_info.push_back( si_tmp );
		s_index = (int)(Shockwave_info.size() - 1);
	}

	Assert( s_index >= 0 );
	si = &Shockwave_info[s_index];

	// make sure to only try loading the shockwave once
	if ( (si->bitmap_id >= 0) || (si->model_id >= 0) )
		return s_index;

	if (shock_3D) {
		si->model_id = model_load( si->filename, 0, NULL );

		if ( si->model_id < 0 ) {
			Error(LOCATION, "Unable to load 3D shockwave '%s'!\n", si->filename);
			return -1;
		}
	} else {
		si->bitmap_id = bm_load_animation( si->filename, &si->num_frames, &si->fps, 1 );

		if ( si->bitmap_id < 0 ) {
			Error(LOCATION, "Unable to load 2D shockwave '%s'!\n", si->filename);
			return -1;
		}
	}
	
	return s_index;
}
Exemplo n.º 5
0
static PyObject* py_model_load(PyObject* module, PyObject* args, PyObject* kwargs)
{
    char*filename = 0;
    static char *kwlist[] = {"filename", NULL};
    if (args && !PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &filename))
        return NULL;
    ModelObject*self = PyObject_New(ModelObject, &ModelClass);
    self->model = model_load(filename);
    if(!self->model)
        return PY_ERROR("Couldn't load model from %s", filename);
    return (PyObject*)self;
}
Exemplo n.º 6
0
static void register_ship(void){
	particle_t*p;
	model_t *mod;
	material_t *mat;

	mod = model_load("data/ship.obj");
	
	mat = material_new();
	material_set_diffuse(mat,1,0,0,1.0);
	material_set_spec(mat,1,0.5,0.2,1.0);
	material_set_edge(mat,0.5,0,0,0.1);
	material_set_shininess(mat,50);
	material_enable(mat, DRAW_FACE | DRAW_EDGE);
	model_set_material(mod,1,mat);

	mat = material_new();
	material_set_diffuse(mat,0.8,0.8,0.8,1);
	material_set_spec(mat,0.8,0.8,0.8,1);
	material_set_shininess(mat,50);
	material_set_edge(mat,0,0,0,0.1);
	material_enable(mat, DRAW_FACE | DRAW_EDGE);
	model_set_material(mod,0,mat);

	mat = material_new();
	material_set_diffuse(mat,0,0,0,1);
	material_set_edge(mat,1,1,1,0.1);
	material_enable(mat, DRAW_FACE | DRAW_EDGE );
	model_set_material(mod,2,mat);


	p = particle_new(box_new(vec_new(0,0),40,32),0);
	p->draw = ship_draw;	
	p->move = particle_simple_move;
	p->action = ship_action;
	p->collide = ship_collide;
	p->vector[MISSILE] = vec_new(100,0);
	p->model[0] = mod;
	particle_set_color(p,1,0.3,0,0.1);
	particle_set_alt_color(p,1,0.5,0,0.5);
	particle_set_collides(p,1);
	particle_set_camera(p,1);
	particle_set_solid(p,1);
	particle_set_group(p,P_SHIP);
	particle_toggle_collide_group(p,P_SHIP);
	particle_toggle_collide_group(p,P_MISSILE);
	particle_set_nprop(p,SHIP_HSPEED,nprop_new(0,SHIP_ACCEL));
	particle_set_nprop(p,SHIP_VSPEED,nprop_new(0,SHIP_ACCEL));
	factory_register(p,P_SHIP);	
}
Exemplo n.º 7
0
// ------------------------------------------------------------------------------------
// shockwave_init()
//
// Call once at the start of each level (mission)
//
void shockwave_level_init()
{
	int i;	

	if ( !Default_shockwave_loaded ) {
		i = -1;

		// try and load in a 3d shockwave first
		// Goober5000 - check for existence of file before trying to load it
		if ( cf_exists_full("shockwave.pof", CF_TYPE_MODELS) ) {
			mprintf(("SHOCKWAVE =>  Loading default shockwave model... \n"));

			i = shockwave_load( Default_shockwave_3D_filename, true );

			if (i >= 0)
				mprintf(("SHOCKWAVE =>  Default model load: SUCCEEDED!!\n"));
			else
				mprintf(("SHOCKWAVE =>  Default model load: FAILED!!  Falling back to 2D effect...\n"));
		}

		// next, try the 2d shockwave effect, unless the 3d effect was loaded
		if (i < 0)
			i = shockwave_load( Default_shockwave_2D_filename );

		if (i < 0)
			Error(LOCATION, "ERROR:  Unable to open neither 3D nor 2D default shockwaves!!");

		Default_shockwave_loaded = 1;
	} else {
		// have to make sure that the default 3D model is still valid and usable
		// the 2D shockwave shouldn't need anything like this
		if (Shockwave_info[0].model_id >= 0)
			Shockwave_info[0].model_id = model_load( Default_shockwave_3D_filename, 0, NULL );
	}

	Assert( ((Shockwave_info[0].bitmap_id >= 0) || (Shockwave_info[0].model_id >= 0)) );

	list_init(&Shockwave_list);

	for ( i = 0; i < MAX_SHOCKWAVES; i++ ) {
		Shockwaves[i].flags = 0;
		Shockwaves[i].objnum = -1;
		Shockwaves[i].model_id = -1;
	}

	Shockwave_inited = 1;
}
Exemplo n.º 8
0
void shockwave_page_in()
{
	uint i;

	// load in shockwaves
	for (i = 0; i < Shockwave_info.size(); i++) {
		if (Shockwave_info[i].bitmap_id >= 0) {
			bm_page_in_texture( Shockwave_info[i].bitmap_id, Shockwave_info[i].num_frames );
		} else if (Shockwave_info[i].model_id >= 0) {
			// for a model we have to run model_load() on it again to make sure
			// that it's ref_count is sane for this mission
			int idx = model_load( Shockwave_info[i].filename, 0, NULL );
			Assert( idx == Shockwave_info[i].model_id );

			model_page_in_textures( Shockwave_info[i].model_id );
		}
	}
}
Exemplo n.º 9
0
static void register_ship_missile(void){
	particle_t *p;
	model_t *mod;
	material_t *mat;

	mod = model_load("data/missile.obj");
	
	mat = material_new();
	material_set_diffuse(mat,1,0,0,1.0);
	material_set_emit(mat,0.2,0.1,0,1.0);
	material_set_spec(mat,1,0.5,0.2,1.0);
	material_set_edge(mat,0.5,0,0,0.1);
	material_set_shininess(mat,50);
	material_enable(mat, DRAW_FACE | DRAW_EDGE);
	model_set_material(mod,0,mat);

	mat = material_new();
	material_set_diffuse(mat,0.416,0.525,0.345,1);
	material_set_spec(mat,0.025,0.149,0,1);
	material_set_shininess(mat,50);
	material_set_edge(mat,0,0,0,0.1);
	material_enable(mat, DRAW_FACE | DRAW_EDGE);
	model_set_material(mod,1,mat);

	p = particle_new(box_new(vec_new(0,0),10,10),-1);
	particle_set_color(p,0,0.5,1,0.1);
	particle_set_alt_color(p,0.1,0.6,1,0.1);
	p->draw = missile_draw;
	p->move = particle_simple_move;
	p->collide = missile_collide;
	p->die	= missile_die;
	p->action = missile_action;
	particle_set_group(p,P_MISSILE);
	particle_toggle_collide_group(p,P_SHIP);
	particle_toggle_collide_group(p,P_MISSILE);
	p->model[0] = mod;
	particle_set_collides(p,1);
	p->a = vec_new(0,0);
	particle_set_solid(p,0);
	factory_register(p,P_MISSILE);
}
Exemplo n.º 10
0
/**
 * Constructor for CJumpNode class, with world position argument
 */
CJumpNode::CJumpNode(vec3d *position) : m_radius(0.0f), m_modelnum(-1), m_objnum(-1), m_flags(0)
{	
	Assert(position != NULL);
	
	gr_init_alphacolor(&m_display_color, 0, 255, 0, 255);
	
	// Set m_name
	sprintf(m_name, XSTR( "Jump Node %d", 632), Jump_nodes.size());
	
	// Set m_modelnum and m_radius
	m_modelnum = model_load(NOX("subspacenode.pof"), 0, NULL, 0);
	if (m_modelnum == -1)
		Warning(LOCATION, "Could not load default model for %s", m_name);
	else
		m_radius = model_get_radius(m_modelnum);
	
    m_pos.xyz.x = position->xyz.x;
    m_pos.xyz.y = position->xyz.y;
    m_pos.xyz.z = position->xyz.z;
    
	// Create the object
    m_objnum = obj_create(OBJ_JUMP_NODE, -1, -1, NULL, &m_pos, m_radius, OF_RENDERS);
}
Exemplo n.º 11
0
/**
 * Call once at the start of each level (mission)
 */
void shockwave_level_init()
{
	int i;	

	if ( !Default_shockwave_loaded ) {
		i = -1;
		
		// try and load in a 3d shockwave first if enabled
		// Goober5000 - check for existence of file before trying to load it
		// chief1983 - Spicious added this check for the command line option.  I've modified the hardcoded "shockwave.pof" that existed in the check 
		// 	to use the static name instead, and added a check to override the command line if a 2d default filename is not found
		//  Note - The 3d shockwave flag is forced on by TBP's flag as of rev 4983
		if ( Cmdline_enable_3d_shockwave && cf_exists_full(Default_shockwave_3D_filename, CF_TYPE_MODELS) ) {
			mprintf(("SHOCKWAVE =>  Loading default shockwave model... \n"));

			i = shockwave_load( Default_shockwave_3D_filename, true );

			if (i >= 0)
				mprintf(("SHOCKWAVE =>  Default model load: SUCCEEDED!!\n"));
			else
				mprintf(("SHOCKWAVE =>  Default model load: FAILED!!  Falling back to 2D effect...\n"));
		}

		// next, try the 2d shockwave effect, unless the 3d effect was loaded
		// chief1983 - added some messages similar to those for the 3d shockwave
		if (i < 0 || Cmdline_fb_explosions) {
			mprintf(("SHOCKWAVE =>  Loading default shockwave animation... \n"));

			i = shockwave_load( Default_shockwave_2D_filename );

			if (i >= 0)
				mprintf(("SHOCKWAVE =>  Default animation load: SUCCEEDED!!\n"));
			else
				mprintf(("SHOCKWAVE =>  Default animation load: FAILED!!  Checking if 3d effect was already tried...\n"));
		}
			
		// chief1983 - The first patch broke mods that don't provide a 2d shockwave or define a specific shockwave for each model/weapon (shame on them)
		// The next patch involved a direct copy of the attempt above, with an i < 0 check in place of the command line check.  I've taken that and modified it to 
		// spit out a more meaningful message.  Might as well not bother trying again if the command line option was checked as it should have tried the first time through
		if ( i < 0 && !Cmdline_enable_3d_shockwave && cf_exists_full(Default_shockwave_3D_filename, CF_TYPE_MODELS) ) {
			mprintf(("SHOCKWAVE =>  Loading default shockwave model as last resort... \n"));

			i = shockwave_load( Default_shockwave_3D_filename, true );

			if (i >= 0)
				mprintf(("SHOCKWAVE =>  Default model load: SUCCEEDED!!\n"));
			else
				mprintf(("SHOCKWAVE =>  Default model load: FAILED!!  No effect loaded...\n"));
		}

		if (i < 0)
			Error(LOCATION, "ERROR:  Unable to open neither 3D nor 2D default shockwaves!!");

		Default_shockwave_loaded = 1;
	} else {
		// have to make sure that the default 3D model is still valid and usable
		// the 2D shockwave shouldn't need anything like this
		if (Shockwave_info[0].model_id >= 0)
			Shockwave_info[0].model_id = model_load( Default_shockwave_3D_filename, 0, NULL );
	}

	Assert( ((Shockwave_info[0].bitmap_id >= 0) || (Shockwave_info[0].model_id >= 0)) );

	list_init(&Shockwave_list);

	for ( i = 0; i < MAX_SHOCKWAVES; i++ ) {
		Shockwaves[i].flags = 0;
		Shockwaves[i].objnum = -1;
		Shockwaves[i].model_id = -1;
	}

	Shockwave_inited = 1;
}
Exemplo n.º 12
0
void load_objectShader () {
	char *fullName;
	char *positionEquation;
	size_t theSize;
	
	// script validation
	if ((mySection->paramNum  != 1)||(mySection->stringNum <  10)) {
		section_error("1 param and 10 strings needed");
		return;
	}

	local = malloc(sizeof(objectShader_section));
	if (!local)
	{
		dkernel_error("insuficient memory");
		return;
	}
	else
	{
		mySection->vars = (void *) local;

		// Depth Buffer Clearing Flag
		local->enableDepthBufferClearing = (int)mySection->param[0];

		// load object model
		theSize = strlen(mySection->strings[0]) + strlen(mySection->strings[1]);
		fullName = calloc(theSize+1, sizeof(char));
		sprintf(fullName, "%s%s", mySection->strings[0], mySection->strings[1]);

		local->object = model_load(fullName, USE_CACHE);
		if (!local->object) {
			section_error("ObjectShader: Error loading object %s for drawing", fullName);
			return;
		}
		
		if (model_upload_tex(local->object, mySection->strings[0]) == -1)
			return;

		// load layers for drawing the object
		local->layers = layers_load(mySection->strings[2]);

		// load sources model
		if (strcmp(mySection->strings[3], "default") != 0) {
			local->sources = model_load(mySection->strings[3], USE_CACHE);
			if (!local->object) {
				section_error("ObjectShader: Error loading object %s for sources positioning", mySection->strings[3]);
				return;
			}
		} else {
			local->sources = NULL;
		}

		// load the object positioning equation
		theSize = strlen(mySection->strings[4]) + strlen(mySection->strings[5]) + strlen(mySection->strings[6]);
		positionEquation = calloc(theSize+1, sizeof(char));
		sprintf(positionEquation, "%s%s%s", mySection->strings[4], mySection->strings[5], mySection->strings[6]);
		local->evalPositioning.equation = positionEquation;

		// load the sources positioning equation
		theSize = strlen(mySection->strings[7]) + strlen(mySection->strings[8]) + strlen(mySection->strings[9]);
		positionEquation = calloc(theSize+1, sizeof(char));
		sprintf(positionEquation, "%s%s%s", mySection->strings[7], mySection->strings[8], mySection->strings[9]);
		local->evalSources.equation = positionEquation;

		// Init the expression evaluation library
		initExpression(&local->evalPositioning);
		initExpression(&local->evalSources);
	}
	mySection->loaded=1;
}
Exemplo n.º 13
0
void			THIS::draw_legacy(
		FND * const & ptr,
		neb::fnd::glsl::program::Base const * const & p,
		gal::math::pose const & pose)
{
	printv_func(DEBUG);

	// load model matrix
	//LOG(lg, neb::gfx::sl, debug) << "load modelview matrix";
	model_load(ptr, p, pose);

	printv(DEBUG, pose);

	//material_.load(p);
	
	//glUseProgram(0);
	//glPushMatrix();
	//glTranslatef(pose.pos_.x, pose.pos_.y, pose.pos_.z);

	//LOG(lg, neb::gfx::sl, debug) << scale_.x << " " << scale_.y << " " << scale_.z;
	//LOG(lg, neb::gfx::sl, debug) << pose.pos_.x << " " << pose.pos_.y << " " << pose.pos_.z;


	// draw
	glBegin(GL_TRIANGLES);
	{
		// front faces
		glNormal3f(0,0,1);
		// face v0-v0.5-v2
		glColor3f(0.5,0.5,0.5);
		glVertex3f(0.5,0.5,0.5);
		glColor3f(0.5,0.5,0);
		glVertex3f(-0.5,0.5,0.5);
		glColor3f(0.5,0,0);
		glVertex3f(-0.5,-0.5,0.5);
		// face v2-v3-v0
		glColor3f(0.5,0,0);
		glVertex3f(-0.5,-0.5,0.5);
		glColor3f(0.5,0,0.5);
		glVertex3f(0.5,-0.5,0.5);
		glColor3f(0.5,0.5,0.5);
		glVertex3f(0.5,0.5,0.5);

		// right faces
		glNormal3f(1,0,0);
		// face v0-v3-v4
		glColor3f(0.5,0.5,0.5);
		glVertex3f(0.5,0.5,0.5);
		glColor3f(0.5,0,0.5);
		glVertex3f(0.5,-0.5,0.5);
		glColor3f(0,0,0.5);
		glVertex3f(0.5,-0.5,-0.5);
		// face v4-v5-v0
		glColor3f(0,0,0.5);
		glVertex3f(0.5,-0.5,-0.5);
		glColor3f(0,0.5,0.5);
		glVertex3f(0.5,0.5,-0.5);
		glColor3f(0.5,0.5,0.5);
		glVertex3f(0.5,0.5,0.5);

		// top faces
		glNormal3f(0,1,0);
		// face v0-v5-v6
		glColor3f(0.5,0.5,0.5);
		glVertex3f(0.5,0.5,0.5);
		glColor3f(0,0.5,0.5);
		glVertex3f(0.5,0.5,-0.5);
		glColor3f(0,0.5,0);
		glVertex3f(-0.5,0.5,-0.5);
		// face v6-v0.5-v0
		glColor3f(0,0.5,0);
		glVertex3f(-0.5,0.5,-0.5);
		glColor3f(0.5,0.5,0);
		glVertex3f(-0.5,0.5,0.5);
		glColor3f(0.5,0.5,0.5);
		glVertex3f(0.5,0.5,0.5);

		// left faces
		glNormal3f(-1,0,0);
		// face  v0.5-v6-v7
		glColor3f(0.5,0.5,0);
		glVertex3f(-0.5,0.5,0.5);
		glColor3f(0,0.5,0);
		glVertex3f(-0.5,0.5,-0.5);
		glColor3f(0,0,0);
		glVertex3f(-0.5,-0.5,-0.5);
		// face v7-v2-v0.5
		glColor3f(0,0,0);
		glVertex3f(-0.5,-0.5,-0.5);
		glColor3f(0.5,0,0);
		glVertex3f(-0.5,-0.5,0.5);
		glColor3f(0.5,0.5,0);
		glVertex3f(-0.5,0.5,0.5);

		// bottom faces
		glNormal3f(0,-1,0);
		// face v7-v4-v3
		glColor3f(0,0,0);
		glVertex3f(-0.5,-0.5,-0.5);
		glColor3f(0,0,0.5);
		glVertex3f(0.5,-0.5,-0.5);
		glColor3f(0.5,0,0.5);
		glVertex3f(0.5,-0.5,0.5);
		// face v3-v2-v7
		glColor3f(0.5,0,0.5);
		glVertex3f(0.5,-0.5,0.5);
		glColor3f(0.5,0,0);
		glVertex3f(-0.5,-0.5,0.5);
		glColor3f(0,0,0);
		glVertex3f(-0.5,-0.5,-0.5);

		// back faces
		glNormal3f(0,0,-1);
		// face v4-v7-v6
		glColor3f(0,0,0.5);
		glVertex3f(0.5,-0.5,-0.5);
		glColor3f(0,0,0);
		glVertex3f(-0.5,-0.5,-0.5);
		glColor3f(0,0.5,0);
		glVertex3f(-0.5,0.5,-0.5);
		// face v6-v5-v4
		glColor3f(0,0.5,0);
		glVertex3f(-0.5,0.5,-0.5);
		glColor3f(0,0.5,0.5);
		glVertex3f(0.5,0.5,-0.5);
		glColor3f(0,0,0.5);
		glVertex3f(0.5,-0.5,-0.5);
	}
	glEnd();

	//glPopMatrix();

}
Exemplo n.º 14
0
void load_objectMatrix() {
	char *evalEquation;
	char *evalSources;
	size_t equationSize;
	H3dsMeshObj *mesh;
	int i;

	// script validation
	if (mySection->stringNum != 14) {
		section_error("14 strings needed");
		return;
	}

	local = malloc(sizeof(objectMatrix_section));
	memset(local, 0, sizeof(objectMatrix_section));

	local->myParticleSystem = particles_init(local->myParticleSystem);

	mySection->vars = (void *) local;

	// load the object that will server as sources
	local->object = model_load(mySection->strings[0], USE_CACHE);
	if (!local->object) {
		section_error("objectMatrix: Error loading object sources: %s", mySection->strings[0]);
		return;
	}
	// load the object that will server as particle (and the shader)
	local->obj_part = model_load(mySection->strings[2], USE_CACHE);
	if (!local->object) {
		section_error("objectMatrix: Error loading particle object: %s", mySection->strings[1]);
		return;
	}
	if (model_upload_tex(local->obj_part, mySection->strings[1]) == -1)
		return;
	
	// load layers for drawing the object
	local->layers = layers_load(mySection->strings[3]);
	
	if (mySection->param[0] > 0) {
		local->myParticleSystem->disableDepthTest = 1;
	} else {
		local->myParticleSystem->disableDepthTest = 0;
	}
	
	// Equation defining the rate at which the particles are created (particles created per second)
	local->myParticleSystem->rate.equation = mySection->strings[4];
	
	// We only take into account the first mesh as particle sources
	mesh = &local->object->meshobjlist[0];
	
	// Get and store the particle source positions
	local->myParticleSystem->sourcesCount = mesh->verts;
	local->myParticleSystem->sources      = (tVector *) malloc(sizeof(tVector) * mesh->verts);
	local->myParticleSystem->sourcesColor = (tColor  *) malloc(sizeof(tColor ) * mesh->verts);

	for (i=0; i<local->myParticleSystem->sourcesCount; i++) {
		local->myParticleSystem->sources[i].x = mesh->vertlist[i].x;
		local->myParticleSystem->sources[i].y = mesh->vertlist[i].y;
		local->myParticleSystem->sources[i].z = mesh->vertlist[i].z;
		
		local->myParticleSystem->sourcesColor[i].r = 1.0;
		local->myParticleSystem->sourcesColor[i].g = 1.0;
		local->myParticleSystem->sourcesColor[i].b = 1.0;
	}
	
	// Particle evaluator
	equationSize = strlen(mySection->strings[5]);
	equationSize += strlen(mySection->strings[6]);
	equationSize += strlen(mySection->strings[7]);
	equationSize += strlen(mySection->strings[8]);
	equationSize += strlen(mySection->strings[9]);
	equationSize += strlen(mySection->strings[10]);
	evalEquation = calloc(equationSize+1, sizeof(char));
	strcat(evalEquation, (char *) mySection->strings[5]);
	strcat(evalEquation, (char *) mySection->strings[6]);
	strcat(evalEquation, (char *) mySection->strings[7]);
	strcat(evalEquation, (char *) mySection->strings[8]);
	strcat(evalEquation, (char *) mySection->strings[9]);
	strcat(evalEquation, (char *) mySection->strings[10]);
	local->myParticleSystem->Evaluator.equation = evalEquation;
	
	// Sources evaluator
	equationSize  = strlen(mySection->strings[11]);
	equationSize += strlen(mySection->strings[12]);
	equationSize += strlen(mySection->strings[13]);
	evalSources = calloc(equationSize+1, sizeof(char));
	strcpy(evalSources, (char *) mySection->strings[11]); //-V525
	strcat(evalSources, (char *) mySection->strings[12]);
	strcat(evalSources, (char *) mySection->strings[13]);
	local->myParticleSystem->Sources.equation = evalSources;
	
	// Init the expression evaluation library
	initExpression(&local->myParticleSystem->Sources);
	initExpression(&local->myParticleSystem->Evaluator);
	initExpression(&local->myParticleSystem->rate);
	mySection->loaded=1;
}