saving alternate build method. About to go back to regular visual studio build, but may pursue this approach in the future
This commit is contained in:
43
src/util.cpp
43
src/util.cpp
@@ -1,43 +0,0 @@
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "util.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool read_file(string* s, const char* filepath) {
|
||||
ifstream file(filepath);
|
||||
if (!file.is_open()) {
|
||||
return false;
|
||||
}
|
||||
*s = { istreambuf_iterator<char>(file), istreambuf_iterator<char>() };
|
||||
}
|
||||
|
||||
vector<string> split_str(string s, char delim) {
|
||||
vector<string> res;
|
||||
string cur_word;
|
||||
istringstream ss(s);
|
||||
while (getline(ss, cur_word, delim)) {
|
||||
res.push_back(cur_word);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// https://songho.ca/opengl/gl_quaternion.html
|
||||
glm::mat4 quat_to_mat4(glm::quat q) {
|
||||
glm::vec4 col0 = glm::vec4(
|
||||
1 - 2 * q.y * q.y - 2 * q.z * q.z, 2 * q.x * q.y + 2 * q.w * q.z, 2 * q.x * q.z - 2 * q.w * q.y, 0);
|
||||
|
||||
glm::vec4 col1 = glm::vec4(
|
||||
2 * q.x * q.y - 2 * q.w * q.z, 1 - 2 * q.x * q.x - 2 * q.z * q.z, 2 * q.y * q.z + 2 * q.w * q.x, 0);
|
||||
|
||||
glm::vec4 col2 = glm::vec4(
|
||||
2 * q.x * q.z + 2 * q.w * q.y, 2 * q.y * q.z - 2 * q.w * q.x, 1 - 2 * q.x * q.x - 2 * q.y * q.y, 0);
|
||||
|
||||
glm::vec4 col3 = glm::vec4(0, 0, 0, 1);
|
||||
|
||||
return glm::mat4(col0, col1, col2, col3);
|
||||
}
|
||||
|
||||
float randf() { return (float)rand() / (float)RAND_MAX; }
|
||||
Reference in New Issue
Block a user