glm-math

How to rotate a vector in opengl?

孤街醉人 提交于 2019-12-13 09:08:55
问题 I want to rotate my object,when I use glm::rotate. It can only rotate on X,Y,Z arrows. For example,Model = vec3(5,0,0) if i use Model = glm::rotate(Model,glm::radians(180),glm::vec3(0, 1, 0)); it become vec3(-5,0,0) i want a API,so i can rotate on vec3(0,4,0) 180 degree,so the Model move to vec3(3,0,0) Any API can I use? 回答1: Yes OpenGL uses 4x4 uniform transform matrices internally. But the glRotate API uses 4 parameters instead of 3: glMatrixMode(GL_MODELVIEW); glRotatef(angle,x,y,z); it

mat4 project/unproject not working

穿精又带淫゛_ 提交于 2019-12-13 07:12:56
问题 I am trying to implement GLM's project and unproject functions in Lua but the results are... questionable. As far as I can tell, my code (shown below) is nearly identical to GLM, yet as the video below shows, the text doesn't display as intended. When I bring the camera to 0,0,0, the text forms a diamond pattern, which is interesting. What should be displayed here is the words cube.001 through cube.009 should be drawn on top of their respective cubes, regardless of where the camera moves.

Draw 2 cubes in OpenGL using GLM

喜你入骨 提交于 2019-12-13 04:37:13
问题 So I can draw a spinning cube using OpenGL3.2+ and translate it away from the 0,0,0 and to the left, but when I try and draw a second one (towards the right), it doesn't render... This is my display function: void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUseProgram(myShader.handle()); GLuint matLocation = glGetUniformLocation(myShader.handle(), "ProjectionMatrix"); glUniformMatrix4fv(matLocation, 1, GL_FALSE, &ProjectionMatrix[0][0]); spinY+=0.03; if(spinY>360) spinY

How to slow down opengl animation read from BVH files?

瘦欲@ 提交于 2019-12-13 03:24:20
问题 Using GLFW3, I currently made a bvh file parser which reads the file in and converts it to a human model I made in opengl. However, whenever I launch it, the movement is so fast that the animation cannot be seen in the eye. So I want to tone the animation speed a little down. Here is my render loop while (!glfwWindowShouldClose(window)) { // per-frame time logic // -------------------- float currentFrame = glfwGetTime(); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; // input

#include “glm/ext.hpp” makes the compiler report a __declspec(align('16')) won't be aligned

蓝咒 提交于 2019-12-13 01:00:55
问题 I get the compiler error __declspec(align('16')) won't be aligned . When I click the error, Visual Studio sends me to GLM_IMPLEMENT_SCAL_MULT(vec4) , which is on the scalar_multiplication.hpp file. What is the cause for this compiler error? How can I fix it? Note: Could it be some kind of conflict with the includes? I have several includes in a header file. The commented one is the one that gives the error. // OpenGL Math library #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp>

Rotate Object around origin as it faces origin in OpenGL with GLM?

此生再无相见时 提交于 2019-12-12 23:04:17
问题 I'm trying to make a simple animation where an object rotates around the world origin in OpenGL using glm lib. My ideia is: Send object to origin Rotate it Send back to original position Make it look at what I want Here's my implementation: // Rotates object around point p void rotate_about(float deltaTime, glm::vec3 p, bool ended) { glm::vec3 axis = glm::vec3(0,1,0); //rotation axis glm::mat4 scale_m = glm::scale(glm::mat4(1.0f), glm::vec3(scale, scale, scale)); //scale matrix glm::mat4

How to set orthographic near/far clipping planes to display all vertices

青春壹個敷衍的年華 提交于 2019-12-12 15:14:55
问题 I am rendering scenes using a glm::ortho projection. I want the rendering to include every vertex I draw without adding unnecessary depth (i.e. with minimal depth buffer resolution impact). I've seen this post for a similar question on perspective projections, but I am looking for both near and far clipping plane values in an orthographic projection. I can calculate the z values of each vertex using the viewMatrix to transform the vertices into screen coordinates. In pseudo code: float near;

How to use GLM in Android NDK Application

一世执手 提交于 2019-12-12 07:31:46
问题 I am currently trying to port my OpenGL application to Android and am stuck on how to import and build GLM http://glm.g-truc.net/ properly. I have no trouble using GLM in standard C++ apps, however I am pretty new to the NDK. I have tried all other solutions posted around the web with no luck. Here is what I have so far: I am using the latest version of GLM (0.9.4) My .cpp file contains: #include <glm\glm.hpp> My Android.mk file looks like: LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS)

GLM::Rotate seems to cause wrong rotation?

大憨熊 提交于 2019-12-12 04:15:07
问题 Simply put, I'm learning OpenGL and am starting to learn about transform matrices. Below is my current code: glm::vec4 myPosition(1.0f, 1.0f, 1.0f, 1.0f); glm::vec3 rotationAxis(0.0f, 1.0f, 0.0f); glm::mat4 scalar = glm::scale(glm::vec3(1.0f, 1.0f, 1.0f)); glm::mat4 rotator = glm::rotate(360.0f, rotationAxis); glm::mat4 translator = glm::translate(glm::vec3(1.0f, 1.0f, 1.0f)); glm::mat4 transform = translator * rotator * scalar; myPosition = transform * myPosition; As far as I can tell, I'm

What does -431602080.000000 value in GLMmodel vertex means?

我与影子孤独终老i 提交于 2019-12-11 18:19:39
问题 I use a GLMmodel object in order to represent a Google Sketch Up model in a C++ program. These objects have a member (vertices) that contains a list of all the vertices of the object in a way like this: [GLfloat x component of vertex 1, GLfloat y component of vertex 1, GLfloat z component of vertex 1, GLfloat x component of vertex 2...]. When I read all these values I get small numbers for all of them except for the first three ones (the coordinates of the first vertex) which are all three