Viewport translation

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Viewport translation

Triffid Hunter
Hi,

Just installed latest openscad from git, looks like a huge amount of
work has been done since the 2011-05 release!

I just have one beef- the viewport translation via mouse controls has
been changed to a less intuitive model.

Previously, the viewport had its own origin about which everything
would rotate. I would change viewport angle a few times and translate
the viewport origin onto the feature I was examining, then be able to
zoom in and rotate to my heart's content. The current git head always
rotates about the object origin rather than viewport origin which
makes it very difficult to view features far from the origin from
multiple angles.

Translating the viewport with right-mouse drag isn't affected by the
zoom setting, so when zoomed in very close, the slightest translation
send the object flying out of the viewport, and when zoomed out a long
way, I have to sit there dragging over and over to get even small
movements.

The viewport still gimbal locks when in top or bottom view. When I
drag left or right, the object still rotates about Z as if I were in
front view when what I actually want is a rotation about Y, just like
dragging up and down produce a rotation about X. If the X and Y axes
were diagonal vs the viewport, I'd expect combined rotations such that
the object rotated about the viewport-local X and Y.


I suppose what I really want is a viewport with an origin in the
viewport center that can be placed anywhere relative to the object
origin, then translated and/or rotated in such a way that the feature
under my cursor stays under my cursor until I've rotated through 45
degrees or so when it will start to curve away _regardless_ of
original orientation or the location of object origin in the viewport.
IIRC blender has a viewport somewhat like this. I'll simply use
ctrl-{4..9} if I get lost :)


Thanks for this amazing work! I use openscad frequently, and enjoy all
the moments when I'm not sitting around waiting for it to render ;)

Reply | Threaded
Open this post in threaded view
|

Re: Viewport translation

donbright
> Previously, the viewport had its own origin about which everything
> would rotate.  . . .
>
> Translating the viewport with right-mouse drag isn't affected by the
> zoom setting

I have a patch here that restores this behavior:

https://github.com/openscad/openscad/pull/43/files#diff-2

Unfortunately some math stuff was removed (mat_rot) so now the
mouse-drag translation is all wacky. I will keep working on it unless
someone else fixes it before me...

> The viewport still gimbal locks when in top or bottom view. When I
> drag left or right, the object still rotates about Z as if I were in
> front view when what I actually want is a rotation about Y, just like
> dragging up and down produce a rotation about X. If the X and Y axes
> were diagonal vs the viewport, I'd expect combined rotations such that
> the object rotated about the viewport-local X and Y.

If you hit 'shift' when you drag left-right, does it work like you are
describing?

-DB

Reply | Threaded
Open this post in threaded view
|

Re: Viewport translation

donbright
ok i translated the old-style (2011.06 release) viewport dragging code
into Eigen math,

https://github.com/openscad/openscad/pull/43/files#diff-2

still don't know how to fix the 'gimbal lock' stuff. im no expert on
the geometry stuff.

-DB

Reply | Threaded
Open this post in threaded view
|

Re: Viewport translation

Triffid Hunter
On Mon, Dec 19, 2011 at 6:33 AM, Don Bright <[hidden email]> wrote:
> I have a patch here that restores this behavior:
>
> https://github.com/openscad/openscad/pull/43/files#diff-2

thanks, I'll check it out

> If you hit 'shift' when you drag left-right, does it work like you are
> describing?

Only from top view, in left or right view it spins the wrong way
still, have to let go of shift and use the original rotation mode.
When looking along the Y axis with Z pointing down, none of the modes
give a sensible result.

On Mon, Dec 19, 2011 at 8:57 AM, Don Bright <[hidden email]> wrote:
> ok i translated the old-style (2011.06 release) viewport dragging code
> into Eigen math,
>
> https://github.com/openscad/openscad/pull/43/files#diff-2
>
> still don't know how to fix the 'gimbal lock' stuff. im no expert on
> the geometry stuff.

need to use quaternions instead of euler angles from what I've read.
gimbal lock is an inherent flaw in the euler angle math itself rather
than any implementation.

A quaternion in this particular context is a rotation matrix
constructed from a unit vector and a rotation angle about that vector,
so I figure on mousedown we'd construct two quaternions, one pointing
along viewport local X and the other along viewport local Y and use
mouse deltas for the rotations. If you create the quaternions on
mousedown and keep using them, I think we might get the effect we're
after. The object being rotated will be the viewport, and we rotate it
about the viewport origin.

Translating this into code would require far more familiarity with
openscad internals than I currently posess.
http://stackoverflow.com/a/764377 may be helpful

Reply | Threaded
Open this post in threaded view
|

Re: Viewport translation

William Adams
In reply to this post by Triffid Hunter
Gimble lock can be solved with quaternions, but that's a whole mother Thing.

From: Don Bright
Sent: 12/18/2011 1:57 PM
To: [hidden email]
Subject: Re: [OpenSCAD] Viewport translation

ok i translated the old-style (2011.06 release) viewport dragging code
into Eigen math,

https://github.com/openscad/openscad/pull/43/files#diff-2

still don't know how to fix the 'gimbal lock' stuff. im no expert on
the geometry stuff.

-DB
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
Reply | Threaded
Open this post in threaded view
|

Re: Viewport translation

Kliment Yanev
I have some quaternion rotation code I wrote/adapted for Printrun. Maybe it will be useful.

https://github.com/kliment/Printrun/blob/experimental/stlview.py#L364

On 12/20/2011 07:11 AM, William Adams wrote:
Gimble lock can be solved with quaternions, but that's a whole mother Thing.
________________________________
From: Don Bright
Sent: 12/18/2011 1:57 PM
To: [hidden email]
Subject: Re: [OpenSCAD] Viewport translation

ok i translated the old-style (2011.06 release) viewport dragging code
into Eigen math,

https://github.com/openscad/openscad/pull/43/files#diff-2

still don't know how to fix the 'gimbal lock' stuff. im no expert on
the geometry stuff.

-DB
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad

_______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscad