- Timestamp:
- Mar 27, 2006 8:47:17 PM (18 years ago)
- Location:
- trunk/gui/vizservers/nanovis
- Files:
-
- 17 added
- 2 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/vizservers/nanovis/Color.cpp
r371 r379 13 13 * ====================================================================== 14 14 */ 15 15 16 #include <stdio.h> 17 #include <assert.h> 18 16 19 #include "Color.h" 17 20 18 Color::Color(float _r, float _g, float _b, float _a): 19 r(_r), 20 g(_g), 21 b(_b), 22 a(_a){} 21 Color::Color(){ 22 R=G=B=0.0; 23 next=0; 24 } 25 26 Color::Color(double r, double g, double b){ 27 R=r; 28 G=g; 29 B=b; 30 next=0; 31 } 32 33 void Color::LimitColors(){ //Limits the color to be in range of 0.0 and 1.0 34 if (R>1.0) R=1.0; 35 if (G>1.0) G=1.0; 36 if (B>1.0) B=1.0; 37 38 if (R<0.0) R=0.0; 39 if (G<0.0) G=0.0; 40 if (B<0.0) B=0.0; 41 } 42 43 Color Color::operator*(double k){ 44 return Color(R*k, G*k, B*k); 45 } 46 47 48 //This is NOT member operator. It's used so we can write (k*V), not only (V*k) (V-vector k-scalar) 49 Color operator*(double k, Color &other){ 50 return Color(other.R*k, other.G*k, other.B*k); 51 } 52 53 Color::~Color(){} 54 55 Color Color::operator +(Color &other){ 56 return Color(this->R+other.R,this->G+other.G,this->B+other.B); 57 } 58 59 Color Color::operator *(Color &other){ 60 return Color(this->R*other.R,this->G*other.G,this->B*other.B); 61 } 62 63 void Color::GetRGBA(double opacity, unsigned char *result){ 64 LimitColors(); 65 66 assert(opacity>=0 && opacity <=1); 67 68 result[0] = (unsigned char) (R*255.0); 69 result[1] = (unsigned char) (G*255.0); 70 result[2] = (unsigned char) (B*255.0); 71 result[3] = (unsigned char) (opacity*255.0); 72 } 73 74 void Color::SetRGBA(unsigned char *color){ 75 R = color[0]; 76 G = color[1]; 77 B = color[2]; 78 } 79 80 void Color::GetRGB(unsigned char *result){ 81 result[0] = (unsigned char) (R*255.0); 82 result[1] = (unsigned char) (G*255.0); 83 result[2] = (unsigned char) (B*255.0); 84 } 85 86 void Color::GetRGB(float *result){ 87 result[0] = (float) (R); 88 result[1] = (float) (G); 89 result[2] = (float) (B); 90 } 91 -
trunk/gui/vizservers/nanovis/Color.h
r373 r379 13 13 * ====================================================================== 14 14 */ 15 15 16 #ifndef _COLOR_H_ 16 17 #define _COLOR_H_ … … 19 20 { 20 21 public: 22 double R; // Red component 23 double G; // Green component 24 double B; // Blue component 21 25 26 void GetRGB(unsigned char *result); 27 void GetRGB(float *result); 28 29 void SetRGBA(unsigned char *color); 30 void GetRGBA(double opacity, unsigned char *result); 31 Color operator *(Color &other); 32 Color* next; //pointer to the next color 33 34 Color(); 35 Color(double r, double g, double b); 36 37 void LimitColors(); //Limits the color to be in range of 0.0 and 1.0 38 Color operator*(double k); 39 friend Color operator*(double k, Color &other); 40 Color operator+(Color &other); 41 ~Color(); 22 42 float r, g, b, a; 23 24 Color(){};25 Color(float _r, float _g, float _b, float _a);26 ~Color(){};27 43 }; 28 44 -
trunk/gui/vizservers/nanovis/Makefile
r377 r379 1 1 OBJ_NANOVIS = nanovis.o Socket.o RenderVertexArray.o Plane.o ConvexPolygon.o Vector4.o Vector3.o Mat4x4.o \ 2 Texture1D.o Texture3D.o ColorMap.o Volume.o Texture2D.o ParticleSystem.o Sphere.o Color.o \ 3 PerfQuery.o 2 Texture1D.o Texture3D.o Volume.o Texture2D.o ParticleSystem.o Sphere.o Color.o \ 3 PerfQuery.o TransferFunction.o ControlPoint.o ColorGradient.o ColorPaletteWindow.o\ 4 ColorGradientGLUTWindow.o TransferFunctionGLUTWindow.o MainWindow.o 4 5 5 6 AUXSRC = config.h define.h global.h … … 7 8 SOCKETSRC = ./socket 8 9 SORTSRC = ./sort 10 TFSRC = ./transfer-function 9 11 10 LIB_NANOVIS = -ltcl8.4 -lGL -lglut -l GLEW -lCg -lCgGL -pthread -lstdc++12 LIB_NANOVIS = -ltcl8.4 -lGL -lglut -lglui -lGLEW -lCg -lCgGL -pthread -lstdc++ 11 13 LIB_CLIENT = -lGL -lglut -pthread 12 14 CFLAG = -g -c -Wall -I../src2/core … … 20 22 gcc -g -o nanovis $(OBJ_NANOVIS) $(LIB_NANOVIS) ../src2/core/*.o 21 23 24 ColorGradient.o: Color.o $(TFSRC)/ColorGradient.cpp 25 gcc $(CFLAG) $(TFSRC)/ColorGradient.cpp 26 27 ColorPaletteWindow.o: Color.o ControlPoint.o $(TFSRC)/ColorPaletteWindow.cpp 28 gcc $(CFLAG) $(TFSRC)/ColorPaletteWindow.cpp 29 30 ColorGradientGLUTWindow.o: ControlPoint.o ColorGradient.o $(TFSRC)/ColorGradientGLUTWindow.cpp 31 gcc $(CFLAG) $(TFSRC)/ColorGradientGLUTWindow.cpp 32 33 TransferFunctionGLUTWindow.o: ColorGradientGLUTWindow.o $(TFSRC)/TransferFunctionGLUTWindow.cpp 34 gcc $(CFLAG) $(TFSRC)/TransferFunctionGLUTWindow.cpp 35 36 MainWindow.o: TransferFunctionGLUTWindow.o ColorGradientGLUTWindow.o ColorPaletteWindow.o $(TFSRC)/MainWindow.cpp 37 gcc $(CFLAG) $(TFSRC)/MainWindow.cpp 38 22 39 Socket.o: $(SOCKETSRC)/Socket.h $(SOCKETSRC)/Socket.cpp 23 40 gcc $(CFLAG) $(SOCKETSRC)/Socket.cpp … … 32 49 gcc $(CFLAG) Color.cpp 33 50 51 ControlPoint.o: $(TFSRC)/ControlPoint.cpp 52 gcc $(CFLAG) $(TFSRC)/ControlPoint.cpp 53 34 54 Sphere.o: Vector3.o Color.o 35 55 gcc $(CFLAG) Sphere.cpp 36 56 37 ColorMap.o: ColorMap.cpp38 gcc $(CFLAG) ColorMap.cpp57 TransferFunction.o: TransferFunction.cpp 58 gcc $(CFLAG) TransferFunction.cpp 39 59 40 60 Texture1D.o: Texture1D.cpp -
trunk/gui/vizservers/nanovis/ParticleSystem.cpp
r378 r379 33 33 reborn = true; 34 34 flip = true; 35 max_life = 100;35 max_life = 500; 36 36 37 37 data = (Particle*) malloc(w*h*sizeof(Particle)); … … 206 206 207 207 //glPointSize(0.5); 208 glPointSize(1. 5);209 glColor4f(. 1,.0,.3,1.);208 glPointSize(1.0); 209 glColor4f(.6,.6,.0,1.); 210 210 211 211 m_vertex_array->SetPointer(0); -
trunk/gui/vizservers/nanovis/Sphere.cpp
r373 r379 18 18 19 19 Sphere::Sphere(float x, float y, float z, 20 float r, float g, float b, float a,20 float r, float g, float b, 21 21 float _radius, 22 22 int _stack, … … 26 26 slice(_slice), 27 27 center(Vector3(x,y,z)), 28 color(Color(r,g,b ,a))28 color(Color(r,g,b)) 29 29 { } 30 30 31 31 32 32 void Sphere::draw(GLUquadric* quad){ 33 glColor 4f(color.r, color.g, color.b, color.a);33 glColor3f(color.R, color.G, color.B); 34 34 35 35 glMatrixMode(GL_MODELVIEW); -
trunk/gui/vizservers/nanovis/Sphere.h
r373 r379 31 31 Sphere(){}; 32 32 ~Sphere(){}; 33 Sphere(float x, float y, float z, float r, float g, float b, float a, float r, int _stack, int _slice);33 Sphere(float x, float y, float z, float r, float g, float b, float _radius, int _stack, int _slice); 34 34 void set_vertical_res(int _stack); 35 35 void set_horizontal_res(int _slice); -
trunk/gui/vizservers/nanovis/nanovis.cpp
r378 r379 13 13 * ====================================================================== 14 14 */ 15 15 16 #include <stdio.h> 16 17 #include <math.h> … … 23 24 #include "RpFieldPrism3D.h" 24 25 26 #include "transfer-function/TransferFunctionMain.h" 27 #include "transfer-function/ControlPoint.h" 28 #include "transfer-function/TransferFunctionGLUTWindow.h" 29 #include "transfer-function/ColorGradientGLUTWindow.h" 30 #include "transfer-function/ColorPaletteWindow.h" 31 #include "transfer-function/MainWindow.h" 32 33 float color_table[256][4]; 34 25 35 // forward declarations 26 36 void init_particles(); … … 41 51 int n_volumes = 0; 42 52 Volume* volume[MAX_N_VOLUMES]; //point to volumes, currently handle up to 10 volumes 43 ColorMap* colormap[MAX_N_VOLUMES]; //transfer functions, currently handle up to 10 colormaps53 TransferFunction* tf[MAX_N_VOLUMES]; //transfer functions, currently handle up to 10 colormaps 44 54 45 55 PerfQuery* perf; //perfromance counter … … 507 517 508 518 //load a colormap 1D texture 509 void load_ colormap(int index, int size, float* data){510 511 if( colormap[index]!=0){512 delete colormap[index];513 colormap[index]=0;519 void load_transfer_function(int index, int size, float* data){ 520 521 if(tf[index]!=0){ 522 delete tf[index]; 523 tf[index]=0; 514 524 } 515 525 516 colormap[index] = new ColorMap(size, data);526 tf[index] = new TransferFunction(size, data); 517 527 } 518 528 … … 702 712 int index = i + psys->psys_height*j; 703 713 bool particle = rand() % 256 > 100; 704 particle = true;714 //particle = true; 705 715 if(particle) 706 716 { 707 717 //assign any location (x,y,z) in range [0,1] 708 data[4*index] = 0.5;718 data[4*index] = lic_slice_x; 709 719 data[4*index+1]= j/float(psys->psys_height); 710 data[4*index+2]= lic_slice_z; //lic_slice_z; //i/float(psys->psys_width);720 data[4*index+2]= i/float(psys->psys_width); 711 721 data[4*index+3]= 30; //shorter life span, quicker iterations 712 722 } … … 766 776 for(int i=0; i<MAX_N_VOLUMES; i++){ 767 777 volume[i] = 0; 768 colormap[i] = 0;778 tf[i] = 0; 769 779 } 770 780 … … 775 785 } 776 786 777 init_vector_field(); //3d vector field787 //init_vector_field(); //3d vector field 778 788 //load_volume_file(0, "./data/A-apbs-2-out-potential-PE0.dx"); 779 789 //load_volume_file(0, "./data/nw-AB-Vg=0.000-Vd=1.000-potential.dx"); … … 1712 1722 volume[0]->aspect_ratio_depth); 1713 1723 1724 /* 1714 1725 1715 1726 //draw line integral convolution quad … … 1720 1731 glTexCoord2f(0, 1); glVertex3f(0, 1, lic_slice_z); 1721 1732 glEnd(); 1722 1733 */ 1734 1735 1723 1736 glPopMatrix(); 1724 1737 … … 1732 1745 volume[0]->aspect_ratio_depth); 1733 1746 1734 psys->display_vertices(); 1747 perf->enable(); 1748 psys->display_vertices(); 1749 perf->disable(); 1750 fprintf(stderr, "particle pixels: %d\n", perf->get_pixel_count()); 1751 perf->reset(); 1735 1752 1736 1753 glPopMatrix(); 1737 1754 1738 //render volume :01739 //volume[0]->location =Vector3(0.,0.,0.);1740 //render_volume(0, 256);1741 1742 //render volume :11743 volume[1]->location =Vector3(0., 0., 0.);1744 render_volume(1, 256);1745 1746 1755 perf->enable(); 1756 //render volume :0 1757 //volume[0]->location =Vector3(0.,0.,0.); 1758 //render_volume(0, 256); 1759 1760 //render volume :1 1761 volume[1]->location =Vector3(0., 0., 0.); 1762 render_volume(1, 256); 1747 1763 perf->disable(); 1748 fprintf(stderr, " pixels: %d\n", perf->get_pixel_count());1764 fprintf(stderr, "volume pixels: %d\n", perf->get_pixel_count()); 1749 1765 perf->reset(); 1750 1766 1751 1767 draw_axis(); 1752 1753 glDisable(GL_DEPTH_TEST);1754 1768 #endif 1755 1769 … … 1829 1843 lic_slice_z-=0.05; 1830 1844 get_slice_vectors(); 1845 break; 1846 case ',': 1847 lic_slice_x+=0.05; 1848 init_particles(); 1849 break; 1850 case '.': 1851 lic_slice_x-=0.05; 1852 init_particles(); 1831 1853 break; 1832 1854 case '1': … … 1899 1921 1900 1922 1901 1902 1923 /*----------------------------------------------------*/ 1903 1924 int main(int argc, char** argv) 1904 1925 { 1926 1905 1927 glutInit(&argc, argv); 1906 1928 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); 1929 1930 MainTransferFunctionWindow * mainWin; 1931 mainWin = new MainTransferFunctionWindow(); 1932 mainWin->mainInit(); 1933 1907 1934 glutInitWindowSize(NPIX, NPIX); 1935 glutInitWindowPosition(10, 10); 1908 1936 glutCreateWindow(argv[0]); 1937 1909 1938 glutDisplayFunc(display); 1910 1939 glutMouseFunc(mouse); … … 1912 1941 glutKeyboardFunc(keyboard); 1913 1942 glutIdleFunc(idle); 1943 1914 1944 initGL(); 1915 1945 initTcl(); -
trunk/gui/vizservers/nanovis/nanovis.h
r378 r379 13 13 * ====================================================================== 14 14 */ 15 16 15 17 16 #include <GL/glew.h> … … 35 34 #include "Texture2D.h" 36 35 #include "Texture1D.h" 37 #include " ColorMap.h"36 #include "TransferFunction.h" 38 37 #include "ConvexPolygon.h" 39 38 #include "Mat4x4.h" … … 112 111 //currently active shader, default renders one volume only 113 112 int cur_shader = 0; 113
Note: See TracChangeset
for help on using the changeset viewer.