Main forum > GLBasic - en
great nebula effect
Kitty Hello:
haha. Great technique.
You need to get the angle of your polygon to the camera.
you get the matrix of the model after x_rotate.. with x_getmatrix
and the camera matrix with x_getcammatrix (or so.. look it up).
Then you need the angle difference. I'd just add (angle_dx+angle_dy+angle_dz) for that.
The angle_dx is atan2(mat[0] - cammat[0], mat[1] - cammat[1]) // or so. I don't know off my head.
the mat[0,1,2] is the direction of the X axis, where mat[4,5,6] is Y and [8,9,10] os the Z axis.
Does it help?
djtoon:
well that didnt work or i just cant get the math
:(
Kitty Hello:
draw the textured quad in X-Y direction (X=0). Then the normal to that quad after X_ROTATION/X_MULTMATRIX would be X_GETMATIX mat[]; MakeVector(mat[8], mat[9], mat[10])
Next you need the loot-at direction vector. The easiest to get this it just to take the parameters you passed to X_CAMERA x,y,z,lx,ly,lz; The direction would be MakeVector(lx-x, ly-y, lz-z)
Now you have to vectors and only need the angle between then:
div = vector_length(v1, v2)
if div=0 then return 0
dot = vector_dot(v2, v1) / div
if dot>1 or dot<-1 then return 1 // 1.5 / 1.49999
// dot is cos(angle). So you have a value of -1 to +1 now (what you need!)
real_angle = acos(dot) // to display as text
I hope this works now.
aroldo:
That is cool!
djtoon can you share your GLBasic code?
djtoon:
MakeVector?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version