prosperon/source/engine/transform.c

45 lines
1.4 KiB
C
Raw Normal View History

2021-11-30 21:29:18 -06:00
#include "transform.h"
#include <string.h>
2023-05-12 13:22:05 -05:00
struct mTransform MakeTransform(mfloat_t pos[3], mfloat_t rotation[4], float scale) {
struct mTransform newT;
memcpy(newT.position, pos, sizeof(*pos));
memcpy(newT.rotation, rotation, sizeof(*rotation));
newT.scale = scale;
return newT;
2021-11-30 21:29:18 -06:00
}
2023-05-12 13:22:05 -05:00
mfloat_t *trans_forward(mfloat_t *res,
const struct mTransform *const trans) {
// YughLog(0, SDL_LOG_PRIORITY_WARN, "Rotation is %f", trans->rotation[0]);
return vec3_rotate_quat(res, FORWARD, trans->rotation);
2021-11-30 21:29:18 -06:00
}
2023-05-12 13:22:05 -05:00
mfloat_t *trans_back(mfloat_t *res, const struct mTransform *trans) {
return vec3_rotate_quat(res, BACK, trans->rotation);
2021-11-30 21:29:18 -06:00
}
2023-05-12 13:22:05 -05:00
mfloat_t *trans_up(mfloat_t *res, const struct mTransform *trans) {
return vec3_rotate_quat(res, UP, trans->rotation);
2021-11-30 21:29:18 -06:00
}
2023-05-12 13:22:05 -05:00
mfloat_t *trans_down(mfloat_t *res, const struct mTransform *trans) {
return vec3_rotate_quat(res, DOWN, trans->rotation);
2021-11-30 21:29:18 -06:00
}
2023-05-12 13:22:05 -05:00
mfloat_t *trans_right(mfloat_t *res, const struct mTransform *trans) {
return vec3_rotate_quat(res, RIGHT, trans->rotation);
2021-11-30 21:29:18 -06:00
}
2023-05-12 13:22:05 -05:00
mfloat_t *trans_left(mfloat_t *res, const struct mTransform *trans) {
return vec3_rotate_quat(res, LEFT, trans->rotation);
2021-11-30 21:29:18 -06:00
}
2022-08-12 14:03:56 -05:00
#include "nuke.h"
2023-05-12 13:22:05 -05:00
void trans_drawgui(struct mTransform *T) {
nuke_property_float3("Position", -1000.f, T->position, 1000.f, 1.f, 1.f);
nuke_property_float3("Rotation", 0.f, T->rotation, 360.f, 1.f, 0.1f);
nuke_property_float("Scale", 0.f, &T->scale, 1000.f, 0.1f, 0.1f);
}