Hello everyone, well, im just practicing with OpenGL after reading quite a few of NeHe''s tutorials (which are great) and im making my own little program that does this: you ''move around'' with teh arrow keys and if you press ''s'' it will lay down a triangle in the position you are, so you can basicly lay triangls around, then after you lay the triange down, it will rotate. Well, i have the movement and everything figured out (well, i just got it from nehe

) but my problems are with the rotation and the laying of triangles. I have no idea why hte rotation isnt working. I can get it so that when you press ''s'' it will put a triangle down, but the position is never right. It just draws the triange in the same place every time. I made 3 arrays, each with 10 units to store the positions of the triangles, but i cant get it working. Here are some parts fo the code:
//ALL THE VARIABLES ----------
bool keys[256]; // Array Used For The Keyboard Routine
bool active=TRUE; // Window Active Flag Set To TRUE By Default
bool fullscreen=TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default
bool sp; //S key pressed?
bool ap; //A key pressed?
int smnt=0; //Number of shapes to draw
GLfloat tril1=0.0f;
GLfloat tril2=0.0f;
GLfloat tril3=0.0f;
int tri=0;
const float piover180 = 0.0174532925f;
float heading;
float xpos;
float zpos;
GLfloat yrot; // Y Rotation
GLfloat walkbias = 0;
GLfloat walkbiasangle = 0;
GLfloat lookupdown = 0.0f;
GLfloat z=0.0f; // Depth Into The Screen
GLfloat xtp[10]; //arrays to store the positions of the triangles
GLfloat ytp[10];
GLfloat ztp[10];
GLfloat txtp; //Stores the positions of where the triangles were put down
GLfloat tytp;
GLfloat tztp;
//---------------------
//GLDrawscene -----------------
int DrawGLScene(GLvoid) // Here''s Where We Do All The Drawing
{
GLfloat xtrans, ztrans, ytrans, txtrans, tztrans;
GLfloat sceneroty;
// Here We Calculate Our Translation And Rotations
xtrans = -xpos;
ztrans = -zpos;
ytrans = -walkbias-0.25f;
sceneroty = 360.0f- yrot;
txtrans= -txtp;
tztrans= -tztp;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity(); // Reset The View
glRotatef(lookupdown, 1.0f,0.0f,0.0f);
glRotatef(sceneroty,0.0f,1.0f,0.0f);
glTranslatef(xtrans, ytrans, ztrans);
glRotatef(1.0f,1.0f,0.3f,0.0f); //roation not working
glColor3f(1.0f,0.0f,0.0f);
glTranslatef(1.0f, 2.5f, -6.0f); //Placekeeper cube
glDrawCube(); //function i have made
glColor3f(0.0f,0.3f,1.0f);
for (tri=0;tri= 359.0f)
{
walkbiasangle = 0.0f;
}
else
{
walkbiasangle+= 10.0f;
}
walkbias = (float)sin(walkbiasangle * piover180)/20.0f;
}
if (keys[VK_DOWN])
{
xpos += (float)sin(yrot*piover180) * 0.15f;
zpos += (float)cos(yrot*piover180) * 0.15f;
if (walkbiasangle <= 1.0f)
{
walkbiasangle = 359.0f;
}
else
{
walkbiasangle-= 10.0f;
}
walkbias = (float)sin(walkbiasangle * piover180)/20.0f;
}
if (keys[VK_PRIOR])
{
lookupdown-= 1.0f;
}
if (keys[VK_NEXT])
{
lookupdown+= 1.0f;
}
txtp=txtp+xpos;
tztp=tztp+zpos;
//end
well, thats about it, thanks for any help, i can send someone the whole source file is they want it. thanks!
McDougal...DUCK McDougal