# GMLscripts.com

Discuss and collaborate on GML scripts

You are not logged in.

## #1 2010-03-05 16:43:37

brac37
Member
Registered: 2010-02-12
Posts: 18

### shear transform

Hello all,

I have already submitted the shear script by way of the web interface, but the few d3d-scripts have not changed.
The shear transform has many applications:
1) Anaglyphs. Using rotations for the different eye-views is incorrect. Use shear transforms instead. See http://host-a.net/brac37/fps6anaglyph.gm6
2) Monitor drawing. You can draw a monitor by way of a surface which you use as a texture, but by way of a shear transform, you can draw the image of the monitor directly onto the screen. See http://host-a.net/brac37/fps6monitor.gm6.
3) Shadow drawing. You can draw shadows of point light by way of drawing onto a surface with the point light as the camera. The same holds for directional lights: use orthogonal camera projection. But shadows of directional lights can also by drawn directly on the screen by way of MitchGraham's method: simply project the scene onto the plane that must contain shadows. If the directional light is orthogonal to the plane, then the projection is simple. If not, then the projection is still simple if you use the shear transform script. See http://host-a.net/brac37/Dynamic%20Shadows%20Newer.gmk
And I did not mention drawing something skew yet.

Expand/*
**  Usage:
**
**  Arguments:
**      x, y, z: coordinates
**
**  Returns:
**      nothing
**
**  Notes:
**      The z-axis is made skew: points (0,0,t) are draw at (t*x,t*y,t*z).
**      The x-axis (points (t,0,0)) and the y-axis (points (0,t,0)) stay
**      the same.
**      The skew transformation is added to the current transformation.
**      This transformation is not orthogonal and hence does not work
**      properly in combination with lighting.
**
**  brac37
*/
{
var xs, ys, zs, n, ya, ya2, za;
xs = argument0;
ys = argument1;
zs = argument2;
n = sqrt(sqr(xs) + sqr(ys) + sqr(zs));
za = radtodeg (arctan2 (ys, xs));
ya2 = 0.5 * arctan2 (zs, sqrt(sqr(xs) + sqr(ys)));
}