Browse Source

add orbit helper function in main.cpp

main
cinnaboot 4 years ago
parent
commit
efa111ae85
  1. 14
      src/main.cpp

14
src/main.cpp

@ -110,7 +110,19 @@ loadScene(RenderState* rs)
return initLights(rs);
}
#include <glm/gtc/matrix_transform.hpp>
void
orbitPositionZ0(glm::vec4* pos, float angle)
{
// get radius length
float r = sqrt(pow(abs(pos->x), 2) + pow(abs(pos->z), 2));
// get current angle about z axis
float a = atan2f(pos->z, pos->x);
// apply increment
a += angle;
// get new x/z components
pos->x = r * cos(a);
pos->z = r * sin(a);
}
void
render_cb_pre(RenderState* rs)

Loading…
Cancel
Save