Tag Info

Hot answers tagged

7

glm::quat myquaternion(glm::vec3(angle.x, angle.y, angle.z)); Where angle is a glm::vec3 containing pitch, yaw, roll respectively. PS. If in doubt, just go to the headers and look. The definition can be found in glm/gtc/quaternion.hpp: explicit tquat(tvec3<T> const & eulerAngles) { tvec3<T> c = glm::cos(eulerAngle * ...


6

I'm not familiar with GLM, but in the absence of a function to directly convert from eular angles into quaternions, you can use the "rotation around an axis" functions (such as "angleAxis") to it yourself. Here's how (pseudocode): Quaternion QuatAroundX = Quaternion( Vector3(1.0,0.0,0.0), EulerAngle.x ); Quaternion QuatAroundY = Quaternion( ...


5

This may be a winding issue. Are you sure that the texture coordinates are parsed in the right sense of rotation? However, this how you should debug you program. Draw in wire frame mode to find out how the rectangle is composed out of two triangles. The OpenGL command for this is glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);. Use a texture with a gradient ...


5

Place your camera target at the center of the arc rotation (That's usually where you want the camera to look anyway). Then simply transform the camera's position around the target with a rotation that uses the appropriate axis. pseudo code: //some angle & some other angle = only the amount you want the camera to rotate since last frame. //pitch ...


5

Your first method is the correct one. According to the OpenGL FAQ: The translation components occupy the 13th, 14th, and 15th elements of the 16-element matrix It can also be seen in the glm source code (from matrix_transform.inl): inline detail::tmat4x4<T> translate /*...*/ { detail::tmat4x4<T> Result(m); Result[3] = m[0] * v[0] + ...


4

GLM's rotation function uses Euler's rotation theorem, which implies that any rotation or sequence of rotations of a rigid body in a three-dimensional space is equivalent to a pure rotation about a single fixed axis. However consecutive calls to GLMs rotate function just multiply the rotation so rotating a rigid body by Yaw, Pitch, Roll is as simple as ...


4

You need to read the error message more carefully: In file included from jni/src/GLIncludes.h:41:0, from jni/androidLauncher.cpp:4: jni/src/glm/glm.hpp:86:18: fatal error: limits: No such file or directory As you can see, the glm.hpp header is found. It's limits that is not found, because by default the NDK uses a stripped-down C++ ...


4

Local versus world is just a matter of the order in which you compose transforms. For instance, when using row-vector math, multiplying the current local-to-world transform by a new transform on the left will perform the new transform in local space, since it will be equivalent to doing the new transform followed by the old local-to-world transform. ...


3

Easy way of building the rotation matrix: Start with an identity matrix Translate the matrix by -centre of the object Rotate the matrix by the desired amount Translate the matrix by centre of the object Use the resulting matrix to transform the object that you desire to rotate


3

Solution is in wikipedia: http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles using that: sx = sin(x/2); sy = sin(y/2); sz = sin(z/2); cx = cos(x/2); cy = cos(y/2); cz = cos(z/2); q( cx*cy*cz + sx*sy*sz, sx*cy*cz - cx*sy*sz, cx*sy*cz + sx*cy*sz, cx*cy*sz - sx*sy*cz ) // for XYZ application order q( cx*cy*cz - sx*sy*sz, ...


2

Just set 'the view matrix' to identity and then translate to like -6.0 on the z axis. You are not using lookAt() correctly. The first paramater is the position you are at (the camera) and the second is where you look at.


2

Thanks to @DaleyPaley I was able to figure this out. The problem lay in my code to figure out the camera vectors Right, Up, and Back. I was just using some code that I found online, and once I started showing the actual camera placement and vectors from the perspective of a hardcoded camera, I could tell that the vectors being produced by Right, Up, and Back ...


2

Rotation/scaling is around the origin. To both scale/rotate around a pivot, you apply a negative translation to move the pivot point to the origin, apply your scale and rotate, and then move your pivot point back. mat4 result = glm::translate(-pivot) * glm::scale(..) * glm::rotate(..) * glm::translate(pivot) * ...


2

I managed to fix everything through a lot of experimenting. It seems my problem came from my own misunderstanding of quaternions. I was under the impression that they represented a change in angle, when actually they represent an orientation. So my rotation matrix was always a bit strange because I was just pushing seemingly random values into it, ...


2

First thing I see is that you shouldn't read the quaternion in reverse order. Also you shouldn't use glm::mix, use glm::slerp instead. And here is how I construct the bone transform: mat = glm::mat4_cast( currentrotation ); mat[0][0] *= currentscale.x; mat[1][0] *= currentscale.x; mat[2][0] *= currentscale.x; mat[0][1] *= currentscale.y; mat[1][1] *= ...


2

Well if I understand well as @user8363 explained in the comments, your problem is that you are making one direction for all the particles, which makes the particles move in that direction. If you want the particles to accelerate toward the point you need to make a direction vector for each particle. For instance: foreach particle: acc = particle - ...


2

historically billboards matrix just copy the camera view matrix, and replace the last row with their own world position. the scale can be world-fixed if you want trees or hard stuff. But it can also be screen-fixed for halo effects, in which case you need to scale using the euclidian distance. this can be done in the vertex shader rather than on CPU as an ...


1

The problem is solved. I changed glUniformMatrix4fv(m_WVPLocation, 1, GL_TRUE, &PVMMat[0][0]); to glUniformMatrix4fv(m_WVPLocation, 1, GL_FALSE, &PVMMat[0][0]); AND glFrontFace(GL_CW); to glFrontFace(GL_CCW);


1

Your camera (and every object with a transform) has its own local space axes, which will usually not be the same as the world axes. Transforming around the world-space axis will give a different result than transforming around a local-space axis. Cameras typically need to work with both. You usually want to rotate a camera horizontally around "world up" ...


1

Your top code chunk is: t2 * (t1 * direction * inverse(t1)) * inverse(t2) Your bottom chunk is: t3 * direction * inverse(t3) Given that t3 = t2 * t1 It's (t2 * t1) * direction * inverse(t2 * t1) As far as my knowledge of Quaternion multiplication goes, I don't think t2 * (t1 * direction * inverse(t1)) * inverse(t2) and (t2 * t1) * direction * ...


1

In V8 you can wrap your own, custom C++ classes expose them to JavaScript and have V8 take care of destructing the instance once the corresponding JS object gets GC'd. But you still have to write your methods in a style like this: Handle<Value> Vector::add(const Arguments& args) { Vector *vector = ...


1

How can I calculate intersection with my scene geometries? it varies depending on your performance needs and scene size, there are different approaches the easiest one is checking ray intersection with all bounding volumes containing geometry in the scene, however this may not be good enough if your scene is huge, or you have limited computational ...


1

Your ray is possibly in view (camera) space. I'm unsure exactly how glm::unproject works. If I'm right, pass its end points through the inverse camera matrix to put then in world space. Remember that a coordinate is expressed in some basis, which for our purposes can be considered a vector space (mathematically there is some difference) or commonly just a ...


1

You can access the memory of any glm type by using glm::value_ptr. Matrix types store their values in column-major order, and as floats.


1

The image of a point A under a rotation around another point B (an affine rotation if B is not the origin of the space) is A', with A' = B + R*(A-B) where R is the matrix of the associated linear rotation. For example, in dimension 2, say you want to rotate A = (1,0) around B = (1,1) by 90 degrees counter-clockwise. That will yield (2,1). Make a picture ...


1

For me, this code looks flawed: glm::mat4 model = glm::mat4(1.0f); model *= glm::translate(model, glm::vec3(0.0f, 0.0f, 0.0f)); model *= glm::rotate(model, angle, glm::vec3(1.0f, 1.0f, 1.0f)); The modelviewmatrix you are creating seems to me to be like something as this: M = I * T * (T * R) (since glm::rotate(model, ...) creates the matrix T * R) but I ...


1

well, turns out my real issue is not using meters as my internal units..that should solve everything.


1

Given your description, your camera representation might look like this. I also included the headers of your maths library GLM needed for the following implementation. #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/constants.hpp> using namespace glm; struct Camera { vec3 Position; vec2 Angles; ...


1

The best way to do that is to generate a vector in the direction your camera is pointing. The simplest way to do it would be to rotate it around the corresponding axes: Vec3 GetCameraDir(float horiz, float vert) { // Start out pointing to the right Vec3 dir = Vec3 (1, 0, 0); // Rotate dir around the Y axis by your horizontal angle dir = ...


1

The angles used to build a rotation for each of the three axes are known as Tait-Bryan angles (often confused with Euler angles). Wikipedia has all the formulas you need to convert Euler or Tait-Bryan angles into a rotation matrix. Here is some code to build a rotation matrix from three Tait-Bryan angles and the order of the rotations: /* i, j and k are ...



Only top voted, non community-wiki answers of a minimum length are eligible