Ignore:
Timestamp:
Mar 13, 2013, 9:57:03 AM (12 years ago)
Author:
ldelgass
Message:

Fix camera reset for nanovis. Includes refactoring of vector/matrix classes
in nanovis to consolidate into vrmath library. Also add preliminary canonical
view control to clients for testing.

File:
1 edited

Legend:

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

    r3465 r3492  
    1515
    1616using namespace nv::graphics;
     17using namespace vrmath;
    1718
    1819ContourLineFilter::ContourLineFilter()
     
    3435Geometry *
    3536ContourLineFilter::create(float min, float max, int linecount,
    36                           Vector3* vertices, int width, int height)
     37                          Vector3f* vertices, int width, int height)
    3738{
    3839    _lines.clear();
     
    5354        }
    5455    }
    55     Vector3* vertexSet = (Vector3 *)malloc(sizeof(Vector3) * totalPoints);
    56     Vector3* colorSet = NULL;
     56    Vector3f* vertexSet = (Vector3f *)malloc(sizeof(Vector3f) * totalPoints);
     57    Vector3f* colorSet = NULL;
    5758    if (_colorMap) {
    58         colorSet = (Vector3 *)malloc(sizeof(Vector3) * totalPoints);
     59        colorSet = (Vector3f *)malloc(sizeof(Vector3f) * totalPoints);
    5960    }
    6061    ContourLineFilter::ContourLineList::iterator iter;
    6162    unsigned int index = 0, colorIndex = 0;
    6263    for (iter = _lines.begin(); iter != _lines.end(); ++iter, ++colorIndex) {
    63         std::list<Vector3>& lines = (*iter)->_points;
    64         std::list<Vector3>::iterator iter2;
     64        std::list<Vector3f>& lines = (*iter)->_points;
     65        std::list<Vector3f>::iterator iter2;
    6566        for (iter2 = lines.begin(); iter2 != lines.end(); ++iter2, ++index) {
    6667            if (_colorMap && (colorIndex < _colorMap->size())) {
     
    7475    VertexBuffer *vertexBuffer =
    7576        new VertexBuffer(VertexBuffer::POSITION3, totalPoints,
    76                          totalPoints * sizeof(Vector3), vertexSet, false);
     77                         totalPoints * sizeof(Vector3f), vertexSet, false);
    7778    VertexBuffer *colorBuffer = NULL;
    7879    if (_colorMap) {
    7980        colorBuffer =
    8081            new VertexBuffer(VertexBuffer::COLOR4, totalPoints,
    81                              totalPoints * sizeof(Vector3), colorSet, false);
     82                             totalPoints * sizeof(Vector3f), colorSet, false);
    8283    }
    8384    Geometry *geometry = new Geometry(Geometry::LINES, vertexBuffer, colorBuffer, 0);
     
    8889Geometry *
    8990ContourLineFilter::create(float min, float max, int linecount,
    90                           Vector4* vertices, int width, int height)
     91                          Vector4f* vertices, int width, int height)
    9192{
    9293    _lines.clear();
     
    108109        }
    109110    }
    110     Vector3* vertexSet = (Vector3 *)malloc(sizeof(Vector3) * totalPoints);
    111     Vector3* colorSet  = (Vector3 *)malloc(sizeof(Vector3) * totalPoints);
     111    Vector3f* vertexSet = (Vector3f *)malloc(sizeof(Vector3f) * totalPoints);
     112    Vector3f* colorSet  = (Vector3f *)malloc(sizeof(Vector3f) * totalPoints);
    112113       
    113114    ContourLineFilter::ContourLineList::iterator iter;
    114115    unsigned int index = 0, colorIndex = 0;
    115116    for (iter = _lines.begin(); iter != _lines.end(); ++iter, ++colorIndex) {
    116         std::list<Vector3>& lines = (*iter)->_points;
    117         std::list<Vector3>::iterator iter2;
     117        std::list<Vector3f>& lines = (*iter)->_points;
     118        std::list<Vector3f>::iterator iter2;
    118119        for (iter2 = lines.begin(); iter2 != lines.end(); ++iter2, ++index) {
    119120            if (_colorMap && (colorIndex < _colorMap->size())) {
     
    128129    VertexBuffer *vertexBuffer =
    129130        new VertexBuffer(VertexBuffer::POSITION3, totalPoints,
    130                          totalPoints * sizeof(Vector3), vertexSet, false);
     131                         totalPoints * sizeof(Vector3f), vertexSet, false);
    131132    VertexBuffer *colorBuffer =
    132133        new VertexBuffer(VertexBuffer::COLOR4, totalPoints,
    133                          totalPoints * sizeof(Vector3), colorSet, false);
     134                         totalPoints * sizeof(Vector3f), colorSet, false);
    134135    Geometry *geometry =
    135136        new Geometry(Geometry::LINES, vertexBuffer, colorBuffer, 0);
     
    147148int
    148149ContourLineFilter::ContourLine::createLine(int width, int height,
    149                                            Vector3* vertices, bool top)
     150                                           Vector3f* vertices, bool top)
    150151{
    151152    _points.clear();
     
    182183int
    183184ContourLineFilter::ContourLine::createLine(int width, int height,
    184                                            Vector4* vertices, bool top)
     185                                           Vector4f* vertices, bool top)
    185186{
    186187    _points.clear();
     
    218219void
    219220ContourLineFilter::ContourLine::getContourPoint(int vertexIndex1,
    220         int vertexIndex2, Vector3* vertices, int width, bool top)
     221        int vertexIndex2, Vector3f* vertices, int width, bool top)
    221222{
    222223    float diff = vertices[vertexIndex2].y - vertices[vertexIndex1].y;
     
    226227    }
    227228
    228     Vector3 p;
     229    Vector3f p;
    229230    p.x = vertices[vertexIndex1].x + t *
    230231        (vertices[vertexIndex2].x - vertices[vertexIndex1].x);
     
    247248void
    248249ContourLineFilter::ContourLine::getContourPoint(int vertexIndex1,
    249         int vertexIndex2, Vector4* vertices, int width, bool top)
     250        int vertexIndex2, Vector4f* vertices, int width, bool top)
    250251{
    251252    float diff = vertices[vertexIndex2].y - vertices[vertexIndex1].y;
     
    255256    }
    256257
    257     Vector3 p;
     258    Vector3f p;
    258259    p.x = vertices[vertexIndex1].x +
    259260        t * (vertices[vertexIndex2].x - vertices[vertexIndex1].x);
     
    275276
    276277void
    277 ContourLineFilter::setColorMap(Vector3Array* colorMap)
     278ContourLineFilter::setColorMap(Vector3fArray* colorMap)
    278279{
    279280    if (colorMap == _colorMap) {
     
    289290       
    290291        if (colorMap && colorMap->size()) {     
    291             _colorMap = new Vector3Array(colorMap->size());
     292            _colorMap = new Vector3fArray(colorMap->size());
    292293            _colorMap->assign(colorMap->begin(), colorMap->end());
    293294        } else {
Note: See TracChangeset for help on using the changeset viewer.