Main Page   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

MDITransparent.cpp

00001 //---------------------------------------------------------------------------
00002 
00003 #include <vcl.h>
00004 #pragma hdrstop
00005 
00006 #include "MDITransparent.h"
00007 #include "MDIEdit.h"
00008 #include "MDIFrame.h"
00009 //---------------------------------------------------------------------------
00010 #pragma package(smart_init)
00011 #pragma resource "*.dfm"
00012 TTransparentForm *TransparentForm;
00013 rgb *transparentview;
00014 
00015     long testx,testy,testz;
00016 const float pi=3.141592;
00017 const float pi2=2*pi;
00018 const float pih=pi/2;
00019 const float pirad=pi/180;
00020 int ox,oy, mrotx, mroty;
00021 bool mdown;
00022 
00023 //---------------------------------------------------------------------------
00024 __fastcall TTransparentForm::TTransparentForm(TComponent* Owner)
00025         : TForm(Owner)
00026 {
00027 }
00028 //---------------------------------------------------------------------------
00029 void __fastcall TTransparentForm::SetPixelFormatDescriptor()
00030 {
00031     PIXELFORMATDESCRIPTOR pfd = {
00032         sizeof(PIXELFORMATDESCRIPTOR),
00033         1,
00034         PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
00035         PFD_TYPE_RGBA,
00036         24,
00037         0,0,0,0,0,0,
00038         0,0,
00039         0,0,0,0,0,
00040         32,
00041         0,
00042         0,
00043         PFD_MAIN_PLANE,
00044         0,
00045         0,0,
00046     };
00047     PixelFormat = ChoosePixelFormat(hdc, &pfd);
00048     SetPixelFormat(hdc, PixelFormat, &pfd);
00049 }
00050 
00051 //---------------------------------------------------------------------
00052 void __fastcall TTransparentForm::FormClose(TObject *Sender, TCloseAction &Action)
00053 {
00054 delete [] transparentview;
00055 Action=caFree;
00056 FrameForm->Transparent->Checked = false;
00057 memusage = memusage - 3*1024*1024;
00058 FrameForm->memupdate();
00059 wglDeleteContext(hrc);
00060 ReleaseDC(Handle,hdc);
00061 }
00062 //---------------------------------------------------------------------
00063 void __fastcall TTransparentForm::FormCreate(TObject *Sender)
00064 {
00065     int i,a;
00066 
00067     transparentview = new rgb[1024*1024];
00068     memusage = memusage + 3*1024*1024;
00069     FrameForm->memupdate();
00070 
00071     mrotx=0; mroty=0;xres=256;yres=256;thresh = 400;
00072     hdc = GetDC(Handle);
00073     SetPixelFormatDescriptor();
00074     hrc = wglCreateContext(hdc);
00075     if(hrc == NULL) ShowMessage("Could not create DC!");
00076     wglMakeCurrent(hdc, hrc);
00077 
00078     w = ClientWidth;
00079     h = ClientHeight;
00080 
00081     glEnable(GL_DEPTH_TEST);
00082     glEnable(GL_CULL_FACE);
00083 
00084     glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
00085     glOrtho (-50.0,50.0,-50.0,50.0,-50.0,50.0);
00086 
00087     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00088     glFlush();
00089     SwapBuffers(hdc);
00090     FormResize(Sender);
00091     RayCast();
00092 }
00093 //---------------------------------------------------------------------
00094 void __fastcall TTransparentForm::FormResize(TObject *Sender)
00095 {
00096         PrepareGLWindow();
00097         if (autores->Checked) {RayCast();}
00098         PaintGL();
00099 }
00100 //---------------------------------------------------------------------------
00101 void __fastcall TTransparentForm::FormPaint(TObject *Sender)
00102 {
00103         PaintGL();
00104 }
00105 //---------------------------------------------------------------------------
00106 void __fastcall TTransparentForm::PaintGL()
00107 {
00108         float i;
00109 
00110         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00111         PrepareGLWindow();
00112         glColor3f(0.6f,0.6f,0.6f);
00113         glLineWidth(3.0f);
00114         glBegin(GL_LINE_STRIP);
00115         glVertex3f(-50,-50,0);
00116         glVertex3f(50,-50,0);
00117         glVertex3f(50,50,0);
00118         glVertex3f(-50,50,0);
00119         glVertex3f(-50,-50,0);
00120         glEnd();
00121 
00122         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
00123         glDrawPixels(xres, yres, GL_RGB, GL_UNSIGNED_BYTE,transparentview);
00124                         // we use unsigned byte (char) to meet speed issues.
00125                         // 16 bit data (__int16) slows down drawing to much.
00126 
00127         glFlush();
00128         SwapBuffers(hdc);
00129 }
00130 
00131 void __fastcall TTransparentForm::PrepareGLWindow()
00132 {
00133         wglMakeCurrent(hdc, hrc);
00134 
00135         GLfloat nRange = 50.0;
00136         w = ClientWidth-200;
00137         h = ClientHeight;
00138 
00139         if(h == 0) h = 1;
00140         if(w == 0) w = 1;
00141 
00142         glViewport(200, 0, w, h);
00143         glLoadIdentity();
00144 
00145         if (w <= h)
00146         {        glOrtho (-nRange, nRange, -nRange*h/w, nRange*h/w, -nRange, nRange);
00147                 glPixelZoom((float)w/(float)xres, (float)w/(float)yres);}
00148          else
00149         {        glOrtho (-nRange*w/h, nRange*w/h, -nRange, nRange, -nRange, nRange);
00150                 glPixelZoom((float)h/(float)xres, (float)h/(float)yres);}
00151 
00152         glRasterPos2d(-50,-50);
00153 }
00154 //---------------------------------------------------------------------------
00155 
00156 void __fastcall TTransparentForm::FormActivate(TObject *Sender)
00157 {
00158         PaintGL();
00159 }
00160 //---------------------------------------------------------------------------
00161 void __fastcall TTransparentForm::RayCast()
00162 {
00163         int a,i,k,maxres;
00164         __int16 value;
00165         int aktpos, rowsize,pagesize, px, py, pz;
00166         int h,ita, ite;
00167         float j,t,ta,te,tx,ty,tz,xrcos,yrcos,zrcos,xrsin,yrsin,zrsin,xrot,yrot,zrot;
00168         float valcr, valcg, valcb, valgx,valgy,valgz,value1,value2,value3, value4, value11, value22,pfx,pfy,pfz,sx,sy,sz,s1x,s1y;
00169         float temp, fr, fg, fb;
00170         bool detset;
00171         double valsh, ac, ac2;
00172         float lx, ly, lz, alphasum, alpha;
00173         unsigned char col, vcol;
00174         const trlimit = 1/256;
00175 
00176         alphasum = 1.0;
00177 
00178         vertex pppos;
00179         vertex dlookup[1024];
00180         if (autores->Checked)
00181         { if (w>h) {xres=h;yres=h;} else {xres=w;yres=w;} }
00182         else
00183         {
00184         xres = StrToInt(textx->Caption);
00185         yres = StrToInt(texty->Caption);
00186         }
00187         xrot = (float)StrToFloat(txrot->Text)*pirad;
00188 //        yrot = (float)StrToFloat(tyrot->Text)*pirad;
00189         zrot = (float)StrToFloat(tzrot->Text)*pirad;
00190 
00191         xrcos = _fm_cos(xrot);
00192 //        yrcos = _fm_cos(yrot);
00193         zrcos = _fm_cos(zrot);
00194         xrsin = _fm_sin(xrot);
00195 //        yrsin = _fm_sin(yrot);
00196         zrsin = _fm_sin(zrot);
00197 
00198         FrameForm->StatusProgress->Position = 0;
00199         FrameForm->StatusProgress->Visible = true;
00200         maxres = MAX(MAX(sizeX,sizeY),sizeZ);
00201 
00202 
00203         lx =0; ly=1; lz=0;
00204 
00205         temp = ly;
00206         ly = temp*xrcos - lz * xrsin;
00207         lz = temp*xrsin + lz * xrcos;
00208 
00209         temp = lx;
00210         lx = temp*zrcos - ly * zrsin;
00211         ly = temp*zrsin + ly * zrcos;
00212 
00213 
00214         dx.x = (float)maxres/(float)xres;
00215         dx.y = 0;
00216         dx.z = 0;
00217 
00218         temp = dx.y;
00219 
00220         dx.x = dx.x;
00221         dx.y = temp * xrcos - dx.z*xrsin;
00222         dx.z = temp * xrsin + dx.z*xrcos;
00223 
00224         temp = dx.x;
00225 
00226         dx.x = temp * zrcos - dx.y * zrsin;
00227         dx.y = temp * zrsin + dx.y * zrcos;
00228         dx.z = dx.z;
00229 
00230         dy.x = 0;
00231         dy.y = 0;
00232         dy.z = (float)maxres/(float)yres;
00233 
00234         temp = dy.y;
00235 
00236         dy.x = dy.x;
00237         dy.y = temp * xrcos - dy.z*xrsin;
00238         dy.z = temp * xrsin + dy.z*xrcos;
00239 
00240         temp = dy.x;
00241 
00242         dy.x = temp * zrcos - dy.y * zrsin;
00243         dy.y = temp * zrsin + dy.y * zrcos;
00244         dy.z = dy.z;
00245 
00246 
00247         dz.x = 0;
00248         dz.y = 1;
00249         dz.z = 0;
00250 
00251         temp = dz.y;
00252 
00253         dz.x = dz.x;
00254         dz.y = temp * xrcos - dz.z*xrsin;
00255         dz.z = temp * xrsin + dz.z*xrcos;
00256 
00257         temp = dz.x;
00258 
00259         dz.x = temp * zrcos - dz.y * zrsin;
00260         dz.y = temp * zrsin + dz.y * zrcos;
00261         dz.z = dz.z;
00262 
00263         o.x = -(maxres/2);
00264         o.y = -(sizeY/2);
00265         o.z = -(maxres/2);
00266 
00267         temp = o.y;
00268 
00269         o.x = o.x;
00270         o.y = temp * xrcos - o.z*xrsin;
00271         o.z = temp * xrsin + o.z*xrcos;
00272 
00273         temp = o.x;
00274 
00275         o.x = temp * zrcos - o.y * zrsin;
00276         o.y = temp * zrsin + o.y * zrcos;
00277         o.z = o.z;
00278 
00279         o.x = o.x + sizeX/2;
00280         o.y = o.y + sizeY/2;
00281         o.z = o.z + sizeZ/2;
00282 
00283         pagesize = sizeX*sizeY;
00284         rowsize = sizeX;
00285 
00286         for (i=0; i<1024; i++)
00287         {
00288         dlookup[i].x = (i-512) * dz.x;        //Lookup-Values für RayCast berechnen
00289         dlookup[i].y = (i-512) * dz.y;
00290         dlookup[i].z = (i-512) * dz.z;
00291         }
00292 
00293         k = 0;
00294         for (a=0; a<yres; a++)
00295         {
00296                 pppos.x = o.x + a * dy.x;
00297                 pppos.y = o.y + a * dy.y;
00298                 pppos.z = o.z + a * dy.z;
00299 
00300                 if (arepaint->Checked == false) {FrameForm->StatusProgress->Position = (int)(100 * ((float)a / (float)yres));}
00301                 for (i=0; i<xres; i++)
00302                 {
00303                         ppos.x = pppos.x + i * dx.x;     // Rotierten Startpunkt für parametrisierte
00304                         ppos.y = pppos.y + i * dx.y;     // Gerade berechnen ...
00305                         ppos.z = pppos.z + i * dx.z;
00306 
00307                         ta = 9999;
00308                         te = 9999;
00309 
00310                         if (dz.x!=0)
00311                         {
00312                           t = -ppos.x/dz.x;                      // Schneide Ray mit x=0
00313                           ty = ppos.y + t*dz.y;
00314                           tz = ppos.z + t*dz.z;
00315                           if (ty>=0 && tz>=2 && ty<sizeY-1 && tz<sizeZ-3) { if (ta==9999) ta=t; else te=t; }
00316 
00317                           t = (sizeX-1-ppos.x)/dz.x;               // Schneide Ray mit x=sizeX
00318                           ty = ppos.y + t*dz.y;
00319                           tz = ppos.z + t*dz.z;
00320                           if (ty>=0 && tz>=2 && ty<sizeY-1 && tz<sizeZ-3) { if (ta==9999) ta=t; else te=t; }
00321                         }
00322 
00323                         if (dz.y!=0)
00324                         {
00325                           t = -ppos.y/dz.y;                      // Schneide Ray mit y=0
00326                           tx = ppos.x + t*dz.x;
00327                           tz = ppos.z + t*dz.z;
00328                           if (tx>=0 && tz>=2 && tx<sizeX-1 && tz<sizeZ-3) { if (ta==9999) ta=t; else te=t; }
00329 
00330                           t = (sizeY-1-ppos.y)/dz.y;               // Schneide Ray mit y=sizeY
00331                           tx = ppos.x + t*dz.x;
00332                           tz = ppos.z + t*dz.z;
00333                           if (tx>=0 && tz>=2 && tx<sizeX-1 && tz<sizeZ-3) { if (ta==9999) ta=t; else te=t; }
00334                         }
00335 
00336                         if (dz.z!=0)
00337                         {
00338                           t = (2-ppos.z)/dz.z;                      // Schneide Ray mit z=0
00339                           tx = ppos.x + t*dz.x;
00340                           ty = ppos.y + t*dz.y;
00341                           if (tx>=0 && ty>=0 && tx<sizeX-1 && ty<sizeY-1) { if (ta==9999) ta=t; else te=t; }
00342 
00343                           t = (sizeZ-3-ppos.z)/dz.z;               // Schneide Ray mit z=sizeZ
00344                           tx = ppos.x + t*dz.x;
00345                           ty = ppos.y + t*dz.y;
00346                           if (tx>=0 && ty>=0 && tx<sizeX-1 && ty<sizeY-1) { if (ta==9999) ta=t; else te=t; }
00347                         }
00348 
00349                         if (ta>te) {t=ta; ta=te; te=t;}
00350 
00351                         if (te==9999)
00352                         {
00353                         transparentview[k].r=transparentview[k].b=transparentview[k].g = 0;
00354                         }
00355                         else
00356                         {
00357                         value = 0; ita = (int)ta+512; ite = (int)te+512-2;
00358                         alphasum = 1.0;fr = 0.0; fg = 0.0; fb = 0.0;
00359                         for (j=ta; j<te && alphasum>trlimit; j = j + 1.0)
00360                         { //if (detset==0) j += detval;
00361 
00362                           pfx = (ppos.x) + j * dz.x;
00363                           pfy = (ppos.y) + j * dz.y;
00364                           pfz = (ppos.z) + j * dz.z;
00365 
00366 /*label1:                   pfx = (ppos.x) + dlookup[j].x;
00367                           pfy = (ppos.y) + dlookup[j].y;
00368                           pfz = (ppos.z) + dlookup[j].z;
00369 */
00370                           px = (int)pfx;
00371                           py = (int)pfy;
00372                           pz = (int)pfz;
00373                           if (pz>=sizeZ) {pz=sizeZ-1;}
00374                           aktpos = pagesize*pz + rowsize*py + px;
00375                           if (trilinear->Checked)
00376                           {
00377                                 sx = pfx-px;
00378                                 sy = pfy-py;
00379                                 sz = pfz-pz;
00380                                 s1x = 1-sx;
00381                                 s1y = 1-sy;
00382                                 value1 = (float)data[aktpos]*s1x                  + (float)data[aktpos+1]*sx;
00383                                 value2 = (float)data[aktpos+rowsize]*s1x          + (float)data[aktpos+rowsize+1]*sx;
00384                                 value3 = (float)data[aktpos+pagesize+rowsize]*s1x + (float)data[aktpos+pagesize+rowsize+1]*sx;
00385                                 value4 = (float)data[aktpos+pagesize]*s1x         + (float)data[aktpos+pagesize+1]*sx;
00386                                 value11 = value1*(s1y) + value2*(sy);
00387                                 value22 = value4*(s1y) + value3*(sy);
00388                                 value = (int)(value11*(1-sz) + value22*(sz));
00389                           }
00390                           else
00391                           {
00392                                 value = data[pagesize*pz + rowsize*py + px];
00393                           }
00394 
00395                                 if (trilinear->Checked)
00396                                 {sx = fabs(pfx-(float)px);
00397                                 sy = fabs(pfy-(float)py);
00398                                 sz = fabs(pfz-(float)pz);
00399                                 s1x = (float)1-sx;
00400                                 value1 = (float)color[aktpos].a*s1x                  + (float)color[aktpos+1].a*sx;
00401                                 value2 = (float)color[aktpos+rowsize].a*s1x          + (float)color[aktpos+rowsize+1].a*sx;
00402                                 value3 = (float)color[aktpos+pagesize+rowsize].a*s1x + (float)color[aktpos+pagesize+rowsize+1].a*sx;
00403                                 value4 = (float)color[aktpos+pagesize].a*s1x         + (float)color[aktpos+pagesize+1].a*sx;
00404                                 value11 = value1*(1-sy) + value2*(sy);
00405                                 value22 = value4*(1-sy) + value3*(sy);
00406                                 alpha=(float)((value11*(1-sz) + value22*(sz))/255);
00407 
00408                                 //alpha = ((float)color[aktpos].a/255);
00409 
00410                                 if (alpha>0.0)
00411                                 {
00412                                 value1 = (float)color[aktpos].r*s1x                  + (float)color[aktpos+1].r*sx;
00413                                 value2 = (float)color[aktpos+rowsize].r*s1x          + (float)color[aktpos+rowsize+1].r*sx;
00414                                 value3 = (float)color[aktpos+pagesize+rowsize].r*s1x + (float)color[aktpos+pagesize+rowsize+1].r*sx;
00415                                 value4 = (float)color[aktpos+pagesize].r*s1x         + (float)color[aktpos+pagesize+1].r*sx;
00416                                 value11 = value1*(1-sy) + value2*(sy);
00417                                 value22 = value4*(1-sy) + value3*(sy);
00418                                 valcr=((value11*(1-sz) + value22*(sz)));
00419                                 //valcr = color[aktpos].r;
00420 
00421                                 value1 = (float)color[aktpos].g*s1x                  + (float)color[aktpos+1].g*sx;
00422                                 value2 = (float)color[aktpos+rowsize].g*s1x          + (float)color[aktpos+rowsize+1].g*sx;
00423                                 value3 = (float)color[aktpos+pagesize+rowsize].g*s1x + (float)color[aktpos+pagesize+rowsize+1].g*sx;
00424                                 value4 = (float)color[aktpos+pagesize].g*s1x         + (float)color[aktpos+pagesize+1].g*sx;
00425                                 value11 = value1*(1-sy) + value2*(sy);
00426                                 value22 = value4*(1-sy) + value3*(sy);
00427                                 valcg=((value11*(1-sz) + value22*(sz)));
00428                                 //valcg = color[aktpos].g;
00429 
00430                                 value1 = (float)color[aktpos].b*s1x                  + (float)color[aktpos+1].b*sx;
00431                                 value2 = (float)color[aktpos+rowsize].b*s1x          + (float)color[aktpos+rowsize+1].b*sx;
00432                                 value3 = (float)color[aktpos+pagesize+rowsize].b*s1x + (float)color[aktpos+pagesize+rowsize+1].b*sx;
00433                                 value4 = (float)color[aktpos+pagesize].b*s1x         + (float)color[aktpos+pagesize+1].b*sx;
00434                                 value11 = value1*(1-sy) + value2*(sy);
00435                                 value22 = value4*(1-sy) + value3*(sy);
00436                                 valcb=((value11*(1-sz) + value22*(sz)));
00437                                 //valcb = color[aktpos].b;
00438 
00439                                 value1 = (float)gradient[aktpos].y*s1x                  + (float)gradient[aktpos+1].y*sx;
00440                                 value2 = (float)gradient[aktpos+rowsize].y*s1x          + (float)gradient[aktpos+rowsize+1].y*sx;
00441                                 value3 = (float)gradient[aktpos+pagesize+rowsize].y*s1x + (float)gradient[aktpos+pagesize+rowsize+1].y*sx;
00442                                 value4 = (float)gradient[aktpos+pagesize].y*s1x         + (float)gradient[aktpos+pagesize+1].y*sx;
00443                                 value11 = value1*(1-sy) + value2*(sy);
00444                                 value22 = value4*(1-sy) + value3*(sy);
00445                                 valgy=((value11*(1-sz) + value22*(sz)));
00446 
00447                                 value1 = (float)gradient[aktpos].x*s1x                  + (float)gradient[aktpos+1].x*sx;
00448                                 value2 = (float)gradient[aktpos+rowsize].x*s1x          + (float)gradient[aktpos+rowsize+1].x*sx;
00449                                 value3 = (float)gradient[aktpos+pagesize+rowsize].x*s1x + (float)gradient[aktpos+pagesize+rowsize+1].x*sx;
00450                                 value4 = (float)gradient[aktpos+pagesize].x*s1x         + (float)gradient[aktpos+pagesize+1].x*sx;
00451                                 value11 = value1*(1-sy) + value2*(sy);
00452                                 value22 = value4*(1-sy) + value3*(sy);
00453                                 valgx=((value11*(1-sz) + value22*(sz)));
00454 
00455                                 value1 = (float)gradient[aktpos].z*s1x                  + (float)gradient[aktpos+1].z*sx;
00456                                 value2 = (float)gradient[aktpos+rowsize].z*s1x          + (float)gradient[aktpos+rowsize+1].z*sx;
00457                                 value3 = (float)gradient[aktpos+pagesize+rowsize].z*s1x + (float)gradient[aktpos+pagesize+rowsize+1].z*sx;
00458                                 value4 = (float)gradient[aktpos+pagesize].z*s1x         + (float)gradient[aktpos+pagesize+1].z*sx;
00459                                 value11 = value1*(1-sy) + value2*(sy);
00460                                 value22 = value4*(1-sy) + value3*(sy);
00461                                 valgz=((value11*(1-sz) + value22*(sz)));
00462 
00463                                 valsh = fabs(valgx*lx+valgy*ly+valgz*lz);
00464                                 if (valsh>1) {valsh=1.0;}
00465                                 if (valsh<0) {valsh=0.0;}
00466                                 ac=_fm_acos(valsh);
00467                                 if (ac<0) {ac=0;}
00468                                 if (ac>pih) {ac=pih;}
00469                                 ac = 1-(ac/pih);
00470                                 //ac = fabs(valsh);
00471                                 if (highlights->Checked) {
00472                                 valsh = valsh*valsh;
00473                                 valsh = valsh*valsh;
00474                                 valsh = valsh*valsh;
00475                                 valsh = valsh*valsh;
00476                                 valsh = valsh*valsh;
00477                                 //valsh = valsh*valsh;
00478                                 ac2 = (float)255*valsh;
00479                                 //h = (int)255*ac2;
00480                                 //if (h>255) {col=255;} else {col = h;}
00481                                 fr = fr + (float)((alphasum) * (alpha) * ac * (valcr+ac2));
00482                                 fg = fg + (float)((alphasum) * (alpha) * ac * (valcg+ac2));
00483                                 fb = fb + (float)((alphasum) * (alpha) * ac * (valcb+ac2));
00484                                 }
00485                                 else {
00486                                 fr = fr + (float)((alphasum) * (alpha) * ac * valcr);
00487                                 fg = fg + (float)((alphasum) * (alpha) * ac * valcg);
00488                                 fb = fb + (float)((alphasum) * (alpha) * ac * valcb);
00489                                 }
00490 
00491                                 alphasum = alphasum * (1-alpha);
00492                                 }
00493                                 }
00494                                 else
00495                                 {
00496                                 alpha = (float)color[aktpos].a/255;
00497 
00498                                 if (alpha>0.0)
00499                                 {valsh = fabs(gradient[pagesize*pz + rowsize*py + px].x*lx+gradient[pagesize*pz + rowsize*py + px].y*ly+gradient[pagesize*pz + rowsize*py + px].z*lz);
00500                                 if (valsh>1) {valsh=1.0;}
00501                                 if (valsh<0) {valsh=0.0;}
00502                                 ac=_fm_acos(valsh);
00503                                 if (ac<0) {ac=0;}
00504                                 if (ac>pih) {ac=pih;}
00505                                 ac = 1-(ac/pih);
00506                                 //ac = fabs(valsh);
00507                                 if (highlights->Checked) {
00508                                 valsh = valsh*valsh;
00509                                 valsh = valsh*valsh;
00510                                 valsh = valsh*valsh;
00511                                 valsh = valsh*valsh;
00512                                 valsh = valsh*valsh;
00513                                 valsh = valsh*valsh;
00514                                 ac2 = 255*valsh;
00515                                 //h = (int)255*ac2;
00516                                 //if (h>255) {col=255;} else {col = h;}
00517                                 fr = fr + (float)((alphasum) * (alpha) * ac * (color[aktpos].r+ac2));
00518                                 fg = fg + (float)((alphasum) * (alpha) * ac * (color[aktpos].g+ac2));
00519                                 fb = fb + (float)((alphasum) * (alpha) * ac * (color[aktpos].b+ac2));
00520                                 }
00521                                 else {
00522                                 fr = fr + (float)((alphasum) * (alpha) * ac * color[aktpos].r);
00523                                 fg = fg + (float)((alphasum) * (alpha) * ac * color[aktpos].g);
00524                                 fb = fb + (float)((alphasum) * (alpha) * ac * color[aktpos].b);
00525                                 }
00526 
00527                                 alphasum = alphasum * (1-alpha);
00528                                 }
00529                                 }
00530                         }
00531                         if (alphasum>trlimit)
00532                         {
00533                         //fr = fr + alphasum*20;
00534                         //fg = fg + alphasum*20;
00535                         //fb = fb + alphasum*30;
00536                         }
00537                         if (fr>255) {fr=255;}
00538                         if (fg>255) {fg=255;}
00539                         if (fb>255) {fb=255;}
00540                         transparentview[k].r= (unsigned char)fr;
00541                         transparentview[k].g= (unsigned char)fg;
00542                         transparentview[k].b= (unsigned char)fb;
00543                         }
00544 
00545                 k++;
00546                 }
00547         }
00548         FrameForm->StatusProgress->Visible = false;
00549 }
00550 
00551 //---------------------------------------------------------------------------
00552 void __fastcall TTransparentForm::FormMouseDown(TObject *Sender,
00553       TMouseButton Button, TShiftState Shift, int X, int Y)
00554 {
00555 mdown=true;
00556 ox = X;
00557 oy = Y;
00558 }
00559 //---------------------------------------------------------------------------
00560 
00561 void __fastcall TTransparentForm::FormMouseMove(TObject *Sender,
00562       TShiftState Shift, int X, int Y)
00563 {
00564 if (mdown)
00565 {
00566 mrotx -= (Y-oy);
00567 mroty -= (X-ox);
00568 if (mrotx<0) mrotx += 360;
00569 if (mrotx>360) mrotx -= 360;
00570 if (mroty<0) mroty += 360;
00571 if (mroty>360) mroty -= 360;
00572 
00573 if (arepaint->Checked) {RayCast(); PaintGL(); }
00574 txrot->Text = IntToStr(mrotx);
00575 tzrot->Text = IntToStr(mroty);
00576 ox = X;
00577 oy = Y;
00578 }
00579         
00580 }
00581 //---------------------------------------------------------------------------
00582 
00583 void __fastcall TTransparentForm::FormMouseUp(TObject *Sender,
00584       TMouseButton Button, TShiftState Shift, int X, int Y)
00585 {
00586 mdown=false;
00587 RayCast();
00588 PaintGL();
00589 
00590 }
00591 //---------------------------------------------------------------------------
00592 
00593 void __fastcall TTransparentForm::autoresClick(TObject *Sender)
00594 {
00595 if (autores->Checked==true)
00596         {
00597         ResTrackBar->Enabled=false;
00598         textx->Enabled=false;
00599         Label2->Enabled=false;
00600         texty->Enabled=false;
00601         }
00602         else
00603         {
00604         ResTrackBar->Enabled=true;
00605         textx->Enabled=true;
00606         Label2->Enabled=true;
00607         texty->Enabled=true;
00608         }
00609 if (arepaint->Checked) {RayCast();PaintGL();}
00610         
00611 }
00612 //---------------------------------------------------------------------------
00613 
00614 void __fastcall TTransparentForm::trilinearClick(TObject *Sender)
00615 {
00616 if (arepaint->Checked) {RayCast();PaintGL();}        
00617 }
00618 //---------------------------------------------------------------------------
00619 
00620 void __fastcall TTransparentForm::ResTrackBarChange(TObject *Sender)
00621 {
00622 switch (ResTrackBar->Position)
00623         {
00624         case 1: textx->Caption = "32"; texty->Caption = "32"; break;
00625         case 2: textx->Caption = "64"; texty->Caption = "64"; break;
00626         case 3: textx->Caption = "128"; texty->Caption = "128"; break;
00627         case 4: textx->Caption = "256"; texty->Caption = "256"; break;
00628         case 5: textx->Caption = "512"; texty->Caption = "512"; break;
00629         case 6: textx->Caption = "1024"; texty->Caption = "1024";
00630         }
00631 if (arepaint->Checked) {RayCast();PaintGL();}
00632 
00633 }
00634 //---------------------------------------------------------------------------
00635 

Generated on Thu Jan 23 06:17:38 2003 for Vol by doxygen1.2.18