Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Perspective Class Reference

#include <raycaster.h>

Inheritance diagram for Perspective:

Raycaster List of all members.

Public Methods

 Perspective ()
 ~Perspective ()
bool Initialize (VECTOR eye, float dist, int width, int height, float steplength, Data *data, Transfunc *tf)
bool RotateX (float alpha)
bool RotateY (float alpha)
bool RotateZ (float alpha)
bool Raycast ()

Private Attributes

VECTOR m_eye
float m_dist

Constructor & Destructor Documentation

Perspective::Perspective  
 

Definition at line 403 of file raycaster.cpp.

References m_dist, Raycaster::m_dOwnType, m_eye, and PERSPECTIVE.

00403                          {
00404         m_eye = VECTOR(0,0,-10);
00405         m_dist = 0;
00406 
00407         m_dOwnType = PERSPECTIVE;
00408 }

Perspective::~Perspective  
 

Definition at line 410 of file raycaster.cpp.

00410 {}


Member Function Documentation

bool Perspective::Initialize VECTOR    eye,
float    dist,
int    width,
int    height,
float    steplength,
Data   data,
Transfunc   tf
 

Definition at line 413 of file raycaster.cpp.

References Data::GetXDim(), Data::GetYDim(), Data::GetZDim(), Raycaster::m_data, m_dist, m_eye, Raycaster::m_height, Raycaster::m_steplength, Raycaster::m_tf, Raycaster::m_viewingplane, Raycaster::m_width, VECTOR::normalize(), and Raycaster::Zoom().

00413                                                                                                                {
00414         m_eye = eye;
00415         m_data = data;
00416         m_tf = tf;
00417         m_width = width;
00418         m_height = height;
00419         m_steplength = steplength;
00420         m_dist = dist;
00421         int maxX = m_data->GetXDim()-1;
00422         int maxY = m_data->GetYDim()-1;
00423         int maxZ = m_data->GetZDim()-1;
00424         VECTOR viewingplanenormal = VECTOR(maxX/2,maxY/2,maxZ/2)-m_eye;
00425         viewingplanenormal.normalize();
00426 
00427         VECTOR viewingplanepos = m_eye + m_dist * viewingplanenormal;
00428         m_viewingplane = new Plane(viewingplanenormal,viewingplanepos);
00429 
00430         Zoom(m_zoom);
00431 
00432         if(m_viewingplane == NULL) return false;
00433         if(m_data == NULL) return false;
00434         if(m_tf == NULL) return false;
00435         return true;
00436 }

bool Perspective::Raycast   [virtual]
 

Reimplemented from Raycaster.

Definition at line 440 of file raycaster.cpp.

References Ray::CastNext(), FH, Ray::GetCurrentColor(), Ray::Initialize(), Raycaster::m_data, m_eye, Raycaster::m_height, Raycaster::m_image, Raycaster::m_raytype, Raycaster::m_viewingplane, Raycaster::m_width, Raycaster::m_xdir, Raycaster::m_ydir, MI, NN, Plane::point, Raycaster::ready, Ray::Reset(), Ray::SetLight(), Ray::SetPosDir(), Data::SetPreCalc(), Ray::SetViewingCondition(), STANDARD, Color::toRGB(), TRI, and XRAY.

00440                      {
00441 
00442         CWnd* pFrame = AfxGetMainWnd();
00443 
00444 
00445         m_data->SetPreCalc(m_precalc);
00446         m_image = new rgb[m_width*m_height];
00447         
00448         VECTOR pos =  m_viewingplane->point-m_width/2*m_xdir-m_height/2*m_ydir;
00449         VECTOR backup = pos;
00450 
00451         VECTOR direction;
00452         
00453         int loadSize = (m_height * m_width) / 100;
00454         int counter = loadSize / 100;
00455         int progPos = 0;
00456 
00457 
00458 
00459         Ray *r;
00460 
00461         switch (m_rendermode) {
00462                 case STANDARD:
00463                         if (m_raytype == NN)
00464                                 r = new Ray();
00465                         else if (m_raytype == TRI)
00466                                 r = new Trilinear();
00467                         break;
00468                 case FH:
00469                         if (m_raytype == NN) {
00470                                 r = new FirstHitNN();
00471                                 ((FirstHitNN *)r)->SetTreshold(m_treshold);
00472                         }
00473                         else if (m_raytype == TRI) {
00474                                 r = new FirstHitTRI();
00475                                 ((FirstHitTRI *)r)->SetTreshold(m_treshold);
00476                         }
00477                         break;
00478                 case MI:
00479                         if (m_raytype == NN)
00480                                 r = new MaxIntensityNN();
00481                         else if (m_raytype == TRI)
00482                                 r = new MaxIntensityTRI();
00483                         break;
00484                 case XRAY:
00485                         if (m_raytype == NN)
00486                                 r = new XRayNN();
00487                         else if (m_raytype == TRI)
00488                                 r = new XRayTRI();
00489                         break;
00490         }
00491         
00492         r->SetViewingCondition(m_lightpos, m_ambient, m_diffuse, m_specular, m_highlight);
00493         r->Initialize(m_background,m_background,m_steplength,m_viewingplane,m_data,m_tf);
00494         r->SetLight(m_light);
00495 
00496         for(int j = 0; j < m_height; j++) {
00497                 for(int i = 0; i < m_width; i++) {
00498                         r->Reset();
00499                         direction = pos-m_eye;
00500                         r->SetPosDir(m_eye,direction);
00501                         r->CastNext();
00502                         m_image[j*m_width+i] = r->GetCurrentColor().toRGB();
00503 
00504 
00505                         pos += m_xdir;
00506 
00507                         if ((counter-- <= 0) && (progPos < 100)) {
00508                                 counter = loadSize;
00509                                 pFrame->SendMessage(MYWM_PROGRESS, progPos++);
00510                         }
00511 
00512 
00513                 } // inner for
00514                 pos = backup;
00515                 pos += j*m_ydir;
00516 
00517                 pFrame->SendMessage(MYWM_PROGRESS, 0);
00518         
00519         }
00520 
00521 
00522 
00523 
00524 
00525 /*
00526         Ray *r;
00527         Trilinear *tri;
00528         FirstHitNN *fhnn;
00529         FirstHitTRI *fhtri;
00530         MaxIntensityNN *minn;
00531         MaxIntensityTRI *mitri;
00532         XRayNN *xraynn;
00533         XRayTRI *xraytri;
00534 
00535         if(m_raytype == NN && m_rendermode == STANDARD) {
00536                 r = new Ray();
00537                 r->SetViewingCondition(m_lightpos, m_ambient, m_diffuse, m_specular, m_highlight);
00538                 r->Initialize(m_background,m_background,m_steplength,m_viewingplane,m_data,m_tf);
00539                 r->SetLight(m_light);
00540         }
00541         if(m_raytype == TRI && m_rendermode == STANDARD) {
00542                 tri = new Trilinear();
00543                 tri->SetViewingCondition(m_lightpos, m_ambient, m_diffuse, m_specular, m_highlight);
00544                 tri->Initialize(m_background,m_background,m_steplength,m_viewingplane,m_data,m_tf);
00545                 tri->SetLight(m_light);
00546         }
00547         if(m_raytype == NN && m_rendermode == FH) {
00548                 fhnn = new FirstHitNN();
00549                 fhnn->SetViewingCondition(m_lightpos, m_ambient, m_diffuse, m_specular, m_highlight);
00550                 fhnn->SetTreshold(m_treshold);
00551                 fhnn->Initialize(m_background,m_background,m_steplength,m_viewingplane,m_data,m_tf);
00552                 fhnn->SetLight(m_light);
00553         }
00554         if(m_raytype == TRI && m_rendermode == FH) {
00555                 fhtri = new FirstHitTRI();
00556                 fhtri->SetViewingCondition(m_lightpos, m_ambient, m_diffuse, m_specular, m_highlight);
00557                 fhtri->SetTreshold(m_treshold);
00558                 fhtri->Initialize(m_background,m_background,m_steplength,m_viewingplane,m_data,m_tf);
00559                 fhtri->SetLight(m_light);
00560         }
00561         if(m_raytype == NN && m_rendermode == MI) {
00562                 minn = new MaxIntensityNN();
00563                 minn->SetViewingCondition(m_lightpos, m_ambient, m_diffuse, m_specular, m_highlight);
00564                 minn->Initialize(m_background,m_background,m_steplength,m_viewingplane,m_data,m_tf);
00565         }
00566         if(m_raytype == TRI && m_rendermode == MI) {
00567                 mitri = new MaxIntensityTRI();
00568                 mitri->SetViewingCondition(m_lightpos, m_ambient, m_diffuse, m_specular, m_highlight);
00569                 mitri->Initialize(m_background,m_background,m_steplength,m_viewingplane,m_data,m_tf);
00570         }
00571         if(m_raytype == NN && m_rendermode == XRAY) {
00572                 xraynn = new XRayNN();
00573                 xraynn->SetViewingCondition(m_lightpos, m_ambient, m_diffuse, m_specular, m_highlight);
00574                 xraynn->Initialize(m_background,m_background,m_steplength,m_viewingplane,m_data,m_tf);
00575         }
00576         if(m_raytype == TRI && m_rendermode == XRAY) {
00577                 xraytri = new XRayTRI();
00578                 xraytri->SetViewingCondition(m_lightpos, m_ambient, m_diffuse, m_specular, m_highlight);
00579                 xraytri->Initialize(m_background,m_background,m_steplength,m_viewingplane,m_data,m_tf);
00580         }
00581         
00582         for(int j = 0; j < m_height; j++) {
00583                 for(int i = 0; i < m_width; i++) {
00584                         if(m_raytype == NN && m_rendermode == STANDARD) {
00585                                 r->Reset();
00586                                 direction = pos-m_eye;
00587                                 r->SetPosDir(m_eye,direction);
00588                                 r->CastNext();
00589                                 m_image[j*m_width+i] = r->GetCurrentColor().toRGB();
00590                         }
00591                         if(m_raytype == TRI && m_rendermode == STANDARD) {
00592                                 tri->Reset();
00593                                 direction = pos-m_eye;
00594                                 tri->SetPosDir(m_eye,direction);
00595                                 tri->CastNext();
00596                                 m_image[j*m_width+i] = tri->GetCurrentColor().toRGB();
00597                         }
00598                         if(m_raytype == NN && m_rendermode == FH) {
00599                                 fhnn->Reset();
00600                                 direction = pos-m_eye;
00601                                 fhnn->SetPosDir(m_eye,direction);
00602                                 fhnn->CastNext();
00603                                 m_image[j*m_width+i] = fhnn->GetCurrentColor().toRGB();
00604                         }
00605                         if(m_raytype == TRI && m_rendermode == FH) {
00606                                 fhtri->Reset();
00607                                 direction = pos-m_eye;
00608                                 fhtri->SetPosDir(m_eye,direction);
00609                                 fhtri->CastNext();
00610                                 m_image[j*m_width+i] = fhtri->GetCurrentColor().toRGB();
00611                         }
00612                         if(m_raytype == NN && m_rendermode == MI) {
00613                                 minn->Reset();
00614                                 direction = pos-m_eye;
00615                                 minn->SetPosDir(m_eye,direction);
00616                                 minn->CastNext();
00617                                 m_image[j*m_width+i] = minn->GetCurrentColor().toRGB();
00618                         }
00619                         if(m_raytype == TRI && m_rendermode == MI) {
00620                                 mitri->Reset();
00621                                 direction = pos-m_eye;
00622                                 mitri->SetPosDir(m_eye,direction);
00623                                 mitri->CastNext();
00624                                 m_image[j*m_width+i] = mitri->GetCurrentColor().toRGB();
00625                         }
00626                         if(m_raytype == NN && m_rendermode == XRAY) {
00627                                 xraynn->Reset();
00628                                 direction = pos-m_eye;
00629                                 xraynn->SetPosDir(m_eye,direction);
00630                                 xraynn->CastNext();
00631                                 m_image[j*m_width+i] = xraynn->GetCurrentColor().toRGB();
00632                         }
00633                         if(m_raytype == TRI && m_rendermode == XRAY) {
00634                                 xraytri->Reset();
00635                                 direction = pos-m_eye;
00636                                 xraytri->SetPosDir(m_eye,direction);
00637                                 xraytri->CastNext();
00638                                 m_image[j*m_width+i] = xraytri->GetCurrentColor().toRGB();
00639                         }
00640                         
00641                         
00642                         pos += m_xdir;
00643 
00644 
00645                         if ((counter-- <= 0) && (progPos < 100)) {
00646                                 counter = loadSize;
00647                                 pFrame->SendMessage(MYWM_PROGRESS, progPos++);
00648                         }
00649 
00650 
00651                 } // inner for
00652                 pos = backup;
00653                 pos += j*m_ydir;
00654 
00655                 pFrame->SendMessage(MYWM_PROGRESS, 0);
00656         
00657         }
00658 */
00659         if (r)
00660                 delete r;
00661 
00662         ready = true;
00663         return true;
00664 }

bool Perspective::RotateX float    alpha [virtual]
 

Reimplemented from Raycaster.

Definition at line 668 of file raycaster.cpp.

References Data::GetXDim(), Data::GetYDim(), Data::GetZDim(), Raycaster::m_data, m_dist, m_eye, Raycaster::m_viewingplane, Plane::normal, VECTOR::normalize(), Plane::point, Matrix4x4::rotateX(), and Raycaster::SetViewingMatrix().

00668                                 {
00669         int maxX = m_data->GetXDim()-1;
00670         int maxY = m_data->GetYDim()-1;
00671         int maxZ = m_data->GetZDim()-1;
00672         Matrix4x4 rotmat;
00673         rotmat.rotateX(-alpha);
00674         m_eye = rotmat*m_eye;
00675         m_viewingplane->normal = VECTOR(maxX/2,maxY/2,maxZ/2)-m_eye;
00676         m_viewingplane->normal.normalize();
00677         m_viewingplane->point = m_eye + m_dist*m_viewingplane->normal;
00678         
00679         SetViewingMatrix();
00680         return true;
00681 }

bool Perspective::RotateY float    alpha [virtual]
 

Reimplemented from Raycaster.

Definition at line 684 of file raycaster.cpp.

References Data::GetXDim(), Data::GetYDim(), Data::GetZDim(), Raycaster::m_data, m_dist, m_eye, Raycaster::m_viewingplane, Plane::normal, VECTOR::normalize(), Plane::point, Matrix4x4::rotateY(), and Raycaster::SetViewingMatrix().

00684                                 {
00685         int maxX = m_data->GetXDim()-1;
00686         int maxY = m_data->GetYDim()-1;
00687         int maxZ = m_data->GetZDim()-1;
00688         Matrix4x4 rotmat;
00689         rotmat.rotateY(-alpha);
00690         m_eye = rotmat*m_eye;
00691         m_viewingplane->normal = VECTOR(maxX/2,maxY/2,maxZ/2)-m_eye;
00692         m_viewingplane->normal.normalize();
00693         m_viewingplane->point = m_eye + m_dist*m_viewingplane->normal;
00694         
00695         SetViewingMatrix();
00696         return true;
00697 }

bool Perspective::RotateZ float    alpha [virtual]
 

Reimplemented from Raycaster.

Definition at line 700 of file raycaster.cpp.

References Data::GetXDim(), Data::GetYDim(), Data::GetZDim(), Raycaster::m_data, m_dist, m_eye, Raycaster::m_viewingplane, Plane::normal, VECTOR::normalize(), Plane::point, Matrix4x4::rotateZ(), and Raycaster::SetViewingMatrix().

00700                                 {
00701         int maxX = m_data->GetXDim()-1;
00702         int maxY = m_data->GetYDim()-1;
00703         int maxZ = m_data->GetZDim()-1;
00704         Matrix4x4 rotmat;
00705         rotmat.rotateZ(-alpha);
00706         m_eye = rotmat*m_eye;
00707         m_viewingplane->normal = VECTOR(maxX/2,maxY/2,maxZ/2)-m_eye;
00708         m_viewingplane->normal.normalize();
00709         m_viewingplane->point = m_eye + m_dist*m_viewingplane->normal;
00710         
00711         SetViewingMatrix();
00712         return true;
00713 }


Member Data Documentation

float Perspective::m_dist [private]
 

Definition at line 82 of file raycaster.h.

Referenced by Initialize(), Perspective(), RotateX(), RotateY(), and RotateZ().

VECTOR Perspective::m_eye [private]
 

Definition at line 81 of file raycaster.h.

Referenced by Initialize(), Perspective(), Raycast(), RotateX(), RotateY(), and RotateZ().


The documentation for this class was generated from the following files:
Generated on Thu Jan 23 12:32:16 2003 by doxygen1.3-rc2