If you want to rotate around a point (x0, y0, z0), assuming
matrix-vector multiplication order is vector * matrix,
your current modelview matrix is M1,
the rotation matrix is MR,
translation matrix from (0, 0, 0) to (x0, y0, z0) is T(x0, y0, z0),
After rotation, the modelview matrix should be
M1*T(-x0, -y0, -z0) * MR * T(x0, y0, z0)
Note if (x0, y0, z0) is in world coordinates, it needs to be first transformed to eye coordinates by
(x0, y0, z0) * M1
Friday, 26 July 2013
OpenGL ES: Is modelview matrix column major or row major?
Modelview matrix is column major. In memory, it is like
M00, M10, M20, M30, M01, M11, M21, M31, M02, M12, M22, M32, M03, M13, M23, M33
A translation of (x, y, z) is
1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1
In GLSL, matrix vector multiplication is defined as matrix * vector.
In host program, depending on how you define your matrix vector multiplication operator, it can be either matrix * vector or vector * matrix.
For a series of transformations M1, M2, M3,
if you define matrix-vector multiplication as matrix * vector, the total transformation is
M3 * M2 * M1
If you define it as vector * matrix, the total transformation is
M1 * M2 * M3
M00, M10, M20, M30, M01, M11, M21, M31, M02, M12, M22, M32, M03, M13, M23, M33
A translation of (x, y, z) is
1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1
In GLSL, matrix vector multiplication is defined as matrix * vector.
In host program, depending on how you define your matrix vector multiplication operator, it can be either matrix * vector or vector * matrix.
For a series of transformations M1, M2, M3,
if you define matrix-vector multiplication as matrix * vector, the total transformation is
M3 * M2 * M1
If you define it as vector * matrix, the total transformation is
M1 * M2 * M3
Monday, 24 June 2013
iOS: How to Debug UIView Layout Issues
Go to https://github.com/glock45/iOS-Hierarchy-Viewer
Download and add it to your project.
When the layout issue shows up in iOS simulator, open a web browser and go to the iOS Hierarchy Viewer page (shown in app debug output at program launch.)
Starting from UIWindow, check frame of the UIViews until the problematic UIView.
Download and add it to your project.
When the layout issue shows up in iOS simulator, open a web browser and go to the iOS Hierarchy Viewer page (shown in app debug output at program launch.)
Starting from UIWindow, check frame of the UIViews until the problematic UIView.
Friday, 14 June 2013
CMake Configuration Failure due to Python
CMake configuration may fail due to python version issue. Sometimes a project requires an old version of python but CMake uses the newer version of python, which causes the failure. On Windows with GUI version of CMake, this can be resolved by choose the advanced option and modify the used python path to be an old version of python.
Saturday, 8 June 2013
UIKit: Stop Touches in a Subview being Handled by its Superview
If view A has a gesture recognizer, and this view has a subview B which does not have gesture recognizer, the gesture happened in the subview B will be recognized by the gesture recognizer of view A.
This may not be what you want. For example, if subview B is showing an introduction, you do not want a tap in it to be handled by view A.
One solution is to make view A a delegate of its gesture recognizer, and define a method:
-(BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldReceiveTouch:(UITouch *)touch {
return touch.view == self;
}
In this way, the gesture recognizer will not recognize gestures happen in its subview.
Wednesday, 5 June 2013
How to move files to another directory in Xcode 4
Move files physically to the desired directory, then open the project in Xcode 4, select the group, in the right "Identity and Type" panel, click the strange looking icon beside "Path" item, and choose the new directory of your files.
P.S. If your files are under version control, you cannot simply move files with Finder or mv command. You need to move them through version control system, otherwise you are in big trouble.
P.S. If your files are under version control, you cannot simply move files with Finder or mv command. You need to move them through version control system, otherwise you are in big trouble.
Sunday, 2 June 2013
iOS: How to find your artist id in app store
Go to http://itunes.apple.com/linkmaker and search for your name, you will find your artist id and all your app ids.
Subscribe to:
Posts (Atom)