Go Back to Parent Web Pages

Analysis of Article

"Use a Swing component to explore three-dimensional computer graphics"
By Jeff Friesen, JavaWorld.com, 08/28/06 (JF)

We are not sure that we interpeted this article correctly, and our description can be approximate:
Please excuse us for lack of elaboration or understanding:
For explanation of our notations, look back at DrawIn3D.htm.

Following steps done or omitted in JF applet:

Steps R,T are omitted. Plainly: no easy way to rotate a sprite.
Step W is done before step H: 
Step W: in subroutine lookFrom of module Panel3D, observer shifted by translate(-x,-y,-z).
Step H: by series of rotations rotateX (90.0), rotateY (-angle), rotateX (-angle), scale (1.0, 1.0, -1.0),
        head of observer turned such the object lies on observes axis z and 2D picture is always centered.
Such combination of R,T,W,H causes the sprite (object, pyramid or tower in article's applet) 
always be in the screen's center. Plainly: the sprite wont fly or rotate 360 degrees.

Step SP: implemented by transform = transform.multiply(p) in subroutine perspective().
TP is implemented by clip()
L in showLine()
TS and SS are omitted.

Possible feature additions:
Our comments are marked with "kvk".
   Addition 1.
public void lookFrom (double x, double y, double z) { identity (); //kvk: apply own sprite rotation before doing anything else // in combination with extra slider: transform=transform.multiply(rotationMatrix); translate (-x, -y, -z); ...
Addition 2.
//kvk: Remove Step H and add Step R. // Sprite becomes moving along X and Y and rotating around own axes: public void lookFrom(double x, double y, double z){ identity (); transform=transform.multiply(rotationMatrix); translate(-x,-y,-z); scale (1.0, 1.0, -1.0); }
Auxiliary additions for principal additions:
//kvk added field and a method: //field: stores object rotation: private Matrix rotationMatrix; //method: sets rotationMatrix: public void setObjectRotation(double alphaX, double alphaY, double alphaZ){ identity(rotationMatrix=(new Matrix(4,4))); rotateX(alphaX,rotationMatrix); rotateY(alphaY,rotationMatrix); rotateZ(alphaZ,rotationMatrix); }
There are more axiliary additions required, but in fear to violate fair copyright use of Jeff Friesen's article, we don't list them here. Full text of revised JF applet is in file Result3.zip. We will publish it if will have permission from original authour. Copyright (C) 2009 Konstantin Kirillov.