Hi all, I have a question that may be somewhat involved, but figured I might just post it. I have somewhat of a game like a first person shooter in the works. I wrote a bsp tree tool for partitioning and it works fine. I can draw all the walls in my game and navigate through the level. I am using the timerfunc to update the position of the player and it was giving me very decent performance. So I came to the floors and ceilings and I found that I needed a tessellator. That was the end of my performance. So after a while I decided I had to use a display list for the ceilings and floors. Thus I had employ either glrotate/translate or glulookat to simulate navigation with static floors and ceilings. It is not going well. The player position is a point in the xz plane. I draw all the ceilings and floors for the whole level in a display list. They are rendered with respect to an initial position and view angle(the positive x-axis is 0 degrees while the positive z axis is 90 and so on). As the player moves I use the position and angle to govern the glulookat coords. Here is the code:
float ang;
point* pos = new point;
glPushMatrix();
//get the eye position for glulookat as the offset of the current position from the initial position
pos->xCoord=-(ipoint->xCoord-GlobalPosition->xCoord);
pos->yCoord=ipoint->yCoord-GlobalPosition->yCoord;
//set the ang of the player to the opposite of the current angle
//other wise turning left actually turns you right
//the angle is a float from 0 to 65536 where 65536 is 360
ang = -GlobalAngle;
if (ang < 0)
ang = ang + 65536;
else if(ang>65536)
ang = ang - 65536;
if (ang==65536)
ang=0;
//get line of sight
line* ln = gimmeeLine(pos,ang);
//get a point in the line of sight for glulookat
if(ang==0)
{
x=pos->xCoord+5;
y=ln->intercept;
}
else if(ang<16384)
{
x=pos->xCoord+5;
y=ln->slope*x + ln->intercept;
}
else if(ang==16384)
{
y = pos->yCoord +5;
x= ln->intercept;
}
else if(ang==32768)
{
x=pos->xCoord-5;
y=ln->intercept;
}
else if(ang>16384&&ang<49152)
{
x=pos->xCoord-5;
y=ln->slope*x + ln->intercept;
}
else if (ang==49152)
{
y = pos->yCoord-5;
x= ln->intercept;
}
else
{
x=pos->xCoord+5;
y=ln->slope*x + ln->intercept;
}
gluLookAt (pos->xCoord,0,pos->yCoord,x, 0,y, 0.0, 1.0, 0.0);
//draw the ceilings and floors
glCallList(tesser);
glPopMatrix();
I can navigate through my whole level with one exception sometimes the floors kind of pull away from the walls a little. I don’t know why, but would really really like to know why things don’t align correctly. The floors only pull away a little but for a serious game it is completely unacceptable. I am sorry I know this is a vague problem.
silicon