Tag Info

New answers tagged

3

I was able to get the rotations expected by rotating an accumulated rotation matrix. setIdentityM(currentRotation, 0); rotateM(currentRotation, 0, angleY, 0, 1, 0); rotateM(currentRotation, 0, angleX, 1, 0, 0); // Multiply the current rotation by the accumulated rotation, // and then set the accumulated rotation to the result. multiplyMM(temporaryMatrix, ...


0

It is not that hard if you think about if for a while. Now the following assumes that you have perfect rectangles as faces in the OBJ. (I honestly don't know how to do arbitrary polygons.) I think you can build a orhtonormal R3 matrix from the values in the OBJ. You have 4 vertices: v 0.0 0.0 0.0 v 0.0 0.0 1.0 v 0.0 1.0 1.0 v 0.0 1.0 0.0 ...


1

Your image corresponds with your rotationMatrix code, by rotating the x axis with your previous y rotation you get the local x axis, when you then rotate the object around that you would get the result that you show in your image. To have the rotation be logical from a users point of view you would want to rotate the object using the world coordinate axis ...


3

The problem your having is called gimble lock. I think what your looking to do is called arcball rotation. The math for arcball can be abit complicated. A simpler way of doing it is finding a 2d vector perpendicular to the 2d swipe on screen. Take the vector and project it onto the camera near plane to get a 3d vector in world space. Screen space to World ...


1

This is a plain old bug, you're reassigning different values to the same spots, like transform[1][1] = 1+cos(rot.x); ... transform[1][1] = cos(rot.z); What you need to do is combine the rotations in the order you want them applied, like transformX[][]... assigned only from rot.x transformY[][]... assigned only from rot.y transformZ[][]... assigned only ...


2

This seems like an optimization question. As such the answer, as always is to profile it. If generating the matrices doesn't take too much time on the fly, then it is simply easier to do on the fly, as you don't have to write and export/import of matrices, and add it to your file format. And perhaps you could simply use other file formats natively and not ...


2

A homogenous transformation matrix (aka a "World matrix") is a 4x4 matrix that defines the translation and rotation of one coordinate system with respect to another. It looks like this: H = [xx, xy, xz, tx; yx, yy, yz, ty; zx, zy, zz, tz; 0, 0, 0, 1]; (Note on notation: This just lays out the matrix row by row. Each row is separated by ...


2

The camera analogy is a lie because there is no camera. Instead all that happens is a transformation of points in 3D space to points on a 2D screen, and the matrices define how that transformation happens. Modelview and projection are conceptually different although mathematically the same (it's all just matrix multiplication). Modelview just moves points ...


10

The graphics pipeline (typically) involves transformation from model space to world space, from world space to view space, and from view space to clip space. There is a transformation matrix associated with each of these (the world, view and projection transformations, respectively). There are of course stages of the pipeline after geometry reaches clip ...


0

You answered your question well. This is exactly how it should be done for a 3D scene at least in OpenGL (not used other graphics APIs). You create your projection matrix using your FOV, aspect ratio, near and far planes and use it to render your entities, by multiplying it against each entities own model matrix. You should only need to set your projection ...



Top 50 recent answers are included