glm-math

Cereal serialization error

拈花ヽ惹草 提交于 2020-08-06 21:25:47
问题 So i'm legit confused. It won't compile for an external serialization function. It gives the error cereal could not find any output serialization functions for the provided type and archive combination. So the code below doesn't compile #include <fstream> #include <glm/glm.hpp> #include "SceneObject.h" #include <cereal/cereal.hpp> #include <cereal/archives/json.hpp> template<typename Archive> void serialize(Archive& archive, glm::vec3& v3) { archive(cereal::make_nvp("x", v3.x), cereal::make

Cereal serialization error

穿精又带淫゛_ 提交于 2020-08-06 21:22:50
问题 So i'm legit confused. It won't compile for an external serialization function. It gives the error cereal could not find any output serialization functions for the provided type and archive combination. So the code below doesn't compile #include <fstream> #include <glm/glm.hpp> #include "SceneObject.h" #include <cereal/cereal.hpp> #include <cereal/archives/json.hpp> template<typename Archive> void serialize(Archive& archive, glm::vec3& v3) { archive(cereal::make_nvp("x", v3.x), cereal::make

GLM: How to transpose a vector?

限于喜欢 提交于 2020-06-24 12:17:05
问题 Maybe I'm just missing something in the docs, but it seem it's not possible with GLM to take the transpose of a vector. I also see no mat3x1 or mat1x3 types. Also glm::transpose doesn't work for vectors. Am I missing something or is this just a feature lacking in GLM? 回答1: GLM is based on GLSL, where there's simply no need to transpose a vector. If you do vector/matrix multiplication, it will multiply the vector in the way that works for the size of the matrix (unless it would have to change

Converting glm::lookat matrix to quaternion and back

半城伤御伤魂 提交于 2020-04-10 08:03:27
问题 I am using glm to create a camera class, and I am running into some problems with a lookat function. I am using a quaternion to represent rotation, but I want to use glm's prewritten lookat function to avoid duplicating code. This is my lookat function right now: void Camera::LookAt(float x, float y, float z) { glm::mat4 lookMat = glm::lookAt(position, glm::vec3(x, y, z), glm::vec3(0, 1, 0)); rotation = glm::toQuat(lookMat); } However when I call LookAt(0.0f,0.0f,0.0f) , my camera is not

Issue in drawing ellipsoid with OpenGL

空扰寡人 提交于 2020-03-23 07:50:22
问题 this is the code I use to create and draw an ellipsoid with OpenGL with shader const float _2pi = 2.0f * M_PI; std::vector<glm::vec3> positions; std::vector<glm::vec3> normals; std::vector<glm::vec2> textureCoords; for(int i = 0; i <= stacks; ++i) { // V texture coordinate float V = i / (float)stacks; float phi = V * M_PI; for( int j = 0; j <= slices; ++j) { // U texture coordinate float U = j / (float)slices; float theta = U * _2pi; float X = a * cos(theta) * cos(phi); float Y = b * cos

2D opengl rotation causes sprite distortion

早过忘川 提交于 2020-01-24 15:55:07
问题 I am quite new to using OpenGL ES 2.0. Also im using an iPhone and the GLM maths library. As I reference I have been using this tutorial a lot: http://tomdalling.com/blog/modern-opengl/03-matrices-depth-buffering-animation/ But I have found it difficult to find a 2D OpenGL tutorial. I am trying to rotate a 2D sprite but the image is being distorted. For example at a rotation angle of 0 degrees: http://i.imgur.com/yBTN2ST.png and at a rotation angle of 45 degrees: http://i.imgur.com/cY5IJcg

How to tell CMAKE to download some necessary header files (more precisely GLM math library) WITHOUT TRYING TO COMPILE THEM?

坚强是说给别人听的谎言 提交于 2020-01-24 03:20:07
问题 I am setting up a CMAKE project that uses a lot of ExternalProjects . To build one of them (CEGUI), I need to download the GLM (OpenGL Math Library) . This Library is include only library , which means that you mustn't compile it. There are some test that can be compiled but there is no need for them in my project (moreover, one of them do not compile properly and breaks the compiling chain). What I would like, is to find a way to tell CMAKE to only download the project (GIT update etc) like

“glm::translate” outputs a matrix with incorrect values

做~自己de王妃 提交于 2020-01-21 13:27:54
问题 I took a sample code to test the glm::translate function: glm::vec4 vec(1.0f, 0.0f, 0.0f, 1.0f); glm::mat4 trans; trans = glm::translate(trans, glm::vec3(1.0f, 1.0f, 0.0f)); vec = trans * vec; std::cout << vec.x << ", " << vec.y << ", " << vec.z << std::endl; It outputs the following: -4.29497e+08, -4.29497e+08, -4.29497e+08 instead of the expected 2, 1, 0 What is the possible cause and what can I do about it? (Should I search for the flaw outside this piece of code?) 回答1: -4.29497e+08 This

How to implement camera pan like in 3dsMax?

末鹿安然 提交于 2020-01-11 04:51:05
问题 What are the necessary maths to achieve the camera panning effect that's used in 3ds max? In 3ds max the distance between the cursor and the mesh will always remain the same throughout the entire movement (mouse_down+mouse_motion+mouse_up). My naive and failed attempt has been trying to move the camera on the plane XY by using dt (frame time) multiplied by some hardcoded constant and the result is really ugly and uintuitive. The code I've got so far is: def glut_mouse(self, button, state, x,

GLM: rotation matrix initialisation

喜夏-厌秋 提交于 2020-01-07 09:26:17
问题 The basic aim of my code is just to rotate a few points around the z-axis. However, after trying to initialise a rotation matrix using glm::rotate(m4, a, v3) and trying to check its components, a quick printf outputs some 1 800 000 000.0000000... for each element. I believe this is not the correct functionality.~ Note: I am not asking about the maths behind spatial transformations. They are clear to me. Code in essence: int main(int argc, char **argv){ InitGL(); // openGL, GLFW..