Advertisement

please help

Started by September 09, 2000 02:20 AM
1 comment, last by bigyellowtoe 24 years, 2 months ago
i took tutorial 10 and tried to fire a bullet in the direction i was originally facing. this was easy enough, but when i started to move the bullet followed me. then i changed it so that when i stand at the origin and just turn left / right or look up / look down the bullet will fly along it''s trajectory for n amount of time. but when i walk around the world everything gets messed up. the bullet starts taking off in bizare places flying every which way. what i''m hoping is that someone could provide some source code that accomplishes this in tutorial 10. i can''t tell you how much that would help me to understand the matrices and their proper order. hope someone is out there... thanks
*.chm
The bullet have to be drawn considering the world, not the camera

sin and cos takes radians (in case of you didn''t know)

You don''t draw things on the correct order, or you rotate and translate wrong


Helping when I have no source to look at is quite hard

Just post your drawing section
(you can find me on IRC : #opengl on undernet)
Advertisement
this is the source i''m working with, snipped some of the drawing stuff but you should get an idea of where i''m at.

why you mention cos / sin is a mystery to me, not sure why i need to use those if i''m just interested in moving something straight back / fwd but maybe that''s what i''m missing and just don''t see it.

glLoadIdentity();
GLfloat x_m, y_m, z_m, u_m, v_m;
GLfloat xtrans = -xpos;
GLfloat ztrans = -zpos;
GLfloat ytrans = -walkbias-0.25f;
GLfloat sceneroty = 360.0f - yrot;

int numtriangles;

glRotatef(lookupdown,1.0f,0,0);
glRotatef(sceneroty,0,1.0f,0);

glTranslatef(xtrans, ytrans, ztrans);
glBindTexture(GL_TEXTURE_2D, texture[filter]);

numtriangles = sector1.numtriangles;

// Process Each Triangle
for (int loop_m = 0; loop_m < numtriangles; loop_m++)
{
glBegin(GL_TRIANGLES);
// all the sector stuff here...
glEnd();
}

// now try to draw this on it''s own trajectory
if (bBulletAlive)
{

bsceneroty = 360.0f - bullet.yrot;
xtrans = -bullet.xpos;
ztrans = bullet.zpos;
ytrans = 0.0f;

xrot += 5;

//glLoadIdentity();
bullet.zpos -= .05f;
if (bullet.zpos < -10) bBulletAlive = FALSE;

glRotatef(bullet.lookupdown,1.0f,0,0);
glRotatef(bsceneroty ,0,1.0f,0);
glTranslatef(xtrans, ytrans, ztrans);

glBegin(GL_QUADS);
glVertex3f(-.2f,-.2f,0);
glVertex3f(-.2f,.2f,0);
glVertex3f(.2f,.2f,0);
glVertex3f(.2f,-.2f,0);
glEnd();

}


*.chm

This topic is closed to new replies.

Advertisement