Cleanup ugh;

This commit is contained in:
bjorn 2017-01-20 19:55:54 -08:00
parent 07803ef16a
commit 8a3d52b3c6
11 changed files with 27 additions and 18 deletions

View File

@ -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() {

View File

@ -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);

View File

@ -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

View File

@ -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) {

View File

@ -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"

View File

@ -1,4 +1,5 @@
#include "graphics/shader.h"
#include "math/mat4.h"
#include "util.h"
#include <stdlib.h>

View File

@ -1,5 +1,5 @@
#include "glfw.h"
#include "math/mat4.h"
#include "math/math.h"
#include "vendor/map/map.h"
#include "util.h"

View File

@ -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>

View File

@ -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);
}

View File

@ -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;

View File

@ -1,4 +1,5 @@
#include "loaders/model.h"
#include "math/mat4.h"
#include <stdlib.h>
#include <assimp/scene.h>
#include <assimp/cimport.h>