# "How do I generate a transform for mapping a regular 3D cube space to irregular "cubish" space?"

"How do I generate a transform for mapping a regular 3D cube space to irregular "cubish" space?"

I've spent 3 days trying to figure this out, and googled every phrase I can think of, but while I can get close, every solution falls apart as soon as it becomes non-affine.

I want to transform an object contained within the regular space to the space contained within the irregular space. I can define the eight vertices for either space, and the edges of the irregular space are straight lines, but some or all of them may no longer be parallel to one another.

Using the same set of 4 verts to create a 4x4 matrix for each space, then multiplying the goal matrix by the inverse of the starting matrix results in a transform matrix that works as long as both spaces maintain perpendicuarity.

Any links or code will be greatly appreciated!

Hi Dan

On ShaderX3 book there is a very short article titled "Deforming of Mesh Objects Using HLSL". Of course the ideas over there can be applied to GLSL or even fixed pipeline.

It is just 7 pages about vertex and normal interpolations, centering objects and functions to interpolate it.

This is a per vertex interpolation, as is not possible to define a single matrix to deform all points.

Hi Dan

On ShaderX3 book there is a very short article titled "Deforming of Mesh Objects Using HLSL". Of course the ideas over there can be applied to GLSL or even fixed pipeline.

It is just 7 pages about vertex and normal interpolations, centering objects and functions to interpolate it.

This is a per vertex interpolation, I guess is not possible to define a single matrix to deform all points.