Sunday, July 03, 2005

Centerline..further development

itself->view->c_sys.origin.x,yz along with itself->x.x,y,z store the current position of the camera, and are the link which connect the camera position and the volume position being rendered.

Using this, we now come to VR.cpp which contains the method volume_ray_casting()

volume_ray_casting() is called for each frame of rendering the current 2d scene. volume_ray_casting further calls cast_ray_for_a_pixel(), WIDTH*HEIGHT times i.e. for each pixel in the 2d image to be rendered.
Before this volume_ray_casting() uses itself->view->c_sys.origin.x,y,z i.e. the current position of the camera to compute the position of the pixel and the ray direction, and passes it as an arguement to cast_ray_for_a_pixel().

cast_ray_for_a_pixel() takes in the position of the pixel as arguement and gets the appropriate color for the pixel and fills the appropriate position in image->rgb.

The above procedure gives the final 2d texture image which is mapped onto the widget.

The idea now is to use the centerline coordinates available and render the green lines appropriately. Trying to do this after the 2d texture has been mapped produces further complications as we have come out of the domain of internal coordinate systems of the colon.

So presently i think manipulating the image at the lower level, and incorporating the centerline into the 2d texture itself before it is mapped is the right way to proceed. This means i have to put the green pixels (instead of the red ones of the colon) at the correct places in image->rgb.

I have with me the position of certain points on the centerline. Traversing through the centerline points array and selecting positions around the current camera position is certainly inefficent and inaccurate.

I should be able to correspond the centerline point to the pixels being colored in cast_ray_for_a_pixel() and by locating the correct projection of the centerline point, i should override the coloring method, and color that particular pixel green and store in image->rgb.
So now we have to think about finding out whether pixel position being colored corresponds to any of the centerline point by traversing through a list. For now lets focus on just rendering those green points on the screen rather than drawing lines. Generation of a huge number of points could possibly help in viewing.

I now have to find a way to transform the centerline points to get corresponding pixel positions on the screen. Looking at how the pixel positions are got from itself->view->c_sys.origin.x,y,z might give a clue.

If this works, a future possible way of drawing continuous lines could be by using equation for a line in 3d coordinate system, and generating all the points between 2 centerline points given and coloring the appropriate pixels.


Post a Comment

<< Home