Oblique projection Shear matrix to set lattice coordscoordinates
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.
TestThe 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?.
How do you freeze or reset a lattice?
import bpy
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(
'XZ',
4,
shear_dist * shear_vec,
)
T = Matrix.Translation((0, 0.5, 0))
def mm(matrix, space=Matrix()):
return space.inverted() @ matrix @ space
bpy.ops.mesh.primitive_cube_add(
location=(0, 0, 0),
)
cube = context.object
bpy.ops.object.add(
type='LATTICE',
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
lat.transform(mm(Sh, T))
Ok, I have it better now, the. The leading face of the cube stays in place.
NextThe next step is to add shape keys for the projections eg, for example, TOP, LEFT, ... have FRONT.