# Tagged Questions

GLM is a C++ math library based on the GLSL language.

29 views

### Limit/Clamp camera movement using quaternions

I'm making a camera object for rendering with OpenGL. However, instead of using the typical "LookAt" method I'm trying to use just a Quaternion for orientation and a Vector3 for position. Instead of ...
21 views

### Problem with Frustum Culling Right-Handed(LookAtRH GLM)

I am trying to do Frustum Culling based on Goemetric Approach, however don't matter how much i try, the frustrum rotate to opposite side, i tried to find a solution over all internet, but couldn't ...
57 views

### Quaternion based camera pitch freaking out, and Z-axis drift

This is the code I use to control my (first person) camera's movement and rotation. Translation successfully keeps orientation in mind, so that up and left and such are always in the expected ...
57 views

The depth is rendered wrong and I can't figure out why. using namespace std; using namespace glm; int width = 640; int height = 480; float aspect = (float)width/height; int fps = 60; void start(){ ...
42 views

### AssImp Skeletal Animation Issues [closed]

Tried creating an animated mesh but I render it, it comes up as a flat mesh that moves with the camera. Followed the OGL Animation tutorial here (http://www.ogldev.org/www/tutorial38/tutorial38.html). ...
58 views

### Failed to understand how to use glm::unProject (OpenGL 4.3)

Situation: I use OpenGL 4.3, FreeGLUT 3.0, and GLM library. Let say i have a simple 2D object (a ball) and it moves accordingly to the simple equations: x = x_0 + v_0 * t * cosf(alpha); y = y_0 + ...
63 views

### Drawn frustum does not match with glm::perspective

I am working on a personal project and I got a 3d viewport with moving camera working nicely. Now I am working on being able to freeze the time and switch to a debug camera and move in the game freely....
110 views

### Convert a direction vector (normalized) to rotation?

Say i have something like this: pos += glm::normalize(target - pos) //PLEASE NOTE: pos is a glm::vec3 and so is target This makes "pos" translate towards "target", but what if i want to make my ...
190 views

### How do you build a rotation matrix from a normalized vector?

I'm trying to find the correct way to build a rotation matrix from a unit vector. I have two arbitrary points in space (p1 and p2), and I'm trying to create the vertices for a rectangle to span ...
137 views

### Using glm to rotate the modelview matrix based on the cursor position

I am rendering a 3D model of an object, and I want the user to be able to rotate around that object by dragging the mouse. To do this, I want to use the cursor position to continually update the ...
87 views

### Why does invoking glm::refract function return NaN?

At the present time, I make a simple raytracing project and I encounter an issue : When I invoking the glm::refract function, it returns me a vec3 with "NaN" values. However, my input data seems to be ...
52 views

### How to get correct quaternion value from real world to screen?

I'm writing an application (not a game per se, but close enough) where we use attitude sensors (an IMU) in the real world to affect the orientation of an object in the application's 3D space (OpenGL). ...
163 views

### OpenGL Arc-Ball Camera Yaw Pitch GLM::Rotate

I'm currently working on a small Voxel-Editor Project. In the editor, I plan on using an Arc-Ball camera which rotate around the model. My camera is currently working but in an odd way. I can't seem ...
47 views

### Formula for model matrix with mouse coordinates

I'm trying to create a simple OpenGL app where I can drag objects with the mouse. The code below is based on a raycasting algorithm covered here. I'm using the diff between the current mouse coord ...
16 views

### C++ Opengl rotation Rotating vector before transform still rotates around 0,0,0… In world position [duplicate]

So how should I get this to work in local position? (Ie, moving to 4,0,4 and rotating around 4,0,4 . (x,y,z)) Here is where I add models / verticies: glm::vec4 pos = glm::vec4(1.0); glm::mat4 ...
180 views

### How should I rotate vertices around the origin on the CPU?

I have tried using glm::rotate and such. glm::translate works fine, but rotate doesn't work (if I rotate before/after a translation). Here is my current setup: glm::vec4 Off = glm::vec4(0, 0, 0, 1); ...
123 views

### C++ Opengl transforming a glm::vec4 with a glm::mat4

Its easy enough doing it on the gpu via GLSL, but how would I do this in c++? When I try it gives me an error telling me I cant cast a glm::mat4 to float, Which makes sense, but how should I do it? ...
52 views

### Shaders wont bind to the uniform block

I'm having an issue with interface block binding. Example shader: const char* vertexShader = "#version 330 core\n" "uniform globalMatrices" "{" " mat4 ...
91 views

### Converting normalized device coordinates to world space coordinates flipping my sprites

I'm trying to convert my game's camera system to use world space coordinates rather than OpenGL's default normalized device coordinates, however in doing so my sprites are being rendered improperly as ...
907 views

### Transformations are not correct using GLM and OpenGL

The aim of my program is to render a simple colored triangle in rotation. The rotations are correct if all Z values of my vertices are equals to 0.0f. If one of these values are different of 0.0f the ...
229 views

### OpenGL 3.3+ Problem with ortho projection for UI/HUD

I have to a little bit of a problem with drawing HUD elements on top of my 3d world using a ortho projection. My 3D world keep getting render but there is nothing showing of my UI. I wrap the code ...
68 views

### Storing component vectors to avoid matrix and quaternion inaccuracies?

I read that I "should really be storing the component vectors (rotation, translation, scale) in addition to the quaternion and matrix forms." The reason for this is that, over time, compound numerical ...
124 views

### Make Camera Look at point using a World transformation matrix?

Variants of this question might have been asked on this site, but none of the answers I found worked in my case. I am trying to make a Camera look at a point. The camera has a world transformation ...
110 views

### Smooth matrix rotation

I have a coded a simple example for a matrix rotation. The example rotates a sphere around its center. The problem is that the rotation is not running perfectly smooth and I'm wondering why. Here is ...
11k views

### GLM: Euler Angles to Quaternion

I hope you know GL Mathematics (GLM) because I've got a problem, I can not break: I have a set of Eular Angles and I need to perform smooth interpolation between them. The best way is converting them ...
1k views

### How to find the “up” direction of the view matrix, with GLM

Using OpenGL and the GLM matrix library, I want to translate my camera relative to the world coordinate system. This requires me to compute the necessary view matrix. To initialise the view matrix, I ...
81 views

### glm Z coordinates are flipped

I am trying to render a 3D model using OpenGL. And for the projection and transformation matrices, I am using glm. I've got my model on the screen and it works just like I intended it to; except one ...
100 views

### issue with ray/physics collision detection

All, I am trying to pick object using ray collision and bullet physics I am initializing my projection and view matrix only once, here is the code projectionMatrix = glm::perspective(90.0f, 4.0f ...
48 views

### Quaternion camera in 3D space with Pitch and Yaw

I am having trouble implementing a quaternion camera that can fly freely in 3D space with only Pitch and Yaw rotations. It works fine except when you look up or down and then try to look left or ...
118 views

### Transformed Vertices have wrong Z Axis

For quite some time I've been working on my open 3D game engine, to learn how this stuff works. You can see the full codebase relating to my problem here on GitHub. I'm using an OpenGL 3.3 Core ...
3k views

### How can I set up an intuitive perspective projection/view matrix combination in OpenGL, using GLM?

Could anyone help me set up an intuitive perspective camera matrix using OpenGL and the GLM library? By "intuitive" I mean that I want the camera to be looking at the middle of the screen down the -Z ...
7k views

### How to implement a basic arcball camera in OpenGL with GLM

I only just started learning OpenGL and even things like vector maths etc a couple of days ago, so I am having a bit of trouble figuring out exactly what to do to implement an arcball camera system. ...
3k views

### Rotating an object with quaternion

I have a question in regards to using quaternions for the rotation of my graphics object. I have a Transform class which has the following constructor with default parameters: Transform(const glm::...
585 views

### OpenGL - Arcball camera rotation

I'm implementing arcball camera rotation, whereby a camera is looking at a coordinate and rotates around it in the x-axis or the y-axis such that the camera is circulating around it; the y-axis will ...
211 views

### Directional lights (not) rotating with camera (opposite problem)

I am trying to implement a shader for directional lights correctly, but I am bit confused as to why it works when it shouldn't and vice versa. People usually encounter problem with lights changing ...
382 views

### Why do these quaterion multiplications produce different results?

I am trying to use quaterions to modify the camera direction vector. This code works perfectly: glm::quat temp1 = glm::normalize( glm::quat((GLfloat)( -Input1.MouseMove.x * mouse_sens * time_step), ...
1k views

### Weird GLM perspective problems with my 2D Game

I am trying to create the graphics system of a 2D game using OpenGL 3.3. To help me in this task I am using the GLM math libraries. However I am having some trouble. When my objects (for now they ...
2k views

### glm direction vector rotation

I'm working on a flight simulator, but I'm stuck with my airplane orientation. I tried some things but noone worked correctly. This is what I have : To be able to move it and roll it around himself, ...
975 views

### How to calculate directional light frustum from camera frustum

I'm playing around with OpenGL for a few weeks now. For the following screenshot I picked the glm::ortho values for my lightsource by trial and error. There are two directional light sources with ...
771 views

### Compute billboard rotation

I'm trying to compute a matrix to have object always facing the camera. For the moment, my result look pretty good, the problem is that my original billboard scale isn't preserved (Every billboard ...
2k views

### OpenGL - have object follow mouse

I want to have an object follow around my mouse on the screen in OpenGL. (I am also using GLEW, GLFW, and GLM). The best idea I've come up with is: Get the coordinates within the window with ...
386 views

### GLM/OpenGL: How Can I Prevent Vector Magnitude From Increasing While Rotating Bones in Skeletal Rig?

ANSWER AT THE BOTTOM OF THIS QUESTION I have been reading tutorials, articles, questions on StackExchange and books all with the subject of skeletal rigging. I have boiled my program down to just the ...
157 views

### OpenGL/GLM Camera

I want to make a camera that can freely look and walk on X/Z plane and rotate 360 degrees. I'm using OpenGL and the lookAt function from the GLM library to create the view matrix. I've looked through ...
209 views

### Making particles accelerate toward a mouse point

I'm currently working on a particle simulation program that makes pixels move towards a mouse point continually accelerating, but i'm running into some math issues. Currently my particle will ...
156 views

### Bounding box center after transformation - want degree values for GUI

Similar to my previous question, I have a bounding box that I have transformed and scaled. Now, I want to get its center by doing this operation and store this value. bbCenter = glm::vec3(bbMin_x + ...
323 views

### GLM Rotating Combining Multiple Quaternions?

I have a camera which I want to control with my mouse. I want the mouse to control the pitch and yaw of the camera but not the roll. To avoid loss of significance, I am storing the quaternions for ...
786 views

### How can I remove the view and projection matrix from ray position to get only the ray model?

I've got a little problem with my picking module and I need your help. I have a method to project a ray from the camera to a fixed point when I click somewhere. The computed ray looks good, it go to ...
2k views

### How Extract Frustum Planes from Clip Coordinates?

I'm having some problems with my Frustum Culling and I want to debug it, so I'm trying to render it's planes, to see exatly the Frustum. But I'm using the Clip Coordinates to do the culling (like ...