On Wed, 2007-05-30 at 17:40 +0100, Paul Emsley wrote:
> While model building without stereo I would like to rotate the
> ED/model by 90 degrees to fit the model. Is there a way to
> "click a button" and have the scene rotate by 90 degrees, once
> the scene is set? Or even "click a button" and get the scene to
> line up along either the X, Y or Z axis?
>
> For example, I have a view down the x-axis (reference is the
> axis drawn on the screen) and I would like to say rotate around
> Z and look down Y, can do that more easily than a rotation by
> hand?
>
>
> Dear Balaji,
>
> Yes, this kind of thing is quite straightforward.
>
> To Rotate Scene 90 degrees round the Y axis:
> (rotate-y-scene 90 1)
> To View down Z axis
> (set-view-quaternion 0 0 0 1)
> To View down X axis
> (set-view-quaternion (/ 1 2) (/ 1 2) (/ 1 2) (/ -1 2))
> To View down Y axis:
> (set-view-quaternion (/ 1 2) (/ 1 2) (/ 1 2) (/ -1 2))
>
> You can bind these to buttons using generic-button-dialog.
> You can also bind these to keys:
>
>
> (define graphics-general-key-press-hook
> (lambda (key)
>
> (cond
> ((= key 65470) ; F1 key
> ; Down Z axis:
> (set-view-quaternion 0 0 0 1))
>
> ; Down X axis
> ((= key 65471) ; F2 key
> (set-view-quaternion (/ 1 2) (/ 1 2) (/ 1 2) (/ -1 2)))
>
> ; Down Y axis:
> ((= key 65472) ; F3 key
> (set-view-quaternion (/ 1 2) (/ 1 2) (/ 1 2) (/ -1 2)))
>
> ; scene rotate 90 degrees
> ((= key 65473) ; F4 key
> (rotate-y-scene 90 1))
>
> ))
And here for completeness is how to add a box of views buttons in 0.3.2,
complete with animated view change.
(generic-buttons-dialog "View Buttons"
(list
(cons "X Axis view"
(lambda ()
(go-to-view (list (list (/ 1 2) (/ 1 2) (/ 1 2) (/ 1 2))
(rotation-centre) (zoom-factor) ""))))
(cons "Y Axis view"
(lambda ()
(go-to-view (list (list (/ 1 2) (/ 1 2) (/ 1 2) (/ -1 2))
(rotation-centre) (zoom-factor) ""))))
(cons "Z Axis view"
(lambda ()
(go-to-view (list (list 0 0 0 1)
(rotation-centre) (zoom-factor) ""))))
(cons "Rotate 90 degree"
(lambda ()
(rotate-y-scene 90 1)))))
|