#### Archived

This topic is now archived and is closed to further replies.

# Problems with particles...

This topic is 6497 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
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

##### Share on other sites
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

##### Share on other sites
Thanks, man... =)))
I''ll try it....

See ya soon....

##### Share on other sites
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.

##### Share on other sites
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!

##### Share on other sites
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.

##### Share on other sites
check out nates site from a few days ago IIRC theres a more thourough? description on the way it works

##### Share on other sites
Ya, that''s what I meant...... Didn''t I tell you my brain was fried?

S.

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
16
5. 5

• 14
• 29
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631774
• Total Posts
3002286
×