Changeset 1963 for GTP/trunk/Lib/Vis
- Timestamp:
- 01/10/07 13:28:42 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp
r1962 r1963 6 6 #include "GlRenderer.h" 7 7 #include "Exporter.h" 8 #include "ViewCellsManager.h" 9 8 10 9 11 // the devil library … … 392 394 393 395 const float sceneSize = Magnitude(bbox.Diagonal()); 394 mViewPoint = midPoint + Vector3(0.5 * sceneSize, 0, 0 );396 mViewPoint = midPoint + Vector3(0.5 * sceneSize, 0, 0.5 * sceneSize); 395 397 396 398 cout << "mid point: " << midPoint << endl; … … 399 401 400 402 mNear = 1; 401 mFar = sceneSize ;403 mFar = sceneSize * 2; 402 404 mWidth = sceneSize; 403 405 … … 580 582 581 583 void GlobalLinesRenderer::ProcessDepthBuffer(VssRayContainer &vssRays, 582 const bool oldBufferInitialised) 584 const bool oldBufferInitialised, 585 const int pass) 583 586 { 584 587 GrabDepthBuffer(mNewDepthBuffer, mNewTexture); … … 603 606 } 604 607 605 cout << "vp: " << "eye: " << mEyeVec << " left: " << mLeftVec << " up: " << mUpVec << endl;608 //cout << "vp: " << "eye: " << mEyeVec << " left: " << mLeftVec << " up: " << mUpVec << endl; 606 609 607 610 for (int y = 0; y < texHeight; ++ y) … … 625 628 false); 626 629 630 if (!termObj1 && !termObj2) // we do not create a ray 631 continue; 632 633 Vector3 clippedOldPt, clippedNewPt; 634 635 ClipToViewSpaceBox(oldPt, newPt, clippedOldPt, clippedNewPt); 636 //clippedOldPt = oldPt; 637 //clippedNewPt = newPt; 638 627 639 // create rays in both directions 628 640 if (termObj1) 629 641 { 630 vssRays.push_back(new VssRay( oldPt, newPt, NULL, termObj1));642 vssRays.push_back(new VssRay(clippedOldPt, clippedNewPt, NULL, termObj1, pass)); 631 643 //cout << "new pt: " << newPt << endl; 632 644 } … … 634 646 if (termObj2) 635 647 { 636 vssRays.push_back(new VssRay( newPt, oldPt, NULL, termObj2));648 vssRays.push_back(new VssRay(clippedNewPt, clippedOldPt, NULL, termObj2, pass)); 637 649 //cout << "old pt: " << oldPt << endl; 638 650 } … … 642 654 643 655 656 bool GlobalLinesRenderer::ClipToViewSpaceBox(const Vector3 &origin, 657 const Vector3 &termination, 658 Vector3 &clippedOrigin, 659 Vector3 &clippedTermination) 660 { 661 Ray ray(origin, termination - origin, Ray::LINE_SEGMENT); 662 ray.Precompute(); 663 664 float tmin, tmax; 665 666 //const AxisAlignedBox3 bbox = mPreprocessor->mViewCellsManager->GetViewSpaceBox(); 667 // hack 668 const AxisAlignedBox3 bbox = mPreprocessor->mKdTree->GetBox(); 669 670 if ((!bbox.ComputeMinMaxT(ray, &tmin, &tmax)) || 671 tmin>=tmax) 672 { 673 return false; 674 } 675 676 if (tmin >= 1.0f || tmax <=0.0f) 677 return false; 678 679 if (tmin > 0.0f) 680 clippedOrigin = ray.Extrap(tmin); 681 else 682 clippedOrigin = origin; 683 684 if (tmax < 1.0f) 685 clippedTermination = ray.Extrap(tmax); 686 else 687 clippedTermination = termination; 688 689 return true; 690 } 691 692 644 693 void GlobalLinesRenderer::Run() 645 694 { 646 695 glutMainLoop(); 647 }648 649 650 void SetupFalseColor(const unsigned int id,651 unsigned char &r,652 unsigned char &g,653 unsigned char &b654 )655 {656 // swap bits of the color657 r = id & 255;658 g = (id >> 8) & 255;659 b = (id >> 16) & 255;660 696 } 661 697 … … 673 709 674 710 VssRayContainer::const_iterator vit, vit_end = vssRays.end(); 711 VssRayContainer outRays; 712 713 Intersectable::NewMail(); 675 714 676 715 for (vit = vssRays.begin(); vit != vit_end; ++ vit) 677 716 { 678 717 VssRay *ray = *vit; 679 Intersectable *obj = (*vit)->mTerminationObject; 680 exporter->ExportIntersectable(obj); 718 Intersectable *obj = (*vit)->mTerminationObject; 719 720 if (!obj->Mailed()) 721 { 722 obj->Mail(); 723 exporter->ExportIntersectable(obj); 724 } 725 726 if (ray->mPass == 4) 727 outRays.push_back(ray); 681 728 } 682 729 683 exporter->ExportRays( vssRays);730 exporter->ExportRays(outRays); 684 731 685 732 delete exporter; … … 691 738 rt->BindDepth(); 692 739 rt->EnableTextureTarget(); 693 cout << "depth: " << mNewTexture->GetDepthBits() << endl;740 //cout << "depth: " << mNewTexture->GetDepthBits() << endl; 694 741 695 742 const int texFormat = GL_DEPTH_COMPONENT; … … 727 774 glGetTexImage(mNewTexture->GetTextureTarget(), 0, texFormat, GL_FLOAT, data); 728 775 729 /*for (int i = texWidth * 123; i < texWidth * 124; ++ i)730 {731 cout << data[i] << " ";732 }733 cout << "Saving image " << texWidth << " " << texHeight << endl;734 */735 776 string filename("depth.tga"); 736 777 ilRegisterType(IL_FLOAT); … … 749 790 } 750 791 751 /* 792 752 793 void GlobalLinesRenderer::ExportItemBuffer() 753 794 { … … 758 799 const int components = 4;//mNewTexture->GetDepthBits() / 8; 759 800 760 float *data = new float[texWidth * texHeight * components*8]; 801 unsigned char *data = new unsigned char [texWidth * texHeight * components]; 802 //const int texFormat = WGL_TEXTURE_DEPTH_COMPONENT_NV; 761 803 const int texFormat = GL_RGBA; 762 glGetTexImage(mNewTexture->GetTextureTarget(), 0, texFormat, GL_ FLOAT, data);763 764 string filename("items. tga");765 ilRegisterType(IL_ FLOAT);804 glGetTexImage(mNewTexture->GetTextureTarget(), 0, texFormat, GL_UNSIGNED_BYTE, data); 805 806 string filename("items.jpg"); 807 ilRegisterType(IL_UNSIGNED_BYTE); 766 808 767 809 const int depth = 1; 768 810 const int bpp = components; 769 811 770 cout << "saving items to file " << endl; 771 772 ilTexImage(16, 16, depth, bpp, IL_RGBA, IL_FLOAT, data); 812 ilTexImage(texWidth, texHeight, depth, bpp, IL_RGBA, IL_UNSIGNED_BYTE, data); 773 813 ilSaveImage((char *const)filename.c_str()); 774 814 … … 779 819 PrintGLerror("grab texture"); 780 820 } 781 */782 void GlobalLinesRenderer::ExportItemBuffer()783 {784 mNewTexture->Bind();785 mNewTexture->EnableTextureTarget();786 cout << "depth: " << mNewTexture->GetDepthBits() << endl;787 788 const int components = 4;//mNewTexture->GetDepthBits() / 8;789 790 unsigned char *data = new unsigned char [texWidth * texHeight * components];791 //const int texFormat = WGL_TEXTURE_DEPTH_COMPONENT_NV;792 const int texFormat = GL_RGBA;793 glGetTexImage(mNewTexture->GetTextureTarget(), 0, texFormat, GL_UNSIGNED_BYTE, data);794 795 string filename("items.jpg");796 ilRegisterType(IL_UNSIGNED_BYTE);797 798 const int depth = 1;799 const int bpp = components;800 801 ilTexImage(texWidth, texHeight, depth, bpp, IL_RGBA, IL_UNSIGNED_BYTE, data);802 ilSaveImage((char *const)filename.c_str());803 804 cout << "finished" << endl;805 delete data;806 cout << "data deleted" << endl;807 mNewTexture->DisableTextureTarget();808 PrintGLerror("grab texture");809 }810 821 811 822 … … 826 837 827 838 // process the buffers for the first layer 828 ProcessDepthBuffer(rays, false );829 830 for(int i = 0; i < mMaxDepth; ++ i)839 ProcessDepthBuffer(rays, false, 0); 840 841 for(int i = 1; i < mMaxDepth; ++ i) 831 842 { 832 843 // Peel another layer … … 836 847 mNewTexture->BeginCapture(); 837 848 { 838 //if (mNewTexture->IsDoubleBuffered())839 // glDrawBuffer(GL_BACK);840 841 849 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 842 850 … … 846 854 cgGLEnableTextureParameter(sTextureParam); 847 855 848 //glutSolidTorus(0.25, 1, 32, 64);849 856 DrawGeometry(); 850 857 851 glPopMatrix();852 853 858 cgGLDisableTextureParameter(sTextureParam); 854 859 cgGLDisableProfile(sCgFragmentProfile); … … 856 861 mNewTexture->EndCapture(); 857 862 858 CLEAR_CONTAINER(rays);859 863 // process the buffers for following layer 860 ProcessDepthBuffer(rays, true );864 ProcessDepthBuffer(rays, true, i); 861 865 } 862 866 -
GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.h
r1960 r1963 54 54 void ExportDepthBuffer(); 55 55 void ExportItemBuffer(); 56 void ProcessDepthBuffer(VssRayContainer &vssRays, const bool oldBufferInitialised );56 void ProcessDepthBuffer(VssRayContainer &vssRays, const bool oldBufferInitialised, const int pass); 57 57 void DisplayBuffer(const bool isDepth); 58 58 59 bool ClipToViewSpaceBox(const Vector3 &origin, 60 const Vector3 &termination, 61 Vector3 &clippedOrigin, 62 Vector3 &clippedTermination); 63 59 64 Intersectable *ExtractSamplePoint(float *depthBuffer, 60 65 unsigned char *itemBuffer,
Note: See TracChangeset
for help on using the changeset viewer.