Changeset 2877 for trunk/packages/vizservers
- Timestamp:
- Mar 23, 2012, 1:31:05 AM (13 years ago)
- Location:
- trunk/packages/vizservers/nanovis
- Files:
-
- 54 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/CircularQueue.h
r2798 r2877 103 103 * It is up to the caller to handle this case 104 104 * 105 * \param item_ return by reference the wanted item106 105 * \return whether operation was successful or not */ 107 106 template<typename Element, unsigned int Size> -
trunk/packages/vizservers/nanovis/Command.cpp
r2854 r2877 259 259 hmPtr = new HeightMap(); 260 260 hmPtr->setHeight(xMin, yMin, xMax, yMax, xNum, yNum, heights); 261 hmPtr->transferFunction(NanoVis::get _transfunc("default"));261 hmPtr->transferFunction(NanoVis::getTransfunc("default")); 262 262 hmPtr->setVisible(true); 263 263 hmPtr->setLineContourVisible(true); … … 607 607 } 608 608 609 610 609 static int 611 610 CameraPanOp(ClientData clientData, Tcl_Interp *interp, int objc, … … 675 674 int w, h; 676 675 677 w = NanoVis::win _width, h = NanoVis::win_height;678 NanoVis::resize _offscreen_buffer(2048, 2048);676 w = NanoVis::winWidth, h = NanoVis::winHeight; 677 NanoVis::resizeOffscreenBuffer(2048, 2048); 679 678 #ifdef notdef 680 NanoVis::cam->set_screen_size(0, 0, NanoVis::win _width,NanoVis::win_height);679 NanoVis::cam->set_screen_size(0, 0, NanoVis::winWidth, NanoVis::winHeight); 681 680 NanoVis::cam->set_screen_size(30, 90, 2048 - 60, 2048 - 120); 682 681 #endif 683 NanoVis::offscreen _buffer_capture(); //enable offscreen render682 NanoVis::offscreenBufferCapture(); //enable offscreen render 684 683 NanoVis::display(); 685 NanoVis::read _screen();684 NanoVis::readScreen(); 686 685 #ifdef notdef 687 686 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 688 687 #endif 689 NanoVis::ppm _write("nv>image -bytes %d -type print");690 NanoVis::resize _offscreen_buffer(w, h);688 NanoVis::ppmWrite("nv>image -bytes %d -type print"); 689 NanoVis::resizeOffscreenBuffer(w, h); 691 690 return TCL_OK; 692 691 } … … 719 718 std::vector<Volume *>::iterator iter; 720 719 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 721 (*iter)->move _cutplane(axis, relval);720 (*iter)->moveCutplane(axis, relval); 722 721 } 723 722 return TCL_OK; … … 748 747 std::vector<Volume *>::iterator iter; 749 748 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 750 (*iter)->enable _cutplane(axis);749 (*iter)->enableCutplane(axis); 751 750 } 752 751 } else { 753 752 std::vector<Volume *>::iterator iter; 754 753 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 755 (*iter)->disable _cutplane(axis);754 (*iter)->disableCutplane(axis); 756 755 } 757 756 } … … 818 817 name = Tcl_GetString(objv[1]); 819 818 TransferFunction *tf; 820 tf = NanoVis::get _transfunc(name);819 tf = NanoVis::getTransfunc(name); 821 820 if (tf == NULL) { 822 821 Tcl_AppendResult(interp, "unknown transfer function \"", name, "\"", … … 829 828 return TCL_ERROR; 830 829 } 831 if (Volume::update _pending) {832 NanoVis:: SetVolumeRanges();833 } 834 NanoVis::render _legend(tf, Volume::valueMin, Volume::valueMax, w, h, name);830 if (Volume::updatePending) { 831 NanoVis::setVolumeRanges(); 832 } 833 NanoVis::renderLegend(tf, Volume::valueMin, Volume::valueMax, w, h, name); 835 834 return TCL_OK; 836 835 } … … 860 859 return TCL_ERROR; 861 860 } 862 NanoVis::resize _offscreen_buffer(w, h);861 NanoVis::resizeOffscreenBuffer(w, h); 863 862 return TCL_OK; 864 863 } … … 964 963 } 965 964 // find or create this transfer function 966 NanoVis:: DefineTransferFunction(Tcl_GetString(objv[2]), nslots, data);965 NanoVis::defineTransferFunction(Tcl_GetString(objv[2]), nslots, data); 967 966 } else { 968 967 Tcl_AppendResult(interp, "bad option \"", string, … … 1010 1009 } 1011 1010 VolumeInterpolator* interpolator; 1012 interpolator = NanoVis::vol _renderer->getVolumeInterpolator();1011 interpolator = NanoVis::volRenderer->getVolumeInterpolator(); 1013 1012 interpolator->start(); 1014 if (interpolator->is _started()) {1013 if (interpolator->isStarted()) { 1015 1014 const char *fileName = (objc < 5) ? NULL : Tcl_GetString(objv[4]); 1016 1015 for (int frame_num = 0; frame_num < total; ++frame_num) { … … 1022 1021 interpolator->update(fraction); 1023 1022 1024 NanoVis::offscreen _buffer_capture(); //enable offscreen render1023 NanoVis::offscreenBufferCapture(); //enable offscreen render 1025 1024 1026 1025 NanoVis::display(); 1027 NanoVis::read _screen();1026 NanoVis::readScreen(); 1028 1027 1029 1028 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1030 1029 1031 NanoVis::bmp _write_to_file(frame_num, fileName);1030 NanoVis::bmpWriteToFile(frame_num, fileName); 1032 1031 } 1033 1032 } … … 1039 1038 Tcl_Obj *const *objv) 1040 1039 { 1041 NanoVis::vol _renderer->clearAnimatedVolumeInfo();1040 NanoVis::volRenderer->clearAnimatedVolumeInfo(); 1042 1041 return TCL_OK; 1043 1042 } … … 1047 1046 Tcl_Obj *const *objv) 1048 1047 { 1049 NanoVis::vol _renderer->startVolumeAnimation();1048 NanoVis::volRenderer->startVolumeAnimation(); 1050 1049 return TCL_OK; 1051 1050 } … … 1055 1054 Tcl_Obj *const *objv) 1056 1055 { 1057 NanoVis::vol _renderer->stopVolumeAnimation();1056 NanoVis::volRenderer->stopVolumeAnimation(); 1058 1057 return TCL_OK; 1059 1058 } … … 1074 1073 Volume *volPtr; 1075 1074 volPtr = (Volume *)Tcl_GetHashValue(hPtr); 1076 NanoVis::vol _renderer->addAnimatedVolume(volPtr);1075 NanoVis::volRenderer->addAnimatedVolume(volPtr); 1077 1076 } 1078 1077 return TCL_OK; … … 1190 1189 // 1191 1190 if (volPtr != NULL) { 1192 //volPtr->n _slices(512-n);1193 //volPtr->n _slices(256-n);1194 volPtr->disable _cutplane(0);1195 volPtr->disable _cutplane(1);1196 volPtr->disable _cutplane(2);1197 volPtr->transferFunction(NanoVis::get _transfunc("default"));1191 //volPtr->numSlices(512-n); 1192 //volPtr->numSlices(256-n); 1193 volPtr->disableCutplane(0); 1194 volPtr->disableCutplane(1); 1195 volPtr->disableCutplane(2); 1196 volPtr->transferFunction(NanoVis::getTransfunc("default")); 1198 1197 volPtr->visible(true); 1199 1198 … … 1201 1200 ssize_t nWritten; 1202 1201 1203 if (Volume::update _pending) {1204 NanoVis:: SetVolumeRanges();1202 if (Volume::updatePending) { 1203 NanoVis::setVolumeRanges(); 1205 1204 } 1206 1205 … … 1229 1228 std::vector<Volume *>::iterator iter; 1230 1229 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 1231 (*iter)->data _enabled(state);1230 (*iter)->dataEnabled(state); 1232 1231 } 1233 1232 return TCL_OK; … … 1274 1273 return TCL_ERROR; 1275 1274 } 1276 NanoVis::remove _volume(volPtr);1277 } 1278 NanoVis:: EventuallyRedraw();1275 NanoVis::removeVolume(volPtr); 1276 } 1277 NanoVis::eventuallyRedraw(); 1279 1278 return TCL_OK; 1280 1279 } … … 1345 1344 std::vector<Volume *>::iterator iter; 1346 1345 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 1347 (*iter)->set _outline_color(rgb);1346 (*iter)->setOutlineColor(rgb); 1348 1347 } 1349 1348 return TCL_OK; … … 1399 1398 return TCL_ERROR; 1400 1399 } 1401 1400 if (diffuse < 0.0f || diffuse > 1.0f) { 1401 WARN("Invalid diffuse coefficient requested: %g, should be [0,1]", diffuse); 1402 } 1402 1403 std::vector<Volume *> ivol; 1403 1404 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) { … … 1446 1447 std::vector<Volume *>::iterator iter; 1447 1448 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 1448 (*iter)->opacity _scale(opacity);1449 (*iter)->opacityScale(opacity); 1449 1450 } 1450 1451 return TCL_OK; … … 1458 1459 if (GetFloatFromObj(interp, objv[3], &specular) != TCL_OK) { 1459 1460 return TCL_ERROR; 1461 } 1462 if (specular < 0.0f || specular > 128.0f) { 1463 WARN("Invalid specular exponent requested: %g, should be [0,128]", specular); 1460 1464 } 1461 1465 std::vector<Volume *> ivol; … … 1476 1480 TransferFunction *tfPtr; 1477 1481 const char *name = Tcl_GetString(objv[3]); 1478 tfPtr = NanoVis::get _transfunc(name);1482 tfPtr = NanoVis::getTransfunc(name); 1479 1483 if (tfPtr == NULL) { 1480 1484 Tcl_AppendResult(interp, "transfer function \"", name, … … 1493 1497 #ifdef USE_POINTSET_RENDERER 1494 1498 // TBD.. 1495 //if ((*iter)->pointsetIndex != -1) {1496 // NanoVis::pointSet[(*iter)->pointsetIndex]->updateColor(tf->getData(), 256);1497 //}1499 if ((*iter)->pointsetIndex != -1) { 1500 NanoVis::pointSet[(*iter)->pointsetIndex]->updateColor(tfPtr->getData(), 256); 1501 } 1498 1502 #endif 1499 1503 } … … 1544 1548 label = Tcl_GetString(objv[4]); 1545 1549 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 1546 (*iter)->set _label(axis, label);1550 (*iter)->setLabel(axis, label); 1547 1551 } 1548 1552 } else { … … 1584 1588 Volume *volPtr; 1585 1589 volPtr = (Volume *)Tcl_GetHashValue(hPtr); 1586 volPtr->data _enabled(false);1590 volPtr->dataEnabled(false); 1587 1591 volPtr->visible(false); 1588 1592 } … … 1680 1684 hmPtr->setHeight(data.xMin(), data.yMin(), data.xMax(), data.yMax(), 1681 1685 data.xNum(), data.yNum(), data.transferValues()); 1682 hmPtr->transferFunction(NanoVis::get _transfunc("default"));1686 hmPtr->transferFunction(NanoVis::getTransfunc("default")); 1683 1687 hmPtr->setVisible(true); 1684 1688 hmPtr->setLineContourVisible(true); 1685 NanoVis:: EventuallyRedraw();1689 NanoVis::eventuallyRedraw(); 1686 1690 return TCL_OK; 1687 1691 } … … 1703 1707 (*iter)->setVisible(visible); 1704 1708 } 1705 NanoVis:: EventuallyRedraw();1709 NanoVis::eventuallyRedraw(); 1706 1710 return TCL_OK; 1707 1711 } … … 1744 1748 (*iter)->setLineContourColor(rgb); 1745 1749 } 1746 NanoVis:: EventuallyRedraw();1750 NanoVis::eventuallyRedraw(); 1747 1751 return TCL_OK; 1748 1752 } … … 1764 1768 (*iter)->setLineContourVisible(visible); 1765 1769 } 1766 NanoVis:: EventuallyRedraw();1770 NanoVis::eventuallyRedraw(); 1767 1771 return TCL_OK; 1768 1772 } … … 1797 1801 } 1798 1802 NanoVis::renderContext->setCullMode(mode); 1799 NanoVis:: EventuallyRedraw();1803 NanoVis::eventuallyRedraw(); 1800 1804 return TCL_OK; 1801 1805 } … … 1823 1827 Tcl_SetHashValue(hPtr, hmPtr); 1824 1828 Tcl_SetStringObj(Tcl_GetObjResult(interp), tag, -1);; 1825 NanoVis:: EventuallyRedraw();1829 NanoVis::eventuallyRedraw(); 1826 1830 TRACE("Number of heightmaps=%d\n", NanoVis::heightmapTable.numEntries); 1827 1831 return TCL_OK; … … 1850 1854 return TCL_ERROR; 1851 1855 } 1852 if (HeightMap::update _pending) {1853 NanoVis:: SetHeightmapRanges();1854 } 1855 NanoVis::render _legend(tfPtr, HeightMap::valueMin, HeightMap::valueMax,1856 1856 if (HeightMap::updatePending) { 1857 NanoVis::setHeightmapRanges(); 1858 } 1859 NanoVis::renderLegend(tfPtr, HeightMap::valueMin, HeightMap::valueMax, 1860 w, h, tag); 1857 1861 return TCL_OK; 1858 1862 } … … 1867 1871 } 1868 1872 NanoVis::renderContext->setPolygonMode(mode); 1869 NanoVis:: EventuallyRedraw();1873 NanoVis::eventuallyRedraw(); 1870 1874 return TCL_OK; 1871 1875 } … … 1880 1884 } 1881 1885 NanoVis::renderContext->setShadingModel(model); 1882 NanoVis:: EventuallyRedraw();1886 NanoVis::eventuallyRedraw(); 1883 1887 return TCL_OK; 1884 1888 } … … 1898 1902 // GEORGE 1899 1903 1900 NanoVis::render _2d_contour(heightmap, image_width, image_height);1901 NanoVis:: EventuallyRedraw();1904 NanoVis::render2dContour(heightmap, image_width, image_height); 1905 NanoVis::eventuallyRedraw(); 1902 1906 return TCL_OK; 1903 1907 } … … 1929 1933 float maxy = 3.5f; 1930 1934 hmPtr->setHeight(minx, miny, maxx, maxy, 20, 20, data); 1931 hmPtr->transferFunction(NanoVis::get _transfunc("default"));1935 hmPtr->transferFunction(NanoVis::getTransfunc("default")); 1932 1936 hmPtr->setVisible(true); 1933 1937 hmPtr->setLineContourVisible(true); … … 1945 1949 int image_height = 512; 1946 1950 1947 NanoVis::render _2d_contour(hmPtr, image_width, image_height);1951 NanoVis::render2dContour(hmPtr, image_width, image_height); 1948 1952 1949 1953 return TCL_OK; … … 1957 1961 name = Tcl_GetString(objv[2]); 1958 1962 TransferFunction *tfPtr; 1959 tfPtr = NanoVis::get _transfunc(name);1963 tfPtr = NanoVis::getTransfunc(name); 1960 1964 if (tfPtr == NULL) { 1961 1965 Tcl_AppendResult(interp, "transfer function \"", name, … … 1971 1975 (*iter)->transferFunction(tfPtr); 1972 1976 } 1973 NanoVis:: EventuallyRedraw();1977 NanoVis::eventuallyRedraw(); 1974 1978 return TCL_OK; 1975 1979 } … … 1992 1996 (*iter)->opacity(opacity); 1993 1997 } 1994 NanoVis:: EventuallyRedraw();1998 NanoVis::eventuallyRedraw(); 1995 1999 return TCL_OK; 1996 2000 } … … 2142 2146 return TCL_ERROR; 2143 2147 } 2144 NanoVis::axis _on = visible;2148 NanoVis::axisOn = visible; 2145 2149 } else { 2146 2150 Tcl_AppendResult(interp, "bad axis option \"", string, -
trunk/packages/vizservers/nanovis/ContourLineFilter.h
r2827 r2877 16 16 { 17 17 public: 18 float _value;19 std::list<Vector3> _points;20 21 18 ContourLine(float value); 22 19 23 20 /** 24 * @brief 25 * @ret Returns the number of points 21 * @return Returns the number of points 26 22 */ 27 23 int createLine(int width, int height, Vector3 *vertices, bool top); 28 24 int createLine(int width, int height, Vector4 *vertices, bool top); 25 26 float _value; 27 std::list<Vector3> _points; 29 28 30 29 private: -
trunk/packages/vizservers/nanovis/ConvexPolygon.cpp
r2870 r2877 100 100 101 101 void 102 ConvexPolygon::clip(Plane& clipPlane, bool copy _to_texcoord)102 ConvexPolygon::clip(Plane& clipPlane, bool copyToTexcoord) 103 103 { 104 104 if (vertices.size() == 0) { … … 123 123 Vector4 plane = clipPlane.get_coeffs(); 124 124 125 bool prevRetained = is _retained(vertices[0], plane);125 bool prevRetained = isRetained(vertices[0], plane); 126 126 if (prevRetained) 127 127 clippedVerts.push_back(vertices[0]); 128 128 129 129 for (unsigned int i = 1; i < vertices.size(); i++) { 130 bool retained = is _retained(vertices[i], plane);130 bool retained = isRetained(vertices[i], plane); 131 131 if (retained != prevRetained) { 132 132 bool found = findIntersection(vertices[i - 1], vertices[i], … … 141 141 } 142 142 143 bool retained = is _retained(vertices[0], plane);143 bool retained = isRetained(vertices[0], plane); 144 144 if (retained != prevRetained) { 145 145 bool found = findIntersection(vertices[vertices.size() - 1], … … 154 154 clippedVerts.end()); 155 155 156 if (copy _to_texcoord)157 copy _vertices_to_texcoords();158 } 159 160 void 161 ConvexPolygon::copy _vertices_to_texcoords()156 if (copyToTexcoord) 157 copyVerticesToTexcoords(); 158 } 159 160 void 161 ConvexPolygon::copyVerticesToTexcoords() 162 162 { 163 163 if (texcoords.size() > 0) … … 170 170 171 171 void 172 ConvexPolygon:: Emit(bool use_texture)172 ConvexPolygon::emit(bool useTexture) 173 173 { 174 174 if (vertices.size() >= 3) { 175 175 for (unsigned int i = 0; i < vertices.size(); i++) { 176 if (use _texture) {176 if (useTexture) { 177 177 glTexCoord4fv((float *)&(texcoords[i])); 178 178 //glTexCoord4fv((float *)&(vertices[i])); … … 184 184 185 185 void 186 ConvexPolygon:: Emit(bool use_texture, const Vector3& shift, const Vector3& scale)186 ConvexPolygon::emit(bool useTexture, const Vector3& shift, const Vector3& scale) 187 187 { 188 188 if (vertices.size() >= 3) { 189 189 for (unsigned int i = 0; i < vertices.size(); i++) { 190 if (use _texture) {190 if (useTexture) { 191 191 glTexCoord4fv((float *)&(vertices[i])); 192 192 } -
trunk/packages/vizservers/nanovis/ConvexPolygon.h
r2822 r2877 29 29 { 30 30 public: 31 VertexVector vertices;32 TexVector texcoords;33 int volume_id; //which volume this polygon slice belongs to34 35 31 ConvexPolygon() 36 32 {} … … 43 39 44 40 // Clips the polygon, retaining the portion where ax + by + cz + d >= 0 45 void clip(Plane& clipPlane, bool copy _to_texcoords);41 void clip(Plane& clipPlane, bool copyToTexcoords); 46 42 47 void Emit(bool use_texture);43 void emit(bool useTexture); 48 44 49 void Emit(bool use_texture, const Vector3& shift, const Vector3& scale);45 void emit(bool useTexture, const Vector3& shift, const Vector3& scale); 50 46 51 void copy _vertices_to_texcoords();47 void copyVerticesToTexcoords(); 52 48 53 void set _id(int v_id)49 void setId(int id) 54 50 { 55 volume _id = v_id;51 volumeId = id; 56 52 } 57 53 58 void append _vertex(const Vector4& vert)54 void appendVertex(const Vector4& vert) 59 55 { 60 56 vertices.push_back(vert); 61 57 } 62 58 63 void insert _vertex(unsigned int index, const Vector4& vert)59 void insertVertex(unsigned int index, const Vector4& vert) 64 60 { 65 assert(index <vertices.size());61 assert(index < vertices.size()); 66 62 vertices.insert(vertices.begin() + index, vert); 67 63 } 68 64 69 bool is _retained(const Vector4& point, const Vector4& plane)65 bool isRetained(const Vector4& point, const Vector4& plane) 70 66 { 71 67 return ((point * plane) >= 0); 72 68 } 69 70 VertexVector vertices; 71 TexVector texcoords; 72 int volumeId; //which volume this polygon slice belongs to 73 73 }; 74 74 -
trunk/packages/vizservers/nanovis/FlowCmd.cpp
r2875 r2877 34 34 #include "Unirect.h" 35 35 #include "VelocityArrowsSlice.h" 36 #include "Volume.h" 36 37 37 38 #define RELPOS 0 … … 294 295 memset(&_sv, 0, sizeof(FlowValues)); 295 296 _sv.sliceVisible = 1; 296 _sv.tfPtr = NanoVis::get _transfunc("default");297 _sv.tfPtr = NanoVis::getTransfunc("default"); 297 298 298 299 Tcl_InitHashTable(&_particlesTable, TCL_STRING_KEYS); … … 317 318 } 318 319 if (_volPtr != NULL) { 319 NanoVis::remove _volume(_volPtr);320 NanoVis::removeVolume(_volPtr); 320 321 _volPtr = NULL; 321 322 } … … 530 531 if (_volPtr != NULL) { 531 532 TRACE("from ScaleVectorField volId=%s\n", _volPtr->name()); 532 NanoVis::remove _volume(_volPtr);533 NanoVis::removeVolume(_volPtr); 533 534 _volPtr = NULL; 534 535 } … … 575 576 NanoVis::licRenderer-> 576 577 setVectorField(_volPtr->id, loc, 577 1.0f / _volPtr->aspect _ratio_width,578 1.0f / _volPtr->aspect _ratio_height,579 1.0f / _volPtr->aspect _ratio_depth,578 1.0f / _volPtr->aspectRatioWidth, 579 1.0f / _volPtr->aspectRatioHeight, 580 1.0f / _volPtr->aspectRatioDepth, 580 581 _volPtr->wAxis.max()); 581 582 SetCurrentPosition(); … … 589 590 //*(volPtr->get_location()), 590 591 1.0f, 591 _volPtr->aspect _ratio_height / _volPtr->aspect_ratio_width,592 _volPtr->aspect _ratio_depth / _volPtr->aspect_ratio_width592 _volPtr->aspectRatioHeight / _volPtr->aspectRatioWidth, 593 _volPtr->aspectRatioDepth / _volPtr->aspectRatioWidth 593 594 //,volPtr->wAxis.max() 594 595 ); … … 657 658 Volume *volPtr; 658 659 659 volPtr = NanoVis::load _volume(_name, _dataPtr->xNum(), _dataPtr->yNum(),660 661 660 volPtr = NanoVis::loadVolume(_name, _dataPtr->xNum(), _dataPtr->yNum(), 661 _dataPtr->zNum(), 4, data, 662 NanoVis::magMin, NanoVis::magMax, 0); 662 663 volPtr->xAxis.SetRange(_dataPtr->xMin(), _dataPtr->xMax()); 663 664 volPtr->yAxis.SetRange(_dataPtr->yMin(), _dataPtr->yMax()); … … 672 673 NanoVis::magMin, NanoVis::magMax); 673 674 volPtr->setPhysicalBBox(physicalMin, physicalMax); 674 //volPtr-> set_n_slice(256 - _volIndex);675 // volPtr->set_n_slice(512- _volIndex);676 //volPtr->n _slices(256-n);675 //volPtr->numSlices(256 - _volIndex); 676 //volPtr->numSlices(512 - _volIndex); 677 //volPtr->numSlices(256 - n); 677 678 // TBD.. 678 679 /* Don't set the slice number until we're are about to render the 679 680 volume. */ 680 volPtr->disable _cutplane(0);681 volPtr->disable _cutplane(1);682 volPtr->disable _cutplane(2);681 volPtr->disableCutplane(0); 682 volPtr->disableCutplane(1); 683 volPtr->disableCutplane(2); 683 684 684 685 /* Initialize the volume with the previously configured values. */ 685 686 volPtr->transferFunction(_sv.tfPtr); 686 volPtr->data _enabled(_sv.showVolume);687 volPtr->dataEnabled(_sv.showVolume); 687 688 volPtr->outline(_sv.showOutline); 688 volPtr->opacity _scale(_sv.opacity);689 volPtr->opacityScale(_sv.opacity); 689 690 volPtr->specular(_sv.specular); 690 691 volPtr->diffuse(_sv.diffuse); … … 695 696 float dz0 = -0.5*volPtr->depth/volPtr->width; 696 697 volPtr->location(Vector3(dx0, dy0, dz0)); 697 Volume::update _pending = true;698 Volume::updatePending = true; 698 699 return volPtr; 699 700 } … … 765 766 } 766 767 flowPtr->data(dataPtr); 767 NanoVis:: EventuallyRedraw(NanoVis::MAP_FLOWS);768 NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS); 768 769 return TCL_OK; 769 770 } … … 857 858 assert(nWritten == (ssize_t)strlen(info)); 858 859 } 859 NanoVis:: EventuallyRedraw(NanoVis::MAP_FLOWS);860 NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS); 860 861 return TCL_OK; 861 862 } … … 1331 1332 TransferFunction **funcPtrPtr = (TransferFunction **)(record + offset); 1332 1333 TransferFunction *funcPtr; 1333 funcPtr = NanoVis::get _transfunc(Tcl_GetString(objPtr));1334 funcPtr = NanoVis::getTransfunc(Tcl_GetString(objPtr)); 1334 1335 if (funcPtr == NULL) { 1335 1336 Tcl_AppendResult(interp, "transfer function \"", Tcl_GetString(objPtr), … … 1350 1351 return TCL_ERROR; 1351 1352 } 1352 NanoVis:: EventuallyRedraw(NanoVis::MAP_FLOWS);1353 NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS); 1353 1354 return TCL_OK; 1354 1355 } … … 1372 1373 } 1373 1374 particlesPtr->Configure(); 1374 NanoVis:: EventuallyRedraw();1375 NanoVis::eventuallyRedraw(); 1375 1376 Tcl_SetObjResult(interp, objv[3]); 1376 1377 return TCL_OK; … … 1391 1392 } 1392 1393 particlesPtr->Configure(); 1393 NanoVis:: EventuallyRedraw(NanoVis::MAP_FLOWS);1394 NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS); 1394 1395 return TCL_OK; 1395 1396 } … … 1408 1409 } 1409 1410 } 1410 NanoVis:: EventuallyRedraw();1411 NanoVis::eventuallyRedraw(); 1411 1412 return TCL_OK; 1412 1413 } … … 1486 1487 return TCL_ERROR; 1487 1488 } 1488 NanoVis:: EventuallyRedraw();1489 NanoVis::eventuallyRedraw(); 1489 1490 Tcl_SetObjResult(interp, objv[3]); 1490 1491 return TCL_OK; … … 1504 1505 } 1505 1506 } 1506 NanoVis:: EventuallyRedraw();1507 NanoVis::eventuallyRedraw(); 1507 1508 return TCL_OK; 1508 1509 } … … 1541 1542 return TCL_ERROR; 1542 1543 } 1543 NanoVis:: EventuallyRedraw();1544 NanoVis::eventuallyRedraw(); 1544 1545 return TCL_OK; 1545 1546 } … … 1613 1614 NanoVis::MapFlows(); 1614 1615 } 1615 NanoVis::render _legend(tf, NanoVis::magMin, NanoVis::magMax, w, h, label);1616 NanoVis::renderLegend(tf, NanoVis::magMin, NanoVis::magMax, w, h, label); 1616 1617 return TCL_OK; 1617 1618 } … … 1681 1682 } 1682 1683 Tcl_SetObjResult(interp, objv[2]); 1683 NanoVis:: EventuallyRedraw();1684 NanoVis::eventuallyRedraw(); 1684 1685 return TCL_OK; 1685 1686 } … … 1699 1700 Tcl_DeleteCommand(interp, flowPtr->name()); 1700 1701 } 1701 NanoVis:: EventuallyRedraw(NanoVis::MAP_FLOWS);1702 NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS); 1702 1703 return TCL_OK; 1703 1704 } … … 1746 1747 NanoVis::AdvectFlows(); 1747 1748 } 1748 NanoVis:: EventuallyRedraw();1749 NanoVis::eventuallyRedraw(); 1749 1750 return TCL_OK; 1750 1751 } … … 1777 1778 NanoVis::MapFlows(); 1778 1779 } 1779 NanoVis:: EventuallyRedraw();1780 NanoVis::eventuallyRedraw(); 1780 1781 NanoVis::licRenderer->convolve(); 1781 1782 NanoVis::AdvectFlows(); … … 1880 1881 values.frameRate = 25.0f; // Default frame rate 25 fps 1881 1882 values.bitRate = 6000000; // Default video bit rate. 1882 values.width = NanoVis::win _width;1883 values.height = NanoVis::win _height;1883 values.width = NanoVis::winWidth; 1884 values.height = NanoVis::winHeight; 1884 1885 values.nFrames = 100; 1885 1886 values.format = Rappture::AVTranslate::MPEG1; … … 1907 1908 // Save the old dimensions of the offscreen buffer. 1908 1909 int oldWidth, oldHeight; 1909 oldWidth = NanoVis::win _width;1910 oldHeight = NanoVis::win _height;1910 oldWidth = NanoVis::winWidth; 1911 oldHeight = NanoVis::winHeight; 1911 1912 1912 1913 TRACE("FLOW started\n"); … … 1926 1927 if ((values.width != oldWidth) || (values.height != oldHeight)) { 1927 1928 // Resize to the requested size. 1928 NanoVis::resize _offscreen_buffer(values.width, values.height);1929 NanoVis::resizeOffscreenBuffer(values.width, values.height); 1929 1930 } 1930 1931 // Now compute the line padding for the offscreen buffer. … … 1946 1947 } 1947 1948 NanoVis::AdvectFlows(); 1948 NanoVis::offscreen _buffer_capture();1949 NanoVis::offscreenBufferCapture(); 1949 1950 NanoVis::display(); 1950 NanoVis::read _screen();1951 NanoVis::readScreen(); 1951 1952 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1952 movie.append(context, NanoVis::screen _buffer, pad);1953 movie.append(context, NanoVis::screenBuffer, pad); 1953 1954 } 1954 1955 movie.done(context); … … 1971 1972 } 1972 1973 if ((values.width != oldWidth) || (values.height != oldHeight)) { 1973 NanoVis::resize _offscreen_buffer(oldWidth, oldHeight);1974 NanoVis::resizeOffscreenBuffer(oldWidth, oldHeight); 1974 1975 } 1975 1976 NanoVis::ResetFlows(); -
trunk/packages/vizservers/nanovis/GradientFilter.cpp
r2870 r2877 15 15 16 16 static int g_numOfSlices[3] = { 256, 256, 256 }; 17 static void *g_volData = 0;17 static void *g_volData = NULL; 18 18 static float g_sliceDists[3]; 19 19 … … 23 23 #define MAX(a,b) ((a) > (b) ? (a) : (b)) 24 24 #define MIN(a,b) ((a) < (b) ? (a) : (b)) 25 #define EPS 1e- 5f25 #define EPS 1e-6f 26 26 27 27 #ifdef notused … … 145 145 } 146 146 147 void computeGradients(float *gradients, void* volData, int *sizes, DataType dataType) 147 void computeGradients(float *gradients, void *volData, int *sizes, 148 float *spacing, DataType dataType) 148 149 { 149 150 ::g_volData = volData; … … 152 153 g_numOfSlices[2] = sizes[2]; 153 154 154 g_sliceDists[0] = 1.0f / sizes[0];155 g_sliceDists[1] = 1.0f / sizes[1];156 g_sliceDists[2] = 1.0f / sizes[2];155 g_sliceDists[0] = spacing[0]; 156 g_sliceDists[1] = spacing[1]; 157 g_sliceDists[2] = spacing[2]; 157 158 158 159 int i, j, k, dir, di, vdi, idz, idy, idx; -
trunk/packages/vizservers/nanovis/GradientFilter.h
r2844 r2877 9 9 } DataType; 10 10 11 extern void computeGradients(float *gradients, void *volData, int *sizes, DataType dataType); 11 extern void computeGradients(float *gradients, void *volData, 12 int *sizes, float *spacing, DataType dataType); 12 13 13 14 extern void filterGradients(float *gradients, int *sizes); -
trunk/packages/vizservers/nanovis/HeightMap.cpp
r2870 r2877 19 19 #include "RenderContext.h" 20 20 21 bool HeightMap::update _pending = false;21 bool HeightMap::updatePending = false; 22 22 double HeightMap::valueMin = 0.0; 23 23 double HeightMap::valueMax = 1.0; … … 260 260 261 261 void 262 HeightMap::setHeight(int xCount, int yCount, Vector3 *heights)262 HeightMap::setHeight(int xCount, int yCount, Vector3 *heights) 263 263 { 264 264 _vertexCount = xCount * yCount; 265 265 reset(); 266 267 _heights = (float *)heights; 266 267 _heights = (float *)heights; 268 268 float min, max; 269 269 min = heights[0].y, max = heights[0].y; … … 287 287 zAxis.SetRange(0.0, 1.0); 288 288 wAxis.SetRange(min, max); 289 update _pending = true;290 289 updatePending = true; 290 291 291 _centerPoint.set(_scale.x * 0.5, _scale.z * 0.5 + min, _scale.y * 0.5); 292 292 … … 334 334 void 335 335 HeightMap::setHeight(float xMin, float yMin, float xMax, float yMax, 336 int xNum, int yNum, float *heights)336 int xNum, int yNum, float *heights) 337 337 { 338 338 _vertexCount = xNum * yNum; … … 376 376 _scale.x = _scale.y = _scale.z = 1.0; 377 377 378 update _pending = true;378 updatePending = true; 379 379 380 380 _centerPoint.set(0.5, 0.5, 0.5); … … 420 420 } 421 421 422 Vector3 *422 Vector3 * 423 423 HeightMap::createHeightVertices(float xMin, float yMin, float xMax, 424 float yMax, int xNum, int yNum, float *height)424 float yMax, int xNum, int yNum, float *height) 425 425 { 426 426 Vector3* vertices = new Vector3[xNum * yNum]; -
trunk/packages/vizservers/nanovis/HeightMap.h
r2870 r2877 20 20 21 21 /** 22 *@class HeightMap23 22 *@brief Create a surface from height map and line contour of the generated surface 24 23 */ … … 123 122 124 123 AxisRange xAxis, yAxis, zAxis, wAxis; 125 static bool update _pending;124 static bool updatePending; 126 125 static double valueMin, valueMax; 127 126 -
trunk/packages/vizservers/nanovis/NvCamera.cpp
r2854 r2877 19 19 #include <GL/glew.h> 20 20 #include <GL/glu.h> 21 22 #include <vrmath/vrQuaternion.h> 23 #include <vrmath/vrRotation.h> 24 #include <vrmath/vrMatrix4x4f.h> 21 25 22 26 #include "NvCamera.h" … … 61 65 glLoadIdentity(); 62 66 67 #ifndef OLD_CAMERA 68 glTranslatef(-_location.x, -_location.y, -_location.z); 69 glMultMatrixf((const GLfloat *)_cameraMatrix.get()); 70 #else 71 63 72 gluLookAt(_location.x, _location.y, _location.z, 64 73 _target.x, _target.y, _target.z, 65 74 0., 1., 0.); 66 75 67 glRotated(_angle.x, 1., 0., 0.); 68 glRotated(_angle.y, 0., 1., 0.); 69 glRotated(_angle.z, 0., 0., 1.); 76 if (_angle.x != 0.0f) 77 glRotated(_angle.x, 1., 0., 0.); 78 if (_angle.y != 0.0f) 79 glRotated(_angle.y, 0., 1., 0.); 80 if (_angle.z != 0.0f) 81 glRotated(_angle.z, 0., 0., 1.); 82 #endif 70 83 } 84 85 void NvCamera::rotate(double *quat) 86 { 87 vrQuaternion q(quat[0], quat[1], quat[2], quat[3]); 88 vrRotation rot; 89 rot.set(q); 90 _cameraMatrix.makeRotation(rot); 91 _cameraMatrix.transpose(); 92 _angle.set(0, 0, 0); 93 TRACE("Set rotation to quat: %g %g %g %g\n", 94 quat[0], quat[1], quat[2], quat[3]); 95 } 96 97 void NvCamera::rotate(float angle_x, float angle_y, float angle_z) 98 { 99 #ifdef OLD_CAMERA 100 _angle = Vector3(angle_x, angle_y, angle_z); 101 #else 102 angle_x = -angle_x; 103 angle_y = angle_y - 180.; 104 _angle = Vector3(angle_x, angle_y, angle_z); 105 106 _cameraMatrix.makeRotation(1, 0, 0, deg2rad(_angle.x)); 107 vrMatrix4x4f mat; 108 mat.makeRotation(0, 1, 0, deg2rad(_angle.y)); 109 _cameraMatrix.multiply(mat); 110 mat.makeRotation(0, 0, 1, deg2rad(_angle.z)); 111 _cameraMatrix.multiply(mat); 112 //_cameraMatrix.transpose(); 113 #endif 114 TRACE("Set rotation to angles: %g %g %g\n", 115 _angle.x, _angle.y, _angle.z); 116 } 117 118 void NvCamera::rotate(const Vector3& angle) 119 { 120 #ifdef OLD_CAMERA 121 _angle = angle; 122 #else 123 _angle.x = -angle.x; 124 _angle.y = angle.y - 180.; 125 _angle.z = angle.z; 126 127 _cameraMatrix.makeRotation(1, 0, 0, deg2rad(_angle.x)); 128 vrMatrix4x4f mat; 129 mat.makeRotation(0, 1, 0, deg2rad(_angle.y)); 130 _cameraMatrix.multiply(mat); 131 mat.makeRotation(0, 0, 1, deg2rad(_angle.z)); 132 _cameraMatrix.multiply(mat); 133 //_cameraMatrix.transpose(); 134 #endif 135 TRACE("Set rotation to angles: %g %g %g\n", 136 _angle.x, _angle.y, _angle.z); 137 } -
trunk/packages/vizservers/nanovis/NvCamera.h
r2854 r2877 17 17 #define CAMERA_H 18 18 19 #include <vrmath/vrMatrix4x4f.h> 20 21 #include "config.h" 19 22 #include "Vector3.h" 20 23 … … 29 32 ~NvCamera() 30 33 {} 31 32 34 33 35 //move location of camera … … 93 95 } 94 96 95 void rotate(float angle_x, float angle_y, float angle_z) 96 { 97 _angle = Vector3(angle_x, angle_y, angle_z); 98 } 97 void rotate(double *quat); 99 98 100 void rotate(const Vector3& angle) 101 { 102 _angle = angle; 103 } 99 void rotate(float angle_x, float angle_y, float angle_z); 100 101 void rotate(const Vector3& angle); 104 102 105 103 Vector3 rotate() const … … 117 115 118 116 /** 119 * \brief make the camera setting active, this has to be117 * \brief Make the camera setting active, this has to be 120 118 * called before drawing things 121 119 */ … … 133 131 /// rotation angles of camera along x, y, z 134 132 Vector3 _angle; 133 134 vrMatrix4x4f _cameraMatrix; 135 135 136 /// screen width 136 137 int _width; -
trunk/packages/vizservers/nanovis/NvFlowVisRenderer.h
r2870 r2877 51 51 /** 52 52 * @brief Specify the axis of the index plane 53 * @param index the index of the array of injection planes54 53 */ 55 54 void setPlaneAxis(const std::string& vfName, const std::string& name, int axis); 56 55 57 56 /** 58 * @param pos :Specify the position of slice57 * @param pos Specify the position of slice 59 58 */ 60 59 void setPlanePos(const std::string& vfName, const std::string& name, float pos); -
trunk/packages/vizservers/nanovis/NvRegularVolumeShader.cpp
r2870 r2877 40 40 if (!sliceMode) { 41 41 cgGLSetParameter4f(_render_param_one_volume_param, 42 volume->n _slices(),43 volume->opacity _scale(),42 volume->numSlices(), 43 volume->opacityScale(), 44 44 volume->diffuse(), 45 45 volume->specular()); … … 47 47 cgGLSetParameter4f(_render_param_one_volume_param, 48 48 0., 49 volume->opacity _scale(),49 volume->opacityScale(), 50 50 volume->diffuse(), 51 51 volume->specular()); -
trunk/packages/vizservers/nanovis/NvShader.cpp
r2870 r2877 99 99 void NvShader::setErrorCallback(NvCgCallbackFunction callback) 100 100 { 101 TRACE("NvShader error callback: %p\n", callback);101 TRACE("NvShader setting error callback to: %p\n", callback); 102 102 cgSetErrorCallback(callback); 103 103 } -
trunk/packages/vizservers/nanovis/NvZincBlendeReconstructor.h
r2844 r2877 37 37 /** 38 38 * @brief Load Zinc blende binary volume data and create ZincBlendeVolume with the file 39 * @param dataZinc blende binary volume data, which data is generated by NEMO-3D and transferred from nanoscale39 * @param stream Zinc blende binary volume data, which data is generated by NEMO-3D and transferred from nanoscale 40 40 */ 41 41 ZincBlendeVolume *loadFromStream(std::istream& stream); … … 71 71 /** 72 72 * @brief Get a line from file. It is used for reading header because header is written in ascii. 73 * @param fp A file pointer of data file74 73 */ 75 74 void getLine(std::istream& stream); -
trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.cpp
r2870 r2877 26 26 _mviParam = cgGetNamedParameter(_cgFP, "modelViewInv"); 27 27 _renderParam = cgGetNamedParameter(_cgFP, "renderParameters"); 28 _option _one_volume_param = cgGetNamedParameter(_cgFP, "options");28 _optionOneVolumeParam = cgGetNamedParameter(_cgFP, "options"); 29 29 } 30 30 … … 35 35 cgGLSetTextureParameter(_tfParam, tfID); 36 36 cgGLSetParameter4f(_cellSizeParam, 37 vol->cell _size.x,38 vol->cell _size.y,39 vol->cell _size.z, 0.);37 vol->cellSize.x, 38 vol->cellSize.y, 39 vol->cellSize.z, 0.); 40 40 41 41 if (!sliceMode) { 42 42 cgGLSetParameter4f(_renderParam, 43 vol->n _slices(),44 vol->opacity _scale(),43 vol->numSlices(), 44 vol->opacityScale(), 45 45 vol->diffuse(), 46 46 vol->specular()); … … 48 48 cgGLSetParameter4f(_renderParam, 49 49 0., 50 vol->opacity _scale(),50 vol->opacityScale(), 51 51 vol->diffuse(), 52 52 vol->specular()); 53 53 } 54 54 55 cgGLSetParameter4f(_option _one_volume_param,55 cgGLSetParameter4f(_optionOneVolumeParam, 56 56 0.0f, 57 57 volume->isosurface(), … … 59 59 0.0f); 60 60 61 cgGLSetTextureParameter(_volumeAParam, vol->zincblende _tex[0]->id());62 cgGLSetTextureParameter(_volumeBParam, vol->zincblende _tex[1]->id());61 cgGLSetTextureParameter(_volumeAParam, vol->zincblendeTex[0]->id()); 62 cgGLSetTextureParameter(_volumeBParam, vol->zincblendeTex[1]->id()); 63 63 cgGLEnableTextureParameter(_volumeAParam); 64 64 cgGLEnableTextureParameter(_volumeBParam); -
trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.h
r2859 r2877 26 26 CGparameter _mviParam; 27 27 CGparameter _renderParam; 28 CGparameter _option _one_volume_param;28 CGparameter _optionOneVolumeParam; 29 29 }; 30 30 -
trunk/packages/vizservers/nanovis/PerfQuery.cpp
r2798 r2877 14 14 * ====================================================================== 15 15 */ 16 #include <assert.h> 16 17 17 #include <assert.h>18 18 #include "PerfQuery.h" 19 19 20 21 PerfQuery::PerfQuery(){22 glGenQueriesARB(1, &id);23 pixel = 0;20 PerfQuery::PerfQuery() 21 { 22 glGenQueriesARB(1, &id); 23 pixel = 0; 24 24 } 25 25 26 PerfQuery::~PerfQuery(){ 27 glDeleteQueriesARB(1, &id); 26 PerfQuery::~PerfQuery() 27 { 28 glDeleteQueriesARB(1, &id); 28 29 } 29 30 30 31 //There can only be one active query at any given moment 31 void PerfQuery::enable(){ 32 glBeginQueryARB(GL_SAMPLES_PASSED_ARB, id); 32 void PerfQuery::enable() 33 { 34 glBeginQueryARB(GL_SAMPLES_PASSED_ARB, id); 33 35 } 34 36 35 void PerfQuery::disable(){ 36 glEndQueryARB(GL_SAMPLES_PASSED_ARB); 37 void PerfQuery::disable() 38 { 39 glEndQueryARB(GL_SAMPLES_PASSED_ARB); 37 40 38 GLuint count;39 glGetQueryObjectuivARB(id, GL_QUERY_RESULT_ARB, &count);41 GLuint count; 42 glGetQueryObjectuivARB(id, GL_QUERY_RESULT_ARB, &count); 40 43 41 //accumulate pixel count count42 pixel+=count;44 //accumulate pixel count count 45 pixel += count; 43 46 } 44 -
trunk/packages/vizservers/nanovis/PerfQuery.h
r2870 r2877 16 16 * ====================================================================== 17 17 */ 18 #ifndef _PERFQUERY_H_19 #define _PERFQUERY_H_18 #ifndef PERFQUERY_H 19 #define PERFQUERY_H 20 20 21 21 #include <stdio.h> … … 25 25 #include "Trace.h" 26 26 27 //check if occlusion query is supported28 inline bool check_query_support()29 {30 int bitsSupported = -1;31 glGetQueryivARB(GL_SAMPLES_PASSED_ARB, GL_QUERY_COUNTER_BITS_ARB,32 &bitsSupported);33 if (bitsSupported == 0) {34 TRACE("occlusion query not supported!\n");35 return false;36 } else {37 TRACE("Occlusion query with %d bits supported\n", bitsSupported);38 return true;39 }40 }41 42 27 class PerfQuery 43 28 { 44 29 public: 45 GLuint id;46 int pixel;47 48 30 PerfQuery(); 49 31 ~PerfQuery(); 50 32 51 33 void enable(); //start counting how many pixels are rendered 52 34 void disable(); //stop counting 53 35 54 36 void reset() 55 { 56 37 { 38 pixel = 0; 57 39 } 58 40 59 int get _pixel_count()41 int getPixelCount() 60 42 { 61 43 return pixel; //return current pixel count 62 44 } 45 46 static bool checkQuerySupport(); 47 48 GLuint id; 49 int pixel; 63 50 }; 64 51 52 //check if occlusion query is supported 53 inline bool PerfQuery::checkQuerySupport() 54 { 55 if (!GLEW_ARB_occlusion_query) { 56 TRACE("ARB_occlusion_query extension not supported\n"); 57 return false; 58 } 59 int bitsSupported = -1; 60 glGetQueryivARB(GL_SAMPLES_PASSED_ARB, GL_QUERY_COUNTER_BITS_ARB, 61 &bitsSupported); 62 if (bitsSupported == 0) { 63 TRACE("occlusion query not supported!\n"); 64 return false; 65 } else { 66 TRACE("Occlusion query with %d bits supported\n", bitsSupported); 67 return true; 68 } 69 } 65 70 #endif 66 71 -
trunk/packages/vizservers/nanovis/R2/include/R2/R2FilePath.h
r2857 r2877 21 21 /** 22 22 * @brief set default data paths 23 * @param filePath all default paths separated by colon(:)23 * @param path all default paths separated by colon(:) 24 24 */ 25 25 bool setPath(const char *path); -
trunk/packages/vizservers/nanovis/R2/src/R2Fonts.cpp
r2870 r2877 166 166 sizeof(unsigned int)); 167 167 168 // read dimensions for each charact or in 256-char ASCII chart168 // read dimensions for each character in 256-char ASCII chart 169 169 for (int i = 0; i < 256; ++i) { 170 170 unsigned int uiSize = 0; -
trunk/packages/vizservers/nanovis/README
r226 r2877 32 32 Nvidia CG Toolkit for GPU (Graphics Processing Unit) programming. 33 33 (See http://developer.nvidia.com/object/cg_toolkit.html) 34 The OpenGL Wrangler Library for OpenGL extension management.34 The OpenGL Wrangler Library (>= 1.1.0) for OpenGL extension management. 35 35 (See http://glew.sourceforge.net/) 36 36 OpenGL Utility Toolkit (GLUT). Freeglut is an opensource GLUT replacement. -
trunk/packages/vizservers/nanovis/Switch.h
r2798 r2877 38 38 39 39 typedef int (SwitchParseProc)(ClientData clientData, Tcl_Interp *interp, 40 const char *switchName, Tcl_Obj *valueObjPtr, char *record, int offset, 41 int flags); 40 const char *switchName, Tcl_Obj *valueObjPtr, 41 char *record, int offset, 42 int flags); 43 42 44 typedef void (SwitchFreeProc)(char *record, int offset, int flags); 43 45 … … 122 124 123 125 extern int ParseSwitches(Tcl_Interp *interp, SwitchSpec *specPtr, 124 int objc, Tcl_Obj *const *objv, void *rec, int flags); 126 int objc, Tcl_Obj *const *objv, 127 void *rec, int flags); 125 128 126 129 extern void FreeSwitches(SwitchSpec *specs, void *rec, int flags); -
trunk/packages/vizservers/nanovis/Texture2D.cpp
r2857 r2877 72 72 void Texture2D::update(void *data) 73 73 { 74 static GLuint floatFormats[] = { -1, GL_LUMINANCE32F_ARB, GL_LUMINANCE_ALPHA32F_ARB, GL_RGB32F_ARB, GL_RGBA32F_ARB }; 75 static GLuint halfFloatFormats[] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB }; 76 static GLuint basicFormats[] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; 77 74 78 glBindTexture(GL_TEXTURE_2D, _id); 75 79 … … 83 87 84 88 //to do: add handling to more formats 85 #ifdef NV40 89 GLuint *targetFormats; 90 #ifdef HAVE_FLOAT_TEXTURES 86 91 if (_type == GL_FLOAT) { 87 GLuint targetFormat[5] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB }; 88 GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; 89 glTexImage2D(GL_TEXTURE_2D, 0, targetFormat[_numComponents], _width, _height, 0, 90 format[_numComponents], _type, data); 92 # ifdef USE_HALF_FLOAT 93 targetFormats = halfFloatFormats; 94 # else 95 targetFormats = floatFormats; 96 # endif 91 97 } else { 92 98 #endif 93 GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; 94 glTexImage2D(GL_TEXTURE_2D, 0, format[_numComponents], _width, _height, 0, 95 format[_numComponents], _type, data); 96 #ifdef NV40 99 targetFormats = basicFormats; 100 #ifdef HAVE_FLOAT_TEXTURES 97 101 } 98 102 #endif 103 104 glTexImage2D(GL_TEXTURE_2D, 0, targetFormats[_numComponents], 105 _width, _height, 0, 106 basicFormats[_numComponents], _type, data); 107 99 108 assert(glGetError() == 0); 100 109 } -
trunk/packages/vizservers/nanovis/Texture3D.cpp
r2857 r2877 88 88 void Texture3D::update(void *data) 89 89 { 90 static GLuint floatFormats[] = { -1, GL_LUMINANCE32F_ARB, GL_LUMINANCE_ALPHA32F_ARB, GL_RGB32F_ARB, GL_RGBA32F_ARB }; 91 static GLuint halfFloatFormats[] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB }; 92 static GLuint basicFormats[] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; 93 90 94 glBindTexture(GL_TEXTURE_3D, _id); 91 95 92 //load texture with 16 bit half floating point precision if card is 6 series NV4093 //half float with linear interpolation is only supported by 6 series and up cards94 //If NV40 not defined, data is quantized to 8-bit from 32-bit.95 96 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 96 97 … … 103 104 104 105 //to do: add handling to more formats 105 #ifdef NV40 106 GLuint *targetFormats; 107 #ifdef HAVE_FLOAT_TEXTURES 106 108 if (_type == GL_FLOAT) { 107 GLuint targetFormat[5] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB }; 108 GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };109 glTexImage3D(GL_TEXTURE_3D, 0, targetFormat[_numComponents], 110 _width, _height, _depth, 0,111 format[_numComponents], _type, data); 109 # ifdef USE_HALF_FLOAT 110 targetFormats = halfFloatFormats; 111 # else 112 targetFormats = floatFormats; 113 # endif 112 114 } else { 113 115 #endif 114 GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; 115 glTexImage3D(GL_TEXTURE_3D, 0, format[_numComponents], 116 _width, _height, _depth, 0, 117 format[_numComponents], _type, data); 118 #ifdef NV40 116 targetFormats = basicFormats; 117 #ifdef HAVE_FLOAT_TEXTURES 119 118 } 120 119 #endif 120 121 glTexImage3D(GL_TEXTURE_3D, 0, targetFormats[_numComponents], 122 _width, _height, _depth, 0, 123 basicFormats[_numComponents], _type, data); 121 124 122 125 assert(glGetError()==0); -
trunk/packages/vizservers/nanovis/Unirect.cpp
r2843 r2877 675 675 _yNum = (size_t)ceil(dy/dmin); 676 676 _zNum = (size_t)ceil(dz/dmin); 677 678 #ifndef NV40677 678 #ifndef HAVE_NPOT_TEXTURES 679 679 // must be an even power of 2 for older cards 680 680 _xNum = (int)pow(2.0, ceil(log10((double)_xNum)/log10(2.0))); -
trunk/packages/vizservers/nanovis/Vector3.h
r2827 r2877 44 44 { 45 45 TRACE("(x:%f, y:%f, z:%f)\n", x, y, z); 46 } 47 48 Vector3 operator -() const 49 { 50 return Vector3(-x, -y, -z); 46 51 } 47 52 … … 99 104 { 100 105 float len = length(); 101 return Vector3(x / len, y / len, z / len); 106 if (len > 1.0e-6) { 107 return Vector3(x / len, y / len, z / len); 108 } else { 109 return *this; 110 } 102 111 } 103 112 -
trunk/packages/vizservers/nanovis/VelocityArrowsSlice.cpp
r2870 r2877 318 318 319 319 //cgSetParameter1f(_mvTanHalfFOVParam, -tan(_fov * 0.5) * _screenHeight * 0.5); 320 cgSetParameter1f(_mvTanHalfFOVParam, tan(30. * 0.5) * NanoVis::win _height * 0.5);320 cgSetParameter1f(_mvTanHalfFOVParam, tan(30. * 0.5) * NanoVis::winHeight * 0.5); 321 321 322 322 cgGLSetStateMatrixParameter(_mvpParticleParam, -
trunk/packages/vizservers/nanovis/Volume.cpp
r2857 r2877 20 20 #include "Trace.h" 21 21 22 bool Volume::update _pending = false;22 bool Volume::updatePending = false; 23 23 double Volume::valueMin = 0.0; 24 24 double Volume::valueMax = 1.0; … … 27 27 int w, int h, int d, float s, 28 28 int n, float *data, 29 double v0, double v1, double n z_min) :30 aspect _ratio_width(1),31 aspect _ratio_height(1),32 aspect _ratio_depth(1),29 double v0, double v1, double nonZeroMin) : 30 aspectRatioWidth(1), 31 aspectRatioHeight(1), 32 aspectRatioDepth(1), 33 33 id(0), 34 34 width(w), … … 38 38 pointsetIndex(-1), 39 39 _tfPtr(NULL), 40 _specular(6.), // default value41 _diffuse(3.), // default value42 _opacity _scale(10.), // default value40 _specular(6.), 41 _diffuse(3.), 42 _opacityScale(10.), 43 43 _name(NULL), 44 44 _data(NULL), 45 _n _components(n),46 _non zero_min(nz_min),45 _numComponents(n), 46 _nonZeroMin(nonZeroMin), 47 47 _tex(NULL), 48 48 _location(x, y, z), 49 _n _slices(512), // default value49 _numSlices(512), 50 50 _enabled(true), 51 _data _enabled(true), // default value52 _outline _enabled(true), // default value53 _outline _color(1., 1., 1.), // default value54 _volume _type(CUBIC), // default is a cubic volume55 _iso _surface(0)51 _dataEnabled(true), 52 _outlineEnabled(true), 53 _outlineColor(1., 1., 1.), 54 _volumeType(CUBIC), 55 _isosurface(0) 56 56 { 57 57 _tex = new Texture3D(w, h, d, GL_FLOAT, GL_LINEAR, n); 58 int fcount = width * height * depth * _n _components;58 int fcount = width * height * depth * _numComponents; 59 59 _data = new float[fcount]; 60 60 if (data != NULL) { … … 64 64 } else { 65 65 TRACE("data is null\n"); 66 memset(_data, 0, sizeof(width * height * depth * _n _components *66 memset(_data, 0, sizeof(width * height * depth * _numComponents * 67 67 sizeof(float))); 68 68 _tex->initialize(_data); … … 74 74 75 75 // VOLUME 76 aspect _ratio_width = s * _tex->aspectRatioWidth();77 aspect _ratio_height = s * _tex->aspectRatioHeight();78 aspect _ratio_depth = s * _tex->aspectRatioDepth();76 aspectRatioWidth = s * _tex->aspectRatioWidth(); 77 aspectRatioHeight = s * _tex->aspectRatioHeight(); 78 aspectRatioDepth = s * _tex->aspectRatioDepth(); 79 79 80 80 //Add cut planes. We create 3 default cut planes facing x, y, z directions. 81 81 //The default location of cut plane is in the middle of the data. 82 82 _plane.clear(); 83 add _cutplane(1, 0.5f);84 add _cutplane(2, 0.5f);85 add _cutplane(3, 0.5f);83 addCutplane(1, 0.5f); 84 addCutplane(2, 0.5f); 85 addCutplane(3, 0.5f); 86 86 87 87 //initialize the labels -
trunk/packages/vizservers/nanovis/Volume.h
r2870 r2877 55 55 Volume(float x, float y, float z, 56 56 int width, int height, int depth, 57 float size, int n _component,57 float size, int numComponents, 58 58 float *data, 59 59 double vmin, double vmax, 60 double non zero_min);60 double nonZeroMin); 61 61 62 62 virtual ~Volume(); … … 84 84 int isosurface() const 85 85 { 86 return _iso _surface;86 return _isosurface; 87 87 } 88 88 89 89 void isosurface(int iso) 90 90 { 91 _iso_surface = iso; 92 } 93 94 int n_components() const 95 { 96 return _n_components; 97 } 98 99 double nonzero_min() const 100 { 101 return _nonzero_min; 102 } 103 104 double range_nzero_min() const 105 { 106 return _nonzero_min; 107 } 108 109 int volume_type() const 110 { 111 return _volume_type; 91 _isosurface = iso; 92 } 93 94 int numComponents() const 95 { 96 return _numComponents; 97 } 98 99 double nonZeroMin() const 100 { 101 return _nonZeroMin; 102 } 103 104 int volumeType() const 105 { 106 return _volumeType; 112 107 } 113 108 … … 122 117 } 123 118 124 int n _slices() const125 { 126 return _n _slices;127 } 128 129 void n _slices(int n)130 { 131 _n _slices = n;119 int numSlices() const 120 { 121 return _numSlices; 122 } 123 124 void numSlices(int n) 125 { 126 _numSlices = n; 132 127 } 133 128 134 129 /// set the drawing size of volume 135 void set _size(float s);130 void setSize(float s); 136 131 137 132 // methods related to cutplanes 138 133 /// add a plane and returns its index 139 int add _cutplane(int orientation, float location);140 141 void enable _cutplane(int index);142 143 void disable _cutplane(int index);144 145 void move _cutplane(int index, float location);146 147 CutPlane *get _cutplane(int index);134 int addCutplane(int orientation, float location); 135 136 void enableCutplane(int index); 137 138 void disableCutplane(int index); 139 140 void moveCutplane(int index, float location); 141 142 CutPlane *getCutplane(int index); 148 143 149 144 /// returns the number of cutplanes in the volume 150 int get _cutplane_count();145 int getCutplaneCount(); 151 146 152 147 /// check if a cutplane is enabled 153 bool cutplane_is_enabled(int index) const;148 bool isCutplaneEnabled(int index) const; 154 149 155 150 // methods related to shading. These parameters are per volume 151 152 /// Get specular exponent 156 153 float specular() const 157 154 { … … 159 156 } 160 157 158 /// Set specular exponent [0,128] 161 159 void specular(float value) 162 160 { 161 if (value < 0.0f) value = 0.0f; 162 if (value > 128.0f) value = 128.0f; 163 163 _specular = value; 164 164 } 165 165 166 /// Get diffuse coefficient 166 167 float diffuse() const 167 168 { … … 169 170 } 170 171 172 /// Set diffuse coefficient [0,1] 171 173 void diffuse(float value) 172 174 { 175 if (value < 0.0f) value = 0.0f; 176 if (value > 1.0f) value = 1.0f; 173 177 _diffuse = value; 174 178 } 175 179 176 float opacity _scale() const177 { 178 return _opacity _scale;179 } 180 181 void opacity _scale(float value)182 { 183 _opacity _scale = value;184 } 185 186 void data _enabled(bool value)187 { 188 _data _enabled = value;189 } 190 191 bool data _enabled() const192 { 193 return _data _enabled;180 float opacityScale() const 181 { 182 return _opacityScale; 183 } 184 185 void opacityScale(float value) 186 { 187 _opacityScale = value; 188 } 189 190 void dataEnabled(bool value) 191 { 192 _dataEnabled = value; 193 } 194 195 bool dataEnabled() const 196 { 197 return _dataEnabled; 194 198 } 195 199 196 200 void outline(bool value) 197 201 { 198 _outline _enabled = value;202 _outlineEnabled = value; 199 203 } 200 204 201 205 bool outline() 202 206 { 203 return _outline _enabled;207 return _outlineEnabled; 204 208 } 205 209 … … 214 218 } 215 219 216 void set _outline_color(float *rgb);217 218 void get _outline_color(float *rgb);219 220 void setOutlineColor(float *rgb); 221 222 void getOutlineColor(float *rgb); 223 220 224 /// change the label displayed on an axis 221 void set _label(int axis, const char *txt);225 void setLabel(int axis, const char *txt); 222 226 223 227 void setPhysicalBBox(const Vector3& min, const Vector3& max); … … 237 241 } 238 242 239 float aspect _ratio_width;240 float aspect _ratio_height;241 float aspect _ratio_depth;243 float aspectRatioWidth; 244 float aspectRatioHeight; 245 float aspectRatioDepth; 242 246 243 247 GLuint id; ///< OpenGL textue identifier (==_tex->id) … … 264 268 std::string label[3]; ///< the labels along each axis 0:x, 1:y, 2:z 265 269 266 static bool update _pending;270 static bool updatePending; 267 271 static double valueMin, valueMax; 268 272 … … 281 285 * the object is to appear like plastic 282 286 */ 283 float _opacity _scale;287 float _opacityScale; 284 288 285 289 const char *_name; 286 Vector3 _physical _min;287 Vector3 _physical _max;290 Vector3 _physicalMin; 291 Vector3 _physicalMax; 288 292 float *_data; 289 293 290 int _n _components;291 292 double _non zero_min;294 int _numComponents; 295 296 double _nonZeroMin; 293 297 294 298 std::vector<CutPlane> _plane; ///< cut planes … … 302 306 * the better quality, lower speed. 303 307 */ 304 int _n _slices;308 int _numSlices; 305 309 bool _enabled; 306 bool _data _enabled; ///< show/hide cloud of volume data307 bool _outline _enabled; ///< show/hide outline around volume308 Color _outline _color; ///< color for outline around volume309 int _volume _type; ///< cubic or zincblende310 int _iso _surface;310 bool _dataEnabled; ///< show/hide cloud of volume data 311 bool _outlineEnabled; ///< show/hide outline around volume 312 Color _outlineColor; ///< color for outline around volume 313 int _volumeType; ///< cubic or zincblende 314 int _isosurface; 311 315 }; 312 316 313 317 inline int 314 Volume::add _cutplane(int orientation, float location)318 Volume::addCutplane(int orientation, float location) 315 319 { 316 320 _plane.push_back(CutPlane(orientation, location)); … … 319 323 320 324 inline void 321 Volume::enable _cutplane(int index)325 Volume::enableCutplane(int index) 322 326 { 323 327 //assert(index < plane.size()); … … 325 329 } 326 330 inline void 327 Volume::disable _cutplane(int index)331 Volume::disableCutplane(int index) 328 332 { 329 333 //assert(index < plane.size()); … … 332 336 333 337 inline void 334 Volume::move _cutplane(int index, float location)338 Volume::moveCutplane(int index, float location) 335 339 { 336 340 //assert(index < plane.size()); … … 339 343 340 344 inline CutPlane * 341 Volume::get _cutplane(int index)345 Volume::getCutplane(int index) 342 346 { 343 347 //assert(index < plane.size()); … … 346 350 347 351 inline int 348 Volume::get _cutplane_count()352 Volume::getCutplaneCount() 349 353 { 350 354 return _plane.size(); … … 352 356 353 357 inline bool 354 Volume:: cutplane_is_enabled(int index) const358 Volume::isCutplaneEnabled(int index) const 355 359 { 356 360 //assert(index < plane.size()); … … 359 363 360 364 inline void 361 Volume::set _size(float s)365 Volume::setSize(float s) 362 366 { 363 367 size = s; 364 aspect _ratio_width = s * _tex->aspectRatioWidth();365 aspect _ratio_height = s * _tex->aspectRatioHeight();366 aspect _ratio_depth = s * _tex->aspectRatioDepth();367 } 368 369 inline void 370 Volume::set _outline_color(float *rgb)371 { 372 _outline _color = Color(rgb[0], rgb[1], rgb[2]);373 } 374 375 inline void 376 Volume::get _outline_color(float *rgb)377 { 378 _outline _color.getRGB(rgb);379 } 380 381 inline void 382 Volume::set _label(int axis, const char* txt)368 aspectRatioWidth = s * _tex->aspectRatioWidth(); 369 aspectRatioHeight = s * _tex->aspectRatioHeight(); 370 aspectRatioDepth = s * _tex->aspectRatioDepth(); 371 } 372 373 inline void 374 Volume::setOutlineColor(float *rgb) 375 { 376 _outlineColor = Color(rgb[0], rgb[1], rgb[2]); 377 } 378 379 inline void 380 Volume::getOutlineColor(float *rgb) 381 { 382 _outlineColor.getRGB(rgb); 383 } 384 385 inline void 386 Volume::setLabel(int axis, const char* txt) 383 387 { 384 388 label[axis] = txt; … … 388 392 Volume::setPhysicalBBox(const Vector3& min, const Vector3& max) 389 393 { 390 _physical _min = min;391 _physical _max = max;394 _physicalMin = min; 395 _physicalMax = max; 392 396 393 397 /* 394 aspect _ratio_width = size * 1;395 aspect _ratio_height = size * (max.y - min.y) / (max.x - min.x);396 aspect _ratio_depth = size* (max.z - min.z) / (max.x - min.x);398 aspectRatioWidth = size * 1; 399 aspectRatioHeight = size * (max.y - min.y) / (max.x - min.x); 400 aspectRatioDepth = size* (max.z - min.z) / (max.x - min.x); 397 401 398 402 location.x = -0.5; 399 location.y = -0.5* aspect _ratio_height;400 location.z = -0.5* aspect _ratio_depth;403 location.y = -0.5* aspectRatioHeight; 404 location.z = -0.5* aspectRatioDepth; 401 405 */ 402 406 } … … 405 409 Volume::getPhysicalBBoxMin() const 406 410 { 407 return _physical _min;411 return _physicalMin; 408 412 } 409 413 … … 411 415 Volume::getPhysicalBBoxMax() const 412 416 { 413 return _physical _max;417 return _physicalMax; 414 418 } 415 419 -
trunk/packages/vizservers/nanovis/VolumeInterpolator.cpp
r2853 r2877 18 18 _numBytes(0), 19 19 _dataCount(0), 20 _n _components(0),20 _numComponents(0), 21 21 _referenceOfVolume(0) 22 22 { … … 34 34 struct timeval clock; 35 35 gettimeofday(&clock, NULL); 36 _start _time = clock.tv_sec + clock.tv_usec/1000000.0;36 _startTime = clock.tv_sec + clock.tv_usec/1000000.0; 37 37 TRACE("End Start - VolumeInterpolator\n"); 38 38 } … … 68 68 *((Vector3*)(result + 1)) = normal; 69 69 70 result += _n _components;71 data1 += _n _components;72 data2 += _n _components;70 result += _numComponents; 71 data1 += _numComponents; 72 data2 += _numComponents; 73 73 } 74 74 … … 125 125 _volumes[0]->height != refPtr->height || 126 126 _volumes[0]->depth != refPtr->depth || 127 _volumes[0]->n _components() != refPtr->n_components()) {127 _volumes[0]->numComponents() != refPtr->numComponents()) { 128 128 TRACE("The volume should be the same width, height, number of components\n"); 129 129 return; … … 131 131 } else { 132 132 _dataCount = refPtr->width * refPtr->height * refPtr->depth; 133 _n _components = refPtr->n_components();134 _numBytes = _dataCount * _n _components * sizeof(float);133 _numComponents = refPtr->numComponents(); 134 _numBytes = _dataCount * _numComponents * sizeof(float); 135 135 Vector3 loc = refPtr->location(); 136 136 _volume = new Volume(loc.x, loc.y, loc.z, 137 137 refPtr->width, refPtr->height, refPtr->depth, 138 138 refPtr->size, 139 refPtr->n _components(),139 refPtr->numComponents(), 140 140 refPtr->data(), 141 141 refPtr->wAxis.min(), 142 142 refPtr->wAxis.max(), 143 refPtr->non zero_min());143 refPtr->nonZeroMin()); 144 144 /* 145 145 _referenceOfVolume = refPtr->dataID(); 146 146 */ 147 _volume->n _slices(256-1);148 _volume->disable _cutplane(0);149 _volume->disable _cutplane(1);150 _volume->disable _cutplane(2);147 _volume->numSlices(256-1); 148 _volume->disableCutplane(0); 149 _volume->disableCutplane(1); 150 _volume->disableCutplane(2); 151 151 _volume->visible(true); 152 _volume->data _enabled(true);152 _volume->dataEnabled(true); 153 153 _volume->specular(refPtr->specular()); 154 154 _volume->diffuse(refPtr->diffuse()); 155 _volume->opacity _scale(refPtr->opacity_scale());155 _volume->opacityScale(refPtr->opacityScale()); 156 156 _volume->isosurface(0); 157 157 TRACE("VOL : location %f %f %f\n\tid : %s\n", loc.x, loc.y, loc.z, -
trunk/packages/vizservers/nanovis/VolumeInterpolator.h
r2853 r2877 24 24 void computeKeys(float fraction, int count, float *interp, int *key1, int *key2); 25 25 26 bool is _started() const;26 bool isStarted() const; 27 27 28 28 double getInterval() const; … … 43 43 unsigned int _numBytes; 44 44 unsigned int _dataCount; 45 unsigned int _n _components;45 unsigned int _numComponents; 46 46 unsigned int _referenceOfVolume; 47 double _start _time;47 double _startTime; 48 48 }; 49 49 50 inline bool VolumeInterpolator::is _started() const50 inline bool VolumeInterpolator::isStarted() const 51 51 { 52 52 return _started; … … 55 55 inline double VolumeInterpolator::getStartTime() const 56 56 { 57 return _start _time;57 return _startTime; 58 58 } 59 59 -
trunk/packages/vizservers/nanovis/VolumeRenderer.cpp
r2853 r2877 40 40 41 41 VolumeRenderer::VolumeRenderer() : 42 slice_mode(false),43 volume_mode(true)44 { 45 init _shaders();42 _sliceMode(false), 43 _volumeMode(true) 44 { 45 initShaders(); 46 46 47 47 const char *path = R2FilePath::getInstance()->getPath("Font.bmp"); … … 50 50 assert(path != NULL); 51 51 } 52 init _font(path);52 initFont(path); 53 53 delete [] path; 54 54 _volumeInterpolator = new VolumeInterpolator(); … … 64 64 65 65 //initialize the volume shaders 66 void VolumeRenderer::init _shaders()66 void VolumeRenderer::initShaders() 67 67 { 68 68 //standard vertex program … … 85 85 struct SortElement { 86 86 float z; 87 int volume _id;88 int slice _id;87 int volumeId; 88 int sliceId; 89 89 90 90 SortElement(float _z, int _v, int _s) : 91 z(_z), volume_id(_v), slice_id(_s) 91 z(_z), 92 volumeId(_v), 93 sliceId(_s) 92 94 {} 93 95 }; 94 96 95 int slice_sort(const void* a, const void*b)97 static int sliceSort(const void *a, const void *b) 96 98 { 97 99 if ((*((SortElement*)a)).z > (*((SortElement*)b)).z) … … 102 104 103 105 void 104 VolumeRenderer::render _all()106 VolumeRenderer::renderAll() 105 107 { 106 108 size_t total_rendered_slices = 0; 107 109 108 if (_volumeInterpolator->is _started()) {110 if (_volumeInterpolator->isStarted()) { 109 111 #ifdef notdef 110 112 ani_vol = _volumeInterpolator->getVolume(); … … 130 132 // at all. 131 133 volumes.push_back(volPtr); 132 volPtr->n _slices(256 - volumes.size());134 volPtr->numSlices(256 - volumes.size()); 133 135 } 134 136 … … 144 146 actual_slices[i] = 0; 145 147 146 int n_slices = volPtr->n _slices();148 int n_slices = volPtr->numSlices(); 147 149 if (volPtr->isosurface()) { 148 150 // double the number of slices … … 174 176 //get modelview matrix with no translation 175 177 glPushMatrix(); 176 glScalef(volPtr->aspect _ratio_width,177 volPtr->aspect _ratio_height,178 volPtr->aspect _ratio_depth);178 glScalef(volPtr->aspectRatioWidth, 179 volPtr->aspectRatioHeight, 180 volPtr->aspectRatioDepth); 179 181 180 182 glEnable(GL_DEPTH_TEST); … … 191 193 glPushMatrix(); 192 194 glTranslatef(shift_4d.x, shift_4d.y, shift_4d.z); 193 glScalef(volPtr->aspect _ratio_width,194 volPtr->aspect _ratio_height,195 volPtr->aspect _ratio_depth);195 glScalef(volPtr->aspectRatioWidth, 196 volPtr->aspectRatioHeight, 197 volPtr->aspectRatioDepth); 196 198 GLfloat mv_trans[16]; 197 199 glGetFloatv(GL_MODELVIEW_MATRIX, mv_trans); … … 204 206 if (volPtr->outline()) { 205 207 float olcolor[3]; 206 volPtr->get _outline_color(olcolor);207 draw _bounding_box(x0, y0, z0, x0+1, y0+1, z0+1,208 volPtr->getOutlineColor(olcolor); 209 drawBoundingBox(x0, y0, z0, x0+1, y0+1, z0+1, 208 210 (double)olcolor[0], (double)olcolor[1], (double)olcolor[2], 209 211 1.5); … … 223 225 volume_planes[j].transform(model_view_no_trans); 224 226 } 225 get _near_far_z(mv_no_trans, zNear, zFar);227 getNearFarZ(mv_no_trans, zNear, zFar); 226 228 227 229 //compute actual rendering slices … … 229 231 size_t n_actual_slices; 230 232 231 if (volPtr->data _enabled()) {233 if (volPtr->dataEnabled()) { 232 234 n_actual_slices = (int)(fabs(zNear-zFar)/z_step + 1); 233 235 polys[i] = new ConvexPolygon*[n_actual_slices]; … … 249 251 250 252 ConvexPolygon static_poly; 251 for (int j = 0; j < volPtr->get _cutplane_count(); j++) {252 if (!volPtr-> cutplane_is_enabled(j)) {253 for (int j = 0; j < volPtr->getCutplaneCount(); j++) { 254 if (!volPtr->isCutplaneEnabled(j)) { 253 255 continue; 254 256 } 255 float offset = volPtr->get _cutplane(j)->offset;256 int axis = volPtr->get _cutplane(j)->orient;257 float offset = volPtr->getCutplane(j)->offset; 258 int axis = volPtr->getCutplane(j)->orient; 257 259 258 260 if (axis == 3) { … … 284 286 p->vertices.clear(); 285 287 286 p->append _vertex(vert1);287 p->append _vertex(vert2);288 p->append _vertex(vert3);289 p->append _vertex(vert4);288 p->appendVertex(vert1); 289 p->appendVertex(vert2); 290 p->appendVertex(vert3); 291 p->appendVertex(vert4); 290 292 291 293 for (size_t k = 0; k < 6; k++) { … … 297 299 298 300 glPushMatrix(); 299 glScalef(volPtr->aspect _ratio_width,300 volPtr->aspect _ratio_height,301 volPtr->aspect _ratio_depth);302 303 activate _volume_shader(volPtr, true);301 glScalef(volPtr->aspectRatioWidth, 302 volPtr->aspectRatioHeight, 303 volPtr->aspectRatioDepth); 304 305 activateVolumeShader(volPtr, true); 304 306 glPopMatrix(); 305 307 … … 308 310 309 311 glBegin(GL_POLYGON); 310 p-> Emit(true);312 p->emit(true); 311 313 glEnd(); 312 314 glDisable(GL_DEPTH_TEST); 313 315 314 deactivate _volume_shader();316 deactivateVolumeShader(); 315 317 } //done cutplanes 316 318 … … 334 336 335 337 poly->vertices.clear(); 336 poly->set _id(i);338 poly->setId(i); 337 339 338 340 //Setting Z-coordinate … … 342 344 vert4.z = slice_z; 343 345 344 poly->append _vertex(vert1);345 poly->append _vertex(vert2);346 poly->append _vertex(vert3);347 poly->append _vertex(vert4);346 poly->appendVertex(vert1); 347 poly->appendVertex(vert2); 348 poly->appendVertex(vert3); 349 poly->appendVertex(vert4); 348 350 349 351 for (size_t k = 0; k < 6; k++) { … … 377 379 378 380 //sort them 379 qsort(slices, total_rendered_slices, sizeof(SortElement), slice _sort);381 qsort(slices, total_rendered_slices, sizeof(SortElement), sliceSort); 380 382 381 383 //Now we are ready to render all the slices from back to front … … 386 388 Volume *volPtr = NULL; 387 389 388 int volume_index = slices[i].volume _id;389 int slice_index = slices[i].slice _id;390 int volume_index = slices[i].volumeId; 391 int slice_index = slices[i].sliceId; 390 392 ConvexPolygon *cur = polys[volume_index][slice_index]; 391 393 … … 393 395 394 396 glPushMatrix(); 395 glScalef(volPtr->aspect_ratio_width, volPtr->aspect_ratio_height, 396 volPtr->aspect_ratio_depth); 397 glScalef(volPtr->aspectRatioWidth, 398 volPtr->aspectRatioHeight, 399 volPtr->aspectRatioDepth); 397 400 398 401 #ifdef notdef … … 400 403 volPtr->name(), volPtr, slice_index, volume_index); 401 404 #endif 402 activate _volume_shader(volPtr, false);405 activateVolumeShader(volPtr, false); 403 406 glPopMatrix(); 404 407 405 408 glBegin(GL_POLYGON); 406 cur-> Emit(true);409 cur->emit(true); 407 410 glEnd(); 408 411 409 deactivate _volume_shader();412 deactivateVolumeShader(); 410 413 } 411 414 … … 428 431 429 432 void 430 VolumeRenderer::draw _bounding_box(float x0, float y0, float z0,431 432 433 433 VolumeRenderer::drawBoundingBox(float x0, float y0, float z0, 434 float x1, float y1, float z1, 435 float r, float g, float b, 436 float line_width) 434 437 { 435 438 glPushMatrix(); … … 547 550 548 551 void 549 VolumeRenderer::activate _volume_shader(Volume* volPtr, bool slice_mode)552 VolumeRenderer::activateVolumeShader(Volume* volPtr, bool sliceMode) 550 553 { 551 554 //vertex shader 552 555 _stdVertexShader->bind(); 553 556 TransferFunction *tfPtr = volPtr->transferFunction(); 554 if (volPtr->volume_type() == Volume::CUBIC) { 555 _regularVolumeShader->bind(tfPtr->id(), volPtr, slice_mode); 556 } else if (volPtr->volume_type() == Volume::ZINCBLENDE) { 557 _zincBlendeShader->bind(tfPtr->id(), volPtr, slice_mode); 558 } 559 } 560 void VolumeRenderer::deactivate_volume_shader() 557 if (volPtr->volumeType() == Volume::CUBIC) { 558 _regularVolumeShader->bind(tfPtr->id(), volPtr, sliceMode); 559 } else if (volPtr->volumeType() == Volume::ZINCBLENDE) { 560 _zincBlendeShader->bind(tfPtr->id(), volPtr, sliceMode); 561 } 562 } 563 564 void VolumeRenderer::deactivateVolumeShader() 561 565 { 562 566 _stdVertexShader->unbind(); … … 565 569 } 566 570 567 void VolumeRenderer::get _near_far_z(const Mat4x4& mv, double& zNear, double& zFar)571 void VolumeRenderer::getNearFarZ(const Mat4x4& mv, double& zNear, double& zFar) 568 572 { 569 573 double x0 = 0; … … 602 606 603 607 bool 604 VolumeRenderer::init _font(const char *filename)608 VolumeRenderer::initFont(const char *filename) 605 609 { 606 610 FILE *f; … … 731 735 732 736 //create opengl texture 733 glGenTextures(1, & font_texture);734 glBindTexture(GL_TEXTURE_2D, font_texture);737 glGenTextures(1, &_fontTexture); 738 glBindTexture(GL_TEXTURE_2D, _fontTexture); 735 739 //glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data); 736 740 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data_with_alpha); … … 741 745 free(data_with_alpha); 742 746 743 build _font();747 buildFont(); 744 748 return (glGetError()==0); 745 749 … … 750 754 751 755 void 752 VolumeRenderer::draw _label(Volume* vol)756 VolumeRenderer::drawLabel(Volume* vol) 753 757 { 754 758 //glEnable(GL_TEXTURE_2D); … … 762 766 glPushMatrix(); 763 767 764 glTranslatef(.5*vol->aspect_ratio_width, vol->aspect_ratio_height, 765 -0.1*vol->aspect_ratio_depth); 768 glTranslatef(.5 * vol->aspectRatioWidth, 769 vol->aspectRatioHeight, 770 -0.1 * vol->aspectRatioDepth); 766 771 glRotatef(180, 0, 0, 1); 767 772 glRotatef(90, 1, 0, 0); … … 777 782 length = vol->label[1].size(); 778 783 glPushMatrix(); 779 glTranslatef(vol->aspect_ratio_width, 0.5*vol->aspect_ratio_height, -0.1*vol->aspect_ratio_depth); 784 glTranslatef(vol->aspectRatioWidth, 785 0.5*vol->aspectRatioHeight, 786 -0.1*vol->aspectRatioDepth); 780 787 glRotatef(90, 0, 1, 0); 781 788 glRotatef(90, 0, 0, 1); … … 791 798 length = vol->label[2].size(); 792 799 glPushMatrix(); 793 glTranslatef(0., 1.*vol->aspect_ratio_height, 0.5*vol->aspect_ratio_depth); 800 glTranslatef(0., 801 1. * vol->aspectRatioHeight, 802 0.5 * vol->aspectRatioDepth); 794 803 glRotatef(90, 0, 1, 0); 795 804 … … 805 814 806 815 void 807 VolumeRenderer::build _font()816 VolumeRenderer::buildFont() 808 817 { 809 818 GLfloat cx, cy; /* the character coordinates in our texture */ 810 font_base = glGenLists(256);811 glBindTexture(GL_TEXTURE_2D, font_texture);819 _fontBase = glGenLists(256); 820 glBindTexture(GL_TEXTURE_2D, _fontTexture); 812 821 for (int loop = 0; loop < 256; loop++) { 813 822 cx = (float) (loop % 16) / 16.0f; 814 823 cy = (float) (loop / 16) / 16.0f; 815 glNewList( font_base + loop, GL_COMPILE);824 glNewList(_fontBase + loop, GL_COMPILE); 816 825 glBegin(GL_QUADS); 817 826 glTexCoord2f(cx, 1 - cy - 0.0625f); … … 835 844 set = 1; 836 845 } 837 glBindTexture(GL_TEXTURE_2D, font_texture);838 glListBase( font_base - 32 + (128 * set));846 glBindTexture(GL_TEXTURE_2D, _fontTexture); 847 glListBase(_fontBase - 32 + (128 * set)); 839 848 glCallLists(strlen(string), GL_BYTE, string); 840 849 } -
trunk/packages/vizservers/nanovis/VolumeRenderer.h
r2853 r2877 35 35 36 36 /// render all enabled volumes 37 void render _all();37 void renderAll(); 38 38 39 39 void specular(float val); … … 42 42 43 43 /// control independently 44 void set _slice_mode(bool val)44 void setSliceMode(bool val) 45 45 { 46 slice_mode = val;46 _sliceMode = val; 47 47 } 48 48 49 void set _volume_mode(bool val)49 void setVolumeMode(bool val) 50 50 { 51 volume_mode = val;51 _volumeMode = val; 52 52 } 53 53 54 54 /// switch_cutplane_mode 55 void switch _slice_mode()55 void switchSliceMode() 56 56 { 57 slice_mode = (!slice_mode);57 _sliceMode = (!_sliceMode); 58 58 } 59 59 60 void switch _volume_mode()60 void switchVolumeMode() 61 61 { 62 volume_mode = (!volume_mode);62 _volumeMode = (!_volumeMode); 63 63 } 64 64 … … 91 91 92 92 private: 93 void init _shaders();93 void initShaders(); 94 94 95 void activate _volume_shader(Volume *vol, bool slice_mode);95 void activateVolumeShader(Volume *vol, bool slice_mode); 96 96 97 void deactivate _volume_shader();97 void deactivateVolumeShader(); 98 98 99 void draw_bounding_box(float x0, float y0, float z0,100 101 99 void drawBoundingBox(float x0, float y0, float z0, 100 float x1, float y1, float z1, 101 float r, float g, float b, float line_width); 102 102 103 void get _near_far_z(const Mat4x4& mv, double& zNear, double& zFar);103 void getNearFarZ(const Mat4x4& mv, double& zNear, double& zFar); 104 104 105 bool init _font(const char *filename);105 bool initFont(const char *filename); 106 106 107 107 /// there are two sets of font in the texture. 0, 1 … … 109 109 110 110 /// draw label using bitmap texture 111 void draw _label(Volume *vol);111 void drawLabel(Volume *vol); 112 112 113 113 /// Register the location of each alphabet in 114 void build _font();114 void buildFont(); 115 115 116 116 VolumeInterpolator *_volumeInterpolator; 117 117 118 bool slice_mode; ///< enable cut planes119 bool volume_mode; ///< enable full volume rendering118 bool _sliceMode; ///< enable cut planes 119 bool _volumeMode; ///< enable full volume rendering 120 120 121 121 /** … … 146 146 147 147 //standard vertex shader parameters 148 CGprogram m_vert_std_vprog;149 CGparameter m_mvp_vert_std_param;150 CGparameter m_mvi_vert_std_param;151 GLuint font_base; //The base of the font display list.152 GLuint font_texture; //the id of the font texture148 CGprogram _vertStdVprog; 149 CGparameter _mvpVertStdParam; 150 CGparameter _mviVertStdParam; 151 GLuint _fontBase; ///< The base of the font display list. 152 GLuint _fontTexture; ///< The id of the font texture 153 153 }; 154 154 -
trunk/packages/vizservers/nanovis/ZincBlendeVolume.cpp
r2844 r2877 24 24 float *dataVolumeA, float *dataVolumeB, 25 25 double v0, double v1, double non_zeromin, 26 const Vector3& cellS ize) :26 const Vector3& cellSz) : 27 27 Volume(x, y, z, w, h, d, s, n, dataVolumeA, v0, v1, non_zeromin), 28 cell _size(cellSize)28 cellSize(cellSz) 29 29 { 30 30 //label it as zincblende 31 _volume _type = ZINCBLENDE;31 _volumeType = ZINCBLENDE; 32 32 33 33 //store member tex initialize in Volume() as zincblende_tex[0] 34 34 assert(_tex); 35 zincblende _tex[0] = _tex;35 zincblendeTex[0] = _tex; 36 36 37 37 //now add another tex as zincblende_tex[1] … … 40 40 secondTex->initialize(dataVolumeB); 41 41 42 zincblende _tex[1] = secondTex;42 zincblendeTex[1] = secondTex; 43 43 } 44 44 … … 48 48 //if (zincblende_tex[0]) 49 49 // delete zincblende_tex[0]; 50 if (zincblende _tex[1])51 delete zincblende _tex[1];50 if (zincblendeTex[1]) 51 delete zincblendeTex[1]; 52 52 } -
trunk/packages/vizservers/nanovis/ZincBlendeVolume.h
r2844 r2877 30 30 virtual ~ZincBlendeVolume(); 31 31 32 Texture3D *zincblende _tex[2];//the textures of two cubic volumes33 Vector3 cell _size; //the cell size in texture space32 Texture3D *zincblendeTex[2]; //the textures of two cubic volumes 33 Vector3 cellSize; //the cell size in texture space 34 34 }; 35 35 -
trunk/packages/vizservers/nanovis/config.h
r2841 r2877 18 18 #define CONFIG_H__ 19 19 20 #define NV40 /* Uncomment if using 6 series 21 * card. By default we assume older 22 * card the 5xxx series */ 20 /* 21 * GeForce 6 series and above cards support non-power-of-two texture 22 * dimensions. If using a 5 series card, disable this define 23 */ 24 #define HAVE_NPOT_TEXTURES 25 26 /* 27 * GeForce 6 series and above cards support 16- or 32-bit float filtering 28 * and blending. If using a 5 series card, disable this define 29 */ 30 #define HAVE_FLOAT_TEXTURES 31 32 /* 33 * GeForce 8 series cards support 32-bit float filtering and blending. 34 * If using a 6 or 7 series card, enable this define to use 16-bit float 35 * textures and blending 36 */ 37 #define USE_HALF_FLOAT 38 23 39 #define XINETD /* Enable render server. */ 24 40 //#define EVENTLOG /* Enable event logging. */ 25 41 //#define DO_RLE /* Do run length compression. */ 26 42 43 #define KEEPSTATS 1 44 27 45 /* 28 46 * Controls if debug trace logging is enabled 29 47 */ 30 //#define WANT_TRACE 48 #define WANT_TRACE 49 50 //#define OLD_CAMERA 31 51 32 52 /* … … 39 59 40 60 /* 41 * The following define controls whether new load_volume_stream or 42 * load_volume_stream2 are used to load DX data. The difference is that 43 * load_volume_stream2 doesn't do any interpolation of the points to a coarser 44 * mesh. Right now, we're using load_volume_stream2 to make isosurfaces 45 * work correctly. 46 61 * The following define controls whether the new or old load_volume_stream 62 * implementation is used to load DX data. The difference is that the old 63 * implementation doesn't do any interpolation of the points to a coarser 64 * mesh. Setting ISO_TEST to 1 will cause the old implementation to be 65 * used, which makes isosurfaces work correctly (FIXME: is this still 66 * true?) 67 * 47 68 * [In the future, we'll use the OpenDX library reader and determine at 48 69 * runtime if mesh decimation is required] 49 70 */ 50 71 #define ISO_TEST 0 72 73 /* 74 * Determines if Sobel filter is applied to gradients when loading a 75 * volume 76 */ 77 #define FILTER_GRADIENTS 1 51 78 52 79 /* -
trunk/packages/vizservers/nanovis/dxReader.cpp
r2874 r2877 35 35 #include "dxReaderCommon.h" 36 36 37 #include "config.h" 37 38 #include "nanovis.h" 38 39 #include "Unirect.h" … … 265 266 dz = nz; 266 267 267 volPtr = NanoVis::load _volume(tag, nx, ny, nz, 4, data,268 268 volPtr = NanoVis::loadVolume(tag, nx, ny, nz, 4, data, 269 vmin, vmax, nzero_min); 269 270 volPtr->xAxis.SetRange(x0, x0 + (nx * dx)); 270 271 volPtr->yAxis.SetRange(y0, y0 + (ny * dy)); 271 272 volPtr->zAxis.SetRange(z0, z0 + (nz * dz)); 272 273 volPtr->wAxis.SetRange(vmin, vmax); 273 volPtr->update _pending = true;274 volPtr->updatePending = true; 274 275 delete [] data; 275 276 } else { … … 319 320 ny = (int)ceil(dy/dmin); 320 321 nz = (int)ceil(dz/dmin); 321 #ifndef NV40322 #ifndef HAVE_NPOT_TEXTURES 322 323 // must be an even power of 2 for older cards 323 324 nx = (int)pow(2.0, ceil(log10((double)nx)/log10(2.0))); … … 358 359 computeSimpleGradient(data, nx, ny, nz); 359 360 360 volPtr = NanoVis::load _volume(tag, nx, ny, nz, 4, data,361 362 361 volPtr = NanoVis::loadVolume(tag, nx, ny, nz, 4, data, 362 field.valueMin(), field.valueMax(), 363 nzero_min); 363 364 volPtr->xAxis.SetRange(field.rangeMin(Rappture::xaxis), 364 365 field.rangeMax(Rappture::xaxis)); … … 368 369 field.rangeMax(Rappture::zaxis)); 369 370 volPtr->wAxis.SetRange(field.valueMin(), field.valueMax()); 370 volPtr->update _pending = true;371 volPtr->updatePending = true; 371 372 delete [] data; 372 373 } … … 590 591 nz = (int)ceil(dz/dmin); 591 592 592 #ifndef NV40593 #ifndef HAVE_NPOT_TEXTURES 593 594 // must be an even power of 2 for older cards 594 595 nx = (int)pow(2.0, ceil(log10((double)nx)/log10(2.0))); … … 597 598 #endif 598 599 599 //#define _SOBEL_ 600 #ifdef _SOBEL_ 600 #ifdef FILTER_GRADIENTS 601 601 const int step = 1; 602 602 float *cdata = new float[nx*ny*nz * step]; … … 668 668 field.valueMin(), field.valueMax(), nzero_min); 669 669 670 volPtr = NanoVis::load _volume(tag, nx, ny, nz, 4, data,671 672 670 volPtr = NanoVis::loadVolume(tag, nx, ny, nz, 4, data, 671 field.valueMin(), field.valueMax(), 672 nzero_min); 673 673 volPtr->xAxis.SetRange(field.rangeMin(Rappture::xaxis), 674 674 field.rangeMax(Rappture::xaxis)); … … 678 678 field.rangeMax(Rappture::zaxis)); 679 679 volPtr->wAxis.SetRange(field.valueMin(), field.valueMax()); 680 volPtr->update _pending = true;680 volPtr->updatePending = true; 681 681 // TBD.. 682 682 #if 0 && defined(USE_POINTSET_RENDERER) … … 735 735 ny = (int)ceil(dy/dmin); 736 736 nz = (int)ceil(dz/dmin); 737 #ifndef NV40737 #ifndef HAVE_NPOT_TEXTURES 738 738 // must be an even power of 2 for older cards 739 739 nx = (int)pow(2.0, ceil(log10((double)nx)/log10(2.0))); … … 774 774 computeSimpleGradient(data, nx, ny, nz); 775 775 776 volPtr = NanoVis::load _volume(tag, nx, ny, nz, 4, data,777 778 776 volPtr = NanoVis::loadVolume(tag, nx, ny, nz, 4, data, 777 field.valueMin(), field.valueMax(), 778 nzero_min); 779 779 volPtr->xAxis.SetRange(field.rangeMin(Rappture::xaxis), 780 780 field.rangeMax(Rappture::xaxis)); … … 784 784 field.rangeMax(Rappture::zaxis)); 785 785 volPtr->wAxis.SetRange(field.valueMin(), field.valueMax()); 786 volPtr->update _pending = true;786 volPtr->updatePending = true; 787 787 // TBD.. 788 788 #if 0 && defined(USE_POINTSET_RENDERER) -
trunk/packages/vizservers/nanovis/dxReader.h
r2853 r2877 14 14 std::iostream& fin); 15 15 16 extern Volume *17 load_volume_stream2(Rappture::Outcome& status, const char *tag,18 std::iostream& fin);19 20 16 #endif -
trunk/packages/vizservers/nanovis/dxReaderCommon.cpp
r2874 r2877 16 16 for (sindex = 0; sindex < size; ++sindex) { 17 17 data[ngen++] = scalar[sindex]; 18 data[ngen++] = g[sindex].x;19 data[ngen++] = g[sindex].y;20 data[ngen++] = g[sindex].z;18 data[ngen++] = 1.0 - g[sindex].x; 19 data[ngen++] = 1.0 - g[sindex].y; 20 data[ngen++] = 1.0 - g[sindex].z; 21 21 } 22 22 return data; … … 29 29 if (v != 0.0f) { 30 30 for (int i = 0; i < count; ++i) { 31 fdata[i] = fdata[i] / v; 31 if (fdata[i] != -1.0) { 32 fdata[i] = (fdata[i] - min)/ v; 33 } 32 34 } 33 35 } 34 36 } 35 37 38 /** 39 * \brief Compute Sobel filtered gradients for a 3D volume 40 * 41 * This technique is fairly expensive in terms of memory and 42 * running time due to the filter extent. 43 */ 36 44 float * 37 computeGradient(float *fdata, int width, int height, int depth, 45 computeGradient(float *fdata, 46 int width, int height, int depth, 47 float dx, float dy, float dz, 38 48 float min, float max) 39 49 { … … 43 53 sizeof(float)); 44 54 int sizes[3] = { width, height, depth }; 45 computeGradients(tempGradients, fdata, sizes, DATRAW_FLOAT); 55 float spacing[3] = { dx, dy, dz }; 56 computeGradients(tempGradients, fdata, sizes, spacing, DATRAW_FLOAT); 46 57 filterGradients(tempGradients, sizes); 47 58 quantizeGradients(tempGradients, gradients, sizes, DATRAW_FLOAT); … … 53 64 } 54 65 66 /** 67 * \brief Compute gradients for a 3D volume with cubic cells 68 * 69 * The gradients are estimated using the central difference 70 * method. This function assumes the data are normalized 71 * to [0,1] with missing data/NaNs represented by a negative 72 * value. 73 * 74 * \param data Data array with X the fastest running. There 75 * should be 4 floats allocated for each node, with the 76 * first float containing the scalar value. The subsequent 77 * 3 floats will be filled with the x,y,z components of the 78 * gradient vector 79 * \param nx The number of nodes in the X direction 80 * \param ny The number of nodes in the Y direction 81 * \param nz The number of nodes in the Z direction 82 * \param dx The spacing (cell length) in the X direction 83 * \param dy The spacing (cell length) in the Y direction 84 * \param dz The spacing (cell length) in the Z direction 85 */ 55 86 void 56 computeSimpleGradient(float *data, int nx, int ny, int nz) 87 computeSimpleGradient(float *data, int nx, int ny, int nz, 88 float dx, float dy, float dz) 57 89 { 90 bool clampToEdge = true; 91 double borderVal = 0.0; 92 93 #define BORDER ((clampToEdge ? data[ngen] : borderVal)) 94 58 95 // Compute the gradient of this data. BE CAREFUL: center 59 96 // calculation on each node to avoid skew in either direction. … … 63 100 for (int ix = 0; ix < nx; ix++) { 64 101 // gradient in x-direction 65 double valm1 = (ix == 0) ? 0.0: data[ngen - 4];66 double valp1 = (ix == nx-1) ? 0.0: data[ngen + 4];102 double valm1 = (ix == 0) ? BORDER : data[ngen - 4]; 103 double valp1 = (ix == nx-1) ? BORDER : data[ngen + 4]; 67 104 if (valm1 < 0.0 || valp1 < 0.0) { 68 105 data[ngen+1] = 0.0; 69 106 } else { 70 data[ngen+1] = valp1-valm1; // assume dx=1 71 //data[ngen+1] = ((valp1-valm1) + 1.0) * 0.5; // assume dx=1 (ISO) 72 } 107 data[ngen+1] = -(valp1-valm1)/(2. * dx); 108 } 73 109 74 110 // gradient in y-direction 75 valm1 = (iy == 0) ? 0.0: data[ngen - 4*nx];76 valp1 = (iy == ny-1) ? 0.0: data[ngen + 4*nx];111 valm1 = (iy == 0) ? BORDER : data[ngen - 4*nx]; 112 valp1 = (iy == ny-1) ? BORDER : data[ngen + 4*nx]; 77 113 if (valm1 < 0.0 || valp1 < 0.0) { 78 114 data[ngen+2] = 0.0; 79 115 } else { 80 data[ngen+2] = valp1-valm1; // assume dy=1 81 //data[ngen+2] = ((valp1-valm1) + 1.0) * 0.5; // assume dy=1 (ISO) 116 data[ngen+2] = -(valp1-valm1)/(2. * dy); 82 117 } 83 118 84 119 // gradient in z-direction 85 valm1 = (iz == 0) ? 0.0: data[ngen - 4*nx*ny];86 valp1 = (iz == nz-1) ? 0.0: data[ngen + 4*nx*ny];120 valm1 = (iz == 0) ? BORDER : data[ngen - 4*nx*ny]; 121 valp1 = (iz == nz-1) ? BORDER : data[ngen + 4*nx*ny]; 87 122 if (valm1 < 0.0 || valp1 < 0.0) { 88 123 data[ngen+3] = 0.0; 89 124 } else { 90 data[ngen+3] = valp1-valm1; // assume dz=1 91 //data[ngen+3] = ((valp1-valm1) + 1.0) * 0.5; // assume dz=1 (ISO) 125 data[ngen+3] = -(valp1-valm1)/(2. * dz); 92 126 } 93 127 // Normalize and scale/bias to [0,1] range 128 // The volume shader will expand to [-1,1] 129 double len = sqrt(data[ngen+1]*data[ngen+1] + 130 data[ngen+2]*data[ngen+2] + 131 data[ngen+3]*data[ngen+3]); 132 if (len < 1.0e-6) { 133 data[ngen+1] = 0.0; 134 data[ngen+2] = 0.0; 135 data[ngen+3] = 0.0; 136 } else { 137 data[ngen+1] = (data[ngen+1]/len + 1.0) * 0.5; 138 data[ngen+2] = (data[ngen+2]/len + 1.0) * 0.5; 139 data[ngen+3] = (data[ngen+3]/len + 1.0) * 0.5; 140 } 94 141 ngen += 4; 95 142 } 96 143 } 97 144 } 145 146 #undef BORDER 98 147 } -
trunk/packages/vizservers/nanovis/dxReaderCommon.h
r2845 r2877 10 10 11 11 extern float * 12 computeGradient(float *fdata, int width, int height, int depth, 12 computeGradient(float *fdata, 13 int width, int height, int depth, 14 float dx, float dy, float dz, 13 15 float min, float max); 14 16 15 17 extern void 16 computeSimpleGradient(float *data, int nx, int ny, int nz); 18 computeSimpleGradient(float *data, int nx, int ny, int nz, 19 float dx = 1.0f, float dy = 1.0f, float dz = 1.0f); 17 20 18 21 #endif -
trunk/packages/vizservers/nanovis/nanovis.cpp
r2870 r2877 56 56 #include <GL/glut.h> 57 57 58 #include "config.h" 58 59 #include "nanovis.h" 59 60 #include "define.h" … … 96 97 }; 97 98 98 #define KEEPSTATS 199 100 99 #define CVT2SECS(x) ((double)(x).tv_sec) + ((double)(x).tv_usec * 1.0e-6) 101 100 … … 120 119 Tcl_HashTable NanoVis::volumeTable; 121 120 Tcl_HashTable NanoVis::heightmapTable; 122 VolumeRenderer *NanoVis::vol _renderer = NULL;121 VolumeRenderer *NanoVis::volRenderer = NULL; 123 122 #ifdef USE_POINTSET_RENDERER 124 PointSetRenderer *NanoVis::point set_renderer = NULL;123 PointSetRenderer *NanoVis::pointSetRenderer = NULL; 125 124 std::vector<PointSet *> NanoVis::pointSet; 126 125 #endif 127 126 128 PlaneRenderer *NanoVis::plane _renderer = NULL;127 PlaneRenderer *NanoVis::planeRenderer = NULL; 129 128 #if PLANE_CMD 130 129 // pointers to 2D planes, currently handle up 10 … … 132 131 #endif 133 132 Texture2D *NanoVis::legendTexture = NULL; 134 NvColorTableRenderer *NanoVis::color _table_renderer = NULL;133 NvColorTableRenderer *NanoVis::colorTableRenderer = NULL; 135 134 136 135 NvFlowVisRenderer *NanoVis::flowVisRenderer = NULL; … … 145 144 FILE *NanoVis::recfile = NULL; 146 145 147 bool NanoVis::axis_on = true; 148 bool NanoVis::config_pending = false; 149 bool NanoVis::debug_flag = false; 146 bool NanoVis::axisOn = true; 147 bool NanoVis::debugFlag = false; 150 148 151 149 Tcl_Interp *NanoVis::interp; … … 153 151 154 152 //frame buffer for final rendering 155 GLuint NanoVis::_final _color_tex = 0;156 GLuint NanoVis::_final _depth_rb = 0;157 GLuint NanoVis::_final _fbo = 0;158 int NanoVis::render _window = 0; /* GLUT handle for the render window */159 int NanoVis::win _width = NPIX; /* Width of the render window */160 int NanoVis::win _height = NPIX; /* Height of the render window */161 162 unsigned char* NanoVis::screen _buffer = NULL;153 GLuint NanoVis::_finalColorTex = 0; 154 GLuint NanoVis::_finalDepthRb = 0; 155 GLuint NanoVis::_finalFbo = 0; 156 int NanoVis::renderWindow = 0; /* GLUT handle for the render window */ 157 int NanoVis::winWidth = NPIX; /* Width of the render window */ 158 int NanoVis::winHeight = NPIX; /* Height of the render window */ 159 160 unsigned char* NanoVis::screenBuffer = NULL; 163 161 164 162 unsigned int NanoVis::flags = 0; … … 179 177 180 178 /* FIXME: This variable is always true. */ 181 bool volume_mode = true;179 static bool volumeMode = true; 182 180 183 181 // in Command.cpp 184 182 extern Tcl_Interp *initTcl(); 185 186 float vert[NMESH*NMESH*3]; //particle positions in main memory187 float slice_vector[NMESH*NMESH*4]; //per slice vectors in main memory188 183 189 184 // maps transfunc name to TransferFunction object … … 205 200 206 201 // Default camera location. 207 const float def_eye_x = -0.0f;208 const float def_eye_y = -0.0f;202 const float def_eye_x = 0.0f; 203 const float def_eye_y = 0.0f; 209 204 const float def_eye_z = -2.5f; 210 205 … … 221 216 // Image based flow visualization slice location 222 217 // FLOW 223 float NanoVis::lic_slice_x = 0.5f; 224 float NanoVis::lic_slice_y = 0.5f; 225 float NanoVis::lic_slice_z = 0.5f; 226 int NanoVis::lic_axis = 2; // z axis 227 228 #define RM_VOLUME 1 229 #define RM_POINT 2 230 231 int renderMode = RM_VOLUME; 232 233 void removeAllData() 218 float NanoVis::_licSliceX = 0.5f; 219 float NanoVis::_licSliceY = 0.5f; 220 float NanoVis::_licSliceZ = 0.5f; 221 int NanoVis::_licAxis = 2; // z axis 222 223 static void 224 removeAllData() 234 225 { 235 226 // … … 237 228 238 229 void 239 NanoVis:: EventuallyRedraw(unsigned int flag)230 NanoVis::eventuallyRedraw(unsigned int flag) 240 231 { 241 232 if (flag) { … … 251 242 252 243 static int 253 WriteStats(const char *who, int code)244 writeStats(const char *who, int code) 254 245 { 255 246 double start, finish; … … 351 342 352 343 static void 353 DoExit(int code)354 { 355 TRACE("in DoExit\n");344 doExit(int code) 345 { 346 TRACE("in doExit\n"); 356 347 removeAllData(); 357 348 … … 367 358 368 359 #if KEEPSTATS 369 WriteStats("nanovis", code);360 writeStats("nanovis", code); 370 361 #endif 371 362 closelog(); … … 374 365 375 366 static int 376 ExecuteCommand(Tcl_Interp *interp, Tcl_DString *dsPtr)367 executeCommand(Tcl_Interp *interp, Tcl_DString *dsPtr) 377 368 { 378 369 struct timeval tv; … … 397 388 stats.cmdTime += finish - start; 398 389 stats.nCommands++; 399 TRACE("leaving ExecuteCommand status=%d\n", result);390 TRACE("leaving executeCommand status=%d\n", result); 400 391 return result; 401 392 } … … 428 419 } 429 420 430 /* Load a 3D volume 431 * index: the index into the volume array, which stores pointers 432 * to 3D volume instances 433 * data: pointer to an array of floats. 434 * n_component: the number of scalars for each space point. All component 435 * scalars for a point are placed consequtively in data array 436 * width, height and depth: number of points in each dimension 421 /** \brief Load a 3D volume 422 * 423 * \param n_component the number of scalars for each space point. All component 424 * scalars for a point are placed consequtively in data array 425 * width, height and depth: number of points in each dimension 426 * \param data pointer to an array of floats. 437 427 */ 438 428 Volume * 439 NanoVis::load _volume(const char *name, int width, int height, int depth,440 int n_component, float*data, double vmin, double vmax,441 429 NanoVis::loadVolume(const char *name, int width, int height, int depth, 430 int n_component, float *data, double vmin, double vmax, 431 double nzero_min) 442 432 { 443 433 Tcl_HashEntry *hPtr; … … 447 437 WARN("volume \"%s\" already exists", name); 448 438 volPtr = (Volume *)Tcl_GetHashValue(hPtr); 449 remove _volume(volPtr);439 removeVolume(volPtr); 450 440 } 451 441 int isNew; … … 461 451 // Gets a colormap 1D texture by name. 462 452 TransferFunction* 463 NanoVis::get _transfunc(const char *name)453 NanoVis::getTransfunc(const char *name) 464 454 { 465 455 Tcl_HashEntry *hPtr; … … 474 464 // Creates of updates a colormap 1D texture by name. 475 465 TransferFunction* 476 NanoVis:: DefineTransferFunction(const char *name, size_t n, float *data)466 NanoVis::defineTransferFunction(const char *name, size_t n, float *data) 477 467 { 478 468 int isNew; … … 497 487 498 488 int 499 NanoVis::render _legend(TransferFunction *tf, double min, double max,500 501 { 502 TRACE("in render _legend\n");503 504 int old_width = win _width;505 int old_height = win _height;506 507 plane _renderer->set_screen_size(width, height);508 resize _offscreen_buffer(width, height);489 NanoVis::renderLegend(TransferFunction *tf, double min, double max, 490 int width, int height, const char* volArg) 491 { 492 TRACE("in renderLegend\n"); 493 494 int old_width = winWidth; 495 int old_height = winHeight; 496 497 planeRenderer->set_screen_size(width, height); 498 resizeOffscreenBuffer(width, height); 509 499 510 500 // generate data for the legend … … 514 504 } 515 505 legendTexture = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data); 516 int index = plane _renderer->add_plane(legendTexture, tf);517 plane _renderer->set_active_plane(index);518 519 offscreen _buffer_capture();506 int index = planeRenderer->add_plane(legendTexture, tf); 507 planeRenderer->set_active_plane(index); 508 509 offscreenBufferCapture(); 520 510 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen 521 plane _renderer->render();511 planeRenderer->render(); 522 512 523 513 // INSOO 524 glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, screen _buffer);525 //glReadPixels(0, 0, width, height, GL_BGR, GL_UNSIGNED_BYTE, screen _buffer); // INSOO's514 glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, screenBuffer); 515 //glReadPixels(0, 0, width, height, GL_BGR, GL_UNSIGNED_BYTE, screenBuffer); // INSOO's 526 516 527 517 { … … 531 521 TRACE("ppm legend image"); 532 522 sprintf(prefix, "nv>legend %s %g %g", volArg, min, max); 533 ppm _write(prefix);523 ppmWrite(prefix); 534 524 nWritten = write(1, "\n", 1); 535 525 assert(nWritten == 1); 536 526 } 537 plane _renderer->remove_plane(index);538 resize _offscreen_buffer(old_width, old_height);539 540 TRACE("leaving render _legend\n");527 planeRenderer->remove_plane(index); 528 resizeOffscreenBuffer(old_width, old_height); 529 530 TRACE("leaving renderLegend\n"); 541 531 delete legendTexture; 542 532 return TCL_OK; … … 545 535 //initialize frame buffer objects for offscreen rendering 546 536 void 547 NanoVis::init _offscreen_buffer()548 { 549 TRACE("in init _offscreen_buffer\n");537 NanoVis::initOffscreenBuffer() 538 { 539 TRACE("in initOffscreenBuffer\n"); 550 540 // Initialize a fbo for final display. 551 glGenFramebuffersEXT(1, &_final _fbo);552 553 glGenTextures(1, &_final _color_tex);554 glBindTexture(GL_TEXTURE_2D, _final _color_tex);541 glGenFramebuffersEXT(1, &_finalFbo); 542 543 glGenTextures(1, &_finalColorTex); 544 glBindTexture(GL_TEXTURE_2D, _finalColorTex); 555 545 556 546 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 557 547 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 558 #ifdef NV40 559 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, win_width, win_height, 0, 548 #if defined(HAVE_FLOAT_TEXTURES) && defined(USE_HALF_FLOAT) 549 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, winWidth, winHeight, 0, 550 GL_RGB, GL_INT, NULL); 551 #elif defined(HAVE_FLOAT_TEXTURES) 552 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, winWidth, winHeight, 0, 560 553 GL_RGB, GL_INT, NULL); 561 554 #else 562 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, win _width, win_height, 0,555 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, winWidth, winHeight, 0, 563 556 GL_RGB, GL_INT, NULL); 564 557 #endif 565 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _final _fbo);566 glGenRenderbuffersEXT(1, &_final _depth_rb);567 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _final _depth_rb);558 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo); 559 glGenRenderbuffersEXT(1, &_finalDepthRb); 560 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _finalDepthRb); 568 561 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, 569 win _width, win_height);562 winWidth, winHeight); 570 563 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, 571 GL_TEXTURE_2D, _final _color_tex, 0);564 GL_TEXTURE_2D, _finalColorTex, 0); 572 565 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, 573 GL_RENDERBUFFER_EXT, _final _depth_rb);566 GL_RENDERBUFFER_EXT, _finalDepthRb); 574 567 575 568 GLenum status; 576 569 if (!CheckFBO(&status)) { 577 PrintFBOStatus(status, "final _fbo");578 DoExit(3);570 PrintFBOStatus(status, "finalFbo"); 571 doExit(3); 579 572 } 580 573 … … 583 576 584 577 //assert(glGetError()==0); 585 TRACE("leaving init _offscreen_buffer\n");578 TRACE("leaving initOffscreenBuffer\n"); 586 579 } 587 580 588 581 //resize the offscreen buffer 589 582 void 590 NanoVis::resize _offscreen_buffer(int w, int h)591 { 592 TRACE("in resize _offscreen_buffer(%d, %d)\n", w, h);593 if ((w == win _width) && (h == win_height)) {583 NanoVis::resizeOffscreenBuffer(int w, int h) 584 { 585 TRACE("in resizeOffscreenBuffer(%d, %d)\n", w, h); 586 if ((w == winWidth) && (h == winHeight)) { 594 587 return; 595 588 } 596 win _width = w;597 win _height = h;589 winWidth = w; 590 winHeight = h; 598 591 599 592 if (fonts) { 600 593 fonts->resize(w, h); 601 594 } 602 TRACE("screen _buffer size: %d %d\n", w, h);603 604 if (screen _buffer != NULL) {605 delete [] screen _buffer;606 screen _buffer = NULL;607 } 608 609 screen _buffer = new unsigned char[4*win_width*win_height];610 assert(screen _buffer != NULL);595 TRACE("screenBuffer size: %d %d\n", w, h); 596 597 if (screenBuffer != NULL) { 598 delete [] screenBuffer; 599 screenBuffer = NULL; 600 } 601 602 screenBuffer = new unsigned char[4*winWidth*winHeight]; 603 assert(screenBuffer != NULL); 611 604 612 605 //delete the current render buffer resources 613 glDeleteTextures(1, &_final _color_tex);614 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _final _depth_rb);615 glDeleteRenderbuffersEXT(1, &_final _depth_rb);606 glDeleteTextures(1, &_finalColorTex); 607 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _finalDepthRb); 608 glDeleteRenderbuffersEXT(1, &_finalDepthRb); 616 609 617 610 TRACE("before deleteframebuffers\n"); 618 glDeleteFramebuffersEXT(1, &_final _fbo);611 glDeleteFramebuffersEXT(1, &_finalFbo); 619 612 620 613 TRACE("reinitialize FBO\n"); 621 614 //Reinitialize final fbo for final display 622 glGenFramebuffersEXT(1, &_final _fbo);623 624 glGenTextures(1, &_final _color_tex);625 glBindTexture(GL_TEXTURE_2D, _final _color_tex);615 glGenFramebuffersEXT(1, &_finalFbo); 616 617 glGenTextures(1, &_finalColorTex); 618 glBindTexture(GL_TEXTURE_2D, _finalColorTex); 626 619 627 620 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 628 621 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 629 #ifdef NV40 630 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, win_width, win_height, 0, 622 #if defined(HAVE_FLOAT_TEXTURES) && defined(USE_HALF_FLOAT) 623 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, winWidth, winHeight, 0, 624 GL_RGB, GL_INT, NULL); 625 #elif defined(HAVE_FLOAT_TEXTURES) 626 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, winWidth, winHeight, 0, 631 627 GL_RGB, GL_INT, NULL); 632 628 #else 633 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, win _width, win_height, 0,629 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, winWidth, winHeight, 0, 634 630 GL_RGB, GL_INT, NULL); 635 631 #endif 636 632 TRACE("before bindframebuffer\n"); 637 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _final _fbo);633 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo); 638 634 TRACE("after bindframebuffer\n"); 639 glGenRenderbuffersEXT(1, &_final _depth_rb);640 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _final _depth_rb);635 glGenRenderbuffersEXT(1, &_finalDepthRb); 636 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _finalDepthRb); 641 637 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, 642 win _width, win_height);638 winWidth, winHeight); 643 639 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, 644 GL_TEXTURE_2D, _final _color_tex, 0);640 GL_TEXTURE_2D, _finalColorTex, 0); 645 641 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, 646 GL_RENDERBUFFER_EXT, _final _depth_rb);642 GL_RENDERBUFFER_EXT, _finalDepthRb); 647 643 648 644 GLenum status; 649 645 if (!CheckFBO(&status)) { 650 PrintFBOStatus(status, "final _fbo");651 DoExit(3);646 PrintFBOStatus(status, "finalFbo"); 647 doExit(3); 652 648 } 653 649 … … 655 651 TRACE("change camera\n"); 656 652 //change the camera setting 657 cam->set_screen_size(0, 0, win _width, win_height);658 plane _renderer->set_screen_size(win_width, win_height);659 660 TRACE("leaving resize _offscreen_buffer(%d, %d)\n", w, h);653 cam->set_screen_size(0, 0, winWidth, winHeight); 654 planeRenderer->set_screen_size(winWidth, winHeight); 655 656 TRACE("leaving resizeOffscreenBuffer(%d, %d)\n", w, h); 661 657 } 662 658 … … 668 664 * to turn it back on. 669 665 */ 670 void671 make _test_2D_data()666 static void 667 makeTest2DData() 672 668 { 673 669 int w = 300; … … 693 689 } 694 690 695 void CgErrorCallback(void) 691 static 692 void cgErrorCallback(void) 696 693 { 697 694 if (!NvShader::printErrorInfo()) { 698 695 TRACE("Cg error, exiting...\n"); 699 DoExit(-1);696 doExit(-1); 700 697 } 701 698 } … … 712 709 if (path == NULL) { 713 710 ERROR("No path defined for shaders or resources\n"); 714 DoExit(1);711 doExit(1); 715 712 } 716 713 GLenum err = glewInit(); 717 714 if (GLEW_OK != err) { 718 ERROR("%s\n", glewGetErrorString(err)); 719 getchar(); 720 //assert(false); 715 ERROR("Can't init GLEW: %s\n", glewGetErrorString(err)); 716 doExit(1); 721 717 } 722 718 TRACE("Using GLEW %s\n", glewGetString(GLEW_VERSION)); 719 720 if (!GLEW_EXT_framebuffer_object) { 721 ERROR("EXT_framebuffer_oject extension is required to run nanovis\n"); 722 doExit(1); 723 } 724 #ifdef HAVE_NPOT_TEXTURES 725 if (!GLEW_ARB_texture_non_power_of_two) { 726 ERROR("GLEW_ARB_texture_non_power_of_two extension is required to run nanovis\n"); 727 doExit(1); 728 } 729 #endif 730 #ifdef HAVE_FLOAT_TEXTURES 731 if (!GLEW_ARB_texture_float || 732 !GLEW_ARB_color_buffer_float) { 733 ERROR("ARB_texture_float and ARB_color_buffer_float extensions are required to run nanovis\n"); 734 doExit(1); 735 } 736 #endif 723 737 724 738 if (!R2FilePath::getInstance()->setPath(path)) { 725 739 ERROR("can't set file path to %s\n", path); 726 DoExit(1);740 doExit(1); 727 741 } 728 742 … … 732 746 733 747 NvShader::initCg(); 734 NvShader::setErrorCallback( CgErrorCallback);748 NvShader::setErrorCallback(cgErrorCallback); 735 749 736 750 fonts = new R2Fonts(); … … 738 752 fonts->setFont("verdana"); 739 753 740 color _table_renderer = new NvColorTableRenderer();741 color _table_renderer->setFonts(fonts);754 colorTableRenderer = new NvColorTableRenderer(); 755 colorTableRenderer->setFonts(fonts); 742 756 743 757 flowVisRenderer = new NvFlowVisRenderer(NMESH, NMESH); … … 745 759 NanoVis::velocityArrowsSlice = new VelocityArrowsSlice; 746 760 747 licRenderer = new NvLIC(NMESH, NPIX, NPIX, lic_axis,748 Vector3( lic_slice_x, lic_slice_y, lic_slice_z),761 licRenderer = new NvLIC(NMESH, NPIX, NPIX, _licAxis, 762 Vector3(_licSliceX, _licSliceY, _licSliceZ), 749 763 NvShader::getCgContext()); 750 764 … … 753 767 754 768 #ifdef USE_POINTSET_RENDERER 755 point set_renderer = new PointSetRenderer();769 pointSetRenderer = new PointSetRenderer(); 756 770 #endif 757 771 } … … 763 777 TRACE("in initGL\n"); 764 778 //buffer to store data read from the screen 765 if (screen _buffer) {766 delete[] screen _buffer;767 screen _buffer = NULL;768 } 769 screen _buffer = new unsigned char[4*win_width*win_height];770 assert(screen _buffer != NULL);779 if (screenBuffer) { 780 delete[] screenBuffer; 781 screenBuffer = NULL; 782 } 783 screenBuffer = new unsigned char[4*winWidth*winHeight]; 784 assert(screenBuffer != NULL); 771 785 772 786 //create the camera with default setting 773 cam = new NvCamera(0, 0, win _width, win_height,787 cam = new NvCamera(0, 0, winWidth, winHeight, 774 788 def_eye_x, def_eye_y, def_eye_z, /* location. */ 775 789 def_target_x, def_target_y, def_target_z, /* target. */ … … 781 795 782 796 glClearColor(0,0,0,1); 783 //glClearColor(0.7,0.7,0.7,1);784 797 glClear(GL_COLOR_BUFFER_BIT); 785 798 … … 801 814 802 815 //check if performance query is supported 803 if (check_query_support()){816 if (PerfQuery::checkQuerySupport()) { 804 817 //create queries to count number of rendered pixels 805 818 perf = new PerfQuery(); 806 819 } 807 820 808 init _offscreen_buffer(); //frame buffer object for offscreen rendering821 initOffscreenBuffer(); //frame buffer object for offscreen rendering 809 822 810 823 //create volume renderer and add volumes to it 811 vol _renderer = new VolumeRenderer();824 volRenderer = new VolumeRenderer(); 812 825 813 826 // create … … 815 828 816 829 //create a 2D plane renderer 817 plane _renderer = new PlaneRenderer(win_width, win_height);830 planeRenderer = new PlaneRenderer(winWidth, winHeight); 818 831 #if PROTOTYPE 819 832 make_test_2D_data(); 820 plane _renderer->add_plane(plane[0], get_transfunc("default"));833 planeRenderer->add_plane(plane[0], getTransfunc("default")); 821 834 #endif 822 835 … … 828 841 #if DO_RLE 829 842 char rle[512*512*3]; 830 int rle _size;843 int rleSize; 831 844 832 845 short offsets[512*512*3]; 833 int offsets _size;834 835 void836 do _rle()837 { 838 int len = NanoVis::win _width*NanoVis::win_height*3;839 rle _size = 0;840 offsets _size = 0;841 842 int i =0;843 while (i<len){844 if (NanoVis::screen _buffer[i] == 0) {846 int offsetsSize; 847 848 static void 849 doRle() 850 { 851 int len = NanoVis::winWidth*NanoVis::winHeight*3; 852 rleSize = 0; 853 offsetsSize = 0; 854 855 int i = 0; 856 while (i < len) { 857 if (NanoVis::screenBuffer[i] == 0) { 845 858 int pos = i+1; 846 while ( (pos <len) && (NanoVis::screen_buffer[pos] == 0)) {859 while ( (pos < len) && (NanoVis::screenBuffer[pos] == 0)) { 847 860 pos++; 848 861 } 849 offsets[offsets _size++] = -(pos - i);862 offsets[offsetsSize++] = -(pos - i); 850 863 i = pos; 851 864 } … … 853 866 else { 854 867 int pos; 855 for (pos = i; (pos <len) && (NanoVis::screen_buffer[pos] != 0);pos++){856 rle[rle _size++] = NanoVis::screen_buffer[pos];868 for (pos = i; (pos < len) && (NanoVis::screenBuffer[pos] != 0); pos++){ 869 rle[rleSize++] = NanoVis::screenBuffer[pos]; 857 870 } 858 offsets[offsets _size++] = (pos - i);871 offsets[offsetsSize++] = (pos - i); 859 872 i = pos; 860 873 } … … 867 880 // Writes an integer value into the header data structure at pos 868 881 static inline void 869 bmp _header_add_int(unsigned char* header, int& pos, int data)882 bmpHeaderAddInt(unsigned char* header, int& pos, int data) 870 883 { 871 884 #ifdef WORDS_BIGENDIAN … … 885 898 // FOR DEBUGGING 886 899 void 887 NanoVis::bmp _write_to_file(int frame_number, const char *directory_name)900 NanoVis::bmpWriteToFile(int frame_number, const char *directory_name) 888 901 { 889 902 unsigned char header[SIZEOF_BMP_HEADER]; … … 895 908 // on each scan line. If need be, we add padding to each line. 896 909 int pad = 0; 897 if ((3*win _width) % 4 > 0) {898 pad = 4 - ((3*win _width) % 4);910 if ((3*winWidth) % 4 > 0) { 911 pad = 4 - ((3*winWidth) % 4); 899 912 } 900 913 901 914 // file size in bytes 902 int fsize = (3*win _width+pad)*win_height + SIZEOF_BMP_HEADER;903 bmp _header_add_int(header, pos, fsize);915 int fsize = (3*winWidth+pad)*winHeight + SIZEOF_BMP_HEADER; 916 bmpHeaderAddInt(header, pos, fsize); 904 917 905 918 // reserved value (must be 0) 906 bmp _header_add_int(header, pos, 0);919 bmpHeaderAddInt(header, pos, 0); 907 920 908 921 // offset in bytes to start of bitmap data 909 bmp _header_add_int(header, pos, SIZEOF_BMP_HEADER);922 bmpHeaderAddInt(header, pos, SIZEOF_BMP_HEADER); 910 923 911 924 // size of the BITMAPINFOHEADER 912 bmp _header_add_int(header, pos, 40);925 bmpHeaderAddInt(header, pos, 40); 913 926 914 927 // width of the image in pixels 915 bmp _header_add_int(header, pos, win_width);928 bmpHeaderAddInt(header, pos, winWidth); 916 929 917 930 // height of the image in pixels 918 bmp _header_add_int(header, pos, win_height);931 bmpHeaderAddInt(header, pos, winHeight); 919 932 920 933 // 1 plane + (24 bits/pixel << 16) 921 bmp _header_add_int(header, pos, 1572865);934 bmpHeaderAddInt(header, pos, 1572865); 922 935 923 936 // no compression 924 937 // size of image for compression 925 bmp _header_add_int(header, pos, 0);926 bmp _header_add_int(header, pos, 0);938 bmpHeaderAddInt(header, pos, 0); 939 bmpHeaderAddInt(header, pos, 0); 927 940 928 941 // x pixels per meter 929 942 // y pixels per meter 930 bmp _header_add_int(header, pos, 0);931 bmp _header_add_int(header, pos, 0);943 bmpHeaderAddInt(header, pos, 0); 944 bmpHeaderAddInt(header, pos, 0); 932 945 933 946 // number of colors used (0 = compute from bits/pixel) 934 947 // number of important colors (0 = all colors important) 935 bmp _header_add_int(header, pos, 0);936 bmp _header_add_int(header, pos, 0);948 bmpHeaderAddInt(header, pos, 0); 949 bmpHeaderAddInt(header, pos, 0); 937 950 938 951 // BE CAREFUL: BMP format wants BGR ordering for screen data 939 unsigned char* scr = screen _buffer;940 for (int row=0; row < win _height; row++) {941 for (int col=0; col < win _width; col++) {952 unsigned char* scr = screenBuffer; 953 for (int row=0; row < winHeight; row++) { 954 for (int col=0; col < winWidth; col++) { 942 955 unsigned char tmp = scr[2]; 943 956 scr[2] = scr[0]; // B … … 970 983 ERROR("can't write header: short write\n"); 971 984 } 972 if (fwrite(screen _buffer, (3*win_width+pad)*win_height, 1, f) != 1) {985 if (fwrite(screenBuffer, (3*winWidth+pad)*winHeight, 1, f) != 1) { 973 986 ERROR("can't write data: short write\n"); 974 987 } … … 977 990 978 991 void 979 NanoVis::bmp _write(const char *prefix)992 NanoVis::bmpWrite(const char *prefix) 980 993 { 981 994 unsigned char header[SIZEOF_BMP_HEADER]; … … 986 999 // on each scan line. If need be, we add padding to each line. 987 1000 int pad = 0; 988 if ((3*win _width) % 4 > 0) {989 pad = 4 - ((3*win _width) % 4);1001 if ((3*winWidth) % 4 > 0) { 1002 pad = 4 - ((3*winWidth) % 4); 990 1003 } 991 1004 pad = 0; 992 int fsize = (3*win _width+pad)*win_height + sizeof(header);1005 int fsize = (3*winWidth+pad)*winHeight + sizeof(header); 993 1006 994 1007 char string[200]; … … 1000 1013 1001 1014 // file size in bytes 1002 bmp _header_add_int(header, pos, fsize);1015 bmpHeaderAddInt(header, pos, fsize); 1003 1016 1004 1017 // reserved value (must be 0) 1005 bmp _header_add_int(header, pos, 0);1018 bmpHeaderAddInt(header, pos, 0); 1006 1019 1007 1020 // offset in bytes to start of bitmap data 1008 bmp _header_add_int(header, pos, SIZEOF_BMP_HEADER);1021 bmpHeaderAddInt(header, pos, SIZEOF_BMP_HEADER); 1009 1022 1010 1023 // size of the BITMAPINFOHEADER 1011 bmp _header_add_int(header, pos, 40);1024 bmpHeaderAddInt(header, pos, 40); 1012 1025 1013 1026 // width of the image in pixels 1014 bmp _header_add_int(header, pos, win_width);1027 bmpHeaderAddInt(header, pos, winWidth); 1015 1028 1016 1029 // height of the image in pixels 1017 bmp _header_add_int(header, pos, win_height);1030 bmpHeaderAddInt(header, pos, winHeight); 1018 1031 1019 1032 // 1 plane + (24 bits/pixel << 16) 1020 bmp _header_add_int(header, pos, 1572865);1033 bmpHeaderAddInt(header, pos, 1572865); 1021 1034 1022 1035 // no compression 1023 1036 // size of image for compression 1024 bmp _header_add_int(header, pos, 0);1025 bmp _header_add_int(header, pos, 0);1037 bmpHeaderAddInt(header, pos, 0); 1038 bmpHeaderAddInt(header, pos, 0); 1026 1039 1027 1040 // x pixels per meter 1028 1041 // y pixels per meter 1029 bmp _header_add_int(header, pos, 0);1030 bmp _header_add_int(header, pos, 0);1042 bmpHeaderAddInt(header, pos, 0); 1043 bmpHeaderAddInt(header, pos, 0); 1031 1044 1032 1045 // number of colors used (0 = compute from bits/pixel) 1033 1046 // number of important colors (0 = all colors important) 1034 bmp _header_add_int(header, pos, 0);1035 bmp _header_add_int(header, pos, 0);1047 bmpHeaderAddInt(header, pos, 0); 1048 bmpHeaderAddInt(header, pos, 0); 1036 1049 1037 1050 // BE CAREFUL: BMP format wants BGR ordering for screen data 1038 unsigned char* scr = screen _buffer;1039 for (int row=0; row < win _height; row++) {1040 for (int col=0; col < win _width; col++) {1051 unsigned char* scr = screenBuffer; 1052 for (int row=0; row < winHeight; row++) { 1053 for (int col=0; col < winWidth; col++) { 1041 1054 unsigned char tmp = scr[2]; 1042 1055 scr[2] = scr[0]; // B … … 1049 1062 nWritten = write(1, header, SIZEOF_BMP_HEADER); 1050 1063 assert(nWritten == SIZEOF_BMP_HEADER); 1051 nWritten = write(1, screen _buffer, (3*win_width+pad)*win_height);1052 assert(nWritten == (3*win _width+pad)*win_height);1064 nWritten = write(1, screenBuffer, (3*winWidth+pad)*winHeight); 1065 assert(nWritten == (3*winWidth+pad)*winHeight); 1053 1066 stats.nFrames++; 1054 stats.nBytes += (3*win _width+pad)*win_height;1067 stats.nBytes += (3*winWidth+pad)*winHeight; 1055 1068 } 1056 1069 1057 1070 /* 1058 * ppm _write --1071 * ppmWrite -- 1059 1072 * 1060 1073 * Writes the screen image as PPM binary data to the nanovisviewer … … 1074 1087 */ 1075 1088 void 1076 NanoVis::ppm _write(const char *prefix)1089 NanoVis::ppmWrite(const char *prefix) 1077 1090 { 1078 1091 #define PPM_MAXVAL 255 1079 1092 char header[200]; 1080 1093 1081 TRACE("Enter ppm _write (%dx%d)\n", win_width, win_height);1094 TRACE("Enter ppmWrite (%dx%d)\n", winWidth, winHeight); 1082 1095 // Generate the PPM binary file header 1083 sprintf(header, "P6 %d %d %d\n", win _width, win_height, PPM_MAXVAL);1096 sprintf(header, "P6 %d %d %d\n", winWidth, winHeight, PPM_MAXVAL); 1084 1097 1085 1098 size_t header_length = strlen(header); 1086 size_t data_length = win _width * win_height * 3;1099 size_t data_length = winWidth * winHeight * 3; 1087 1100 1088 1101 char command[200]; … … 1090 1103 (unsigned long)header_length + data_length); 1091 1104 1092 size_t wordsPerRow = (win _width * 24 + 31) / 32;1105 size_t wordsPerRow = (winWidth * 24 + 31) / 32; 1093 1106 size_t bytesPerRow = wordsPerRow * 4; 1094 size_t rowLength = win _width * 3;1095 size_t nRecs = win _height + 2;1107 size_t rowLength = winWidth * 3; 1108 size_t nRecs = winHeight + 2; 1096 1109 1097 1110 struct iovec *iov; … … 1107 1120 // Image data. 1108 1121 int y; 1109 unsigned char *srcRowPtr = screen _buffer;1110 for (y = win _height + 1; y >= 2; y--) {1122 unsigned char *srcRowPtr = screenBuffer; 1123 for (y = winHeight + 1; y >= 2; y--) { 1111 1124 iov[y].iov_base = srcRowPtr; 1112 1125 iov[y].iov_len = rowLength; … … 1118 1131 free(iov); 1119 1132 stats.nFrames++; 1120 stats.nBytes += (bytesPerRow * win _height);1121 TRACE("Leaving ppm _write (%dx%d)\n", win_width, win_height);1133 stats.nBytes += (bytesPerRow * winHeight); 1134 TRACE("Leaving ppmWrite (%dx%d)\n", winWidth, winHeight); 1122 1135 } 1123 1136 … … 1129 1142 1130 1143 // Generate the PPM binary file header 1131 sprintf(header, "P6 %d %d %d\n", win _width, win_height, PPM_MAXVAL);1144 sprintf(header, "P6 %d %d %d\n", winWidth, winHeight, PPM_MAXVAL); 1132 1145 1133 1146 size_t header_length = strlen(header); 1134 size_t data_length = win _width * win_height * 3;1147 size_t data_length = winWidth * winHeight * 3; 1135 1148 1136 1149 char command[200]; … … 1139 1152 */ 1140 1153 1141 // size_t wordsPerRow = (win _width * 24 + 31) / 32;1154 // size_t wordsPerRow = (winWidth * 24 + 31) / 32; 1142 1155 // size_t bytesPerRow = wordsPerRow * 4; 1143 // size_t rowLength = win _width * 3;1156 // size_t rowLength = winWidth * 3; 1144 1157 size_t nRecs = 2; 1145 1158 … … 1160 1173 delete [] iov; 1161 1174 // stats.nFrames++; 1162 // stats.nBytes += (bytesPerRow * win _height);1175 // stats.nBytes += (bytesPerRow * winHeight); 1163 1176 } 1164 1177 … … 1169 1182 { 1170 1183 TRACE("in idle()\n"); 1171 glutSetWindow(render _window);1184 glutSetWindow(renderWindow); 1172 1185 1173 1186 #ifdef XINETD 1174 xinetd _listen();1187 xinetdListen(); 1175 1188 #else 1176 1189 glutPostRedisplay(); … … 1180 1193 1181 1194 void 1182 NanoVis::display _offscreen_buffer()1195 NanoVis::displayOffscreenBuffer() 1183 1196 { 1184 1197 TRACE("in display_offscreen_buffer\n"); 1185 1198 glEnable(GL_TEXTURE_2D); 1186 1199 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1187 glBindTexture(GL_TEXTURE_2D, _final _color_tex);1188 1189 glViewport(0, 0, win _width, win_height);1200 glBindTexture(GL_TEXTURE_2D, _finalColorTex); 1201 1202 glViewport(0, 0, winWidth, winHeight); 1190 1203 glMatrixMode(GL_PROJECTION); 1191 1204 glLoadIdentity(); 1192 gluOrtho2D(0, win _width, 0, win_height);1205 gluOrtho2D(0, winWidth, 0, winHeight); 1193 1206 glMatrixMode(GL_MODELVIEW); 1194 1207 glLoadIdentity(); … … 1198 1211 { 1199 1212 glTexCoord2f(0, 0); glVertex2f(0, 0); 1200 glTexCoord2f(1, 0); glVertex2f(win _width, 0);1201 glTexCoord2f(1, 1); glVertex2f(win _width, win_height);1202 glTexCoord2f(0, 1); glVertex2f(0, win _height);1213 glTexCoord2f(1, 0); glVertex2f(winWidth, 0); 1214 glTexCoord2f(1, 1); glVertex2f(winWidth, winHeight); 1215 glTexCoord2f(0, 1); glVertex2f(0, winHeight); 1203 1216 } 1204 1217 glEnd(); … … 1208 1221 #if 0 1209 1222 //oddeven sort on GPU 1210 void1223 static void 1211 1224 sortstep() 1212 1225 { … … 1287 1300 #endif 1288 1301 1289 void1290 draw _3d_axis()1302 static void 1303 draw3dAxis() 1291 1304 { 1292 1305 glDisable(GL_TEXTURE_2D); … … 1379 1392 void NanoVis::update() 1380 1393 { 1381 if (vol _renderer->_volumeInterpolator->is_started()) {1394 if (volRenderer->_volumeInterpolator->isStarted()) { 1382 1395 struct timeval clock; 1383 1396 gettimeofday(&clock, NULL); … … 1385 1398 1386 1399 elapsed_time = clock.tv_sec + clock.tv_usec/1000000.0 - 1387 vol _renderer->_volumeInterpolator->getStartTime();1400 volRenderer->_volumeInterpolator->getStartTime(); 1388 1401 1389 1402 TRACE("%lf %lf\n", elapsed_time, 1390 vol _renderer->_volumeInterpolator->getInterval());1403 volRenderer->_volumeInterpolator->getInterval()); 1391 1404 float fraction; 1392 1405 float f; 1393 1406 1394 f = fmod((float) elapsed_time, (float)vol _renderer->_volumeInterpolator->getInterval());1407 f = fmod((float) elapsed_time, (float)volRenderer->_volumeInterpolator->getInterval()); 1395 1408 if (f == 0.0) { 1396 1409 fraction = 0.0f; 1397 1410 } else { 1398 fraction = f / vol _renderer->_volumeInterpolator->getInterval();1411 fraction = f / volRenderer->_volumeInterpolator->getInterval(); 1399 1412 } 1400 1413 TRACE("fraction : %f\n", fraction); 1401 vol _renderer->_volumeInterpolator->update(fraction);1414 volRenderer->_volumeInterpolator->update(fraction); 1402 1415 } 1403 1416 } 1404 1417 1405 1418 void 1406 NanoVis:: SetVolumeRanges()1419 NanoVis::setVolumeRanges() 1407 1420 { 1408 1421 double xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax; … … 1454 1467 Volume::valueMax = wMax; 1455 1468 } 1456 Volume::update _pending = false;1469 Volume::updatePending = false; 1457 1470 TRACE("leaving SetVolumeRanges\n"); 1458 1471 } 1459 1472 1460 1473 void 1461 NanoVis:: SetHeightmapRanges()1474 NanoVis::setHeightmapRanges() 1462 1475 { 1463 1476 double xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax; 1464 1477 1465 TRACE("in SetHeightmapRanges\n");1478 TRACE("in setHeightmapRanges\n"); 1466 1479 xMin = yMin = zMin = wMin = DBL_MAX; 1467 1480 xMax = yMax = zMax = wMax = -DBL_MAX; … … 1515 1528 hmPtr->MapToGrid(grid); 1516 1529 } 1517 HeightMap::update _pending = false;1518 TRACE("leaving SetHeightmapRanges\n");1530 HeightMap::updatePending = false; 1531 TRACE("leaving setHeightmapRanges\n"); 1519 1532 } 1520 1533 … … 1537 1550 } 1538 1551 //assert(glGetError()==0); 1539 if (HeightMap::update _pending) {1540 SetHeightmapRanges();1541 } 1542 if (Volume::update _pending) {1543 SetVolumeRanges();1552 if (HeightMap::updatePending) { 1553 setHeightmapRanges(); 1554 } 1555 if (Volume::updatePending) { 1556 setVolumeRanges(); 1544 1557 } 1545 1558 TRACE("in display: glClear\n"); … … 1547 1560 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen 1548 1561 1549 if (volume _mode) {1550 TRACE("in display: volume _mode\n");1562 if (volumeMode) { 1563 TRACE("in display: volumeMode\n"); 1551 1564 //3D rendering mode 1552 1565 // TBD.. … … 1588 1601 1589 1602 //now render things in the scene 1590 if (axis _on) {1591 draw _3d_axis();1603 if (axisOn) { 1604 draw3dAxis(); 1592 1605 } 1593 1606 if (grid->isVisible()) { … … 1617 1630 1618 1631 //perf->enable(); 1619 vol _renderer->render_all();1632 volRenderer->renderAll(); 1620 1633 //perf->disable(); 1621 1634 … … 1637 1650 //2D rendering mode 1638 1651 perf->enable(); 1639 plane _renderer->render();1652 planeRenderer->render(); 1640 1653 perf->disable(); 1641 1654 } … … 1678 1691 1679 1692 void 1680 NanoVis::update _rot(int delta_x, int delta_y)1693 NanoVis::updateRot(int delta_x, int delta_y) 1681 1694 { 1682 1695 Vector3 angle; … … 1700 1713 1701 1714 void 1702 NanoVis::update _trans(int delta_x, int delta_y, int delta_z)1715 NanoVis::updateTrans(int delta_x, int delta_y, int delta_z) 1703 1716 { 1704 1717 cam->x(cam->x() + delta_x * 0.03); … … 1707 1720 } 1708 1721 1722 #ifdef notdef 1723 static 1709 1724 void addVectorField(const char* filename, const char* vf_name, 1710 1725 const char* plane_name1, const char* plane_name2, … … 1719 1734 Volume *volPtr = NanoVis::volume[n]; 1720 1735 if (volPtr != NULL) { 1721 volPtr-> set_n_slice(256-n);1722 // volPtr-> set_n_slice(512-n);1723 volPtr->disable _cutplane(0);1724 volPtr->disable _cutplane(1);1725 volPtr->disable _cutplane(2);1726 volPtr->transferFunction(NanoVis::get _transfunc("default"));1736 volPtr->numSlices(256-n); 1737 // volPtr->numSlices(512-n); 1738 volPtr->disableCutplane(0); 1739 volPtr->disableCutplane(1); 1740 volPtr->disableCutplane(2); 1741 volPtr->transferFunction(NanoVis::getTransfunc("default")); 1727 1742 1728 1743 float dx0 = -0.5; … … 1733 1748 volPtr->data(false); 1734 1749 NanoVis::flowVisRenderer->addVectorField(vf_name, volPtr, 1735 *(volPtr->get_location()),1750 volPtr->location(), 1736 1751 1.0f, 1737 1752 volPtr->height / (float)volPtr->width, … … 1759 1774 setVectorField(volPtr->id, 1760 1775 *(volPtr->get_location()), 1761 1.0f / volPtr->aspect _ratio_width,1762 1.0f / volPtr->aspect _ratio_height,1763 1.0f / volPtr->aspect _ratio_depth,1776 1.0f / volPtr->aspectRatioWidth, 1777 1.0f / volPtr->aspectRatioHeight, 1778 1.0f / volPtr->aspectRatioDepth, 1764 1779 volPtr->wAxis.max()); 1765 1780 } … … 1767 1782 //NanoVis::initParticle(); 1768 1783 } 1784 #endif 1769 1785 1770 1786 void … … 1772 1788 { 1773 1789 #ifdef EVENTLOG 1774 if (log){1790 if (log) { 1775 1791 float param[3]; 1776 1792 param[0] = cam->x(); … … 1807 1823 "}\n" 1808 1824 }; 1825 Tcl_Eval(interp, cmd); 1809 1826 #ifdef notdef 1810 1827 NanoVis::flowVisRenderer->active(false); … … 1818 1835 char cmd[] = { 1819 1836 "flow create flow1\n" 1820 "flow1 data file /home/iwoo/projects/nanovis/rappture/packages/vizservers/nanovis/data/flowvis_dx_files/jwire/J-wire-vec.dx 3\n"1837 "flow1 data file data/flowvis_dx_files/jwire/J-wire-vec.dx 3\n" 1821 1838 "flow1 particles add plane1 -color { 0 0 1 1 }\n" 1822 1839 "flow1 particles add plane2 -color { 0 1 1 1 }\n" … … 1824 1841 Tcl_Eval(interp, cmd); 1825 1842 #ifdef notdef 1826 addVectorField(" /home/iwoo/projects/nanovis/rappture/packages/vizservers/nanovis/data/flowvis_dx_files/jwire/J-wire-vec.dx",1843 addVectorField("data/flowvis_dx_files/jwire/J-wire-vec.dx", 1827 1844 "vf_name2", "plane_name1", "plane_name2", Vector4(0, 0, 1, 1), Vector4(0, 1, 1, 1)); 1828 1845 #endif … … 1833 1850 char cmd[] = { 1834 1851 "flow create flow2\n" 1835 "flow2 data file /home/iwoo/projects/nanovis/rappture/packages/vizservers/nanovis/data/flowvis_dx_files/3DWireLeakage/SiO2/SiO2.dx 3\n"1852 "flow2 data file data/flowvis_dx_files/3DWireLeakage/SiO2/SiO2.dx 3\n" 1836 1853 "flow2 particles add plane1 -color { 1 0 0 1 }\n" 1837 1854 "flow2 particles add plane2 -color { 1 1 0 1 }\n" … … 1839 1856 Tcl_Eval(interp, cmd); 1840 1857 TRACE("add vector field\n"); 1841 addVectorField("/home/iwoo/projects/nanovis/rappture/packages/vizservers/nanovis/data/flowvis_dx_files/3DWireLeakage/SiO2/SiO2.dx", 1858 #ifdef notdef 1859 addVectorField("data/flowvis_dx_files/3DWireLeakage/SiO2/SiO2.dx", 1842 1860 "vf_name1", "plane_name1", "plane_name2", Vector4(1, 0, 0, 1), Vector4(1, 1, 0, 1)); 1861 #endif 1843 1862 } 1844 1863 break; … … 1994 2013 left_last_y = y; 1995 2014 1996 update _rot(-delta_y, -delta_x);2015 updateRot(-delta_y, -delta_x); 1997 2016 } else if (right_down) { 1998 2017 //TRACE("right mouse motion (%d,%d)\n", x, y); … … 2001 2020 right_last_y = y; 2002 2021 2003 update _trans(0, 0, delta_x);2022 updateTrans(0, 0, delta_x); 2004 2023 } 2005 2024 … … 2046 2065 2047 2066 void 2048 NanoVis::xinetd _listen(void)2067 NanoVis::xinetdListen(void) 2049 2068 { 2050 2069 NanoVis::flags &= ~REDRAW_PENDING; 2051 2070 2052 TRACE("Enter xinetd _listen\n");2071 TRACE("Enter xinetdListen\n"); 2053 2072 2054 2073 int flags = fcntl(0, F_GETFL, 0); … … 2071 2090 // here. 2072 2091 // 2073 TRACE("in xinetd _listen: EOF=%d\n", feof(NanoVis::stdin));2092 TRACE("in xinetdListen: EOF=%d\n", feof(NanoVis::stdin)); 2074 2093 while (!feof(NanoVis::stdin)) { 2075 2094 int c = fgetc(NanoVis::stdin); … … 2079 2098 break; 2080 2099 } 2081 DoExit(100);2100 doExit(100); 2082 2101 } 2083 2102 ch = (char)c; … … 2097 2116 // back to original flags during command evaluation... 2098 2117 fcntl(0, F_SETFL, flags & ~O_NONBLOCK); 2099 status = ExecuteCommand(interp, &cmdbuffer);2118 status = executeCommand(interp, &cmdbuffer); 2100 2119 // non-blocking for next read -- we might not get anything 2101 2120 fcntl(0, F_SETFL, flags | O_NONBLOCK); … … 2128 2147 } 2129 2148 if (feof(NanoVis::stdin)) { 2130 DoExit(90);2149 doExit(90); 2131 2150 } 2132 2151 2133 2152 NanoVis::update(); 2134 2153 2135 NanoVis::offscreen _buffer_capture(); //enable offscreen render2154 NanoVis::offscreenBufferCapture(); //enable offscreen render 2136 2155 2137 2156 NanoVis::display(); … … 2139 2158 // INSOO 2140 2159 #ifdef XINETD 2141 NanoVis::read _screen();2160 NanoVis::readScreen(); 2142 2161 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 2143 2162 #else 2144 NanoVis::display _offscreen_buffer(); //display the final rendering on screen2145 NanoVis::read _screen();2163 NanoVis::displayOffscreenBuffer(); //display the final rendering on screen 2164 NanoVis::readScreen(); 2146 2165 glutSwapBuffers(); 2147 2166 #endif 2148 2167 2149 2168 if (feof(NanoVis::stdin)) { 2150 DoExit(90);2169 doExit(90); 2151 2170 } 2152 2171 #if DO_RLE … … 2158 2177 write(1, rle, rle_size); //unsigned byte 2159 2178 #else 2160 NanoVis::ppm _write("\nnv>image -type image -bytes");2179 NanoVis::ppmWrite("\nnv>image -type image -bytes"); 2161 2180 #endif 2162 2181 TRACE("Leaving xinetd_listen OK\n"); … … 2187 2206 glutInit(&argc, argv); 2188 2207 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); 2189 glutInitWindowSize(NanoVis::win _width, NanoVis::win_height);2208 glutInitWindowSize(NanoVis::winWidth, NanoVis::winHeight); 2190 2209 glutInitWindowPosition(10, 10); 2191 NanoVis::render _window = glutCreateWindow("nanovis");2210 NanoVis::renderWindow = glutCreateWindow("nanovis"); 2192 2211 glutIdleFunc(NanoVis::idle); 2193 2212 … … 2200 2219 #else 2201 2220 glutDisplayFunc(NanoVis::display); 2202 glutReshapeFunc(NanoVis::resize _offscreen_buffer);2221 glutReshapeFunc(NanoVis::resizeOffscreenBuffer); 2203 2222 #endif 2204 2223 … … 2236 2255 case 3: 2237 2256 case 'd': 2238 NanoVis::debug _flag = true;2257 NanoVis::debugFlag = true; 2239 2258 break; 2240 2259 case 0: … … 2320 2339 Tcl_DStringInit(&NanoVis::cmdbuffer); 2321 2340 NanoVis::interp = initTcl(); 2322 NanoVis::resize _offscreen_buffer(NanoVis::win_width, NanoVis::win_height);2341 NanoVis::resizeOffscreenBuffer(NanoVis::winWidth, NanoVis::winHeight); 2323 2342 2324 2343 glutMainLoop(); 2325 DoExit(80);2344 doExit(80); 2326 2345 } 2327 2346 2328 2347 int 2329 NanoVis::render _2d_contour(HeightMap* heightmap, int width, int height)2330 { 2331 int old_width = win _width;2332 int old_height = win _height;2333 2334 resize _offscreen_buffer(width, height);2348 NanoVis::render2dContour(HeightMap* heightmap, int width, int height) 2349 { 2350 int old_width = winWidth; 2351 int old_height = winHeight; 2352 2353 resizeOffscreenBuffer(width, height); 2335 2354 2336 2355 /* 2337 plane _renderer->set_screen_size(width, height);2356 planeRenderer->set_screen_size(width, height); 2338 2357 2339 2358 // generate data for the legend … … 2343 2362 } 2344 2363 plane[0] = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data); 2345 int index = plane _renderer->add_plane(plane[0], tf);2346 plane _renderer->set_active_plane(index);2347 2348 offscreen _buffer_capture();2364 int index = planeRenderer->add_plane(plane[0], tf); 2365 planeRenderer->set_active_plane(index); 2366 2367 offscreenBufferCapture(); 2349 2368 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen 2350 2369 2351 //plane _renderer->render();2370 //planeRenderer->render(); 2352 2371 // INSOO : is going to implement here for the topview of the heightmap 2353 2372 heightmap->render(renderContext); … … 2364 2383 //char prefix[200]; 2365 2384 //sprintf(prefix, "nv>height_top_view %s %g %g", volArg, min, max); 2366 //ppm _write(prefix);2385 //ppmWrite(prefix); 2367 2386 //write(1, "\n", 1); 2368 //plane _renderer->remove_plane(index);2387 //planeRenderer->remove_plane(index); 2369 2388 2370 2389 // CURRENT 2371 offscreen _buffer_capture();2390 offscreenBufferCapture(); 2372 2391 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen 2373 2392 //glEnable(GL_TEXTURE_2D); … … 2375 2394 //heightmap->render_topview(renderContext, width, height); 2376 2395 //NanoVis::display(); 2377 if (HeightMap::update _pending) {2378 SetHeightmapRanges();2396 if (HeightMap::updatePending) { 2397 setHeightmapRanges(); 2379 2398 } 2380 2399 … … 2383 2402 heightmap->render_topview(renderContext, width, height); 2384 2403 2385 NanoVis::read _screen();2404 NanoVis::readScreen(); 2386 2405 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 2387 2406 2388 2407 // INSOO TEST CODE 2389 bmp _write_to_file(1, "/tmp");2390 2391 resize _offscreen_buffer(old_width, old_height);2408 bmpWriteToFile(1, "/tmp"); 2409 2410 resizeOffscreenBuffer(old_width, old_height); 2392 2411 2393 2412 return TCL_OK; … … 2395 2414 2396 2415 void 2397 NanoVis::remove _volume(Volume *volPtr)2416 NanoVis::removeVolume(Volume *volPtr) 2398 2417 { 2399 2418 Tcl_HashEntry *hPtr; -
trunk/packages/vizservers/nanovis/nanovis.h
r2870 r2877 73 73 74 74 static void init(const char *path); 75 static void xinetd _listen();75 static void xinetdListen(); 76 76 static void initGL(); 77 static void init _offscreen_buffer();78 static void resize _offscreen_buffer(int w, int h);77 static void initOffscreenBuffer(); 78 static void resizeOffscreenBuffer(int w, int h); 79 79 static void resize(int w, int h); 80 80 static void render(); … … 82 82 static void idle(); 83 83 static void update(); 84 static void display _offscreen_buffer();84 static void displayOffscreenBuffer(); 85 85 static void pan(float dx, float dy); 86 86 static void zoom(float z); 87 87 88 static void EventuallyRedraw(unsigned int flag = 0); 89 90 static void SetVolumeRanges(); 91 static void SetHeightmapRanges(); 92 93 static void init_lic(); 88 static void eventuallyRedraw(unsigned int flag = 0); 89 90 static void setVolumeRanges(); 91 static void setHeightmapRanges(); 92 94 93 static void initParticle(); 95 94 96 static void ppm _write(const char *prefix);95 static void ppmWrite(const char *prefix); 97 96 static void sendDataToClient(const char *command, const char *data, 98 97 size_t dlen); 99 static void bmp _write(const char *prefix);100 static void bmp _write_to_file(int frame_number, const char* directory_name);98 static void bmpWrite(const char *prefix); 99 static void bmpWriteToFile(int frame_number, const char* directory_name); 101 100 102 static TransferFunction *get _transfunc(const char *name);103 static TransferFunction * DefineTransferFunction(const char *name,101 static TransferFunction *getTransfunc(const char *name); 102 static TransferFunction *defineTransferFunction(const char *name, 104 103 size_t n, float *data); 105 104 106 static int render_2d_contour(HeightMap *heightmap, int width, int height); 107 108 static int render_legend(TransferFunction *tf, double min, double max, 109 int width, int height, const char *volArg); 110 111 static Volume *load_volume(const char *tag, int width, int height, 112 int depth, int n, float* data, double vmin, double vmax, 113 double nzero_min); 114 static void remove_volume(Volume *volPtr); 105 static int render2dContour(HeightMap *heightmap, int width, int height); 106 107 static int renderLegend(TransferFunction *tf, double min, double max, 108 int width, int height, const char *volArg); 109 110 static Volume *loadVolume(const char *tag, int width, int height, int depth, 111 int n, float* data, double vmin, double vmax, 112 double nonZeroMin); 113 114 static void removeVolume(Volume *volPtr); 115 115 116 116 #ifndef XINETD … … 118 118 static void mouse(int button, int state, int x, int y); 119 119 static void motion(int x, int y); 120 static void update _rot(int delta_x, int delta_y);121 static void update _trans(int delta_x, int delta_y, int delta_z);122 #endif 123 124 static void read _screen()120 static void updateRot(int delta_x, int delta_y); 121 static void updateTrans(int delta_x, int delta_y, int delta_z); 122 #endif 123 124 static void readScreen() 125 125 { 126 glReadPixels(0, 0, win _width, win_height, GL_RGB, GL_UNSIGNED_BYTE,127 screen _buffer);126 glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE, 127 screenBuffer); 128 128 } 129 static void offscreen _buffer_capture()129 static void offscreenBufferCapture() 130 130 { 131 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _final _fbo);131 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo); 132 132 } 133 133 … … 148 148 149 149 static unsigned int flags; 150 static bool debug_flag; 151 static bool axis_on; 152 static bool config_pending; // Indicates if the limits need to be recomputed. 153 static int win_width; //size of the render window 154 static int win_height; //size of the render window 155 static int render_window; 156 static unsigned char *screen_buffer; 150 static bool debugFlag; 151 static bool axisOn; 152 static int winWidth; //size of the render window 153 static int winHeight; //size of the render window 154 static int renderWindow; 155 static unsigned char *screenBuffer; 157 156 static Grid *grid; 158 157 static R2Fonts *fonts; … … 169 168 static float xOrigin, yOrigin, zOrigin; 170 169 171 static VolumeRenderer *vol _renderer;170 static VolumeRenderer *volRenderer; 172 171 static NvFlowVisRenderer *flowVisRenderer; 173 172 static VelocityArrowsSlice *velocityArrowsSlice; 174 173 static NvLIC *licRenderer; 175 static PlaneRenderer *plane _renderer;174 static PlaneRenderer *planeRenderer; 176 175 #if PLANE_CMD 177 176 static Texture2D *plane[]; ///< Pointers to 2D planes 178 177 #endif 179 178 #ifdef USE_POINTSET_RENDERER 180 static PointSetRenderer *point set_renderer;179 static PointSetRenderer *pointSetRenderer; 181 180 static std::vector<PointSet *> pointSet; 182 181 #endif … … 184 183 static Tcl_HashTable tfTable; 185 184 static Texture2D *legendTexture; 186 static NvColorTableRenderer *color _table_renderer;185 static NvColorTableRenderer *colorTableRenderer; 187 186 188 187 static std::vector<HeightMap *> heightMap; 189 188 static Tcl_HashTable heightmapTable; 190 189 191 static float lic_slice_x;192 static float lic_slice_y;193 static float lic_slice_z;194 static int lic_axis; /* 0:x, 1:y, 2:z */195 196 190 static Tcl_Interp *interp; 197 191 static Tcl_DString cmdbuffer; 198 192 199 193 private: 194 static float _licSliceX; 195 static float _licSliceY; 196 static float _licSliceZ; 197 static int _licAxis; /* 0:x, 1:y, 2:z */ 198 200 199 //frame buffer for final rendering 201 static GLuint _final _fbo, _final_color_tex, _final_depth_rb;200 static GLuint _finalFbo, _finalColorTex, _finalDepthRb; 202 201 }; 203 202 -
trunk/packages/vizservers/nanovis/shaders/one_volume.cg
r2852 r2877 16 16 /* 17 17 * render one volume 18 * 19 * renderParameters: 20 * x: number of slices 21 * y: opacity scale (1-21) 22 * z: diffuse coefficient 23 * w: specular exponent 24 * options: 25 * y = isosurface flag (opacity scaling on/off) 18 26 */ 19 27 PixelOut main(v2f IN, 20 28 uniform sampler3D volume, 21 29 uniform sampler1D tf, 22 //uniform sampler1D tf_cutplane,23 30 uniform float4x4 modelViewInv, 24 31 uniform float4x4 modelView, … … 35 42 if (renderParameters.x < 0.5) { 36 43 //If single slice render, only flat shading, completely opaque. 37 //color = tex1D(tf_cutplane, sample.x);38 44 color.w = 1; 39 //color.w = renderParameters.y*color.w/renderParameters.x;40 45 } else { 41 46 //regular volume rendering, we do PHONG SHADING 42 //lighting parameters 47 //lighting parameters 48 #if 1 43 49 float3 normal; 44 if (length(sample.yzw) > 0.0) { 45 // INSOO (iso) 46 //normal = sample.yzw * 2.0 - 1.0; //(iso) 47 //normal = normalize(normal); 48 normal = normalize(sample.yzw); 50 float diffuse, specular; 51 if (dot(sample.yzw, sample.yzw) < 5.0e-5) { 52 diffuse = 0; 53 specular = 0; 54 } else { 55 normal = normalize(sample.yzw * 2.0 - 1.0); 56 float3 light_vector = normalize(IN.Light); 57 float3 eye_vector = normalize(IN.EyeVector); 58 float3 half_vector = normalize(eye_vector+light_vector); 59 60 //lighting computation 61 #ifndef LIGHT_TWO_SIDE 62 float normal_dot_light = max(dot(normal, light_vector), 0); 63 float normal_dot_half = max(dot(normal, half_vector), 0); 64 #else 65 float normal_dot_light = dot(normal, light_vector); 66 if (normal_dot_light < 0.0) { 67 normal_dot_light = dot(-normal, light_vector); 68 } 69 float normal_dot_half = dot(normal, half_vector); 70 if (normal_dot_half < 0.0) { 71 normal_dot_half = dot(-normal, half_vector); 72 } 73 #endif 74 diffuse = normal_dot_light * renderParameters.z; 75 //specular = pow(normal_dot_half, renderParameters.w)*(1-ambient-diffuse); 76 if (diffuse > 1.0e-6) 77 specular = pow(normal_dot_half, 90.)*0.3; 78 else 79 specular = 0.0; 49 80 } 50 51 float3 light_vector = normalize(IN.Light); 52 float3 eye_vector = normalize(IN.EyeVector); 53 float3 half_vector = normalize(eye_vector+light_vector); 54 55 //lighting computation 56 float normal_dot_light = max(dot(normal, light_vector), 0); 57 float normal_dot_half = max(dot(normal, half_vector), 0); 58 59 // INSOO (iso) 60 //float normal_dot_light = abs(dot(normal, light_vector)); 61 //float normal_dot_half = abs(dot(normal, half_vector)); 62 63 float ambient = 0.8; 64 65 float diffuse = normal_dot_light * renderParameters.z; 66 67 float specular = pow(normal_dot_half, renderParameters.w)*(1-ambient-diffuse); 81 float ambient = max(.2, 1.0 - renderParameters.z); 68 82 69 83 float lighting = ambient + diffuse + specular; 70 color.xyz = color.xyz * lighting; 84 color.xyz = color.xyz * ambient + color.xyz * diffuse + float3(specular); 85 #else 86 if (dot(sample.yzw, sample.yzw) < 5.0e-5) { 87 color.xyz = float3(0); 88 } else { 89 color.xyz = normalize(sample.yzw); 90 } 91 #endif 71 92 72 93 if (options.y < 0.5) { 73 94 //opacity is modulated by the number of total slices 74 95 //to avoid very opaque volume when number of slices is high 75 color.w = renderParameters.y*color.w/renderParameters.x; 96 // renderParameters.x = number of slices 97 // renderParameters.y = opacity scale (1-21) 98 color.w = color.w * 0.2 * renderParameters.y/renderParameters.x; 76 99 77 100 // INSOO (iso) 78 101 //opacity is modulated by the number of total slices 79 //color.w = renderParameters.y*color.w/renderParameters.x * 0.2;102 //color.w = color.w * renderParameters.y/renderParameters.x * 0.2; 80 103 } 81 104 } 82 105 83 OUT.Color = color;106 OUT.Color = min(max(color, 0.0), 1.0); 84 107 85 108 return OUT; -
trunk/packages/vizservers/nanovis/shaders/particlefp.cg
r2852 r2877 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include "particlemacro.h"3 2 #include "particle_common.cg" 4 3 -
trunk/packages/vizservers/nanovis/shaders/velocity.cg
r2852 r2877 21 21 22 22 // Velocity change operations. 23 #include "velocityOps.cg"23 //#include "velocityOps.cg" 24 24 25 25 // Uniform parameters influencing velocity. … … 32 32 { 33 33 float3 gravity = float3(0, -.01, 0); 34 34 35 35 float3 acceleration = gravity; 36 36 … … 73 73 float3 velocity = (float3)texRECT(_VelocityTexture, _TexCoord); 74 74 float3 position = (float3)texRECT(_PositionTexture, _TexCoord); 75 75 76 76 return float4(advanceVelocity(velocity, position, _TimeStep), 0); 77 77 } -
trunk/packages/vizservers/nanovis/shaders/velocityslicevp.cg
r2857 r2877 50 50 float4 posEye = mul(modelview, posin); 51 51 //pointSize = tanHalfFOV / -posEye.z / 5; 52 pointSize = tanHalfFOV / -posEye.z / 10; //j-wire53 //pointSize = 10 / -posEye.z;52 //pointSize = tanHalfFOV / -posEye.z / 10; //j-wire 53 pointSize = 20; //0 / -posEye.z; 54 54 55 55 posout = mul(mvp, vec); -
trunk/packages/vizservers/nanovis/shaders/vertex_std.cg
r2852 r2877 20 20 v2f OUT; 21 21 22 // IN.Position is in eye coords 23 float4 objPos = mul(modelViewInv, IN.Position); 24 float4 eyePosObjSpace = mul(modelViewInv, float4(0,0,0,1)); 25 22 26 //clip space vertex position 23 OUT.HPosition = mul(modelViewProjMatrix, mul(modelViewInv, IN.Position)); 27 //OUT.HPosition = mul(modelViewProjMatrix, mul(modelViewInv, IN.Position)); 28 OUT.HPosition = mul(modelViewProjMatrix, objPos); 24 29 25 30 //eye space texture coordinates … … 27 32 28 33 //world space eye position 29 OUT.EyeVector = normalize(-IN.Position.xyz); 34 //OUT.EyeVector = normalize(-IN.Position.xyz); 35 OUT.EyeVector = normalize(eyePosObjSpace - objPos); 30 36 31 37 //world space light postion 32 OUT.Light = normalize(float3(1,1,1)-IN.Position.xyz); 38 //OUT.Light = normalize(float3(1,1,1)-IN.Position.xyz); 39 OUT.Light = normalize(mul(modelViewInv, float4(1,1,1,1))-objPos); 33 40 34 41 return OUT; -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrBPlane.h
r2841 r2877 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /** \class vrPlane vrPlane <R2/math/vrPlane.h> 3 * \brief plane 2 /** \class vrBPlane vrBPlane.h <vrmath/vrBPlane.h> 4 3 * \author Insoo Woo(iwoo@purdue.edu), Sung-Ye Kim (inside@purdue.edu) 5 4 * \author PhD research assistants in PURPL at Purdue University -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrLineSegment.h
r2841 r2877 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /** \class vrPlane vrPlane <R2/math/vrPlane.h> 3 * \brief plane 2 /** \class vrLineSegment vrLineSegment.h <vrmath/vrLineSegment.h> 4 3 * \author Insoo Woo(iwoo@purdue.edu), Sung-Ye Kim (inside@purdue.edu) 5 4 * \author PhD research assistants in PURPL at Purdue University -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrMatrix4x4f.h
r2844 r2877 24 24 /** 25 25 * @brief make a translation matrix 26 * @param translation translation27 26 */ 28 27 void makeTranslation(const vrVector3f& translation); … … 30 29 /** 31 30 * @brief make a translation matrix 32 * @param x x position33 31 */ 34 32 void makeTranslation(float x, float y, float z); … … 36 34 /** 37 35 * @brief make a rotation matrix 38 * @param rotation rotation39 36 */ 40 37 void makeRotation(const vrRotation& rotation); … … 42 39 /** 43 40 * @brief Make a rotation matrix 44 * @param rotation rotation45 41 */ 46 42 void makeRotation(float x, float y, float z, float angle); … … 50 46 /** 51 47 * @brief make a scale matrix 52 * @param scale scale53 48 */ 54 49 void makeScale(const vrVector3f& scale); -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrPlane.h
r2841 r2877 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /** \class vrPlane vrPlane <R2/math/vrPlane.h> 3 * \brief plane 2 /** \class vrPlane vrPlane.h <vrmath/vrPlane.h> 4 3 * \author Insoo Woo(iwoo@purdue.edu), Sung-Ye Kim (inside@purdue.edu) 5 4 * \author PhD research assistants in PURPL at Purdue University -
trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrPlane2.h
r2841 r2877 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /** \class vrPlane vrPlane <vrmath/vrPlane.h> 3 * \brief plane 2 /** \class vrPlane2 vrPlane2.h <vrmath/vrPlane2.h> 4 3 * \author Insoo Woo(iwoo@purdue.edu), Sung-Ye Kim (inside@purdue.edu) 5 4 * \author PhD research assistants in PURPL at Purdue University … … 17 16 public: 18 17 void makePts(const vrVector3f& pt1, const vrVector3f& pt2, const vrVector3f& pt3); 18 19 19 void makeNormalPt(const vrVector3f& norm, const vrVector3f& pos); 20 20 21 bool intersect(const vrLineSegment &seg, float &d) const; 22 21 23 float distance(const vrVector3f& point) const; 24 22 25 vrVector3f crossPoint(const vrVector3f& point) const; 23 26
Note: See TracChangeset
for help on using the changeset viewer.