Hi,

I am reading a txt file which has coordinates for moving some entities in a cube room.

i notice it takes long time to read the file. and the movements look very bad. like there is a long gap between the movements.

Below is the function to read the data of the file, Is there any way i can improve the reading of the file. cause the movements are really bad.


---------------


function load_file()
{
var anim_percent = 0;
file_handle = file_open_read("debugLog32.txt");



if(file_handle == 0)
printf("Error Reading File");
else
{
while(eof_count!=1)
{
//wait(1);
eof_count = file_str_read(file_handle,sfile);


if(str_cmp(sfile,"CREATE"))
{
agent_count++;

//id
eof_count = file_str_read(file_handle,sfile);
str_num = str_to_num(sfile);

i = integer(str_num);

Agent[i].ID = i;



//x
eof_count = file_str_read(file_handle,sfile);
str_num = str_to_num(sfile);
Agent[i].xpos = str_num;


//y
eof_count = file_str_read(file_handle,sfile);
str_num = str_to_num(sfile);
Agent[i].ypos = str_num;



//z
eof_count = file_str_read(file_handle,sfile);
str_num = str_to_num(sfile);
Agent[i].zpos = str_num;


//timestamp
eof_count = file_str_read(file_handle,sfile);
str_num = str_to_num(sfile);
Agent[i].timestamp = str_num;



//CREATE ENTITY
Agent[i].entAgent = ent_create(strModel, vector(Agent[i].xpos,Agent[i].ypos,-55), NULL);
set(Agent[i].entAgent, SHADOW);

}


if(str_cmp(sfile,"RUN"))
{

//id
eof_count = file_str_read(file_handle,sfile);
str_num = str_to_num(sfile);
i = integer(str_num);
tempAgent.ID = i;

//x
eof_count = file_str_read(file_handle,sfile);
str_num = str_to_num(sfile);
tempAgent.xpos = str_num;

//y
eof_count = file_str_read(file_handle,sfile);
str_num = str_to_num(sfile);
tempAgent.ypos = str_num;

//z
eof_count = file_str_read(file_handle,sfile);
str_num = str_to_num(sfile);
tempAgent.zpos = str_num;

//timestamp
eof_count = file_str_read(file_handle,sfile);
str_num = str_to_num(sfile);
tempAgent.timestamp = str_num;


// CALCULATE speed, pan angle, distance and MAKE MOVEMENT

//x-distance
xdist = tempAgent.xpos - Agent[i].xpos;

//y-distance
ydist = tempAgent.ypos - Agent[i].ypos;

//timecount
timecount = tempAgent.timestamp - Agent[i].timestamp;

//keeping track of time
timelock = total_ticks;

while((total_ticks - timelock)/16 <= timecount )
{


Agent[i].entAgent.pan += ydist*time_step;
c_move (Agent[i].entAgent, vector(5*xdist*time_step, 0, 0), nullvector, GLIDE | IGNORE_YOU | IGNORE_MODELS);

if ((xdist == 0) && (ydist == 0))
{
//no animation
anim_percent += 5*time_step;
ent_animate(Agent[i].entAgent, "stand", anim_percent, ANM_CYCLE);
}
else
{
anim_percent += 1.3 * xdist * time_step * 5;
ent_animate(Agent[i].entAgent, "walk", anim_percent, ANM_CYCLE);
}

wait(1);
}



//UPDATING THE ARRAY
Agent[i].ID = tempAgent.ID;



Agent[i].xpos = tempAgent.xpos;




Agent[i].ypos = tempAgent.ypos;



Agent[i].zpos = tempAgent.zpos;



Agent[i].timestamp = tempAgent.timestamp;


//wait(1);

}



}
}



}


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook