Changeset 407


Ignore:
Timestamp:
Apr 24, 2006 12:46:14 PM (18 years ago)
Author:
qiaow
Message:

Added 3 cut planes for each volume object

Location:
trunk/gui/vizservers/nanovis
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/vizservers/nanovis/Makefile

    r406 r407  
    101101        gcc $(CFLAG) Lic.cpp
    102102
    103 Volume.o: Texture3D.o Volume.cpp $(AUXSRC)
     103Volume.o: Texture3D.o Volume.cpp Volume.h $(AUXSRC)
    104104        gcc $(CFLAG) Volume.cpp
    105105
  • trunk/gui/vizservers/nanovis/Volume.cpp

    r374 r407  
    3737
    3838  location = Vector3(x,y,z);
     39
     40  //add cut planes
     41  plane.clear();
     42  plane.push_back(CutPlane(1, 0.5));
     43  plane.push_back(CutPlane(2, 0.5));
     44  plane.push_back(CutPlane(3, 0.5));
     45 
    3946}
    4047
  • trunk/gui/vizservers/nanovis/Volume.h

    r371 r407  
    1717#define _VOLUME_H_
    1818
     19#include <vector>
     20
    1921#include "define.h"
    2022#include "Texture3D.h"
    2123#include "Vector3.h"
     24
     25using namespace std;
     26
     27struct CutPlane{
     28  int orient;   //orientation - 1: xy slice, 2: yz slice, 3: xz slice
     29  float offset; //normalized offset [0,1] in the volume
     30
     31  CutPlane(int _orient, float _offset):
     32        orient(_orient),
     33        offset(_offset){}
     34};
     35
    2236
    2337class Volume{
     
    2539public:
    2640        Vector3 location;
     41        vector <CutPlane> plane; //cut planes
    2742
    2843        int width;
  • trunk/gui/vizservers/nanovis/VolumeRenderer.cpp

    r406 r407  
    131131  glEnable(GL_DEPTH_TEST);
    132132  glEnable(GL_BLEND);
    133  
     133
     134  //render the cut planes
     135  for(int i=0; i<volume[volume_index]->plane.size(); i++){
     136    float offset = volume[volume_index]->plane[i].offset;
     137    int axis = volume[volume_index]->plane[i].orient;
     138
     139    if(axis==1){
     140      vert1 = Vector4(-10, -10, offset, 1);
     141      vert2 = Vector4(-10, +10, offset, 1);
     142      vert3 = Vector4(+10, +10, offset, 1);
     143      vert4 = Vector4(+10, -10, offset, 1);
     144    }
     145    else if(axis==2){
     146      vert1 = Vector4(offset, -10, -10, 1);
     147      vert2 = Vector4(offset, +10, -10, 1);
     148      vert3 = Vector4(offset, +10, +10, 1);
     149      vert4 = Vector4(offset, -10, +10, 1);
     150    }
     151    else if(axis==3){
     152      vert1 = Vector4(-10, offset, -10, 1);
     153      vert2 = Vector4(+10, offset, -10, 1);
     154      vert3 = Vector4(+10, offset, +10, 1);
     155      vert4 = Vector4(-10, offset, +10, 1);
     156    }
     157
     158    vert1 = model_view.transform(vert1);
     159    vert2 = model_view.transform(vert2);
     160    vert3 = model_view.transform(vert3);
     161    vert4 = model_view.transform(vert4);
     162
     163    ConvexPolygon *poly;
     164    poly = &staticPoly;
     165    poly->vertices.clear();
     166
     167    poly->append_vertex(vert1);
     168    poly->append_vertex(vert2);
     169    poly->append_vertex(vert3);
     170    poly->append_vertex(vert4);
     171
     172    for(int k=0; k<6; k++){
     173      poly->clip(volume_planes[k]);
     174    }
     175
     176    poly->copy_vertices_to_texcoords();
     177    poly->transform(model_view_inverse);
     178    poly->translate(shift_4d);
     179    poly->transform(model_view);
     180
     181    glPushMatrix();
     182    glScalef(volume[volume_index]->aspect_ratio_width, volume[volume_index]->aspect_ratio_height, volume[volume_index]->aspect_ratio_depth);
     183
     184    activate_one_volume_shader(volume_index, 1, 1);
     185    glPopMatrix();
     186
     187    glBegin(GL_POLYGON);
     188      poly->Emit(true);
     189    glEnd();
     190
     191    deactivate_one_volume_shader();
     192  }
     193
     194#if 1
    134195  for (int i=0; i<n_actual_slices; i++){
    135196    slice_z = zFar + i * z_step;        //back to front
     
    181242    */
    182243   
    183     activate_one_volume_shader(volume_index, n_actual_slices);
     244    activate_one_volume_shader(volume_index, n_actual_slices, 30);
    184245    glPopMatrix();
    185246
     
    191252               
    192253  }
     254#endif
    193255
    194256  glDisable(GL_BLEND);
     
    248310
    249311
    250 void VolumeRenderer::activate_one_volume_shader(int volume_index, int n_actual_slices){
     312void VolumeRenderer::activate_one_volume_shader(int volume_index, int n_actual_slices, float scale){
    251313
    252314  cgGLSetStateMatrixParameter(m_mvp_vert_std_param, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);
     
    261323  cgGLEnableTextureParameter(m_tf_one_volume_param);
    262324
    263   cgGLSetParameter4f(m_render_param_one_volume_param, n_actual_slices, 0., live_diffuse, live_specular);
     325  cgGLSetParameter4f(m_render_param_one_volume_param, n_actual_slices, scale, live_diffuse, live_specular);
    264326  cgGLBindProgram(m_one_volume_fprog);
    265327  cgGLEnableProfile(CG_PROFILE_FP30);
  • trunk/gui/vizservers/nanovis/VolumeRenderer.h

    r406 r407  
    6363  CGparameter m_mvi_vert_std_param;
    6464
    65   void activate_one_volume_shader(int volume_index, int n_actual_slices);
     65  void activate_one_volume_shader(int volume_index, int n_actual_slices, float opacity_scale);
    6666  void deactivate_one_volume_shader();
    6767
  • trunk/gui/vizservers/nanovis/shaders/one_volume.cg

    r401 r407  
    4949      //sample the transfer function texture
    5050      float4 color = tex1D(tf, sample.x);
    51       color.w = 30*color.w/renderParameters.x;
     51      color.w = renderParameters.y*color.w/renderParameters.x;
    5252
    5353      //float4 color = float4(sample.x, 0, 0, 1);
Note: See TracChangeset for help on using the changeset viewer.