I wanted to tweak the angle of the stars a bit for the skybox I'm working on, so RotatePointAroundVector seemed to be the appropriate function to use, however, instead of just rotating, it seems I've managed to collapse the universe!
I'm rotating around 0,1,0 (y axis), and here are the results from 0 to -100 degrees:
Does anybody have a fixed version of the function, or is this how it's expected to work? Doesn't seem right...
RotatePointAroundVector Broken?
Re: RotatePointAroundVector Broken?
AngleVectors('0 1 0' * time, forward,left,up);
neworg_x = dot(forward,origorg);
neworg_y = dot(left,origorg);
neworg_z = dot(up,origorg);
or in other words, use a matrix.
and rotate the matrix a little so that you're not standing at the north pole.
if you're just making a skybox image, you could just swizzle+negate accordingly without bothering with complex rotations.
neworg_x = dot(forward,origorg);
neworg_y = dot(left,origorg);
neworg_z = dot(up,origorg);
or in other words, use a matrix.
and rotate the matrix a little so that you're not standing at the north pole.
if you're just making a skybox image, you could just swizzle+negate accordingly without bothering with complex rotations.
Re: RotatePointAroundVector Broken?
I'm just doing the rotation on load.
I ended up rewriting the function like this, and it appears to work:
Edit: Wonder if model culling was buggy because of this? Or maybe this fix will create new bugs?
I ended up rewriting the function like this, and it appears to work:
Code: Select all
void RotatePointAroundVector (vec3_t dst, const vec3_t dir, const vec3_t point, float degrees)
{
float u = dir[0], v = dir[1], w = dir[2];
float x = point[0], y = point[1], z = point[2];
float ux = u * x, uy = u * y, uz = u * z, vx = v * x, vy = v * y, vz = v * z, wx = w * x, wy = w * y, wz = w * z;
float uu = u * u, ww = w * w, vv = v * v;
float s = (float)sin(DEG2RAD(degrees));
float c = (float)cos(DEG2RAD(degrees));
dst[0] = u * (ux + vy + wz) + (x * (vv + ww) - u * (vy + wz)) * c + (vz - wy) * s;
dst[1] = v * (ux + vy + wz) + (y * (uu + ww) - v * (ux + wz)) * c + (wx - uz) * s;
dst[2] = w * (ux + vy + wz) + (z * (uu + vv) - w * (ux + vy)) * c + (uy - vx) * s;
}
Edit: Wonder if model culling was buggy because of this? Or maybe this fix will create new bugs?
Re: RotatePointAroundVector Broken?
You might want to look at LordHavoc's matrix lib to replace or at least augment the sparse / incomplete / seemingly arbitrary / questionably buggy transform functions included in Quake2:
https://github.com/jdolan/quake2world/b ... r_matrix.c
It works very well; I've never had to touch it.
https://github.com/jdolan/quake2world/b ... r_matrix.c
It works very well; I've never had to touch it.