Skip to content
Snippets Groups Projects
Commit 177f0c61 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

GL14 tensor lines now wotk with any transformation - the code was

previously assuming that voxel axes equaled display space axes. Also,
bugfix in transform.scaleOffsetXform
parent c1060e93
No related branches found
No related tags found
No related merge requests found
......@@ -54,13 +54,15 @@ TEX voxValue, normVoxCoord, texture[0], 3D;
ADD voxValue, voxValue, { 0.0, 0.0, 0.0, 1.0 };
# Look up the modulation value
# from the modulation texture
# from the modulation texture -
# initialise modValue transparency
# to 1.0, so it doesn't corrupt
# our voxel colour value later on
MOV modValue, { 0.0, 0.0, 0.0, 1.0 };
TEX modValue, normVoxCoord, texture[1], 3D;
ADD modValue, modValue, { 0.0, 0.0, 0.0, 1.0 };
# Use those values to look up
# the colours for each xyz
# direction
# Use those values to look up the
# colours for each xyz direction
TEX xColour, voxValue.x, texture[2], 1D;
TEX yColour, voxValue.y, texture[3], 1D;
TEX zColour, voxValue.z, texture[4], 1D;
......@@ -71,7 +73,7 @@ MOV voxColour, xColour;
ADD voxColour, voxColour, yColour;
ADD voxColour, voxColour, zColour;
# But take the average of the alpha channel
# Take the average of the alpha channel
MUL voxColour, voxColour, { 1.0, 1.0, 1.0, 0.333333 };
# Apply the modulation factor
......
......@@ -121,6 +121,7 @@ def draw(self, zpos, xform=None):
# Transform the world coordinates to
# floating point voxel coordinates
dToVMat = display.displayToVoxMat
vToDMat = display.voxToDisplayMat
voxCoords = transform.transform(worldCoords, dToVMat).transpose()
imageData = image.data
......@@ -157,23 +158,17 @@ def draw(self, zpos, xform=None):
# make a bunch of vertices which represent lines
# (two vertices per line), centered at the origin
# and scaled appropriately
vecs[:, xax] *= 0.5 * self.xpixdim
vecs[:, yax] *= 0.5 * self.ypixdim
vecs *= 0.5
vecs = np.hstack((-vecs, vecs)).reshape((2 * nVoxels, 3))
# Flatten on the depth axis
vecs[:, zax] = 0.0
vecs = np.hstack((-vecs, vecs)).reshape((2 * nVoxels, 3))
#
# TODO The above code assumes a correspondence
# between the image array axes and the display
# coordinate system axes. I'm not currently
# sure how to get around this.
#
# Offset each of those vertices by
# their original voxel coordinates
vecs += voxCoords.T.repeat(2, 0)
# Translate the world coordinates
# by those line vertices
worldCoords = worldCoords.repeat(2, 0) + vecs
worldCoords = transform.transform(vecs, vToDMat)
worldCoords[:, zax] = zpos
worldCoords = np.array(worldCoords, dtype=np.float32).ravel('C')
# Draw all the lines!
......
......@@ -44,8 +44,8 @@ def scaleOffsetXform(scales, offsets):
xform[2, 2] = scales[2]
xform[3, 0] = offsets[0]
xform[3, 1] = offsets[0]
xform[3, 2] = offsets[0]
xform[3, 1] = offsets[1]
xform[3, 2] = offsets[2]
return xform
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment