Hi again list,

using the OrbitBehavior to look at some terrain for instance
always makes me feel 'drunk' ... I'm not a trained astronaut,
so when I'm turning left for instance, I expect the horizon to
remain horizontal, if not, I know I had much too much beer and
will fall down a moment later.

OrbitBehaviour almost ever gives me that feeling, and trying to
get the horizon back to where it should be by slight circles
with the mouse makes me feel even more drunk, because in 70%
of the time I start with circling the wrong way.

So I want to fix that ... and found a simple solution;
modify OrbitBehavior (somewhere around line 460):

  protected synchronized void integrateTransforms() {
    ...
    longditudeTransform.rotY( longditude );
    latitudeTransform.rotX( latitude );

    rotateTransform.mul(rotateTransform, latitudeTransform);
-   rotateTransform.mul(rotateTransform, longditudeTransform);
+   rotateTransform.mul(longditudeTransform, rotateTransform);

    distanceVector.z = distanceFromCenter ...
    ...
}

This EVER maps the 3D Y axis to a vertical line in 2D (though
the positive Y direction may actually point down, or degenerate
to a point, when looking from top or bottom into the world),
all in all I consider this good 'HorizontalOrbitBehavior'.

But this solution has the disadvantage, that I have to copy
the source of OrbitBehavior into my project and modify it,
because integrateTransform() heavily uses private members
of OrbitBehavior, thus disabling a complete reimplementation
in a subclass. I would then be responsible to update accordingly
whenever SUN changes the implementation. Not a good approach.

Instead I tried to override integrateTransforms() in a subclass
with this:

/**
 * Overridden to maintain a 'horizontal' behaviour, meaning: the 3D Y axis
 * ever is projected to a vertical line in 2D. Note, that, by request, the
 * Y axis projection actually may appear upside down, but ever being
 * vertical, maintaining the horizon horizontal.
 * <p>
 * One improvement would be to restrict the Y axis turn, so that the world
 * can't be viewed upside down.
 *
 * @todo  though at first it seemed to work, this impl has the notable
 *        difference, that the 'improvement' is built in already, but
 *        with the UNWANTED effect, that X (latitude) rotation gets
 *        more and more overwhelming, when world is seen from near above
 *        or below. And over all this impl really behaves strange, when
 *        zooming and/or translating and then rotating again: too
 *        complicated to describe, one has to explore the strangeness.
 */
protected synchronized void integrateTransforms() {
    super.integrateTransforms();
    Vector3d camera = new Vector3d();
    targetTransform.get(camera);
    Point3d center = new Point3d();
    getRotationCenter(center);
    targetTransform.lookAt(new Point3d(camera), center, new Vector3d(0, 1, 0));
    targetTransform.invert();
    targetTG.setTransform(targetTransform);
}


As you see from my JavaDoc comments above, I'm currently
clueless, how to proceed and I'm near to believe, that OrbitBehavior
should be fixed to allow for this 'horizontal' (and may be other)
arrangement(s); i.e. by providing additional flags/methods or by
calling some 'template' method, that does the actual calculation
and has access to all neccessary members.

Or may be, I'm just too stupid or tired (or drunk)?

Any hint is welcome, regards

Georg
 ___   ___
| + | |__    Georg Rehfeld      Woltmanstr. 12     20097 Hamburg
|_|_\ |___   [EMAIL PROTECTED]           +49 (40) 23 53 27 10

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to