Changeset 780 for trunk/vizservers


Ignore:
Timestamp:
Jul 10, 2007, 7:55:13 AM (17 years ago)
Author:
vrinside
Message:

Add changing the color of linecontour

Location:
trunk/vizservers/nanovis
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/vizservers/nanovis/ContourLineFilter.cpp

    r776 r780  
    5252
    5353        Vector3* vertexSet = (Vector3*) malloc(sizeof(Vector3) * totalNumOfPoints);
    54         Vector3* colorSet = (Vector3*) malloc(sizeof(Vector3) * totalNumOfPoints);
     54        Vector3* colorSet = 0;
     55    if (_colorMap)
     56    {
     57        colorSet = (Vector3*) malloc(sizeof(Vector3) * totalNumOfPoints);
     58    }
    5559       
    5660        ContourLineFilter::ContourLineList::iterator iter;
     
    6872                        else
    6973                        {
    70                                 colorSet[index].set((*iter)->_value, (*iter)->_value, (*iter)->_value);
     74                                //colorSet[index].set((*iter)->_value, (*iter)->_value, (*iter)->_value);
    7175                        }
    7276                        vertexSet[index] = (*iter2);
     
    7680        R2VertexBuffer* vertexBuffer = new R2VertexBuffer(R2VertexBuffer::POSITION3, totalNumOfPoints,
    7781                                                                                totalNumOfPoints * sizeof(Vector3), vertexSet, false);
    78         R2VertexBuffer* colorBuffer = new R2VertexBuffer(R2VertexBuffer::COLOR4, totalNumOfPoints,
     82        R2VertexBuffer* colorBuffer = 0;
     83        R2Geometry* geometry = 0;
     84    if (_colorMap)
     85    {
     86        colorBuffer  = new R2VertexBuffer(R2VertexBuffer::COLOR4, totalNumOfPoints,
    7987                                                                                totalNumOfPoints * sizeof(Vector3), colorSet, false);
    80         R2Geometry* geometry = new R2Geometry(R2Geometry::LINES, vertexBuffer, colorBuffer, 0);
     88    }
     89
     90        geometry = new R2Geometry(R2Geometry::LINES, vertexBuffer, colorBuffer, 0);
    8191
    8292        clear();
  • trunk/vizservers/nanovis/HeightMap.cpp

    r779 r780  
    1111HeightMap::HeightMap()
    1212: _contour(0), _colorMap(0), _indexBuffer(0), _vertexBufferObjectID(0), _vertexCount(0), _textureBufferObjectID(0),
    13   _contourVisible(true), _scale(1.0f, 1.0f, 1.0f), _contourColor(0.0f, 0.0f, 0.0f)
     13  _contourVisible(true), _scale(1.0f, 1.0f, 1.0f), _contourColor(1.0f, 0.0f, 0.0f)
    1414{
    1515        _shader = new NvShader();
  • trunk/vizservers/nanovis/HeightMap.h

    r776 r780  
    4444        bool isVisible() const;
    4545        void setLineContourVisible(bool visible);
     46    void setLineContourColor(float r, float g, float b);
    4647};
    4748
     
    6162}
    6263
     64inline void HeightMap::setLineContourColor(float r, float g, float b)
     65{
     66    _contourColor.x = r;
     67    _contourColor.y = g;
     68    _contourColor.z = b;
     69}
    6370#endif
  • trunk/vizservers/nanovis/R2/src/R2Geometry.cpp

    r776 r780  
    2020void R2Geometry::render()
    2121{
     22        //glDisableClientState(GL_NORMAL_ARRAY);
     23        //glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    2224        glEnableClientState(GL_VERTEX_ARRAY);
    2325        glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer->getGraphicObjectID());
  • trunk/vizservers/nanovis/nanovis.cpp

    r779 r780  
    11251125        srand( (unsigned)time( NULL ) );
    11261126        int size = 20 * 20;
     1127        float sigma = 5.0f;
     1128        float mean = exp(0.0f) / (sigma * sqrt(2.0f));
    11271129        float* data = (float*) malloc(sizeof(float) * size);
     1130
     1131        float x;
    11281132        for (int i = 0; i < size; ++i)
    11291133        {
    1130             data[i] = rand() * 1.0f / RAND_MAX;
     1134            x = - 10 + i%20;
     1135            data[i] = exp(- (x * x)/(2 * sigma * sigma)) / (sigma * sqrt(2.0f)) / mean;
    11311136        }
    11321137
     
    11951200                }
    11961201            }
     1202            return TCL_OK;
     1203        }
     1204        else if (strcmp(argv[2],"color") == 0)
     1205        {
     1206            double r, g, b;
     1207            if ((Tcl_GetDouble(interp, argv[3], &r) == TCL_OK) &&
     1208                (Tcl_GetDouble(interp, argv[4], &g) == TCL_OK) &&
     1209                (Tcl_GetDouble(interp, argv[5], &b) == TCL_OK)) {
     1210                r = r / 255.0;
     1211                g = g / 255.0;
     1212                b = b / 255.0;
     1213            }
     1214            else
     1215            {
     1216                return TCL_ERROR;
     1217            }
     1218
     1219            vector<int> indices;
     1220            if (GetIndices(interp, argc-6, argv+6, &indices) != TCL_OK)
     1221            {
     1222                return TCL_ERROR;
     1223            }
     1224            for (int i = 0; i < indices.size(); ++i)
     1225            {
     1226                if ((indices[i] < g_heightMap.size()) && (g_heightMap[indices[i]] != NULL))
     1227                {
     1228                    g_heightMap[indices[i]]->setLineContourColor(r, g, b);
     1229                }
     1230            }
     1231
    11971232            return TCL_OK;
    11981233        }
Note: See TracChangeset for help on using the changeset viewer.