Oblique projection Shear matrix to set lattice coordinates
Note: this is adjusting the lattice coordinates based on the shear required, not the camera. IIRC, it has been asked as a feature request to add an Oblique projection to the camera, but AFAIK it isn't available yet.
Without getting into too much theory, I believe this is pretty much shearing the coordinates of the lattice.
For a front ortho projection, it will shear the XZ plane (side walls) along the x, y vector (1, 1) or some multiple of it.
The test code adds a cube with an encompassing default lattice and shears it based on settings for a front view.
EDIT. Oops, I forgot to scale the lattice object, not the data.
How do you freeze or reset a lattice?
from mathutils import Matrix, Vector
from bpy import context
shear_dist = 1 # sqrt(2) for (1, 1)
shear_vec = Vector((-1, 1)).normalized()
lattice_res = 8
Sh = Matrix.Shear(
shear_dist * shear_vec,
T = Matrix.Translation((0, 0.5, 0))
def mm(matrix, space=Matrix()):
return space.inverted() @ matrix @ space
location=(0, 0, 0),
cube = context.object
location=(0, 0, 0))
latob = context.object
latob.dimensions = cube.dimensions
lat = latob.data
lat.points_u = lattice_res
lat.points_v = lattice_res
lat.points_w = lattice_res
latmod = cube.modifiers.new("Oblique", type='LATTICE')
latmod.object = latob
Ok, I have it better now. The leading face of the cube stays in place.
The next step is to add shape keys for the projections, for example, TOP, LEFT, ... have FRONT.