Skip to main content

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.

enter image description hereEnter image description here

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.

Oblique projection Shear matrix to set lattice coords

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 isn't available yet

enter image description here

Without getting into too much theory believe this is pretty much shearing the coordinates of the lattice.

For a front ortho projection will shear the XZ plane (side walls) along the x, y vector (1, 1) or some multiple of it.

Test code, adds a cube with an encompassing default lattice and shears it based on settings for front view.

EDIT. Oops forgot to scale the lattice object not the data 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 have it better now, the leading face of the cube stays in place.

Next step add shape keys for the projections eg TOP, LEFT, ... have FRONT

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.

Enter image description here

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?

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 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.

deleted 375 characters in body
Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244

Oblique projection Shear matrix to set lattice coords

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 isn't available yet

enter image description here Left to right test runs with shear distance set to 1, sqrt(2), and 2enter image description here

Without getting into too much theory believe this is pretty much shearing the coordinates of the lattice.

For a front ortho projection will shear the XZ plane (side walls) along the x, y vector (1, 1) or some multiple of it.

Test code, adds a cube with an encompassing default lattice and shears it based on settings for front view.

EDIT. Oops forgot to scale the lattice object not the data 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))

Of many improvements here possibly moving the origin of the lattice to its front face would be ideal to keep "front" of cube constant, and project back fromOk have it when changingbetter now, the distanceleading face of the shear.

Make an operator so can fiddle the settings and visualizecube stays in place.

Add shapekeysNext step add shape keys for different views and settings,the projections eg Basis is standard no deformTOP, add shape for front view with deform as shownLEFT, then add shapekey for side view but shear XZ plane. These could be associated with a set up of ortho cameras or from the views direction vector. (be an interesting exersize). have FRONT

Oblique projection Shear matrix to set lattice coords

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 isn't available yet

enter image description here Left to right test runs with shear distance set to 1, sqrt(2), and 2

Without getting into too much theory believe this is pretty much shearing the coordinates of the lattice.

For a front ortho projection will shear the XZ plane (side walls) along the x, y vector (1, 1) or some multiple of it.

Test code, adds a cube with an encompassing default lattice and shears it based on settings for front view.

EDIT. Oops forgot to scale the lattice object not the data 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()
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

latmod = cube.modifiers.new("Oblique", type='LATTICE')
latmod.object = latob

lat.transform(mm(Sh))

Of many improvements here possibly moving the origin of the lattice to its front face would be ideal to keep "front" of cube constant, and project back from it when changing the distance of the shear.

Make an operator so can fiddle the settings and visualize.

Add shapekeys for different views and settings, eg Basis is standard no deform, add shape for front view with deform as shown, then add shapekey for side view but shear XZ plane. These could be associated with a set up of ortho cameras or from the views direction vector. (be an interesting exersize)

Oblique projection Shear matrix to set lattice coords

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 isn't available yet

enter image description here

Without getting into too much theory believe this is pretty much shearing the coordinates of the lattice.

For a front ortho projection will shear the XZ plane (side walls) along the x, y vector (1, 1) or some multiple of it.

Test code, adds a cube with an encompassing default lattice and shears it based on settings for front view.

EDIT. Oops forgot to scale the lattice object not the data 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 have it better now, the leading face of the cube stays in place.

Next step add shape keys for the projections eg TOP, LEFT, ... have FRONT

deleted 25 characters in body
Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244

Oblique projection Shear matrix to set lattice coords

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 isn't available yet

enter image description here Left to right test runs with shear distance set to 1, sqrt(2), and 2

Without getting into too much theory believe this is pretty much shearing the coordinates of the lattice.

For a front ortho projection will shear the XZ plane (side walls) along the x, y vector (1, 1) or some multiple of it.

Test code, adds a cube with an encompassing default lattice and shears it based on settings for front view.

EDIT. Oops forgot to scale the lattice object not the data 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()
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

latmod = cube.modifiers.new("Oblique", type='LATTICE')
latmod.object = latob

cube.parent = latob
lat.transform(mm(Sh))

Of many improvements here possibly moving the origin of the lattice to its front face would be ideal to keep "front" of cube constant, and project back from it when changing the distance of the shear.

Make an operator so can fiddle the settings and visualize.

Add shapekeys for different views and settings, eg Basis is standard no deform, add shape for front view with deform as shown, then add shapekey for side view but shear XZ plane. These could be associated with a set up of ortho cameras or from the views direction vector. (be an interesting exersize)

Oblique projection Shear matrix to set lattice coords

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 isn't available yet

enter image description here Left to right test runs with shear distance set to 1, sqrt(2), and 2

Without getting into too much theory believe this is pretty much shearing the coordinates of the lattice.

For a front ortho projection will shear the XZ plane (side walls) along the x, y vector (1, 1) or some multiple of it.

Test code, adds a cube with an encompassing default lattice and shears it based on settings for front view.

EDIT. Oops forgot to scale the lattice object not the data 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()
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

latmod = cube.modifiers.new("Oblique", type='LATTICE')
latmod.object = latob

cube.parent = latob
lat.transform(mm(Sh))

Of many improvements here possibly moving the origin of the lattice to its front face would be ideal to keep "front" of cube constant, and project back from it when changing the distance of the shear.

Make an operator so can fiddle the settings and visualize.

Add shapekeys for different views and settings, eg Basis is standard no deform, add shape for front view with deform as shown, then add shapekey for side view but shear XZ plane. These could be associated with a set up of ortho cameras or from the views direction vector. (be an interesting exersize)

Oblique projection Shear matrix to set lattice coords

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 isn't available yet

enter image description here Left to right test runs with shear distance set to 1, sqrt(2), and 2

Without getting into too much theory believe this is pretty much shearing the coordinates of the lattice.

For a front ortho projection will shear the XZ plane (side walls) along the x, y vector (1, 1) or some multiple of it.

Test code, adds a cube with an encompassing default lattice and shears it based on settings for front view.

EDIT. Oops forgot to scale the lattice object not the data 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()
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

latmod = cube.modifiers.new("Oblique", type='LATTICE')
latmod.object = latob

lat.transform(mm(Sh))

Of many improvements here possibly moving the origin of the lattice to its front face would be ideal to keep "front" of cube constant, and project back from it when changing the distance of the shear.

Make an operator so can fiddle the settings and visualize.

Add shapekeys for different views and settings, eg Basis is standard no deform, add shape for front view with deform as shown, then add shapekey for side view but shear XZ plane. These could be associated with a set up of ortho cameras or from the views direction vector. (be an interesting exersize)

added 288 characters in body
Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244
Loading
added 72 characters in body
Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244
Loading
Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244
Loading