◼ Intuitively “rotate” objects by mouse dragging. ◼ It is often combined with translation and scaling controls. ◼ It is commonly used in CAD and DCC (digital content creation) software such as Maya. Computer Graphics Course @Waseda University Default Rotation Translation Scaling 2
to object translation? ◼ Mouse drag → motion in “screen space” ◼ Object translation → motion in “object space” → Inverse translation from screen space to object space Computer Graphics Course @Waseda University Object space coordinate World space coordinate Camera space coordinate Screen space coordinate Mouse drag Object translation Model matrix View matrix Projection matrix 3
Axis of rotation ◼ Angle of rotation → They can be computed from motion on “arcball sphere” ◼ Screen and arcball sphere Computer Graphics Course @Waseda University Required rotation translate red vector to blue vector 4
perspective projection distort sphere. → For intuitive control, assume arcball is in camera space. Computer Graphics Course @Waseda University 引用: コンピュータグラフィックス [改訂新版] (コンピュータグラフィックス編集委員会 著) P. 43 7
vector for object translation in object space. → Translate two endpoints of mouse motion to object space. Then take their difference. ◼ Notice ◼ You shouldn’t take difference of screen space positions because depth information is lost! ◼ Alternatively, you should first transform two screen space positions back to world space, then take difference! Computer Graphics Course @Waseda University 8
pixels ◼ Depth information can be read with glReadPixels. ◼ For simplicity, gravity center of the object is used instead in sample program. ◼ Code snippet Computer Graphics Course @Waseda University 9
of scaling → Calculate the ratio from amount of mouse motion. ◼ This time, it’ll be calculated by mouse wheel or mouse drag during middle button press. Computer Graphics Course @Waseda University 11
wheel ◼ Its parameters represent amount of wheel (not mouse position) ◼ Y coordinate corresponds to ordinary mouse wheel. Computer Graphics Course @Waseda University New 12
middle button press ◼ Calculate the ratio from horizontal mouse move. ◼ In sample program, scale up when mouse move to upward. ◼ Scaling update Computer Graphics Course @Waseda University 13
selected object can be controlled using arcball control. ◼ Prepare two simple cubes to be controlled. ◼ You should prepare an object class which manages translation parameters for each object. Computer Graphics Course @Waseda University 20