- Timestamp:
- Feb 25, 2013 1:13:15 PM (11 years ago)
- Location:
- branches/nanovis2/packages/vizservers/nanovis
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/nanovis2/packages/vizservers/nanovis/Command.cpp
r3334 r3354 1893 1893 } 1894 1894 1895 1896 static int1897 HeightMapTopView(ClientData data, Tcl_Interp *interp, int objc,1898 Tcl_Obj *const *objv)1899 {1900 1901 // the variables below should be reassigned1902 int image_width = 512;1903 int image_height = 512;1904 HeightMap* heightmap = 0;1905 1906 // HELP ME1907 // GEORGE1908 1909 NanoVis::render2dContour(heightmap, image_width, image_height);1910 NanoVis::eventuallyRedraw();1911 return TCL_OK;1912 }1913 1914 static int1915 HeightMapTestOp(ClientData clientData, Tcl_Interp *interp, int objc,1916 Tcl_Obj *const *objv)1917 {1918 srand((unsigned)time(NULL));1919 1920 int size = 20 * 20;1921 double sigma = 5.0;1922 double mean = exp(0.0) / (sigma * sqrt(2.0));1923 float* data = (float*) malloc(sizeof(float) * size);1924 1925 float x, y;1926 for (int i = 0; i < size; ++i) {1927 x = - 10 + i%20;1928 y = - 10 + (i/20);1929 data[i] = exp(- (x * y)/(2 * sigma * sigma)) /1930 (sigma * sqrt(2.0)) / mean * 2 + 1000;1931 //data[i] = ((float)rand()) / RAND_MAX * 1.0;1932 }1933 1934 HeightMap* hmPtr = new HeightMap();1935 float minx = 0.0f;1936 float maxx = 1.0f;1937 float miny = 0.5f;1938 float maxy = 3.5f;1939 hmPtr->setHeight(minx, miny, maxx, maxy, 20, 20, data);1940 hmPtr->transferFunction(NanoVis::getTransfunc("default"));1941 hmPtr->setVisible(true);1942 hmPtr->setLineContourVisible(true);1943 NanoVis::grid->setVisible(true);1944 Tcl_HashEntry *hPtr;1945 int isNew;1946 hPtr = Tcl_CreateHashEntry(&NanoVis::heightmapTable, "test", &isNew);1947 if (!isNew) {1948 Tcl_AppendResult(interp, "heightmap \"test\" already exists.",1949 (char *)NULL);1950 return TCL_ERROR;1951 }1952 Tcl_SetHashValue(hPtr, hmPtr);1953 int image_width = 512;1954 int image_height = 512;1955 1956 NanoVis::render2dContour(hmPtr, image_width, image_height);1957 1958 return TCL_OK;1959 }1960 1961 1895 static int 1962 1896 HeightMapTransFuncOp(ClientData clientData, Tcl_Interp *interp, int objc, … … 2014 1948 {"polygon", 1, HeightMapPolygonOp, 3, 3, "mode",}, 2015 1949 {"shading", 1, HeightMapShadingOp, 3, 3, "model",}, 2016 {"test", 2, HeightMapTestOp, 2, 2, "",},2017 1950 {"transfunc", 2, HeightMapTransFuncOp, 3, 0, "name ?heightmap...?",}, 2018 2019 // HELP ME2020 // GOERGE2021 {"topview", 2, HeightMapTopView, 2, 2, "",},2022 1951 }; 2023 1952 static int nHeightMapOps = NumCmdSpecs(heightMapOps); -
branches/nanovis2/packages/vizservers/nanovis/HeightMap.cpp
r2956 r3354 12 12 double HeightMap::valueMax = 1.0; 13 13 14 #define TOPCONTOUR 015 //#define TOPCONTOUR 116 14 HeightMap::HeightMap() : 17 15 _vertexBufferObjectID(0), … … 19 17 _vertexCount(0), 20 18 _contour(0), 21 _topContour(0),22 19 _tfPtr(0), 23 20 _opacity(0.5f), … … 26 23 _contourColor(1.0f, 0.0f, 0.0f), 27 24 _contourVisible(false), 28 _topContourVisible(true),29 25 _visible(false), 30 26 _scale(1.0f, 1.0f, 1.0f), … … 140 136 } 141 137 142 #if TOPCONTOUR143 if (_topContourVisible) {144 glDisable(GL_BLEND);145 glDisable(GL_TEXTURE_2D);146 glColor4f(_contourColor.x, _contourColor.y, _contourColor.z,147 _opacity /*1.0f*/);148 //glDepthRange (0.0, 0.999);149 _topContour->render();150 }151 #endif152 138 glDepthRange (0.0, 1.0); 153 139 } … … 303 289 _contour = lineFilter.create(0.0f, 1.0f, 10, heights, xCount, yCount); 304 290 305 #if TOPCONTOUR306 ContourLineFilter topLineFilter;307 topLineFilter.setHeightTop(true);308 _topContour = topLineFilter.create(0.0f, 1.0f, 10, heights, xCount, yCount);309 #endif310 311 291 //if (heightMap) 312 292 //{ … … 396 376 //lineFilter.transferFunction(_tfPtr); 397 377 _contour = lineFilter.create(0.0f, 1.0f, 10, map, xNum, yNum); 398 399 #if TOPCONTOUR 400 ContourLineFilter topLineFilter; 401 topLineFilter.setHeightTop(true); 402 _topContour = topLineFilter.create(0.0f, 1.0f, 10, map, xNum, yNum); 403 #endif 378 404 379 this->createIndexBuffer(xNum, yNum, heights); 405 380 delete [] map; … … 495 470 _contour = lineFilter.create(0.0f, 1.0f, 10, vertices, _xNum, _yNum); 496 471 497 #if TOPCONTOUR498 ContourLineFilter topLineFilter;499 topLineFilter.setHeightTop(true);500 _topContour = topLineFilter.create(0.0f, 1.0f, 10, vertices, _xNum, _yNum);501 #endif502 472 this->createIndexBuffer(_xNum, _yNum, normHeights); 503 473 delete [] normHeights; 504 474 delete [] vertices; 505 475 } 506 507 void508 HeightMap::renderTopview(graphics::RenderContext* renderContext,509 int render_width, int render_height)510 {511 glClear(GL_COLOR_BUFFER_BIT);512 glPushAttrib(GL_VIEWPORT_BIT);513 glViewport(0, 0, render_width, render_height);514 glMatrixMode(GL_PROJECTION);515 glPushMatrix();516 glLoadIdentity();517 //gluOrtho2D(0, render_width, 0, render_height);518 glOrtho(-.5, .5, -.5, .5, -50, 50);519 glMatrixMode(GL_MODELVIEW);520 glPushMatrix();521 glLoadIdentity();522 523 glTranslatef(0.0, 0.0, -10.0);524 525 // put camera rotation and translation526 //glScalef(1 / _scale.x, 1 / _scale.y , 1 / _scale.z);527 528 if (renderContext->getCullMode() == graphics::RenderContext::NO_CULL) {529 glDisable(GL_CULL_FACE);530 } else {531 glEnable(GL_CULL_FACE);532 glCullFace((GLuint) renderContext->getCullMode());533 }534 535 glPolygonMode(GL_FRONT_AND_BACK, (GLuint) renderContext->getPolygonMode());536 glShadeModel((GLuint) renderContext->getShadingModel());537 538 glPushMatrix();539 540 //glTranslatef(-_centerPoint.x, -_centerPoint.y, -_centerPoint.z);541 542 //glScalef(0.01, 0.01, 0.01f);543 glRotatef(90.0f, 1.0f, 0.0f, 0.0f);544 glTranslatef(-_centerPoint.x, -_centerPoint.y, -_centerPoint.z);545 if (_contour != NULL) {546 glDepthRange (0.001, 1.0);547 }548 549 glEnable(GL_DEPTH_TEST);550 551 glEnable(GL_BLEND);552 glEnable(GL_TEXTURE_2D);553 if (_vertexBufferObjectID)554 {555 TRACE("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\n");556 glColor3f(1.0f, 1.0f, 1.0f);557 glShadeModel(GL_SMOOTH);558 glEnable(GL_BLEND);559 glEnableClientState(GL_VERTEX_ARRAY);560 glDisableClientState(GL_COLOR_ARRAY);561 glDisableClientState(GL_INDEX_ARRAY);562 glDisableClientState(GL_NORMAL_ARRAY);563 564 if (_tfPtr != NULL) {565 _shader->bind();566 567 _shader->setFPTextureParameter("tf", _tfPtr->id());568 569 glEnable(GL_TEXTURE_1D);570 _tfPtr->getTexture()->activate();571 572 glEnableClientState(GL_TEXTURE_COORD_ARRAY);573 } else {574 glDisableClientState(GL_TEXTURE_COORD_ARRAY);575 }576 577 glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferObjectID);578 glVertexPointer(3, GL_FLOAT, 12, 0);579 580 glBindBuffer(GL_ARRAY_BUFFER, _texcoordBufferObjectID);581 glTexCoordPointer(3, GL_FLOAT, 12, 0);582 583 #define _TRIANGLES_584 #ifdef _TRIANGLES_585 glDrawElements(GL_TRIANGLES, _indexCount, GL_UNSIGNED_INT,586 _indexBuffer);587 #else588 glDrawElements(GL_QUADS, _indexCount, GL_UNSIGNED_INT,589 _indexBuffer);590 #endif591 592 glBindBuffer(GL_ARRAY_BUFFER, 0);593 594 glDisableClientState(GL_VERTEX_ARRAY);595 if (_tfPtr != NULL) {596 _tfPtr->getTexture()->deactivate();597 glDisableClientState(GL_TEXTURE_COORD_ARRAY);598 599 _shader->disableFPTextureParameter("tf");600 _shader->unbind();601 }602 }603 604 glShadeModel(GL_FLAT);605 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);606 607 if (_contour != NULL) {608 if (_contourVisible) {609 glDisable(GL_BLEND);610 glDisable(GL_TEXTURE_2D);611 glColor4f(_contourColor.x, _contourColor.y, _contourColor.z, 1.0f);612 glDepthRange (0.0, 0.999);613 _contour->render();614 glDepthRange (0.0, 1.0);615 }616 617 #if TOPCONTOUR618 if (_topContourVisible) {619 glDisable(GL_BLEND);620 glDisable(GL_TEXTURE_2D);621 glColor4f(_contourColor.x, _contourColor.y, _contourColor.z, 1.0f);622 //glDepthRange (0.0, 0.999);623 _topContour->render();624 //glDepthRange (0.0, 1.0);625 }626 #endif627 }628 629 glPopMatrix();630 glPopMatrix();631 632 glMatrixMode(GL_PROJECTION);633 glPushMatrix();634 glMatrixMode(GL_MODELVIEW);635 636 glPopAttrib();637 } -
branches/nanovis2/packages/vizservers/nanovis/HeightMap.h
r2956 r3354 28 28 29 29 void render(graphics::RenderContext *renderContext); 30 31 void renderTopview(graphics::RenderContext *renderContext,32 int render_width, int render_height);33 30 34 31 /** … … 94 91 } 95 92 96 void setTopLineContourVisible(bool visible)97 {98 _topContourVisible = visible;99 }100 101 93 void opacity(float opacity) 102 94 { … … 134 126 int _vertexCount; 135 127 R2Geometry *_contour; 136 R2Geometry *_topContour;137 128 TransferFunction *_tfPtr; 138 129 float _opacity; … … 143 134 144 135 bool _contourVisible; 145 bool _topContourVisible;146 136 bool _visible; 147 137 -
branches/nanovis2/packages/vizservers/nanovis/nanovis.cpp
r3341 r3354 2134 2134 } 2135 2135 2136 int2137 NanoVis::render2dContour(HeightMap* heightmap, int width, int height)2138 {2139 int old_width = winWidth;2140 int old_height = winHeight;2141 2142 resizeOffscreenBuffer(width, height);2143 2144 /*2145 planeRenderer->setScreenSize(width, height);2146 2147 // generate data for the legend2148 float data[512];2149 for (int i=0; i < 256; i++) {2150 data[i] = data[i+256] = (float)(i/255.0);2151 }2152 plane[0] = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data);2153 int index = planeRenderer->addPlane(plane[0], tf);2154 planeRenderer->setActivePlane(index);2155 2156 bindOffscreenBuffer();2157 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen2158 2159 //planeRenderer->render();2160 // INSOO : is going to implement here for the topview of the heightmap2161 heightmap->render(renderContext);2162 2163 // INSOO2164 glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, screen_buffer);2165 //glReadPixels(0, 0, width, height, GL_BGR, GL_UNSIGNED_BYTE, screen_buffer); // INSOO's2166 */2167 2168 2169 // HELP ME2170 // GEORGE2171 // I am not sure what I should do2172 //char prefix[200];2173 //sprintf(prefix, "nv>height_top_view %s %g %g", volArg, min, max);2174 //ppmWrite(prefix);2175 //write(1, "\n", 1);2176 //planeRenderer->removePlane(index);2177 2178 // CURRENT2179 bindOffscreenBuffer();2180 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen2181 //glEnable(GL_TEXTURE_2D);2182 //glEnable(GL_DEPTH_TEST);2183 //heightmap->renderTopview(renderContext, width, height);2184 //NanoVis::display();2185 if (HeightMap::updatePending) {2186 setHeightmapRanges();2187 }2188 2189 //cam->initialize();2190 2191 heightmap->renderTopview(renderContext, width, height);2192 2193 readScreen();2194 2195 // INSOO TEST CODE2196 bmpWriteToFile(1, "/tmp");2197 2198 resizeOffscreenBuffer(old_width, old_height);2199 2200 return TCL_OK;2201 }2202 2203 2136 void 2204 2137 NanoVis::removeVolume(Volume *volPtr) -
branches/nanovis2/packages/vizservers/nanovis/nanovis.h
r3334 r3354 107 107 size_t n, float *data); 108 108 109 static int render2dContour(HeightMap *heightmap, int width, int height);110 111 109 static int renderLegend(TransferFunction *tf, double min, double max, 112 110 int width, int height, const char *volArg);
Note: See TracChangeset
for help on using the changeset viewer.