view aligned slices

i am trying to perform volume rendering using view-aligned slices using a 3D texture. I dont know how to have view-aligned slices (slices perpendicular to the viewport) at all times even if i rotate the volume.
unfortuantely when i rotate the volume i can see some popping and at some instances the volume disappears… please help…

This is code that I saw somewhere:

float quad_size = 20;

// Start of with a simple quad…
CTEDVector vec0(-1.0, -1.0, 0.0f);
CTEDVector vec1( 1.0, -1.0, 0.0f);
CTEDVector vec2( 1.0, 1.0, 0.0f);
CTEDVector vec3(-1.0, 1.0, 0.0f);

float mat[16];

CTEDVector vec_right(mat[0],mat[4],mat[8]);
CTEDVector vec_up(mat[1],mat[5],mat[9]);
CTEDVector vec_eye(mat[2],mat[6],mat[10]);

CTEDVector vec_center = i_pos;

// Now, build a quad around the center point based on the vec_right
// and vec_up vectors. This will guarantee that the quad will be
// orthogonal to the view.
vec0 = vec_center + ((-vec_right - vec_up) * quad_size);
vec1 = vec_center + (( vec_right - vec_up) * quad_size);
vec2 = vec_center + (( vec_right + vec_up) * quad_size);
vec3 = vec_center + ((-vec_right + vec_up) * quad_size);

You can have a look at the source code of our open source volume renderer OpenQVis at:

Browse the CVS:

Basic algorithm:
for all slicing planes with distance d from center of the volume

  1. compute slicing plane equation (a,b,c,d) from view vector (a,b,c) and distance from center of the volume (d)
  2. determine vertices by intersecting each bounding box edge with slicing plane
  3. sort vertices
  4. draw triangle fan
  • Klaus

[This message has been edited by Klaus (edited 02-21-2004).]

[This message has been edited by Klaus (edited 02-21-2004).]