Rotate PolygonSurface to Camera
I want to optimate my particlesystem
now i try to rotate the particlepolygons to the cameraposition, because the camera moves and i dont want to see the particle from the side as lines
my question:
how to rotate a polygon FAST to the camera. i think to rotate every particle over a matrix could not be the best way?!
OR
how to skip the rotation an draw a polygon on x,y,z with full face to the camera
thx to all who can help me
if you mean
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=19
i found nothing what can help me. because the camera dont move.
the particles are all directed to the front. if i move the camera to the side of the particle burst, i see only lines.
but they should face the camera
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=19
i found nothing what can help me. because the camera dont move.
the particles are all directed to the front. if i move the camera to the side of the particle burst, i see only lines.
but they should face the camera
use the theory of that lesson, but also undo the rotation of the camera*2
: you rotate stuff because the camera-angle changed right? you have to undo that rotation just like in the tutorial as well
: you rotate stuff because the camera-angle changed right? you have to undo that rotation just like in the tutorial as well
the problem is, that i use gluLookAt
i am only calculate with the vector of the camera, the target and the normal
the idea that i have till now is something like this:
use gluProject to change the particlevector to windowcoordinates
and use scale to draw it in the right size as "2d bitmap"... as polygon on the 2d level...
but i dont know, if this a good idea cause the calctime...
or is there a point of opengl i missunderstood in translations and rotations? (no irony or sarcasm... is a real question)
i am only calculate with the vector of the camera, the target and the normal
the idea that i have till now is something like this:
use gluProject to change the particlevector to windowcoordinates
and use scale to draw it in the right size as "2d bitmap"... as polygon on the 2d level...
but i dont know, if this a good idea cause the calctime...
or is there a point of opengl i missunderstood in translations and rotations? (no irony or sarcasm... is a real question)
July 10, 2003 02:02 PM
i dont get it, if you use gllookat, cant you just rotate the particles to face the eye coordinate(using surface normals of particles)
is this the same as billboards?
is this the same as billboards?
i dont know if i understand you right...
now i have tried this
but without success. nothings happen
(started with opengl this week)
now i have tried this
but without success. nothings happen
normal = cameraVector - pos; //cameravector - particlevector = normalvector
glBegin (GL_TRIANGLES);
glNormal3f( normal.x,normal.y,normal.z);
glColor4f (this->rCol, this->gCol, this->bCol, alpha);
glVertex3f( pos.x, pos.y, pos.z);
glColor4f (0.0f, 0.0f, 0.0f, 0.0f);
glVertex3f( pos.x-0.5f,pos.y, pos.z);
glColor4f (0.0f, 0.0f, 0.0f, 0.0f);
glVertex3f( pos.x,pos.y+0.5f, pos.z);
[... + 3 other vertices]
glEnd ();
(started with opengl this week)
I assume you have some sort of camera class. Every time you update your camera, grab the modelviewmatrix and dump it in a float matrix[16]; by doing glGetFloatv(GL_MODELVIEW_MATRIX, &matrix);
Now,
matrix[0], [1] and [2] is your right vector (from the camera)
matrix[4], [5] and [6] is up and
matrix[8], [9] and [10] is your forward vector.
assign them like:
VEC3D *right = &matrix[0];
VEC3D *up = &matrix[4];
VEC3D *forward = &matrix[8];
Now, when you render the particles, explode from the particles position using these vectors to the 4 particle vertices like:
VEC3D vertex1 = particle.position - right + up;
VEC3D vertex2 = particle.position + right + up;
VEC3D vertex3 = particle.position - right - up;
VEC3D vertex4 = particle.position + right - up;
and use these 4 vertices to render your particle.
Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]
GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don''t post crap!
Now,
matrix[0], [1] and [2] is your right vector (from the camera)
matrix[4], [5] and [6] is up and
matrix[8], [9] and [10] is your forward vector.
assign them like:
VEC3D *right = &matrix[0];
VEC3D *up = &matrix[4];
VEC3D *forward = &matrix[8];
Now, when you render the particles, explode from the particles position using these vectors to the 4 particle vertices like:
VEC3D vertex1 = particle.position - right + up;
VEC3D vertex2 = particle.position + right + up;
VEC3D vertex3 = particle.position - right - up;
VEC3D vertex4 = particle.position + right - up;
and use these 4 vertices to render your particle.
Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]
GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don''t post crap!
<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>
i think i understand the idea of your solution...
(big thx)
i have implemented it.
my cameraclass use gluLookAt to set the camera.
after i use it, i get the right,up and forward vectors as you discribe it and draw the particles with them.
but it looks the same as before.
is there something else i have to look for?
[edited by - GaRaOne on July 11, 2003 11:45:51 AM]
(big thx)
i have implemented it.
my cameraclass use gluLookAt to set the camera.
after i use it, i get the right,up and forward vectors as you discribe it and draw the particles with them.
but it looks the same as before.
is there something else i have to look for?
//cameraclass/////////CUTint Camera::update(){ GLfloat* matrix; matrix = new GLfloat[16]; glGetFloatv(GL_MODELVIEW_MATRIX, matrix); right.x = matrix[0]; right.y = matrix[1]; right.z = matrix[2]; up.x = matrix[4]; up.y = matrix[5]; up.z = matrix[6]; forward.x = matrix[8]; forward.y = matrix[9]; forward.z = matrix[10]; delete [] matrix; return true;}int Camera::draw(){ gluLookAt( pos.x, pos.y, pos.z, target.x, target.y, target.z, normal.x, normal.y, normal.z ); this->update(); return true;}///////////END CUT
[edited by - GaRaOne on July 11, 2003 11:45:51 AM]
quote:
Original post by Sander
Now,
matrix[0], [1] and [2] is your right vector (from the camera)
matrix[4], [5] and [6] is up and
matrix[8], [9] and [10] is your forward vector.
i found in a tutorial the answer, why it wont go.
we have to invert the matrix.. because that, the camera vectors are like the following...
big thanx to all. special to sanders, he gives the right direction
right.x = matrix[0]; right.y = matrix[4]; right.z = matrix[8]; up.x = matrix[1]; up.y = matrix[5]; up.z = matrix[9];
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement