Changeset 1188
- Timestamp:
- Oct 16, 2008 1:30:45 PM (16 years ago)
- Location:
- trunk/packages/vizservers/nanovis
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/Command.cpp
r1163 r1188 40 40 41 41 #include <tcl.h> 42 #include <stdlib.h> 42 43 #include "Trace.h" 43 44 #include "Command.h" … … 1314 1315 // 1315 1316 if (NanoVis::volume[n] != NULL) { 1317 //NanoVis::volume[n]->set_n_slice(512-n); 1316 1318 NanoVis::volume[n]->set_n_slice(256-n); 1317 1319 NanoVis::volume[n]->disable_cutplane(0); … … 1897 1899 // 1898 1900 if (volPtr != NULL) { 1899 volPtr->set_n_slice(256-n); 1901 //volPtr->set_n_slice(256-n); 1902 volPtr->set_n_slice(512-n); 1900 1903 volPtr->disable_cutplane(0); 1901 1904 volPtr->disable_cutplane(1); … … 2129 2132 // GEORGE 2130 2133 2131 2132 2134 NanoVis::render_2d_contour(heightmap, image_width, image_height); 2133 2135 … … 2141 2143 srand((unsigned)time(NULL)); 2142 2144 2143 int size = 20 * 20 0;2145 int size = 20 * 20; 2144 2146 double sigma = 5.0; 2145 2147 double mean = exp(0.0) / (sigma * sqrt(2.0)); 2146 2148 float* data = (float*) malloc(sizeof(float) * size); 2147 2149 2148 float x ;2150 float x, y; 2149 2151 for (int i = 0; i < size; ++i) { 2150 2152 x = - 10 + i%20; 2151 data[i] = exp(- (x * x)/(2 * sigma * sigma)) / 2153 y = - 10 + (i/20); 2154 data[i] = exp(- (x * y)/(2 * sigma * sigma)) / 2152 2155 (sigma * sqrt(2.0)) / mean * 2 + 1000; 2156 //data[i] = ((float)rand()) / RAND_MAX * 1.0; 2153 2157 } 2154 2158 … … 2158 2162 float miny = 0.5f; 2159 2163 float maxy = 3.5f; 2160 hmPtr->setHeight(minx, miny, maxx, maxy, 20, 20 0, data);2164 hmPtr->setHeight(minx, miny, maxx, maxy, 20, 20, data); 2161 2165 hmPtr->setColorMap(NanoVis::get_transfunc("default")); 2162 2166 hmPtr->setVisible(true); … … 2164 2168 NanoVis::grid->setVisible(true); 2165 2169 NanoVis::heightMap.push_back(hmPtr); 2170 2171 int image_width = 512; 2172 int image_height = 512; 2173 2174 NanoVis::render_2d_contour(hmPtr, image_width, image_height); 2175 2166 2176 return TCL_OK; 2167 2177 } … … 2205 2215 // HELP ME 2206 2216 // GOERGE 2207 {"topview", 1, HeightMapTopView, 3, 3, "model",},2217 {"topview", 2, HeightMapTopView, 2, 2, "",}, 2208 2218 }; 2209 2219 static int nHeightMapOps = NumCmdSpecs(heightMapOps); -
trunk/packages/vizservers/nanovis/HeightMap.cpp
r1161 r1188 23 23 24 24 #define TOPCONTOUR 0 25 //#define TOPCONTOUR 1 25 26 HeightMap::HeightMap() : 26 27 _vertexBufferObjectID(0), … … 512 513 } 513 514 515 void HeightMap::render_topview(graphics::RenderContext* renderContext, int render_width, int render_height) 516 { 517 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 518 glPushAttrib(GL_VIEWPORT_BIT); 519 glViewport(0, 0, render_width, render_height); 520 glMatrixMode(GL_PROJECTION); 521 glPushMatrix(); 522 glLoadIdentity(); 523 //gluOrtho2D(0, render_width, 0, render_height); 524 glOrtho(-.5, .5, -.5, .5, -50, 50); 525 glMatrixMode(GL_MODELVIEW); 526 glPushMatrix(); 527 glLoadIdentity(); 528 529 glTranslatef(0.0, 0.0, -10.0); 530 531 // put camera rotation and traslation 532 //glScalef(1 / _scale.x, 1 / _scale.y , 1 / _scale.z); 533 534 if (renderContext->getCullMode() == graphics::RenderContext::NO_CULL) { 535 glDisable(GL_CULL_FACE); 536 } else { 537 glEnable(GL_CULL_FACE); 538 glCullFace((GLuint) renderContext->getCullMode()); 539 } 540 541 glPolygonMode(GL_FRONT_AND_BACK, (GLuint) renderContext->getPolygonMode()); 542 glShadeModel((GLuint) renderContext->getShadingModel()); 543 544 glPushMatrix(); 545 546 //glTranslatef(-_centerPoint.x, -_centerPoint.y, -_centerPoint.z); 547 548 //glScalef(0.01, 0.01, 0.01f); 549 glRotatef(90.0f, 1.0f, 0.0f, 0.0f); 550 glTranslatef(-_centerPoint.x, -_centerPoint.y, -_centerPoint.z); 551 if (_contour != NULL) { 552 glDepthRange (0.001, 1.0); 553 } 554 555 glEnable(GL_DEPTH_TEST); 556 557 glEnable(GL_BLEND); 558 glEnable(GL_TEXTURE_2D); 559 if (_vertexBufferObjectID) 560 { 561 printf("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\n"); 562 glColor3f(1.0f, 1.0f, 1.0f); 563 glShadeModel(GL_SMOOTH); 564 glEnable(GL_BLEND); 565 glEnableClientState(GL_VERTEX_ARRAY); 566 glDisableClientState(GL_COLOR_ARRAY); 567 glDisableClientState(GL_INDEX_ARRAY); 568 glDisableClientState(GL_NORMAL_ARRAY); 569 570 if (_colorMap) { 571 cgGLBindProgram(_shader->getFP()); 572 cgGLEnableProfile(CG_PROFILE_FP30); 573 574 cgGLSetTextureParameter(_tf, _colorMap->id); 575 cgGLEnableTextureParameter(_tf); 576 577 glEnable(GL_TEXTURE_1D); 578 _colorMap->getTexture()->activate(); 579 580 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 581 } 582 else { 583 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 584 } 585 586 glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferObjectID); 587 glVertexPointer(3, GL_FLOAT, 12, 0); 588 589 glBindBuffer(GL_ARRAY_BUFFER, _textureBufferObjectID); 590 ::glTexCoordPointer(3, GL_FLOAT, 12, 0); 591 592 #define _TRIANGLES_ 593 #ifdef _TRIANGLES_ 594 glDrawElements(GL_TRIANGLES, _indexCount, GL_UNSIGNED_INT, 595 _indexBuffer); 596 #else 597 glDrawElements(GL_QUADS, _indexCount, GL_UNSIGNED_INT, 598 _indexBuffer); 599 #endif 600 601 glBindBuffer(GL_ARRAY_BUFFER, 0); 602 603 glDisableClientState(GL_VERTEX_ARRAY); 604 if (_colorMap) { 605 _colorMap->getTexture()->deactivate(); 606 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 607 608 cgGLDisableProfile(CG_PROFILE_FP30); 609 } 610 } 611 612 glShadeModel(GL_FLAT); 613 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 614 615 if (_contour != NULL) { 616 if (_contourVisible) { 617 glDisable(GL_BLEND); 618 glDisable(GL_TEXTURE_2D); 619 glColor4f(_contourColor.x, _contourColor.y, _contourColor.z, 1.0f); 620 glDepthRange (0.0, 0.999); 621 _contour->render(); 622 glDepthRange (0.0, 1.0); 623 } 624 625 #if TOPCONTOUR 626 if (_topContourVisible) { 627 glDisable(GL_BLEND); 628 glDisable(GL_TEXTURE_2D); 629 glColor4f(_contourColor.x, _contourColor.y, _contourColor.z, 1.0f); 630 //glDepthRange (0.0, 0.999); 631 _topContour->render(); 632 //glDepthRange (0.0, 1.0); 633 } 634 #endif 635 } 636 637 glPopMatrix(); 638 glPopMatrix(); 639 640 glMatrixMode(GL_PROJECTION); 641 glPushMatrix(); 642 glMatrixMode(GL_MODELVIEW); 643 644 glPopAttrib(); 645 } 646 -
trunk/packages/vizservers/nanovis/HeightMap.h
r1112 r1188 65 65 public : 66 66 void render(graphics::RenderContext* renderContext); 67 void render_topview(graphics::RenderContext* renderContext, int render_width, int render_height); 67 68 /** 68 69 *@brief Create a height map with heigh values -
trunk/packages/vizservers/nanovis/RpDX.cpp
r1181 r1188 47 47 48 48 if (filename == NULL) { 49 resultPtr->AddError("filename is NULL");49 //resultPtr->AddError("filename is NULL"); 50 50 return; 51 51 } … … 56 56 _dxobj = DXImportDX((char*)filename,NULL,NULL,NULL,NULL); 57 57 if (_dxobj == NULL) { 58 resultPtr->AddError("can't import DX file \"%s\"", filename);58 //resultPtr->AddError("can't import DX file \"%s\"", filename); 59 59 return; 60 60 } … … 67 67 dxpos = (Array) DXGetComponentValue((Field) _dxobj, (char *)"positions"); 68 68 if (dxpos == NULL) { 69 resultPtr->AddError("can't get component value of \"positions\"");69 //resultPtr->AddError("can't get component value of \"positions\""); 70 70 return; 71 71 } … … 74 74 fprintf(stdout, "_n = %d\n",_n); 75 75 if (type != TYPE_FLOAT) { 76 resultPtr->AddError("\"positions\" is not type float (type=%d)\n", type);76 //resultPtr->AddError("\"positions\" is not type float (type=%d)\n", type); 77 77 return; 78 78 } … … 83 83 pos = (float*) DXGetArrayData(dxpos); 84 84 if (pos == NULL) { 85 resultPtr->AddError("DXGetArrayData failed to return positions array");85 //resultPtr->AddError("DXGetArrayData failed to return positions array"); 86 86 return; 87 87 } … … 91 91 if (DXQueryGridConnections(dxgrid, &_numAxis, NULL) == NULL) { 92 92 // raise error, data is not a regular grid and we cannot handle it 93 resultPtr->AddError("DX says our grid is not regular, we cannot handle this data");93 //resultPtr->AddError("DX says our grid is not regular, we cannot handle this data"); 94 94 return; 95 95 } … … 98 98 if (_positions == NULL) { 99 99 // malloc failed, raise error 100 resultPtr->AddError("malloc of _positions array failed");100 //resultPtr->AddError("malloc of _positions array failed"); 101 101 return; 102 102 } … … 106 106 if (_axisLen == NULL) { 107 107 // malloc failed, raise error 108 resultPtr->AddError("malloc of _axisLen array failed");108 //resultPtr->AddError("malloc of _axisLen array failed"); 109 109 return; 110 110 } … … 113 113 _delta = new float[_numAxis*_numAxis]; 114 114 if (_delta == NULL) { 115 resultPtr->AddError("malloc of _delta array failed");115 //resultPtr->AddError("malloc of _delta array failed"); 116 116 return; 117 117 } … … 120 120 _origin = new float[_numAxis]; 121 121 if (_origin == NULL) { 122 resultPtr->AddError("malloc of _origin array failed");122 //resultPtr->AddError("malloc of _origin array failed"); 123 123 return; 124 124 } … … 127 127 _max = new float[_numAxis]; 128 128 if (_max == NULL) { 129 resultPtr->AddError("malloc of _max array failed");129 //resultPtr->AddError("malloc of _max array failed"); 130 130 return; 131 131 } … … 151 151 _data = new float[_n]; 152 152 if (_data == NULL) { 153 resultPtr->AddError("malloc of _data array failed");153 //resultPtr->AddError("malloc of _data array failed"); 154 154 return; 155 155 } … … 172 172 173 173 default: 174 resultPtr->AddError("don't know how to handle data of type %d\n", type);174 //resultPtr->AddError("don't know how to handle data of type %d\n", type); 175 175 return; 176 176 } -
trunk/packages/vizservers/nanovis/Volume.cpp
r1053 r1188 34 34 pointsetIndex(-1), 35 35 enabled(true), 36 n_slice(256), // default value 36 //n_slice(256), // default value 37 n_slice(512), // default value 37 38 specular(6.), // default value 38 39 diffuse(3.), // default value -
trunk/packages/vizservers/nanovis/define.h
r434 r1188 60 60 void debug(char *message, double v1, double v2, double v3); 61 61 62 #define __NANOVIS_DEBUG__ 0 63 //#define __NANOVIS_DEBUG__ 1 64 62 65 #endif -
trunk/packages/vizservers/nanovis/nanovis.cpp
r1182 r1188 879 879 880 880 glClearColor(0,0,0,1); 881 //glClearColor(0.7,0.7,0.7,1); 881 882 glClear(GL_COLOR_BUFFER_BIT); 882 883 … … 2403 2404 //ppm_write(prefix); 2404 2405 //write(0, "\n", 1); 2405 2406 2407 2408 2409 2406 //plane_render->remove_plane(index); 2407 2408 // CURRENT 2409 offscreen_buffer_capture(); 2410 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen 2411 //glEnable(GL_TEXTURE_2D); 2412 //glEnable(GL_DEPTH_TEST); 2413 //heightmap->render_topview(renderContext, width, height); 2414 //NanoVis::display(); 2415 if (HeightMap::update_pending) { 2416 SetHeightmapRanges(); 2417 } 2418 2419 //cam->activate(); 2420 2421 heightmap->render_topview(renderContext, width, height); 2422 2423 NanoVis::read_screen(); 2424 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 2425 2426 // INSOO TEST CODE 2427 bmp_write_to_file(1, "/tmp"); 2410 2428 2411 2429 resize_offscreen_buffer(old_width, old_height); -
trunk/packages/vizservers/nanovis/shaders/one_volume.cg
r1000 r1188 64 64 //float normal_dot_half = abs(dot(normal, half_vector)); 65 65 66 67 66 float ambient = 0.8; 68 67 … … 87 86 return OUT; 88 87 } 88
Note: See TracChangeset
for help on using the changeset viewer.