Problems with particles...
I''ve made an algorithm to show always the polygon faceing to the camera....
here is the algorithm:
posx,posy and posz are the position of the polygon.
difx=CAM[actual].posx-posx;
dify=CAM[actual].posy-posy;
difz=CAM[actual].posz-posz;
if (difz==0) {
if (difx>=0) yaw=-3.14/2;
else yaw=-3*3.14/2;
if (dify>=0) pitch=-3.14/2;
else pitch=-3*3.14/2;
}
else {
yaw=-atan(difx/difz);
pitch=-atan(dify/difz);
}
if (difz<0) {
rotx=pitch*180/3.14+180;
roty=yaw*180/3.14+180;
}
else {
rotx=pitch*180/3.14;
roty=-yaw*180/3.14+180;
}
glLoadIdentity();
gluLookAt(CAM[actual].posx,
CAM[actual].posy,CAM[actual].posz,
CAM[actual].x,CAM[actual].y,
CAM[actual].z,0,1,0);
glTranslatef(posx,posy,posz);
glRotatef(rotx,1.0f,0.0f,0.0f);
glRotatef(roty,0.0f,1.0f,0.0f);
well... here is the problem... When the -1<difz<1, the algorithm doesn''t work...
WHY????!!!!!
damn it... some characters doesn''t work so well...
well... here is the problem... When difz is between -1 and 1, the algorithm doesn''t work any more!!! WHY??????!
Well.. see ya
well... here is the problem... When difz is between -1 and 1, the algorithm doesn''t work any more!!! WHY??????!
Well.. see ya
Try doing this, it should be a lot easier to use.
Get your current model view matrix from OpenGL.
glGetFloatv(GL_MODELVIEW_MATRIX, mat)
Take the transpose of that matrix and store it.
tmat = mat.Transpose().
Create two vectors, x and y, and set them as follows using the transposed matrix.
x.Set(tmat[0], tmat[1], tmat[2]);
y.Set(tmat[4], tmat[5], tmat[6]);
x is a vector that points right and y is a vector that points up. With these two vectors you can easily construct triangles that will always face the camera.
Hope this helps.
Nate Miller
http://nate.scuzzy.net
Get your current model view matrix from OpenGL.
glGetFloatv(GL_MODELVIEW_MATRIX, mat)
Take the transpose of that matrix and store it.
tmat = mat.Transpose().
Create two vectors, x and y, and set them as follows using the transposed matrix.
x.Set(tmat[0], tmat[1], tmat[2]);
y.Set(tmat[4], tmat[5], tmat[6]);
x is a vector that points right and y is a vector that points up. With these two vectors you can easily construct triangles that will always face the camera.
Hope this helps.
Nate Miller
http://nate.scuzzy.net
I would have said that the value passed to atan has to be between 1 and -1 and by making the denominator a fraction, then it''s obviously not going to be very probable... At least that''s what I think right now... I''m a little brain fried since I have answered to and read so many posts today... (yesterday my connection was down {whine whine complain complain} )
S.
S.
hahaha.... well.. thanks anyway...
I couldn''t solved the problem... Someone help me!!!
I don''t know how to use the matrix from Nate....
I saw that I have to use a pointer... but a pointer to what?
A pointer to an array?? A pointer to a structure?
And something else... I''m programming in c, not c++...
I''m not using classes....
well... thanks all of you...
Phew!! The people here are fantastic!!
See ya!
I couldn''t solved the problem... Someone help me!!!
I don''t know how to use the matrix from Nate....
I saw that I have to use a pointer... but a pointer to what?
A pointer to an array?? A pointer to a structure?
And something else... I''m programming in c, not c++...
I''m not using classes....
well... thanks all of you...
Phew!! The people here are fantastic!!
See ya!
quote:Original post by Strylinys
I would have said that the value passed to atan has to be between 1 and -1
uh, no. -PI/2 to PI/2.
check out nates site from a few days ago IIRC theres a more thourough? description on the way it works
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement