polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

commit fdf03948a1c605b7d74ebf2a0dc7dafe6b7e6610
parent 4a630c47a3e39dc9a567541d50534464b5e230fd
Author: William Casarin <jb55@jb55.com>
Date:   Tue,  6 Nov 2018 12:38:14 -0800

orbit camera wip

Diffstat:
Msrc/orbit.c | 16+++++++---------
Msrc/vec3.c | 9+++++++++
2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/orbit.c b/src/orbit.c @@ -4,16 +4,14 @@ #include "vec3.h" #include <math.h> -void orbit_to_quat(struct orbit *orbit, float *quat) +void orbit_to_mat4(struct orbit *orbit, float *m) { - float phi = orbit->azimuth; - float theta = orbit->inclination; - - // vector - quat[0] = cos(phi/2.0)*cos(theta/2.0); // scalar quaternion components - quat[1] = -sin(phi/2.0)*sin(theta/2.0); // x quaternion components - quat[2] = cos(phi/2.0)*sin(theta/2.0); // y quaternion components - quat[3] = sin(phi/2.0)*cos(theta/2.0); // z quaternion components +} + + +static void orbit_to_vec3(struct orbit *orbit, float *v3) +{ + float x = r * sin(theta) * cos(phi); } /* static void orbit_update_node(struct node *node) { */ diff --git a/src/vec3.c b/src/vec3.c @@ -259,3 +259,12 @@ vec3 *vec3_max(vec3 *vec, vec3* vec2, vec3 *dest) { dest[2] = max(vec[2], vec2[2]); return dest; } + + +vec3 *vec3_from_yaw_pitch(float yaw, float pitch, float *dest) { + float theta = yaw; + float phi = pitch; + dest[0] = sin(theta) * cos(phi); + dest[1] = sin(theta) * sin(phi); + dest[2] = cos(theta); +}