camera-facing 2d stripes
category: general [glöplog]
Hey,
I have an array of points (say, a b-spline) in 3d, and I'm trying to get this to always render facing camera.
What I'm doing now is I'm first inverting the modelview matrix. Then the OpenGL docs says I should multiply that with the vector (0,0,0,1) which doesn't make sense as the fourth row is irrelevant anyway for rotation?
I've tried with various values for this vector, (0,0,1) would make sense in the next step where I will cross-product the camera position with the delta vector from the spline to get the direction vector of the face.
Any thoughts?
I have an array of points (say, a b-spline) in 3d, and I'm trying to get this to always render facing camera.
What I'm doing now is I'm first inverting the modelview matrix. Then the OpenGL docs says I should multiply that with the vector (0,0,0,1) which doesn't make sense as the fourth row is irrelevant anyway for rotation?
I've tried with various values for this vector, (0,0,1) would make sense in the next step where I will cross-product the camera position with the delta vector from the spline to get the direction vector of the face.
Any thoughts?
(It isn't working properly, when the spline ends up in corners it still gets flat)
google up on "camera-facing quads" or "billboarding" -- that should tell you all you need.
SPEED OMA: that's not very helpful.
jaw: just billabong the billboard bungle biggle...that should fix it.
jaw: just billabong the billboard bungle biggle...that should fix it.
billboarding helps everyone.
Fail.
i never said it was very helpful :) anyway, you just gotta make sure that your camera translation or whatever it is you do prior to projection does not rotate the 4 points of the camera-facing quad (if thats the case) away from the camera in any sort of way. you just need it to displace in terms of 2d pos (usually center of the quad) and depth.
i could send you a load of sourcecode doing exactly what you wanna see but i think you're better off finding out yourself.
i could send you a load of sourcecode doing exactly what you wanna see but i think you're better off finding out yourself.
a quick method, maybe not the best:
do that for each billboard, before its drawing.
you will obviously need also glpushmatrix/glpopmatrix around that
float gmlmtx[16];
glGetFloatv(GL_MODELVIEW_MATRIX,gmlmtx );
// keep translation terms only (note: pGlMtx = & gmlmtx)
float rescale = 1.0f;
pGlMtx[0]=rescale; pGlMtx[1]=0.0f; pGlMtx[2]=0.0f;
pGlMtx[4]=0.0f; pGlMtx[5]=rescale; pGlMtx[6]=0.0f;
pGlMtx[8]=0.0f; pGlMtx[9]=0.0f; pGlMtx[10]=1.0f;
glLoadMatrixf(gmlmtx);
do that for each billboard, before its drawing.
you will obviously need also glpushmatrix/glpopmatrix around that
float gmlmtx[16];
glGetFloatv(GL_MODELVIEW_MATRIX,gmlmtx );
// keep translation terms only (note: pGlMtx = & gmlmtx)
float rescale = 1.0f;
pGlMtx[0]=rescale; pGlMtx[1]=0.0f; pGlMtx[2]=0.0f;
pGlMtx[4]=0.0f; pGlMtx[5]=rescale; pGlMtx[6]=0.0f;
pGlMtx[8]=0.0f; pGlMtx[9]=0.0f; pGlMtx[10]=1.0f;
glLoadMatrixf(gmlmtx);
... well the drawing after that, and the glpopmatrix after the drawing.