Jump to content

  • Log In with Google      Sign In   
  • Create Account


weird problems with my realtime mesh changer


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Norbs   Members   -  Reputation: 122

Like
Likes
Like

Posted 25 November 2001 - 10:49 AM

Hey all,
ok I''m getting some wierd crash messages some of the time only when I am changing the mesh in real time.

It''s telling me that its doing an invalid floating point operation on the lines i''ll point out. However If I''m not changing the matix, it works....Can someone plz point out to me what the problem is?? I call it with this line:

t=(clock()-initTime)/CLK_TCK; //i initialize the clock farther up.
recalc( matrix, t, centers );

CreatePlane( 2.0, matrix, 2.0, 7, 7 );

The matrix is an array of 49. I''m pretty sure im not over running the bounds of my array, because I''ve tried increasing it...nada.

I''m trying to create a plane with a certain amount of vertices so I can animate it. SHould I be doing something differently to achieve this end?

void CreatePlane( float width, float *height, float length, int widthseg, int lengthseg )
{
int i=0;

float xstep=width/widthseg; // <------ crashes at this line
float zstep=length/lengthseg; // <------ and this one too
float initwidth=width;
float initlength=length;

glBindTexture(GL_TEXTURE_2D, g_Texture[0]);

glBegin (GL_QUADS); // This is our BEGIN to draw

for (float length=initlength/(-2); length<=((initlength/2)-zstep); length+=zstep )
for(float width=initwidth/(-2); width<= ((initwidth/2)-xstep); width+=xstep)
{
// Display the top left vertice
glTexCoord2f(0.0f, 1.0f);
glVertex3f(width, height, length);

// Display the bottom left vertice
glTexCoord2f(0.0f, 0.0f);
glVertex3f(width, height[i+row], length+zstep);

// Display the bottom right vertice
glTexCoord2f(1.0f, 0.0f);
glVertex3f(width+xstep, height[i+row+1], length+zstep);

// Display the top right vertice
glTexCoord2f(1.0f, 1.0f);
glVertex3f(width+xstep, height[i+1], length);
i++;
}

glEnd(); // This is the END of drawing

}


/////////////////////////////Here is that mesh changing function

const int MAXSIZE=49;
int row =sqrt(MAXSIZE);

const float xscale=1.0;
const float yscale=1.0;

void recalc( float * matrix, float time, DATA *centers )
{
float dis;
float h;
int i=0;

clear( matrix ); //resets it to zero

while ( centers[i].startTime>=0 )
{

for (int point=0; point {

dis=sqrt( pow( ((point % row)-(centers[i].center % row ))*xscale , 2)
+ pow( ((point /row )-(centers[i].center/row))*yscale, 2) );

if ( (time-centers[i].startTime-dis) > 0 )
{
h=-3*sin(5*( time-centers[i].startTime)- dis ) * float (exp( double( (-time-centers[i].startTime)/5.0 ) ) );
matrix[point]+=h;
}

}
i++;
}

}

the centers bit is just an array of structures that can keep track of the center points of the waves, and when they start. I''ve tested this function may times; it works. But as soon as I try to use it in ogl, the program crashes

Thanks for any help you give....

Norbs


Sponsor:

#2 AdmiralBinary   Banned   -  Reputation: 100

Like
Likes
Like

Posted 25 November 2001 - 10:55 AM

Usually if a program crashes when you are dividing, it means you''re dividing by zero. Hope that helps.

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

I finally got it all together...
...and then forgot where I put it.

#3 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 25 November 2001 - 11:21 AM

But it works some of the time

I can run it once or twice and then I get that error message. If you look at the code, it SHOULDN''t be zero, values are hard coded into the program.

#4 Norbs   Members   -  Reputation: 122

Like
Likes
Like

Posted 25 November 2001 - 11:23 AM

But it works some of the time

I can run it once or twice and then I get that error message. If you look at the code, it SHOULDN''t be zero, values are hard coded into the program.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS