mirror of https://github.com/bjornbytes/lovr.git
Cleanup ugh;
This commit is contained in:
parent
07803ef16a
commit
8a3d52b3c6
|
@ -76,7 +76,9 @@ void lovrAudioGetOrientation(float* angle, float* ax, float* ay, float* az) {
|
|||
}
|
||||
|
||||
void lovrAudioGetPosition(float* x, float* y, float* z) {
|
||||
alGetListener3f(AL_POSITION, x, y, z);
|
||||
*x = state.position[0];
|
||||
*y = state.position[1];
|
||||
*z = state.position[2];
|
||||
}
|
||||
|
||||
float lovrAudioGetVolume() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "graphics/graphics.h"
|
||||
#include "loaders/texture.h"
|
||||
#include "math/quat.h"
|
||||
#include "math/mat4.h"
|
||||
#include "math/vec3.h"
|
||||
#include "util.h"
|
||||
#include "glfw.h"
|
||||
#define _USE_MATH_DEFINES
|
||||
|
@ -343,8 +344,9 @@ void lovrGraphicsScale(float x, float y, float z) {
|
|||
mat4_scale(state.transforms[state.transform], x, y, z);
|
||||
}
|
||||
|
||||
// M *= T * S * R
|
||||
void lovrGraphicsTransform(float tx, float ty, float tz, float sx, float sy, float sz, float angle, float ax, float ay, float az) {
|
||||
|
||||
// M *= T * S * R
|
||||
float transform[16];
|
||||
mat4_identity(transform);
|
||||
mat4_translate(transform, tx, ty, tz);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "graphics/shader.h"
|
||||
#include "graphics/skybox.h"
|
||||
#include "graphics/texture.h"
|
||||
#include "math/mat4.h"
|
||||
#include "math/math.h"
|
||||
|
||||
#ifndef LOVR_GRAPHICS_TYPES
|
||||
#define LOVR_GRAPHICS_TYPES
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "graphics/model.h"
|
||||
#include "graphics/graphics.h"
|
||||
#include "math/mat4.h"
|
||||
#include "math/vec3.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
static void visitNode(ModelData* modelData, ModelNode* node, mat4 transform, vec_float_t* vertices, vec_uint_t* indices) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "graphics/buffer.h"
|
||||
#include "graphics/texture.h"
|
||||
#include "math/mat4.h"
|
||||
#include "math/vec3.h"
|
||||
#include "math/math.h"
|
||||
#include "glfw.h"
|
||||
#include "util.h"
|
||||
#include "vendor/vec/vec.h"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "graphics/shader.h"
|
||||
#include "math/mat4.h"
|
||||
#include "util.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "glfw.h"
|
||||
#include "math/mat4.h"
|
||||
#include "math/math.h"
|
||||
#include "vendor/map/map.h"
|
||||
#include "util.h"
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "graphics/texture.h"
|
||||
#include "graphics/graphics.h"
|
||||
#include "math/mat4.h"
|
||||
#include "util.h"
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -455,7 +455,7 @@ void* viveControllerGetModel(void* headset, Controller* controller, ControllerMo
|
|||
|
||||
void viveRenderTo(void* headset, headsetRenderCallback callback, void* userdata) {
|
||||
Vive* vive = (Vive*) headset;
|
||||
float headMatrix[16], eyeMatrix[16], projectionMatrix[16];
|
||||
float head[16], transform[16], projection[16];
|
||||
float (*matrix)[4];
|
||||
|
||||
lovrGraphicsPushCanvas();
|
||||
|
@ -464,28 +464,27 @@ void viveRenderTo(void* headset, headsetRenderCallback callback, void* userdata)
|
|||
|
||||
// Head transform
|
||||
matrix = vive->renderPoses[vive->headsetIndex].mDeviceToAbsoluteTracking.m;
|
||||
mat4_invert(mat4_fromMat34(headMatrix, matrix));
|
||||
mat4_invert(mat4_fromMat34(head, matrix));
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
EVREye eye = (i == 0) ? EVREye_Eye_Left : EVREye_Eye_Right;
|
||||
for (EVREye eye = EYE_LEFT; eye <= EYE_RIGHT; eye++) {
|
||||
|
||||
// Eye transform
|
||||
matrix = vive->system->GetEyeToHeadTransform(eye).m;
|
||||
mat4_invert(mat4_fromMat34(eyeMatrix, matrix));
|
||||
mat4 transformMatrix = mat4_multiply(eyeMatrix, headMatrix);
|
||||
mat4_invert(mat4_fromMat34(transform, matrix));
|
||||
mat4_multiply(transform, head);
|
||||
|
||||
// Projection
|
||||
matrix = vive->system->GetProjectionMatrix(eye, vive->clipNear, vive->clipFar).m;
|
||||
mat4_fromMat44(projectionMatrix, matrix);
|
||||
mat4_fromMat44(projection, matrix);
|
||||
|
||||
// Render
|
||||
lovrTextureBindFramebuffer(vive->texture);
|
||||
lovrGraphicsPush();
|
||||
lovrGraphicsOrigin();
|
||||
lovrGraphicsMatrixTransform(transformMatrix);
|
||||
lovrGraphicsSetProjectionRaw(projectionMatrix);
|
||||
lovrGraphicsMatrixTransform(transform);
|
||||
lovrGraphicsSetProjectionRaw(projection);
|
||||
lovrGraphicsClear(1, 1);
|
||||
callback(i, userdata);
|
||||
callback(eye - EYE_LEFT, userdata);
|
||||
lovrGraphicsPop();
|
||||
lovrTextureResolveMSAA(vive->texture);
|
||||
|
||||
|
@ -499,6 +498,5 @@ void viveRenderTo(void* headset, headsetRenderCallback callback, void* userdata)
|
|||
|
||||
vive->isRendering = 0;
|
||||
lovrGraphicsPopCanvas();
|
||||
|
||||
lovrGraphicsPlaneFullscreen(vive->texture);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
#ifndef LOVR_VIVE_TYPES
|
||||
#define LOVR_VIVE_TYPES
|
||||
|
||||
#define EYE_LEFT EVREye_Eye_Left
|
||||
#define EYE_RIGHT EVREye_Eye_Right
|
||||
|
||||
typedef struct {
|
||||
Headset headset;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "loaders/model.h"
|
||||
#include "math/mat4.h"
|
||||
#include <stdlib.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/cimport.h>
|
||||
|
|
Loading…
Reference in New Issue