Changeset 3492


Ignore:
Timestamp:
Mar 13, 2013, 12:57:03 PM (7 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.

Location:
trunk
Files:
2 added
8 deleted
83 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/flowvisviewer.tcl

    r3485 r3492  
    123123    private method streams { tag name }
    124124    private method arrows { tag name }
     125    private method SetOrientation {}
    125126
    126127    private variable _arcball ""
     
    318319    pack $itk_component(volume) -padx 2 -pady 2
    319320
    320     BuildViewTab
    321     BuildVolumeTab
    322     BuildCutplanesTab
    323     BuildCameraTab
     321    if { [catch {
     322        BuildViewTab
     323        BuildVolumeTab
     324        BuildCutplanesTab
     325        BuildCameraTab
     326    } errs] != 0 } {
     327        global errorInfo
     328        puts stderr "errs=$errs errorInfo=$errorInfo"
     329    }
    324330
    325331    bind $itk_component(3dview) <Configure> \
     
    959965        $_arcball quaternion $q
    960966        SendCmd "camera orient $q"
    961         #SendCmd "camera reset"
     967        SendCmd "camera reset"
    962968        PanCamera
    963969        SendCmd "camera zoom $_view(zoom)"
     
    12571263    $_arcball quaternion $q
    12581264    SendCmd "camera orient $q"
    1259     #SendCmd "camera reset"
     1265    SendCmd "camera reset"
    12601266    PanCamera
    12611267    SendCmd "camera zoom $_view(zoom)"
     
    13671373            $_arcball quaternion $q
    13681374            SendCmd "camera orient $q"
    1369             #SendCmd "camera reset"
    1370             SendCmd "camera zoom $_view(zoom)"
     1375            SendCmd "camera reset"
    13711376            set _settings($this-qw)    $_view(qw)
    13721377            set _settings($this-qx)    $_view(qx)
     
    13761381            set _settings($this-pan-y) $_view(pan-y)
    13771382            set _settings($this-zoom)  $_view(zoom)
     1383            $itk_component(orientation) value "default"
    13781384        }
    13791385    }
     
    23872393    $inner configure -borderwidth 4
    23882394
     2395    set row 0
     2396    label $inner.orientation_l -text "View" -font "Arial 9"
     2397    itk_component add orientation {
     2398        Rappture::Combobox $inner.orientation -width 10 -editable no
     2399    }
     2400    $inner.orientation choices insert end \
     2401        "1 0 0 0" "front" \
     2402        "0 0 1 0" "back" \
     2403        "0.707107 -0.707107 0 0" "top" \
     2404        "0.707107 0.707107 0 0" "bottom" \
     2405        "0.707107 0 -0.707107 0" "left" \
     2406        "0.707107 0 0.707107 0" "right" \
     2407        "0.853553 -0.353553 0.353553 0.146447" "default"
     2408    $itk_component(orientation) value "default"
     2409    bind $inner.orientation <<Value>> [itcl::code $this SetOrientation]
     2410    if 1 {
     2411    blt::table $inner \
     2412            $row,0 $inner.orientation_l -anchor e -pady 2 \
     2413            $row,1 $inner.orientation -anchor w -pady 2 -fill x
     2414    blt::table configure $inner r$row -resize none
     2415    incr row
     2416    }
     2417
    23892418    set labels { qw qx qy qz pan-x pan-y zoom }
    2390     set row 0
    23912419    foreach tag $labels {
    23922420        label $inner.${tag}label -text $tag -font "Arial 9"
     
    26112639                }
    26122640                "qx" - "qy" - "qz" - "qw" {
     2641                    set _view($who) $_settings($this-$who)
    26132642                    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    26142643                    $_arcball quaternion $q
     
    29863015}
    29873016
     3017itcl::body Rappture::FlowvisViewer::SetOrientation {} {
     3018    set quat [$itk_component(orientation) value]
     3019    set quat [$itk_component(orientation) translate $quat]
     3020    foreach name { qw qx qy qz } comp $quat {
     3021        set _view($name) $comp
     3022        set _settings($this-$name) $comp
     3023    }
     3024    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     3025    $_arcball quaternion $q
     3026    SendCmd "camera orient $q"
     3027    SendCmd "camera reset"
     3028    set $_view(pan-x) 0.0
     3029    set $_view(pan-y) 0.0
     3030    set $_view(zoom) 1.0
     3031    set _settings($this-pan-x) $_view(pan-x)
     3032    set _settings($this-pan-y) $_view(pan-y)
     3033    set _settings($this-zoom)  $_view(zoom)
     3034}
  • trunk/gui/scripts/nanovisviewer.tcl

    r3485 r3492  
    286286    pack $itk_component(volume) -padx 2 -pady 2
    287287
    288     BuildViewTab
    289     BuildVolumeTab
    290     BuildCutplanesTab
    291     BuildCameraTab
     288    if { [catch {
     289        BuildViewTab
     290        BuildVolumeTab
     291        BuildCutplanesTab
     292        BuildCameraTab
     293    } errs] != 0 } {
     294        global errorInfo
     295        puts stderr "errs=$errs errorInfo=$errorInfo"
     296    }
    292297
    293298    # Legend
     
    913918        $_arcball quaternion $q
    914919        SendCmd "camera orient $q"
    915         #SendCmd "camera reset"
     920        SendCmd "camera reset"
    916921        PanCamera
    917922        SendCmd "camera zoom $_view(zoom)"
     
    10231028            $_arcball quaternion $q
    10241029            SendCmd "camera orient $q"
    1025             #SendCmd "camera reset"
    1026             SendCmd "camera zoom $_view(zoom)"
     1030            SendCmd "camera reset"
    10271031            set _settings($this-qw)    $_view(qw)
    10281032            set _settings($this-qx)    $_view(qx)
     
    10321036            set _settings($this-pan-y) $_view(pan-y)
    10331037            set _settings($this-zoom)  $_view(zoom)
     1038            $itk_component(orientation) value "default"
    10341039        }
    10351040    }
     
    18921897    $inner configure -borderwidth 4
    18931898
     1899    set row 0
     1900    label $inner.orientation_l -text "View" -font "Arial 9"
     1901    itk_component add orientation {
     1902        Rappture::Combobox $inner.orientation -width 10 -editable no
     1903    }
     1904    $inner.orientation choices insert end \
     1905        "1 0 0 0" "front" \
     1906        "0 0 1 0" "back" \
     1907        "0.707107 -0.707107 0 0" "top" \
     1908        "0.707107 0.707107 0 0" "bottom" \
     1909        "0.707107 0 -0.707107 0" "left" \
     1910        "0.707107 0 0.707107 0" "right" \
     1911        "0.853553 -0.353553 0.353553 0.146447" "default"
     1912    $itk_component(orientation) value "default"
     1913    bind $inner.orientation <<Value>> [itcl::code $this SetOrientation]
     1914    if 1 {
     1915    blt::table $inner \
     1916            $row,0 $inner.orientation_l -anchor e -pady 2 \
     1917            $row,1 $inner.orientation -anchor w -pady 2 -fill x
     1918    blt::table configure $inner r$row -resize none
     1919    incr row
     1920    }
     1921
    18941922    set labels { qw qx qy qz pan-x pan-y zoom }
    1895     set row 0
    18961923    foreach tag $labels {
    18971924        label $inner.${tag}label -text $tag -font "Arial 9"
     
    20012028                }
    20022029                "qx" - "qy" - "qz" - "qw" {
     2030                    set _view($who) $_settings($this-$who)
    20032031                    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    20042032                    $_arcball quaternion $q
     
    20722100    SendCmd "volume statue $bool $name"
    20732101}
     2102
     2103itcl::body Rappture::NanovisViewer::SetOrientation {} {
     2104    set quat [$itk_component(orientation) value]
     2105    set quat [$itk_component(orientation) translate $quat]
     2106    foreach name { qw qx qy qz } comp $quat {
     2107        set _view($name) $comp
     2108        set _settings($this-$name) $comp
     2109    }
     2110    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2111    $_arcball quaternion $q
     2112    SendCmd "camera orient $q"
     2113    SendCmd "camera reset"
     2114    set $_view(pan-x) 0.0
     2115    set $_view(pan-y) 0.0
     2116    set $_view(zoom) 1.0
     2117    set _settings($this-pan-x) $_view(pan-x)
     2118    set _settings($this-pan-y) $_view(pan-y)
     2119    set _settings($this-zoom)  $_view(zoom)
     2120}
  • trunk/packages/vizservers/nanovis/BucketSort.cpp

    r2798 r3492  
    33
    44using namespace PCA;
     5
     6#include <vrmath/Vector3f.h>
     7#include <vrmath/Matrix4x4d.h>
    58
    69void
     
    1215
    1316void
    14 BucketSort::sort(ClusterAccel* clusterAccel, const Mat4x4& cameraMat, int level)
     17BucketSort::sort(ClusterAccel* clusterAccel, const Matrix4x4d& cameraMat, int level)
    1518{
    1619    if (clusterAccel == 0) {
     
    2124    Cluster* end = &(cluster[clusterAccel->numOfClusters[level - 1] - 1]);
    2225
    23     Vector3 pos;
     26    Vector3f pos;
    2427    for (; c <= end; c = (Cluster*) ((char *)c + sizeof(Cluster))) {
    25         pos.transform(c->centroid, cameraMat);
     28        pos = cameraMat.transform(c->centroid);
    2629        addBucket(c, pos.length()*_invMaxLength);
    2730    }
  • trunk/packages/vizservers/nanovis/BucketSort.h

    r2822 r3492  
    55#include <vector>
    66#include <list>
    7 #include "Vector3.h"
    8 #include "Mat4x4.h"
     7
     8#include <vrmath/Matrix4x4d.h>
     9
    910#include "PCASplit.h"
    1011
    1112namespace PCA {
    1213
    13 class ClusterList {
    14 public :
    15     Cluster* data;
    16     ClusterList* next;
     14class ClusterList
     15{
    1716public :
    1817    ClusterList(Cluster *d, ClusterList *n) :
     
    2827        //if (next) delete next;
    2928    }
     29
     30    Cluster *data;
     31    ClusterList *next;
    3032};
    3133
    32 class BucketSort {
    33     ClusterList **_buffer;
    34     int _size;
    35     int _count;
    36 
    37     int _memChuckSize;
    38     bool _memChunckUsedFlag;
    39     ClusterList *_memChunck;
    40 
    41     float _invMaxLength;
    42 private:
    43     void _sort(Cluster *cluster, const Mat4x4& cameraMat, int level);
     34class BucketSort
     35{
    4436public:
    4537    BucketSort(int maxSize)
     
    6961    void init();
    7062
    71     void sort(ClusterAccel* cluster, const Mat4x4& cameraMat, int level);
     63    void sort(ClusterAccel* cluster, const vrmath::Matrix4x4d& cameraMat, int level);
    7264
    7365    void addBucket(Cluster* cluster, float ratio);
     
    7567    ClusterList **getBucket()
    7668    { return _buffer; }
     69
     70private:
     71    void _sort(Cluster *cluster, const vrmath::Matrix4x4d& cameraMat, int level);
     72
     73    ClusterList **_buffer;
     74    int _size;
     75    int _count;
     76
     77    int _memChuckSize;
     78    bool _memChunckUsedFlag;
     79    ClusterList *_memChunck;
     80
     81    float _invMaxLength;
    7782};
    7883
  • trunk/packages/vizservers/nanovis/Command.cpp

    r3478 r3492  
    4949#include <RpOutcome.h>
    5050#include <RpBuffer.h>
     51
     52#include <vrmath/Vector3f.h>
    5153
    5254#include "nanovis.h"
     
    587589
    588590static int
     591CameraResetOp(ClientData clientData, Tcl_Interp *interp, int objc,
     592              Tcl_Obj *const *objv)
     593{
     594    bool all = false;
     595    if (objc == 3) {
     596        const char *string = Tcl_GetString(objv[2]);
     597        char c = string[0];
     598        if ((c != 'a') || (strcmp(string, "all") != 0)) {
     599            Tcl_AppendResult(interp, "bad camera reset option \"", string,
     600                             "\": should be all", (char*)NULL);
     601            return TCL_ERROR;
     602        }
     603        all = true;
     604    }
     605    NanoVis::resetCamera(all);
     606    return TCL_OK;
     607}
     608
     609static int
    589610CameraZoomOp(ClientData clientData, Tcl_Interp *interp, int objc,
    590611             Tcl_Obj *const *objv)
     
    603624    {"pan",     2, CameraPanOp,      4, 4, "x y",},
    604625    {"pos",     2, CameraPositionOp, 5, 5, "x y z",},
     626    {"reset",   1, CameraResetOp,    2, 3, "?all?",},
    605627    {"zoom",    1, CameraZoomOp,     3, 3, "factor",},
    606628};
     
    12211243        TRACE("finish loading");
    12221244
    1223         Vector3 scale = volPtr->getPhysicalScaling();
    1224         float dx0 = -0.5 * scale.x;
    1225         float dy0 = -0.5 * scale.y;
    1226         float dz0 = -0.5 * scale.z;
    1227         volPtr->location(Vector3(dx0, dy0, dz0));
     1245        vrmath::Vector3f scale = volPtr->getPhysicalScaling();
     1246        vrmath::Vector3f loc(scale);
     1247        loc *= -0.5;
     1248        volPtr->location(loc);
    12281249
    12291250        int isNew;
  • 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 {
  • trunk/packages/vizservers/nanovis/ContourLineFilter.h

    r3465 r3492  
    44
    55#include <list>
     6#include <vector>
    67
    78#include <graphics/Geometry.h>
    8 
    9 #include "Vector3.h"
    10 #include "Vector4.h"
     9#include <vrmath/Vector3f.h>
     10#include <vrmath/Vector4f.h>
    1111
    1212class ContourLineFilter
     
    2121         * @return Returns the number of points
    2222         */
    23         int createLine(int width, int height, Vector3 *vertices, bool top);
    24         int createLine(int width, int height, Vector4 *vertices, bool top);
     23        int createLine(int width, int height, vrmath::Vector3f *vertices, bool top);
     24        int createLine(int width, int height, vrmath::Vector4f *vertices, bool top);
    2525
    2626        float _value;
    27         std::list<Vector3> _points;
     27        std::list<vrmath::Vector3f> _points;
    2828
    2929    private:
     
    3333                    (_value >= v2 && _value <= v1));
    3434        }
    35         void getContourPoint(int vertexIndex1, int vertexIndex2, Vector3 *vertices, int width, bool top);
    36         void getContourPoint(int vertexIndex1, int vertexIndex2, Vector4 *vertices, int width, bool top);
     35        void getContourPoint(int vertexIndex1, int vertexIndex2, vrmath::Vector3f *vertices, int width, bool top);
     36        void getContourPoint(int vertexIndex1, int vertexIndex2, vrmath::Vector4f *vertices, int width, bool top);
    3737    };
    3838
    3939    typedef std::list<ContourLine *> ContourLineList;
     40    typedef std::vector<vrmath::Vector3f> Vector3fArray;
    4041
    4142    ContourLineFilter();
    4243
    43     nv::graphics::Geometry *create(float min, float max, int linecount, Vector3 *vertices, int width, int height);
    44     nv::graphics::Geometry *create(float min, float max, int linecount, Vector4 *vertices, int width, int height);
     44    nv::graphics::Geometry *create(float min, float max, int linecount, vrmath::Vector3f *vertices, int width, int height);
     45    nv::graphics::Geometry *create(float min, float max, int linecount, vrmath::Vector4f *vertices, int width, int height);
    4546
    46     void setColorMap(Vector3Array *colorMap);
     47    void setColorMap(Vector3fArray *colorMap);
    4748   
    4849    void setHeightTop(bool top)
     
    5556
    5657    ContourLineList _lines;
    57     Vector3Array *_colorMap;
     58    Vector3fArray *_colorMap;
    5859    bool _top;
    5960};
  • trunk/packages/vizservers/nanovis/ConvexPolygon.cpp

    r3452 r3492  
    2121#include "Trace.h"
    2222
     23using namespace vrmath;
     24
    2325ConvexPolygon::ConvexPolygon(VertexVector newvertices)
    2426{
     
    2729
    2830void
    29 ConvexPolygon::transform(const Mat4x4& mat)
     31ConvexPolygon::transform(const Matrix4x4d& mat)
    3032{
    3133    VertexVector tmp = vertices;
     
    3335
    3436    for (unsigned int i = 0; i < tmp.size(); i++) {
    35         Vector4 vec = tmp[i];
     37        Vector4f vec = tmp[i];
    3638        vertices.push_back(mat.transform(vec));
    3739    }
     
    3941
    4042void
    41 ConvexPolygon::translate(const Vector4& shift)
     43ConvexPolygon::translate(const Vector4f& shift)
    4244{
    4345    VertexVector tmp = vertices;
     
    4547
    4648    for (unsigned int i = 0; i < tmp.size(); i++) {
    47         Vector4 vec = tmp[i];
    48         vertices.push_back(vec+shift);
     49        Vector4f vec = tmp[i];
     50        vertices.push_back(vec + shift);
    4951    }
    5052}
     
    5456
    5557bool
    56 ConvexPolygon::clip(Plane& clipPlane, bool copyToTexcoord)
     58ConvexPolygon::clip(nv::Plane& clipPlane, bool copyToTexcoord)
    5759{
    5860    if (vertices.size() == 0) {
     
    7476    // add it to the new list as well.
    7577
    76     Vector4 plane = clipPlane.getCoeffs();
     78    Vector4f plane = clipPlane.getCoeffs();
    7779
    7880    // This implementation is based on the Mesa 3D library (MIT license)
     
    149151
    150152void
    151 ConvexPolygon::emit(bool useTexture, const Vector3& shift, const Vector3& scale)
     153ConvexPolygon::emit(bool useTexture, const Vector3f& shift, const Vector3f& scale)
    152154{
    153155    if (vertices.size() >= 3) {
     
    156158                glTexCoord4fv((float *)&(vertices[i]));
    157159            }
    158             Vector4 tmp = (vertices[i]);
    159             Vector4 shift_4d = Vector4(shift.x, shift.y, shift.z, 0);
     160            Vector4f tmp = (vertices[i]);
     161            Vector4f shift_4d = Vector4f(shift.x, shift.y, shift.z, 0);
    160162            tmp = tmp + shift_4d;
    161163            tmp.x = tmp.x * scale.x;
  • trunk/packages/vizservers/nanovis/ConvexPolygon.h

    r3362 r3492  
    2020#include <vector>
    2121
    22 #include "Vector4.h"
     22#include <vrmath/Vector3f.h>
     23#include <vrmath/Vector4f.h>
     24#include <vrmath/Matrix4x4d.h>
     25
    2326#include "Plane.h"
    2427
    25 typedef std::vector<Vector4> VertexVector;
    26 typedef std::vector<Vector4> TexVector;
     28typedef std::vector<vrmath::Vector4f> VertexVector;
     29typedef std::vector<vrmath::Vector4f> TexVector;
    2730
    2831class ConvexPolygon
     
    3437    ConvexPolygon(VertexVector vertices);
    3538
    36     void transform(const Mat4x4& mat);
     39    void transform(const vrmath::Matrix4x4d& mat);
    3740
    38     void translate(const Vector4& shift);
     41    void translate(const vrmath::Vector4f& shift);
    3942
    4043    // Clips the polygon, retaining the portion where ax + by + cz + d >= 0
    41     bool clip(Plane& clipPlane, bool copyToTexcoords);
     44    bool clip(nv::Plane& clipPlane, bool copyToTexcoords);
    4245
    4346    void emit(bool useTexture);
    4447
    45     void emit(bool useTexture, const Vector3& shift, const Vector3& scale);
     48    void emit(bool useTexture, const vrmath::Vector3f& shift, const vrmath::Vector3f& scale);
    4649
    4750    void copyVerticesToTexcoords();
     
    5255    }
    5356
    54     void appendVertex(const Vector4& vert)
     57    void appendVertex(const vrmath::Vector4f& vert)
    5558    {
    5659        vertices.push_back(vert);
    5760    }
    5861
    59     void insertVertex(unsigned int index, const Vector4& vert)
     62    void insertVertex(unsigned int index, const vrmath::Vector4f& vert)
    6063    {
    6164        assert(index < vertices.size());
  • trunk/packages/vizservers/nanovis/Doxyfile.in

    r3437 r3492  
    2626# by quotes) that should identify the project.
    2727
    28 PROJECT_NAME           = "Rappture Nanovis Render Server"
     28PROJECT_NAME           = "HUBzero Nanovis Render Server"
    2929
    3030# The PROJECT_NUMBER tag can be used to enter a project or revision number.
  • trunk/packages/vizservers/nanovis/FlowCmd.cpp

    r3476 r3492  
    1414#include <RpFieldPrism3D.h>
    1515#include <RpOutcome.h>
     16
     17#include <vrmath/Vector3f.h>
     18#include <vrmath/Vector4f.h>
     19#include <vrmath/Matrix4x4d.h>
    1620
    1721#include "nvconf.h"
     
    3842#define RELPOS 0
    3943#define ABSPOS 1
     44
     45using namespace vrmath;
    4046
    4147static Rappture::SwitchParseProc AxisSwitchProc;
     
    170176{
    171177    _rendererPtr->setPos(FlowCmd::GetRelativePosition(&_sv.position));
    172     _rendererPtr->setColor(Vector4(_sv.color.r, _sv.color.g, _sv.color.b,
    173                                    _sv.color.a));
     178    _rendererPtr->setColor(Vector4f(_sv.color.r, _sv.color.g, _sv.color.b,
     179                                    _sv.color.a));
    174180    _rendererPtr->particleSize(_sv.particleSize);
    175181    _rendererPtr->setAxis(_sv.position.axis);
     
    192198}
    193199
     200void
     201FlowBox::getWorldSpaceBounds(Vector3f& bboxMin,
     202                             Vector3f& bboxMax,
     203                             const Volume *vol) const
     204{
     205    bboxMin.set(FLT_MAX, FLT_MAX, FLT_MAX);
     206    bboxMax.set(-FLT_MAX, -FLT_MAX, -FLT_MAX);
     207
     208    Vector3f origin = vol->location();
     209    Vector3f scale = vol->getPhysicalScaling();
     210
     211    Matrix4x4d mat;
     212    mat.makeTranslation(origin);
     213    Matrix4x4d mat2;
     214    mat2.makeScale(scale);
     215
     216    mat.multiply(mat2);
     217
     218    Vector3f min, max;
     219    min.x = vol->xAxis.min();
     220    min.y = vol->yAxis.min();
     221    min.z = vol->zAxis.min();
     222    max.x = vol->xAxis.max();
     223    max.y = vol->yAxis.max();
     224    max.z = vol->zAxis.max();
     225
     226    float x0, y0, z0, x1, y1, z1;
     227    x0 = y0 = z0 = 0.0f;
     228    x1 = y1 = z1 = 0.0f;
     229    if (max.x > min.x) {
     230        x0 = (_sv.corner1.x - min.x) / (max.x - min.x);
     231        x1 = (_sv.corner2.x - min.x) / (max.x - min.x);
     232    }
     233    if (max.y > min.y) {
     234        y0 = (_sv.corner1.y - min.y) / (max.y - min.y);
     235        y1 = (_sv.corner2.y - min.y) / (max.y - min.y);
     236    }
     237    if (max.z > min.z) {
     238        z0 = (_sv.corner1.z - min.z) / (max.z - min.z);
     239        z1 = (_sv.corner2.z - min.z) / (max.z - min.z);
     240    }
     241
     242    TRACE("Box model bounds: (%g,%g,%g) - (%g,%g,%g)", x0, y0, z0, x1, y1, z1);
     243
     244    Vector3f modelMin(x0, y0, z0);
     245    Vector3f modelMax(x1, y1, z1);
     246
     247    Vector4f bvert[8];
     248    bvert[0] = Vector4f(modelMin.x, modelMin.y, modelMin.z, 1);
     249    bvert[1] = Vector4f(modelMax.x, modelMin.y, modelMin.z, 1);
     250    bvert[2] = Vector4f(modelMin.x, modelMax.y, modelMin.z, 1);
     251    bvert[3] = Vector4f(modelMin.x, modelMin.y, modelMax.z, 1);
     252    bvert[4] = Vector4f(modelMax.x, modelMax.y, modelMin.z, 1);
     253    bvert[5] = Vector4f(modelMax.x, modelMin.y, modelMax.z, 1);
     254    bvert[6] = Vector4f(modelMin.x, modelMax.y, modelMax.z, 1);
     255    bvert[7] = Vector4f(modelMax.x, modelMax.y, modelMax.z, 1);
     256
     257    for (int i = 0; i < 8; i++) {
     258        Vector4f worldVert = mat.transform(bvert[i]);
     259        if (worldVert.x < bboxMin.x) bboxMin.x = worldVert.x;
     260        if (worldVert.x > bboxMax.x) bboxMax.x = worldVert.x;
     261        if (worldVert.y < bboxMin.y) bboxMin.y = worldVert.y;
     262        if (worldVert.y > bboxMax.y) bboxMax.y = worldVert.y;
     263        if (worldVert.z < bboxMin.z) bboxMin.z = worldVert.z;
     264        if (worldVert.z > bboxMax.z) bboxMax.z = worldVert.z;
     265    }
     266
     267    TRACE("Box world bounds: (%g,%g,%g) - (%g,%g,%g)",
     268          bboxMin.x, bboxMin.y, bboxMin.z,
     269          bboxMax.x, bboxMax.y, bboxMax.z);
     270}
     271
    194272void
    195 FlowBox::Render(Volume *volPtr)
     273FlowBox::Render(Volume *vol)
    196274{
    197275    TRACE("Rendering box %s", _name);
     
    206284    glPushMatrix();
    207285
    208     Vector3 origin = volPtr->location();
     286    Vector3f origin = vol->location();
    209287    glTranslatef(origin.x, origin.y, origin.z);
    210288
    211     Vector3 scale = volPtr->getPhysicalScaling();
    212     glScaled(scale.x, scale.y, scale.z);
    213 
    214     Vector3 min, max;
    215     min.x = volPtr->xAxis.min();
    216     min.y = volPtr->yAxis.min();
    217     min.z = volPtr->zAxis.min();
    218     max.x = volPtr->xAxis.max();
    219     max.y = volPtr->yAxis.max();
    220     max.z = volPtr->zAxis.max();
     289    Vector3f scale = vol->getPhysicalScaling();
     290    glScalef(scale.x, scale.y, scale.z);
     291
     292    Vector3f min, max;
     293    min.x = vol->xAxis.min();
     294    min.y = vol->yAxis.min();
     295    min.z = vol->zAxis.min();
     296    max.x = vol->xAxis.max();
     297    max.y = vol->yAxis.max();
     298    max.z = vol->zAxis.max();
    221299
    222300    TRACE("box is %g,%g %g,%g %g,%g",
     
    557635    }
    558636
    559     Vector3 scale = volPtr->getPhysicalScaling();
    560     Vector3 location = _volPtr->location();
     637    Vector3f scale = volPtr->getPhysicalScaling();
     638    Vector3f location = _volPtr->location();
    561639
    562640    _fieldPtr->setVectorField(_volPtr,
     
    688766    volPtr->visible(_sv.showVolume);
    689767
    690     Vector3 volScaling = volPtr->getPhysicalScaling();
    691     float dx0 = -0.5 * volScaling.x;
    692     float dy0 = -0.5 * volScaling.y;
    693     float dz0 = -0.5 * volScaling.z;
    694     volPtr->location(Vector3(dx0, dy0, dz0));
     768    Vector3f volScaling = volPtr->getPhysicalScaling();
     769    Vector3f loc(volScaling);
     770    loc *= -0.5;
     771    volPtr->location(loc);
    695772
    696773    Volume::updatePending = true;
     
    10131090{
    10141091    flags &= ~MAP_FLOWS;
    1015     TRACE("MapFlows");
     1092    TRACE("Enter");
    10161093
    10171094    /*
     
    10571134        }
    10581135    }
     1136
    10591137    TRACE("MapFlows magMin=%g magMax=%g", NanoVis::magMin, NanoVis::magMax);
    10601138
     
    10791157    AdvectFlows();
    10801158    return true;
     1159}
     1160
     1161void
     1162NanoVis::GetFlowBounds(Vector3f& min,
     1163                       Vector3f& max,
     1164                       bool onlyVisible)
     1165{
     1166    TRACE("Enter");
     1167
     1168    min.set(FLT_MAX, FLT_MAX, FLT_MAX);
     1169    max.set(-FLT_MAX, -FLT_MAX, -FLT_MAX);
     1170
     1171    FlowCmd *flow;
     1172    FlowIterator iter;
     1173    for (flow = FirstFlow(&iter); flow != NULL;
     1174         flow = NextFlow(&iter)) {
     1175        if (onlyVisible && !flow->visible())
     1176            continue;
     1177 #if 0  // Using volume bounds instead of these
     1178        if (flow->isDataLoaded()) {
     1179            Vector3f umin, umax;
     1180            Rappture::Unirect3d *unirect = flow->data();
     1181            unirect->getWorldSpaceBounds(umin, umax);
     1182            if (min.x > umin.x) {
     1183                min.x = umin.x;
     1184            }
     1185            if (max.x < umax.x) {
     1186                max.x = umax.x;
     1187            }
     1188            if (min.y > umin.y) {
     1189                min.y = umin.y;
     1190            }
     1191            if (max.y < umax.y) {
     1192                max.y = umax.y;
     1193            }
     1194            if (min.z > umin.z) {
     1195                min.z = umin.z;
     1196            }
     1197            if (max.z < umax.z) {
     1198                max.z = umax.z;
     1199            }
     1200        }
     1201#endif
     1202        FlowBox *box;
     1203        FlowBoxIterator iter;
     1204        for (box = flow->FirstBox(&iter); box != NULL;
     1205             box = flow->NextBox(&iter)) {
     1206            TRACE("found box %s", box->name());
     1207            if (!onlyVisible || box->visible()) {
     1208                Vector3f fbmin, fbmax;
     1209                box->getWorldSpaceBounds(fbmin, fbmax,
     1210                                         flow->getVolume());
     1211                if (min.x > fbmin.x) {
     1212                    min.x = fbmin.x;
     1213                }
     1214                if (max.x < fbmax.x) {
     1215                    max.x = fbmax.x;
     1216                }
     1217                if (min.y > fbmin.y) {
     1218                    min.y = fbmin.y;
     1219                }
     1220                if (max.y < fbmax.y) {
     1221                    max.y = fbmax.y;
     1222                }
     1223                if (min.z > fbmin.z) {
     1224                    min.z = fbmin.z;
     1225                }
     1226                if (max.z < fbmax.z) {
     1227                    max.z = fbmax.z;
     1228                }
     1229            }
     1230        }
     1231    }
    10811232}
    10821233
  • trunk/packages/vizservers/nanovis/FlowCmd.h

    r3397 r3492  
    2727#include <tcl.h>
    2828
     29#include <vrmath/Vector3f.h>
     30
    2931#include "Switch.h"
    3032#include "NvLIC.h"
     
    110112    }
    111113
    112     void setVectorField(Volume *volPtr, const Vector3& location,
     114    void setVectorField(Volume *volPtr, const vrmath::Vector3f& location,
    113115                        float scaleX, float scaleY, float scaleZ,
    114116                        float max)
     
    144146
    145147struct FlowBoxValues {
    146     float position;                ///< Position on axis of particle plane
    147148    FlowPoint corner1, corner2;    ///< Coordinates of the box.
    148     FlowColor color;               ///< Color of particles
     149    FlowColor color;               ///< Color of box
    149150    float lineWidth;
    150     /// Indicates if particle injection plane is active or not
    151151    int isHidden;
    152152};
     
    190190
    191191    void Render(Volume *volPtr);
     192
     193    const FlowBoxValues *getValues() const
     194    {
     195        return &_sv;
     196    }
     197
     198    void getWorldSpaceBounds(vrmath::Vector3f& min,
     199                             vrmath::Vector3f& max,
     200                             const Volume *vol) const;
    192201
    193202private:
     
    381390    }
    382391
     392    const Volume *getVolume() const
     393    {
     394        return _volPtr;
     395    }
     396
    383397    static float GetRelativePosition(FlowPosition *posPtr);
    384398
  • trunk/packages/vizservers/nanovis/HeightMap.cpp

    r3465 r3492  
    11 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2#include <float.h>
     3
    24#include <GL/glew.h>
    35
     
    1416
    1517using namespace nv::graphics;
     18using namespace vrmath;
    1619
    1720HeightMap::HeightMap() :
     
    237240#if 0
    238241void
    239 HeightMap::setHeight(int xCount, int yCount, Vector3 *heights)
     242HeightMap::setHeight(int xCount, int yCount, Vector3f *heights)
    240243{
    241244    _vertexCount = xCount * yCount;
     
    268271    _centerPoint.set(_scale.x * 0.5, _scale.z * 0.5 + min, _scale.y * 0.5);
    269272
    270     Vector3* texcoord = new Vector3[count];
     273    Vector3f* texcoord = new Vector3f[count];
    271274    for (int i = 0; i < count; ++i) {
    272275        texcoord[i].set(0, 0, heights[i].y);
     
    275278    glGenBuffers(1, &_vertexBufferObjectID);
    276279    glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferObjectID);
    277     glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof( Vector3 ), heights,
     280    glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof( Vector3f ), heights,
    278281        GL_STATIC_DRAW);
    279282    glGenBuffers(1, &_texcoordBufferObjectID);
     
    294297    //if (heightMap)
    295298    //{
    296     //  VertexBuffer* vertexBuffer = new VertexBuffer(VertexBuffer::POSITION3, xCount * yCount, sizeof(Vector3) * xCount * yCount, heightMap, false);
     299    //  VertexBuffer* vertexBuffer = new VertexBuffer(VertexBuffer::POSITION3, xCount * yCount, sizeof(Vector3f) * xCount * yCount, heightMap, false);
    297300    this->createIndexBuffer(xCount, yCount, 0);
    298301    //}
     
    351354   
    352355#ifndef notdef
    353     Vector3* texcoord = new Vector3[_vertexCount];
     356    Vector3f* texcoord = new Vector3f[_vertexCount];
    354357    for (int i = 0; i < _vertexCount; ++i) {
    355358        texcoord[i].set(0, 0, heights[i]);
    356359    }
    357360   
    358     Vector3* map = createHeightVertices(xMin, yMin, xMax, yMax, xNum, yNum,
     361    Vector3f* map = createHeightVertices(xMin, yMin, xMax, yMax, xNum, yNum,
    359362                                        heights);
    360363   
    361364    glGenBuffers(1, &_vertexBufferObjectID);
    362365    glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferObjectID);
    363     glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(Vector3), map,
     366    glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(Vector3f), map,
    364367        GL_STATIC_DRAW);
    365368    glGenBuffers(1, &_texcoordBufferObjectID);
     
    385388}
    386389
    387 Vector3 *
     390Vector3f *
    388391HeightMap::createHeightVertices(float xMin, float yMin, float xMax,
    389392                                float yMax, int xNum, int yNum, float *height)
    390393{
    391     Vector3* vertices = new Vector3[xNum * yNum];
    392 
    393     Vector3* dstDataPtr = vertices;
     394    Vector3f* vertices = new Vector3f[xNum * yNum];
     395
     396    Vector3f* dstDataPtr = vertices;
    394397    float* srcDataPtr = height;
    395398   
     
    431434        *q = (*p - gridPtr->yAxis.min()) * yScale;
    432435    }
    433     Vector3 *t, *texcoord;
    434     texcoord = new Vector3[count];
     436    Vector3f *t, *texcoord;
     437    texcoord = new Vector3f[count];
    435438    for (t = texcoord, p = normHeights, pend = p + count; p < pend; p++, t++) {
    436439        t->set(0, 0, *p);
     
    450453    zMax = (zAxis.max() - gridPtr->zAxis.min()) * zScale;
    451454
    452     Vector3* vertices;
     455    Vector3f* vertices;
    453456    vertices = createHeightVertices(xMin, zMin, xMax, zMax, _xNum, _yNum,
    454457        normHeights);
     
    456459    glGenBuffers(1, &_vertexBufferObjectID);
    457460    glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferObjectID);
    458     glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(Vector3), vertices,
     461    glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(Vector3f), vertices,
    459462        GL_STATIC_DRAW);
    460463    glGenBuffers(1, &_texcoordBufferObjectID);
     
    477480    delete [] vertices;
    478481}
     482
     483void
     484HeightMap::getWorldSpaceBounds(Vector3f& bboxMin,
     485                               Vector3f& bboxMax) const
     486{
     487    bboxMin.set(FLT_MAX, FLT_MAX, FLT_MAX);
     488    bboxMax.set(-FLT_MAX, -FLT_MAX, -FLT_MAX);
     489
     490   
     491}
  • trunk/packages/vizservers/nanovis/HeightMap.h

    r3465 r3492  
    55#include <graphics/Geometry.h>
    66#include <graphics/RenderContext.h>
     7#include <vrmath/Vector3f.h>
    78
    89#include "TransferFunction.h"
    910#include "NvShader.h"
    10 #include "Vector3.h"
    1111#include "AxisRange.h"
    1212
     
    4343     *@param yCount the number of rows of height values
    4444     */
    45     void setHeight(int xCount, int yCount, Vector3 *heights);
     45    void setHeight(int xCount, int yCount, vrmath::Vector3f *heights);
    4646#endif
    4747    void mapToGrid(Grid *gridPtr);
     
    107107    }
    108108
     109    void getWorldSpaceBounds(vrmath::Vector3f& bboxMin, vrmath::Vector3f& bboxMax) const;
     110
    109111    AxisRange xAxis, yAxis, zAxis, wAxis;
    110112    static bool updatePending;
     
    113115private:
    114116    void createIndexBuffer(int xCount, int zCount, float *heights);
    115     Vector3 *createHeightVertices(float startX, float startY,
    116                                   float endX, float endY,
    117                                   int xCount, int yCount, float *height);
     117    vrmath::Vector3f *createHeightVertices(float startX, float startY,
     118                                           float endX, float endY,
     119                                           int xCount, int yCount, float *height);
    118120    void reset();
    119121
     
    127129    int *_indexBuffer;
    128130    int _indexCount;
    129     Vector3 _contourColor;
     131    vrmath::Vector3f _contourColor;
    130132
    131133    bool _contourVisible;
    132134    bool _visible;
    133135
    134     Vector3 _scale;
    135     Vector3 _centerPoint;
     136    vrmath::Vector3f _scale;
     137    vrmath::Vector3f _centerPoint;
    136138    int _xNum, _yNum;           // Number of elements x and y axes in grid.
    137139    float *_heights;            // Array of original (unscaled) heights
  • trunk/packages/vizservers/nanovis/Makefile.in

    r3474 r3492  
    1 TRACE                   = #yes
     1TRACE           = #yes
    22
    33SHELL = /bin/sh
     
    112112                Chain.o \
    113113                CmdProc.o \
    114                 Color.o \
    115114                Command.o \
    116115                ContourLineFilter.o \
     
    120119                Grid.o \
    121120                HeightMap.o \
    122                 Mat4x4.o \
    123121                NvCamera.o \
    124122                NvColorTableRenderer.o \
     
    279277
    280278Axis.o: Axis.cpp Axis.h Chain.h
    281 BucketSort.o: BucketSort.cpp BucketSort.h Vector3.h Vector4.h Mat4x4.h PCASplit.h
     279BucketSort.o: BucketSort.cpp BucketSort.h $(VRMATH_DIR)/include/vrmath/Vector3f.h $(VRMATH_DIR)/include/vrmath/Vector4f.h $(VRMATH_DIR)/include/vrmath/Matrix4x4d.h PCASplit.h
    282280Chain.o: Chain.cpp Chain.h
    283281CmdProc.o: CmdProc.cpp CmdProc.h
    284 Color.o: Color.cpp Color.h
    285282Command.o: Command.cpp nanovis.h $(AUXSRC) CmdProc.h Trace.h PlaneRenderer.h PointSet.h dxReader.h Grid.h HeightMap.h NvCamera.h NvZincBlendeReconstructor.h Unirect.h Volume.h VolumeRenderer.h
    286283ContourLineFilter.o: ContourLineFilter.cpp ContourLineFilter.h
    287 ConvexPolygon.o: ConvexPolygon.cpp ConvexPolygon.h Vector4.h Mat4x4.h Plane.h
     284ConvexPolygon.o: ConvexPolygon.cpp ConvexPolygon.h $(VRMATH_DIR)/include/vrmath/Vector4f.h $(VRMATH_DIR)/include/vrmath/Matrix4x4d.h Plane.h
    288285FlowCmd.o: FlowCmd.cpp FlowCmd.h Switch.h Trace.h TransferFunction.h nanovis.h CmdProc.h NvLIC.h Unirect.h Volume.h VelocityArrowsSlice.h
    289286GradientFilter.o: GradientFilter.cpp GradientFilter.h
    290287Grid.o: Grid.cpp Grid.h Axis.h Chain.h
    291288HeightMap.o: HeightMap.cpp HeightMap.h
    292 Mat4x4.o: Mat4x4.cpp Mat4x4.h
    293 NvCamera.o: NvCamera.cpp NvCamera.h config.h
     289Mat4x4.o: Mat4x4.cpp $(VRMATH_DIR)/include/vrmath/Matrix4x4d.h
     290NvCamera.o: NvCamera.cpp NvCamera.h config.h $(VRMATH_DIR)/include/vrmath/Matrix4x4d.h
    294291NvColorTableRenderer.o: NvColorTableRenderer.cpp NvColorTableRenderer.h
    295292NvColorTableShader.o: NvColorTableShader.cpp NvColorTableShader.h NvShader.h
     
    303300NvVectorField.o: NvVectorField.cpp NvVectorField.h NvParticleRenderer.h
    304301NvVolumeShader.o: NvVolumeShader.cpp NvVolumeShader.h NvShader.h
    305 NvZincBlendeReconstructor.o: NvZincBlendeReconstructor.cpp NvZincBlendeReconstructor.h ZincBlendeVolume.h Volume.h Vector3.h
     302NvZincBlendeReconstructor.o: NvZincBlendeReconstructor.cpp NvZincBlendeReconstructor.h ZincBlendeVolume.h Volume.h $(VRMATH_DIR)/include/vrmath/Vector3f.h
    306303NvZincBlendeVolumeShader.o: NvZincBlendeVolumeShader.cpp NvZincBlendeVolumeShader.h NvVolumeShader.h NvShader.h
    307304ParticleEmitter.o: ParticleEmitter.cpp ParticleEmitter.h
     
    310307PCASplit.o: PCASplit.cpp PCASplit.h
    311308PerfQuery.o: PerfQuery.cpp PerfQuery.h
    312 Plane.o: Plane.cpp Plane.h Vector4.h Mat4x4.h
     309Plane.o: Plane.cpp Plane.h $(VRMATH_DIR)/include/vrmath/Vector4f.h $(VRMATH_DIR)/include/vrmath/Matrix4x4d.h
    313310PlaneRenderer.o: PlaneRenderer.cpp PlaneRenderer.h
    314311PointSet.o: PointSet.cpp PointSet.h
     
    331328ZincBlendeVolume.o: ZincBlendeVolume.cpp ZincBlendeVolume.h $(AUXSRC)
    332329dxReader.o: dxReader.cpp dxReaderCommon.h config.h nanovis.h Unirect.h ZincBlendeVolume.h NvZincBlendeReconstructor.h
    333 dxReaderCommon.o: dxReaderCommon.cpp dxReaderCommon.h GradientFilter.h Vector3.h
     330dxReaderCommon.o: dxReaderCommon.cpp dxReaderCommon.h GradientFilter.h $(VRMATH_DIR)/include/vrmath/Vector3f.h
    334331nanovis.o: nanovis.cpp nanovis.h $(AUXSRC) FlowCmd.h Grid.h HeightMap.h NvCamera.h NvColorTableRenderer.h NvFlowVisRenderer.h NvLIC.h NvZincBlendeReconstructor.h PerfQuery.h PlaneRenderer.h PointSetRenderer.h PointSet.h Switch.h Trace.h Unirect.h VelocityArrowsSlice.h VolumeInterpolator.h VolumeRenderer.h ZincBlendeVolume.h Axis.h Chain.h
  • trunk/packages/vizservers/nanovis/NvCamera.cpp

    r3467 r3492  
    2323#include <vrmath/Quaternion.h>
    2424#include <vrmath/Rotation.h>
    25 #include <vrmath/Matrix4x4f.h>
    26 
     25#include <vrmath/Matrix4x4d.h>
     26#include <vrmath/Vector3f.h>
     27#include <vrmath/Vector4f.h>
     28
     29#include "nanovis.h"
    2730#include "NvCamera.h"
    2831#include "Trace.h"
    2932
    30 static inline float deg2rad(float deg)
     33using namespace vrmath;
     34
     35static inline double deg2rad(double deg)
    3136{
    3237    return ((deg * M_PI) / 180.);
    3338}
    3439
    35 static inline float rad2deg(float rad)
     40static inline double rad2deg(double rad)
    3641{
    3742    return ((rad * 180.) / M_PI);
     
    5257
    5358void
    54 NvCamera::setClippingRange(const Vector3& bboxMin, const Vector3& bboxMax)
    55 {
    56     // Transform bounds by modelview matrix
    57     GLfloat mv[16];
    58     glGetFloatv(GL_MODELVIEW_MATRIX, mv);
    59     Mat4x4 modelView = Mat4x4(mv);
    60     Vector4 bboxEye[8];
    61     bboxEye[0] = Vector4(bboxMin.x, bboxMin.y, bboxMin.z, 1);
    62     bboxEye[1] = Vector4(bboxMax.x, bboxMin.y, bboxMin.z, 1);
    63     bboxEye[2] = Vector4(bboxMin.x, bboxMax.y, bboxMin.z, 1);
    64     bboxEye[3] = Vector4(bboxMin.x, bboxMin.y, bboxMax.z, 1);
    65     bboxEye[4] = Vector4(bboxMax.x, bboxMax.y, bboxMin.z, 1);
    66     bboxEye[5] = Vector4(bboxMax.x, bboxMin.y, bboxMax.z, 1);
    67     bboxEye[6] = Vector4(bboxMin.x, bboxMax.y, bboxMax.z, 1);
    68     bboxEye[7] = Vector4(bboxMax.x, bboxMax.y, bboxMax.z, 1);
    69     double zMin = DBL_MAX;
    70     double zMax = -DBL_MAX;
     59NvCamera::getUpDirMatrix(Matrix4x4d& upMat)
     60{
     61    switch (NanoVis::updir) {
     62    case NanoVis::X_POS: {
     63        upMat.makeRotation(0, 0, 1, deg2rad(90));
     64        Matrix4x4d tmp;
     65        tmp.makeRotation(1, 0, 0, deg2rad(90));
     66        upMat.multiply(tmp);
     67    }
     68        break;
     69    case NanoVis::Y_POS:
     70        upMat.makeIdentity();
     71        break;
     72    case NanoVis::Z_POS: {
     73        upMat.makeRotation(1, 0, 0, deg2rad(-90));
     74        Matrix4x4d tmp;
     75        tmp.makeRotation(0, 0, 1, deg2rad(-90));
     76        upMat.multiply(tmp);
     77    }
     78        break;
     79    case NanoVis::X_NEG:
     80        upMat.makeRotation(0, 0, 1, deg2rad(-90));
     81        break;
     82    case NanoVis::Y_NEG: {
     83        upMat.makeRotation(0, 0, 1, deg2rad(180));
     84        Matrix4x4d tmp;
     85        tmp.makeRotation(0, 1, 0, deg2rad(-90));
     86        upMat.multiply(tmp);
     87    }
     88        break;
     89    case NanoVis::Z_NEG:
     90        upMat.makeRotation(1, 0, 0, deg2rad(90));
     91        break;
     92    }
     93}
     94
     95/**
     96 * \brief Reset zoom to include extents
     97 */
     98void
     99NvCamera::reset(const Vector3f& bboxMin,
     100                const Vector3f& bboxMax,
     101                bool resetOrientation)
     102{
     103    TRACE("Enter");
     104
     105    if (resetOrientation) {
     106        _cameraMatrix.makeIdentity();
     107    }
     108
     109    Vector3f center(bboxMin + bboxMax);
     110    center.scale(0.5);
     111
     112    Matrix4x4d mat, upMat;
     113    getUpDirMatrix(upMat);
     114    mat.makeTranslation(-center);
     115    mat.multiply(_cameraMatrix, mat);
     116    mat.multiply(upMat);
     117
     118    Vector3f emin(FLT_MAX, FLT_MAX, FLT_MAX), emax(-FLT_MAX, -FLT_MAX, -FLT_MAX);
     119
     120    // Transform bounds by camera matrix
     121    Vector4f bboxEye[8];
     122    bboxEye[0] = Vector4f(bboxMin.x, bboxMin.y, bboxMin.z, 1);
     123    bboxEye[1] = Vector4f(bboxMax.x, bboxMin.y, bboxMin.z, 1);
     124    bboxEye[2] = Vector4f(bboxMin.x, bboxMax.y, bboxMin.z, 1);
     125    bboxEye[3] = Vector4f(bboxMin.x, bboxMin.y, bboxMax.z, 1);
     126    bboxEye[4] = Vector4f(bboxMax.x, bboxMax.y, bboxMin.z, 1);
     127    bboxEye[5] = Vector4f(bboxMax.x, bboxMin.y, bboxMax.z, 1);
     128    bboxEye[6] = Vector4f(bboxMin.x, bboxMax.y, bboxMax.z, 1);
     129    bboxEye[7] = Vector4f(bboxMax.x, bboxMax.y, bboxMax.z, 1);
     130
    71131    for (int i = 0; i < 8; i++) {
    72         Vector4 eyeVert = modelView.transform(bboxEye[i]);
    73         if (eyeVert.z < zMin) zMin = eyeVert.z;
    74         if (eyeVert.z > zMax) zMax = eyeVert.z;
    75     }
    76     if (zMax > 0.0) {
    77         zMax = -.001;
    78     }
    79     if (zMin > 0.0) {
    80         zMin = -50.0;
    81     }
    82     _near = -zMax;
    83     _far = -zMin;
     132        Vector4f eyeVert = mat.transform(bboxEye[i]);
     133        if (eyeVert.x < emin.x) emin.x = eyeVert.x;
     134        if (eyeVert.x > emax.x) emax.x = eyeVert.x;
     135        if (eyeVert.y < emin.y) emin.y = eyeVert.y;
     136        if (eyeVert.y > emax.y) emax.y = eyeVert.y;
     137        if (eyeVert.z < emin.z) emin.z = eyeVert.z;
     138        if (eyeVert.z > emax.z) emax.z = eyeVert.z;
     139    }
     140
     141    TRACE("Eye bounds: (%g,%g,%g) - (%g,%g,%g)",
     142          emin.x, emin.y, emin.z,
     143          emax.x, emax.y, emax.z);
     144
     145    double bwidth = emax.x - emin.x;
     146    double bheight = emax.y - emin.y;
     147    double bdepth = emax.z - emin.z;
     148
     149    TRACE("bwidth: %g, bheight: %g, bdepth: %g", bwidth, bheight, bdepth);
     150
     151    double angle = deg2rad(_fov);
     152    double distance;
     153
     154    // Deal with vertical aspect window
     155    double winAspect = (double)(_width - _startX)/(double)(_height - _startY);
     156    double sceneAspect = 1.0;;
     157    if (bheight > 0.0)
     158        sceneAspect = bwidth / bheight;
     159
     160    if (sceneAspect >= winAspect) {
     161        angle = 2.0 * atan(tan(angle*0.5)*winAspect);
     162        _near = bwidth / (2.0 * tan(angle*0.5));
     163    } else {
     164        _near = bheight / (2.0 * tan(angle*0.5));
     165    }
     166
     167    distance = _near + bdepth * 0.5;
     168    _far = _near + bdepth;
     169
     170    _location.set(center.x, center.y, center.z + distance);
     171
     172    TRACE("win aspect: %g scene aspect: %g", winAspect, sceneAspect);
     173    TRACE("c: %g,%g,%g, d: %g", center.x, center.y, center.z, distance);
     174    TRACE("near: %g, far: %g", _near, _far);
     175
     176    initialize();
     177    resetClippingRange(bboxMin, bboxMax);
     178}
     179
     180void
     181NvCamera::resetClippingRange(const Vector3f& bboxMin, const Vector3f& bboxMax)
     182{
     183    Vector3f emin(bboxMin.x, bboxMin.y, bboxMin.z), emax(bboxMax.x, bboxMax.y, bboxMax.z);
     184
     185    Vector3f center(emin + emax);
     186    center.scale(0.5);
     187
     188    // Compute the radius of the enclosing sphere,
     189    // which is half the bounding box diagonal
     190    Vector3f diagonal(emax - emin);
     191    double radius = diagonal.length() * 0.5;
     192
     193    // If we have just a single point, pick a radius of 1.0
     194    radius = (radius == 0) ? 1.0 : radius;
     195
     196    TRACE("c: %g,%g,%g, r: %g cam z: %g", center.x, center.y, center.z, radius, _location.z);
     197
     198    _near = _location.z - radius;
     199    _far = _location.z + radius;
     200
     201    if (_near < 0.0) {
     202        _near = 0.001;
     203    }
     204    if (_far < 0.0) {
     205        _far = 1.0;
     206    }
    84207
    85208    TRACE("Resetting camera clipping range to: near: %g, far: %g", _near, _far);
     
    91214                   _near, _far);
    92215    glMatrixMode(GL_MODELVIEW);
     216
     217    print();
    93218}
    94219
     
    96221NvCamera::initialize()
    97222{
    98     TRACE("camera: %d, %d", _width, _height);
     223    TRACE("Enter");
     224    print();
     225
    99226    glViewport(_startX, _startY, _width, _height);
    100227    glMatrixMode(GL_PROJECTION);
     
    108235
    109236    glTranslatef(-_location.x, -_location.y, -_location.z);
    110     glMultMatrixf((const GLfloat *)_cameraMatrix.get());
     237    glMultMatrixd((const GLdouble *)_cameraMatrix.get());
    111238}
    112239
    113240void NvCamera::rotate(double *quat)
    114241{
    115     vrQuaternion q(quat[0], quat[1], quat[2], quat[3]);
    116     vrRotation rot;
     242    Quaternion q(quat[0], quat[1], quat[2], quat[3]);
     243    Rotation rot;
    117244    rot.set(q);
    118245    _cameraMatrix.makeRotation(rot);
     
    128255
    129256    _cameraMatrix.makeRotation(1, 0, 0, deg2rad(angleX));
    130     vrMatrix4x4f mat;
     257    Matrix4x4d mat;
    131258    mat.makeRotation(0, 1, 0, deg2rad(angleY));
    132259    _cameraMatrix.multiply(mat);
     
    138265          angleX, angleY, angleZ);
    139266}
     267
     268void NvCamera::print() const
     269{
     270    TRACE("x: %d y: %d w: %d h: %d", _startX, _startY, _width, _height);
     271    TRACE("loc: %g %g %g",
     272          _location.x, _location.y, _location.z);
     273    TRACE("Camera matrix: ");
     274    _cameraMatrix.print();
     275    TRACE("fov: %g near: %g far: %g", _fov, _near, _far);
     276}
  • trunk/packages/vizservers/nanovis/NvCamera.h

    r3467 r3492  
    1717#define CAMERA_H
    1818
    19 #include <vrmath/Matrix4x4f.h>
     19#include <vrmath/Matrix4x4d.h>
     20#include <vrmath/Vector3f.h>
    2021
    2122#include "config.h"
    22 #include "Vector3.h"
    2323
    2424class NvCamera
     
    7676    }
    7777
     78    void reset(const vrmath::Vector3f& bboxMin,
     79               const vrmath::Vector3f& bboxMax,
     80               bool resetOrientation = false);
     81
    7882    void setClippingRange(float near, float far)
    7983    {
     
    8286    }
    8387
    84     void setClippingRange(const Vector3& bboxMin, const Vector3& bboxMax);
     88    void resetClippingRange(const vrmath::Vector3f& bboxMin,
     89                            const vrmath::Vector3f& bboxMax);
    8590
    8691    void setScreenSize(int sx, int sy, int w, int h)
     
    98103    void initialize();
    99104
     105    void print() const;
     106
    100107private:
     108    void getUpDirMatrix(vrmath::Matrix4x4d& upMat);
     109
    101110    /// Location of the camera in the scene
    102     Vector3 _location;
     111    vrmath::Vector3f _location;
    103112    /// Camera view matrix (orientation only, no translation)
    104     vrMatrix4x4f _cameraMatrix;
     113    vrmath::Matrix4x4d _cameraMatrix;
    105114    /// Field of view (vertical angle in degrees)
    106115    float _fov;
  • trunk/packages/vizservers/nanovis/NvFlowVisRenderer.cpp

    r3177 r3492  
    1515 */
    1616
     17#include <vrmath/Vector3f.h>
     18
    1719#include "NvFlowVisRenderer.h"
     20
     21using namespace vrmath;
    1822
    1923#define NV_32
     
    8589void
    8690NvFlowVisRenderer::addVectorField(const std::string& vfName, Volume* volPtr,
    87                                   const Vector3& ori,
     91                                  const Vector3f& ori,
    8892                                  float scaleX, float scaleY, float scaleZ, float max)
    8993{
  • trunk/packages/vizservers/nanovis/NvFlowVisRenderer.h

    r2953 r3492  
    66#include <string>
    77
    8 #include "Vector3.h"
     8#include <vrmath/Vector3f.h>
     9#include <vrmath/Vector4f.h>
     10
    911#include "NvVectorField.h"
    1012
     
    2830    void render();
    2931
    30     void addVectorField(Volume *volPtr, const Vector3& ori, float scaleX,
     32    void addVectorField(Volume *volPtr, const vrmath::Vector3f& ori, float scaleX,
    3133                        float scaleY, float scaleZ, float max);
    3234
    33     void addVectorField(const std::string& vfName, Volume *volPtr, const Vector3& ori,
     35    void addVectorField(const std::string& vfName, Volume *volPtr, const vrmath::Vector3f& ori,
    3436                        float scaleX, float scaleY, float scaleZ, float max);
    3537
     
    5052    void setPlanePos(const std::string& vfName, const std::string& name, float pos);
    5153
    52     void setParticleColor(const std::string& vfName, const std::string& name, const Vector4& color);
     54    void setParticleColor(const std::string& vfName, const std::string& name, const vrmath::Vector4f& color);
    5355
    5456    void activatePlane(const std::string& vfName, const std::string& name);
  • trunk/packages/vizservers/nanovis/NvLIC.cpp

    r3452 r3492  
    2828#define DM ((float) (1.0/(NMESH-1.0))) //distance in world coords between mesh lines
    2929#define SCALE 3.0 //scale for background pattern. small value -> fine texture
     30
     31using namespace vrmath;
    3032
    3133NvLIC::NvLIC(int size, int width, int height, int axis,
     
    488490
    489491void
    490 NvLIC::setVectorField(unsigned int texID, const Vector3& origin,
     492NvLIC::setVectorField(unsigned int texID, const Vector3f& origin,
    491493                      float scaleX, float scaleY, float scaleZ, float max)
    492494{
     
    494496    _vectorFieldId = texID;
    495497    _origin = origin;
    496     _scale = Vector3(scaleX, scaleY, scaleZ);
     498    _scale = Vector3f(scaleX, scaleY, scaleZ);
    497499    _max = max;
    498500
  • trunk/packages/vizservers/nanovis/NvLIC.h

    r3177 r3492  
    1919#include <GL/glew.h>
    2020
    21 #include "Vector3.h"
     21#include <vrmath/Vector3f.h>
     22
    2223#include "Volume.h"
    2324#include "NvShader.h"
     
    5455    void setAxis(int axis);
    5556
    56     void setVectorField(unsigned int texID, const Vector3& origin,
     57    void setVectorField(unsigned int texID, const vrmath::Vector3f& origin,
    5758                        float scaleX, float scaleY, float scaleZ, float max);
    5859
     
    8485     * the inherited Vector3 location is its center
    8586     */
    86     Vector3 _normal;
     87    vrmath::Vector3f _normal;
    8788
    8889    int _width, _height;
     
    9192    float *_sliceVector;        /**< Storage for the per slice vectors
    9293                                   driving the flow */
    93     Vector3 _scale;             /**< Scaling factor stretching the lic
     94    vrmath::Vector3f _scale;             /**< Scaling factor stretching the lic
    9495                                   plane to fit the actual dimensions */
    95     Vector3 _origin;
     96    vrmath::Vector3f _origin;
    9697    float _offset;            ///< [0,1] offset of slice plane
    9798    int _axis;                ///< Axis normal to slice plane
  • trunk/packages/vizservers/nanovis/NvParticleAdvectionShader.h

    r2956 r3492  
    33#define NV_PARTICLE_ADV_SHADER_H
    44
    5 #include "Vector3.h"
     5#include <vrmath/Vector3f.h>
     6
    67#include "NvShader.h"
    78
     
    1718    virtual void unbind();
    1819
    19     void setScale(const Vector3& scale)
     20    void setScale(const vrmath::Vector3f& scale)
    2021    {
    2122        _scale = scale;
     
    4546
    4647    unsigned int _velocityVolumeID;
    47     Vector3 _scale;
     48    vrmath::Vector3f _scale;
    4849    float _max;
    4950    float _timeStep;
  • trunk/packages/vizservers/nanovis/NvParticleRenderer.cpp

    r3452 r3492  
    344344
    345345void
    346 NvParticleRenderer::setVectorField(unsigned int texID, const Vector3& origin,
     346NvParticleRenderer::setVectorField(unsigned int texID, const vrmath::Vector3f& origin,
    347347                                   float scaleX, float scaleY, float scaleZ,
    348348                                   float max)
  • trunk/packages/vizservers/nanovis/NvParticleRenderer.h

    r3177 r3492  
    1919#include <GL/glew.h>
    2020
     21#include <vrmath/Vector3f.h>
     22#include <vrmath/Vector4f.h>
     23
    2124#include "NvParticleAdvectionShader.h"
    2225#include "RenderVertexArray.h"
    23 #include "Vector3.h"
    24 #include "Vector4.h"
    2526
    2627struct Particle {
     
    4546    ~NvParticleRenderer();
    4647
    47     void setVectorField(unsigned int texID, const Vector3& origin,
     48    void setVectorField(unsigned int texID, const vrmath::Vector3f& origin,
    4849                        float scaleX, float scaleY, float scaleZ, float max);
    4950
     
    6869    }
    6970
    70     void setColor(const Vector4& color)
     71    void setColor(const vrmath::Vector4f& color)
    7172    {
    7273        _color = color;
     
    118119
    119120    /// scale of flow data
    120     Vector3 _scale;
     121    vrmath::Vector3f _scale;
    121122
    122     Vector3 _origin;
     123    vrmath::Vector3f _origin;
    123124
    124125    bool _activate;
     
    127128    int _sliceAxis;
    128129
    129     Vector4 _color;
     130    vrmath::Vector4f _color;
    130131
    131132    //the storage of particles is implemented as a 2D array.
  • trunk/packages/vizservers/nanovis/NvVectorField.cpp

    r3452 r3492  
    22#include "nanovis.h"
    33
     4#include <vrmath/Vector3f.h>
     5#include <vrmath/Vector4f.h>
     6
    47#include "NvVectorField.h"
    58#include "NvParticleRenderer.h"
     9
     10using namespace vrmath;
    611
    712NvVectorField::NvVectorField() :
     
    2833
    2934void
    30 NvVectorField::setVectorField(Volume *volPtr, const Vector3& origin,
     35NvVectorField::setVectorField(Volume *volPtr, const Vector3f& origin,
    3136                              float scaleX, float scaleY, float scaleZ,
    3237                              float max)
     
    135140}
    136141
    137 void NvVectorField::setParticleColor(const std::string& name, const Vector4& color)
     142void NvVectorField::setParticleColor(const std::string& name, const vrmath::Vector4f& color)
    138143{
    139144    std::map<std::string, NvParticleRenderer *>::iterator iter = _particleRendererMap.find(name);
     
    147152    std::map<std::string, NvParticleRenderer *>::iterator iter = _particleRendererMap.find(name);
    148153    if (iter != _particleRendererMap.end()) {
    149         if ((*iter).second) (*iter).second->setColor(Vector4(r,g,b,a));
     154        if ((*iter).second) (*iter).second->setColor(vrmath::Vector4f(r,g,b,a));
    150155    }
    151156}
     
    187192    glPushMatrix();
    188193
    189     Vector3 origin = _volPtr->location();
     194    Vector3f origin = _volPtr->location();
    190195    glTranslatef(origin.x, origin.y, origin.z);
    191196
    192     Vector3 scale = _volPtr->getPhysicalScaling();
     197    Vector3f scale = _volPtr->getPhysicalScaling();
    193198    glScaled(scale.x, scale.y, scale.z);
    194199
    195     Vector3 min, max;
     200    Vector3f min, max;
    196201    min.x = _volPtr->xAxis.min();
    197202    min.y = _volPtr->yAxis.min();
  • trunk/packages/vizservers/nanovis/NvVectorField.h

    r3362 r3492  
    66#include <map>
    77
     8#include <vrmath/Vector3f.h>
     9#include <vrmath/Vector4f.h>
     10
    811#include "Volume.h"
    9 #include "Vector3.h"
    1012#include "NvParticleRenderer.h"
    1113
     
    1820    }
    1921
    20     Vector3 min;
    21     Vector3 max;
    22     Vector4 color;
     22    vrmath::Vector3f min;
     23    vrmath::Vector3f max;
     24    vrmath::Vector4f color;
    2325    bool visible;
    2426};
     
    3133    ~NvVectorField();
    3234
    33     void setVectorField(Volume *vol, const Vector3& origin,
     35    void setVectorField(Volume *vol, const vrmath::Vector3f& origin,
    3436                        float scaleX, float scaleY, float scaleZ, float max);
    3537
     
    8688    void setParticleColor(const std::string& name, float r, float g, float b, float a);
    8789
    88     void setParticleColor(const std::string& name, const Vector4& color);
     90    void setParticleColor(const std::string& name, const vrmath::Vector4f& color);
    8991
    9092private:
     
    99101    bool _activated;
    100102
    101     Vector3 _origin;
     103    vrmath::Vector3f _origin;
    102104    float _scaleX;
    103105    float _scaleY;
  • trunk/packages/vizservers/nanovis/NvZincBlendeReconstructor.cpp

    r3452 r3492  
    44#include <stdlib.h>
    55
     6#include <vrmath/Vector3f.h>
     7
    68#include "NvZincBlendeReconstructor.h"
    79#include "ZincBlendeVolume.h"
     10#include "Trace.h"
     11
     12using namespace vrmath;
    813
    914NvZincBlendeReconstructor *NvZincBlendeReconstructor::_instance = NULL;
     
    2833ZincBlendeVolume *NvZincBlendeReconstructor::loadFromFile(const char *fileName)
    2934{
    30     Vector3 origin, delta;
    31 
    3235    std::ifstream stream;
    3336    stream.open(fileName, std::ios::binary);
     
    4346{
    4447    ZincBlendeVolume *volume = NULL;
    45     Vector3 origin, delta;
     48    Vector3f origin, delta;
    4649    int width = 0, height = 0, depth = 0;
    4750    void *data = NULL;
     
    194197
    195198ZincBlendeVolume *
    196 NvZincBlendeReconstructor::buildUp(const Vector3& origin, const Vector3& delta,
     199NvZincBlendeReconstructor::buildUp(const Vector3f& origin, const Vector3f& delta,
    197200                                   int width, int height, int depth, void *data)
    198201{
     
    249252    }
    250253
    251     Vector3 cellSize;
     254    Vector3f cellSize;
    252255    cellSize.x = 0.25 / width;
    253256    cellSize.y = 0.25 / height;
     
    263266
    264267ZincBlendeVolume *
    265 NvZincBlendeReconstructor::buildUp(const Vector3& origin, const Vector3& delta,
     268NvZincBlendeReconstructor::buildUp(const Vector3f& origin, const Vector3f& delta,
    266269                                   int width, int height, int depth,
    267270                                   int datacount, double emptyvalue, void* data)
     
    327330    }
    328331
    329     Vector3 cellSize;
     332    Vector3f cellSize;
    330333    cellSize.x = 0.25 / width;
    331334    cellSize.y = 0.25 / height;
     
    365368{
    366369    ZincBlendeVolume *volume = NULL;
    367     Vector3 origin, delta;
     370    Vector3f origin, delta;
    368371    int width = 0, height = 0, depth = 0;
    369372    void *data = NULL;
  • trunk/packages/vizservers/nanovis/NvZincBlendeReconstructor.h

    r3177 r3492  
    2222#include <fstream>
    2323
    24 #include "Vector3.h"
     24#include <vrmath/Vector3f.h>
    2525
    2626class ZincBlendeVolume;
     
    5252     * @param data the memory block of output data of NEMO-3D
    5353     */
    54     ZincBlendeVolume *buildUp(const Vector3& origin, const Vector3& delta,
     54    ZincBlendeVolume *buildUp(const vrmath::Vector3f& origin, const vrmath::Vector3f& delta,
    5555                              int width, int height, int depth, void *data);
    5656
    57     ZincBlendeVolume *buildUp(const Vector3& origin, const Vector3& delta,
     57    ZincBlendeVolume *buildUp(const vrmath::Vector3f& origin, const vrmath::Vector3f& delta,
    5858                              int width, int height, int depth,
    5959                              int datacount, double emptyvalue, void *data);
  • trunk/packages/vizservers/nanovis/PCASplit.cpp

    r3452 r3492  
    1111#include "PCASplit.h"
    1212
     13using namespace vrmath;
     14
    1315#ifdef use_namespace
    1416using namespace NEWMAT;              // access NEWMAT namespace
     
    3941
    4042void
    41 PCASplit::computeCentroid(Point *data, int count, Vector3& mean)
     43PCASplit::computeCentroid(Point *data, int count, Vector3f& mean)
    4244{
    4345    float sumx = 0, sumy = 0, sumz = 0;
     
    5658
    5759void
    58 PCASplit::computeCovariant(Point *data, int count, const Vector3& mean,
     60PCASplit::computeCovariant(Point *data, int count, const Vector3f& mean,
    5961                           float *m)
    6062{
     
    8385
    8486void
    85 PCASplit::computeDistortion(Point *data, int count, const Vector3& mean,
     87PCASplit::computeDistortion(Point *data, int count, const Vector3f& mean,
    8688                            float& distortion, float& finalSize)
    8789{
     
    164166    _clusterHeader->startPointerCluster[0] = root;
    165167
    166     Vector3 mean;
     168    Vector3f mean;
    167169    float distortion, scale;
    168170
     
    213215PCASplit::split(Point *data, int count, float limit)
    214216{
    215     Vector3 mean;
     217    Vector3f mean;
    216218    float m[9];
    217219
     
    245247    DiagonalMatrix D;
    246248    eigenvalues(A, D ,U);
    247     Vector3 emax(U(1, 3), U(2, 3), U(3, 3));
     249    Vector3f emax(U(1, 3), U(2, 3), U(3, 3));
    248250
    249251    // End newmat11 dependency
     
    303305    }
    304306
    305     //Vector3 mean;
     307    //Vector3f mean;
    306308    //computeCentroid(cluster->points, cluster->numOfPoints, mean);
    307309
  • trunk/packages/vizservers/nanovis/PCASplit.h

    r2844 r3492  
    55#include <memory.h>
    66
    7 #include "Vector3.h"
    8 #include "Vector4.h"
     7#include <vrmath/Vector3f.h>
     8#include <vrmath/Vector4f.h>
    99
    1010namespace PCA {
     
    1818    {}
    1919
    20     Vector3 position;
    21     Vector4 color;
     20    vrmath::Vector3f position;
     21    vrmath::Vector4f color;
    2222    float size;
    2323    float value;
     
    5252    }
    5353
    54     Vector3 centroid;
    55     Vector4 color;
     54    vrmath::Vector3f centroid;
     55    vrmath::Vector4f color;
    5656    float scale;
    5757
     
    9393    {}
    9494
    95     Vector3 centroid_t;
     95    vrmath::Vector3f centroid_t;
    9696    int numOfPoints_t;
    9797    float scale_t;
     
    139139    }
    140140
    141     static void computeDistortion(Point *data, int count, const Vector3& mean, float& distortion, float& maxSize);
     141    static void computeDistortion(Point *data, int count, const vrmath::Vector3f& mean, float& distortion, float& maxSize);
    142142
    143     static void computeCentroid(Point *data, int count, Vector3& mean);
     143    static void computeCentroid(Point *data, int count, vrmath::Vector3f& mean);
    144144
    145     static void computeCovariant(Point *data, int count, const Vector3& mean, float *m);
     145    static void computeCovariant(Point *data, int count, const vrmath::Vector3f& mean, float *m);
    146146
    147147private:
  • trunk/packages/vizservers/nanovis/ParticleEmitter.h

    r3467 r3492  
    2323
    2424    std::string _name;
    25     vrVector3f _position;
     25    vrmath::Vector3f _position;
    2626
    27     vrVector3f _oldPosition;
     27    vrmath::Vector3f _oldPosition;
    2828
    2929    float _minLifeTime;
     
    3131
    3232    // [0..1] * _maxPositionOffset;
    33     vrVector3f _maxPositionOffset;
     33    vrmath::Vector3f _maxPositionOffset;
    3434
    3535    int _minNumOfNewParticles;
  • trunk/packages/vizservers/nanovis/ParticleSystem.cpp

    r3467 r3492  
    1717#include <ImageLoaderFactory.h>
    1818
    19 #include <vrmath/Matrix4x4f.h>
     19#include <vrmath/Matrix4x4d.h>
    2020#include <vrmath/Vector3f.h>
    2121#include <vrmath/Vector4f.h>
     
    124124    float *img = new float[DIM*DIM];
    125125
    126     vrVector3f light(1,1,3);
    127     light.normalize();
     126    vrmath::Vector3f light(1,1,3);
     127    light = light.normalize();
    128128
    129129    for (int y = 0; y < DIM; y++) {
     
    133133                img[y*DIM+x] = 0;
    134134            } else {
    135                 vrVector3f p(x, y, 0);
    136                 p = p - vrVector3f(DIM2, DIM2, 0);
     135                vrmath::Vector3f p(x, y, 0);
     136                p = p - vrmath::Vector3f(DIM2, DIM2, 0);
    137137                float len = p.length();
    138138                float z = sqrt(DIM2*DIM2 - len*len);
     
    143143                }
    144144
    145                 p.normalize();
     145                p = p.normalize();
    146146                float v = p.dot(light);
    147147                if(v < 0) v = 0;
     
    160160}
    161161
    162 //extern void algorithm_test(vrVector4f* data, int flowWidth, int flowHeight, int flowDepth);
    163 //extern std::vector<vrVector3f>* find_critical_points(vrVector4f* data, int flowWidth, int flowHeight, int flowDepth);
     162//extern void algorithm_test(vrmath::Vector4f* data, int flowWidth, int flowHeight, int flowDepth);
     163//extern std::vector<vrmath::Vector3f>* find_critical_points(vrmath::Vector4f* data, int flowWidth, int flowHeight, int flowDepth);
    164164ParticleSystem::ParticleSystem(int width, int height,
    165165                               const std::string& fileName,
     
    215215    memset(_colorBuffer, 0, sizeof(color4) * _particleMaxCount);
    216216
    217     _positionBuffer = new vrVector3f[_particleMaxCount];
     217    _positionBuffer = new vrmath::Vector3f[_particleMaxCount];
    218218    _vertices = new RenderVertexArray(_particleMaxCount, 3, GL_FLOAT);
    219219
     
    263263#endif
    264264        }
    265         //_criticalPoints = find_critical_points((vrVector4f*) data, _flowWidth,  _flowHeight,  _flowDepth);
    266         //algorithm_test((vrVector4f*) data,  _flowWidth,  _flowHeight,  _flowDepth);
     265        //_criticalPoints = find_critical_points((vrmath::Vector4f*) data, _flowWidth,  _flowHeight,  _flowDepth);
     266        //algorithm_test((vrmath::Vector4f*) data,  _flowWidth,  _flowHeight,  _flowDepth);
    267267    }
    268268
     
    568568
    569569    // POSITION
    570     memset(_positionBuffer, 0, sizeof(vrVector3f) * _width * _height);
     570    memset(_positionBuffer, 0, sizeof(vrmath::Vector3f) * _width * _height);
    571571    for (int y = 0; y < _height; y++) {
    572572        for (int x = 0; x < _width; x++) {
     
    11051105            unsigned int numOfNewParticles = (unsigned int)(randomRange(_emitters[i]->_minNumOfNewParticles, _emitters[i]->_maxNumOfNewParticles) * deltaT);
    11061106            for (unsigned int k = 0; k < numOfNewParticles; ++k) {
    1107                 vrVector3f position = _emitters[i]->_position;
     1107                vrmath::Vector3f position = _emitters[i]->_position;
    11081108                position += _emitters[i]->_maxPositionOffset *
    1109                     vrVector3f(randomRange(-1.0f, 1.0f), randomRange(-1.0f, 1.0f), randomRange(-1.0f, 1.0f));
     1109                    vrmath::Vector3f(randomRange(-1.0f, 1.0f), randomRange(-1.0f, 1.0f), randomRange(-1.0f, 1.0f));
    11101110
    11111111                float lifetime = randomRange(_emitters[i]->_minLifeTime, _emitters[i]->_maxLifeTime);
    11121112
    11131113                // TBD..
    1114                 allocateParticle(position, vrVector3f(0.0f, 0.0f, 0.0f),  lifetime, 1 - (float) k / numOfNewParticles);
     1114                allocateParticle(position, vrmath::Vector3f(0.0f, 0.0f, 0.0f),  lifetime, 1 - (float) k / numOfNewParticles);
    11151115            }
    11161116        }
     
    11261126}
    11271127
    1128 void ParticleSystem::allocateParticle(const vrVector3f& position, const vrVector3f& velocity,
     1128void ParticleSystem::allocateParticle(const vrmath::Vector3f& position, const vrmath::Vector3f& velocity,
    11291129                                      float lifeTime, float initTimeStep)
    11301130{
     
    12981298    ///////////////////////////////////////////////////////////
    12991299    // BEGIN - COMPUTE DISTANCE
    1300     vrVector3f pos;
    1301     vrMatrix4x4f mat;
     1300    vrmath::Vector3f pos;
     1301    vrmath::Matrix4x4d mat;
    13021302    glPushMatrix();
    13031303    glLoadIdentity();
    13041304    glScalef(_scalex, _scaley, _scalez);
    13051305    glTranslatef(-0.5f, -0.5f, -0.5f);
    1306     glGetFloatv(GL_MODELVIEW_MATRIX, mat.get());
     1306    glGetDoublev(GL_MODELVIEW_MATRIX, mat.get());
    13071307    glPopMatrix();
    13081308    mat.invert();
     
    17321732#ifdef notdef
    17331733        if (_criticalPoints && _criticalPoints->size()) {
    1734             std::vector<vrVector3f>::iterator iter;
     1734            std::vector<vrmath::Vector3f>::iterator iter;
    17351735            glColor4f(1, 1, 1, 1);
    17361736            glPointSize(10);
  • trunk/packages/vizservers/nanovis/ParticleSystem.h

    r3468 r3492  
    2222struct NewParticle {
    2323    int index;
    24     vrVector3f position;
    25     vrVector3f velocity;
     24    vrmath::Vector3f position;
     25    vrmath::Vector3f velocity;
    2626    float timeOfDeath;
    2727    float initTimeStep;
     
    204204
    205205    Particle *_particles;
    206     vrVector3f *_positionBuffer;
     206    vrmath::Vector3f *_positionBuffer;
    207207    color4 *_colorBuffer;
    208208    unsigned _colorBufferID;
     
    304304    // INSOO
    305305    // TEST
    306     std::vector<vrVector3f> *_criticalPoints;
     306    std::vector<vrmath::Vector3f> *_criticalPoints;
    307307
    308308    // TEMP
     
    322322    void initInitPosTex();
    323323
    324     void allocateParticle(const vrVector3f&, const vrVector3f&, float, float);
     324    void allocateParticle(const vrmath::Vector3f&, const vrmath::Vector3f&, float, float);
    325325    void initNewParticles();
    326326    void cleanUpParticles();
  • trunk/packages/vizservers/nanovis/Plane.cpp

    r3177 r3492  
    1717
    1818#include "Plane.h"
     19
     20using namespace nv;
    1921
    2022Plane::Plane(float _a, float _b, float _c, float _d) :
     
    3840
    3941void
    40 Plane::transform(const Mat4x4& mat)
     42Plane::transform(const vrmath::Matrix4x4d& mat)
    4143{
    42     Vector4 coeffs(a, b, c, d);
     44    vrmath::Vector4f coeffs(a, b, c, d);
    4345
    44     Mat4x4 inv = mat.inverse();
    45     Vector4 new_coeffs = inv.multiplyRowVector(coeffs);
     46    vrmath::Matrix4x4d inv = mat.inverse();
     47    vrmath::Vector4f new_coeffs = inv.preMultiplyRowVector(coeffs);
    4648    a = new_coeffs.x;
    4749    b = new_coeffs.y;
     
    5153
    5254void
    53 Plane::getPoint(Vector3& point)
     55Plane::getPoint(vrmath::Vector3f& point)
    5456{
    5557    if (a != 0) {
  • trunk/packages/vizservers/nanovis/Plane.h

    r3362 r3492  
    1717#define PLANE_H
    1818
    19 #include "Vector3.h"
    20 #include "Mat4x4.h"
     19#include <vrmath/Vector3f.h>
     20#include <vrmath/Vector4f.h>
     21#include <vrmath/Matrix4x4d.h>
     22
     23namespace nv {
    2124
    2225class Plane
     
    3033    {}
    3134
    32     void getPoint(Vector3& point);
     35    void getPoint(vrmath::Vector3f& point);
    3336
    3437    //bool clips(float point[3]) const { return !retains(point); }
    3538
    36     void transform(const Mat4x4& mat);
     39    void transform(const vrmath::Matrix4x4d& mat);
    3740
    3841    void transform(float *m)
    3942    {
    40         Mat4x4 mat(m);
     43        vrmath::Matrix4x4d mat;
     44        mat.setFloat(m);
    4145        transform(mat);
    4246    }
    4347
    44     bool retains(const Vector3& point) const
     48    bool retains(const vrmath::Vector3f& point) const
    4549    {
    4650        return ((a*point.x + b*point.y + c*point.z + d) >= 0);
    4751    }
    4852
    49     Vector4 getCoeffs() const
     53    vrmath::Vector4f getCoeffs() const
    5054    {
    51         return Vector4(a, b, c, d);
     55        return vrmath::Vector4f(a, b, c, d);
    5256    }
    5357
     
    5761    }
    5862
    59     void getNormal(Vector3& normal) const
     63    void getNormal(vrmath::Vector3f& normal) const
    6064    {
    6165        normal.x = a;
     
    6872};
    6973
     74}
    7075
    7176#endif
  • trunk/packages/vizservers/nanovis/PointSet.cpp

    r2844 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #include "PointSet.h"
    3 #include "PCASplit.h"
    42#include <stdlib.h>
    53#include <stdio.h>
    64
     5#include <vrmath/Vector3f.h>
     6#include <vrmath/Vector4f.h>
     7
     8#include "PointSet.h"
     9#include "PCASplit.h"
     10
    711void
    8 PointSet::initialize(Vector4 *values, const unsigned int count,
    9                      const Vector3& scale, const Vector3& origin,
     12PointSet::initialize(vrmath::Vector4f *values, const unsigned int count,
     13                     const vrmath::Vector3f& scale, const vrmath::Vector3f& origin,
    1014                     float min, float max)
    1115{
     
    4549    PCA::Cluster *end = &(cluster[_cluster->numOfClusters[level - 1] - 1]);
    4650
    47     Vector3 pos;
     51    vrmath::Vector3f pos;
    4852
    4953    PCA::Point *points;
    50     Vector4 *colors = (Vector4 *)color;
     54    vrmath::Vector4f *colors = (vrmath::Vector4f *)color;
    5155    int numOfPoints;
    5256    int index;
     
    6569    }
    6670}
    67 
  • trunk/packages/vizservers/nanovis/PointSet.h

    r2844 r3492  
    33#define POINT_SET_H
    44
     5#include <vrmath/Vector3f.h>
     6#include <vrmath/Vector4f.h>
     7
    58#include "PCASplit.h"
    6 #include "Vector4.h"
    7 #include "Vector3.h"
    89
    910class PointSet
     
    2526    }
    2627
    27     void initialize(Vector4 *values, const unsigned int count,
    28                     const Vector3& scale, const Vector3& origin,
     28    void initialize(vrmath::Vector4f *values, const unsigned int count,
     29                    const vrmath::Vector3f& scale, const vrmath::Vector3f& origin,
    2930                    float min, float max);
    3031
     
    5152    }
    5253
    53     Vector3& getScale()
     54    vrmath::Vector3f& getScale()
    5455    {
    5556        return _scale;
    5657    }
    5758
    58     const Vector3& getScale() const
     59    const vrmath::Vector3f& getScale() const
    5960    {
    6061        return _scale;
    6162    }
    6263
    63     Vector3& getOrigin()
     64    vrmath::Vector3f& getOrigin()
    6465    {
    6566        return _origin;
    6667    }
    6768
    68     const Vector3& getOrigin() const
     69    const vrmath::Vector3f& getOrigin() const
    6970    {
    7071        return _origin;
     
    7576    PCA::ClusterAccel *_cluster;
    7677
    77     Vector3 _scale;
    78     Vector3 _origin;
     78    vrmath::Vector3f _scale;
     79    vrmath::Vector3f _origin;
    7980    float _max;
    8081    float _min;
  • trunk/packages/vizservers/nanovis/PointSetRenderer.cpp

    r3465 r3492  
    103103}
    104104
    105 void PointSetRenderer::render(PCA::ClusterAccel *cluster, const Mat4x4& mat,
    106                               int sortLevel, const Vector3& scale, const Vector3& origin)
     105void PointSetRenderer::render(PCA::ClusterAccel *cluster, const Matrix4x4d& mat,
     106                              int sortLevel, const Vector3f& scale, const Vector3f& origin)
    107107{
    108108    _bucketSort->init();
  • trunk/packages/vizservers/nanovis/PointSetRenderer.h

    r2953 r3492  
    22#ifndef POINT_SET_RENDERER_H
    33#define POINT_SET_RENDERER_H
     4
     5#include <vrmath/Vector3f.h>
     6#include <vrmath/Matrix4x4d.h>
    47
    58#include "PCASplit.h"
     
    710#include "PointShader.h"
    811#include "Texture2D.h"
    9 #include "Mat4x4.h"
    1012
    1113class PointSetRenderer
     
    1517    ~PointSetRenderer();
    1618
    17     void render(PCA::ClusterAccel *cluster, const Mat4x4& mat,
    18                 int sortLevel, const Vector3& scale, const Vector3& origin);
     19    void render(PCA::ClusterAccel *cluster, const vrmath::Matrix4x4d& mat,
     20                int sortLevel, const vrmath::Vector3f& scale, const vrmath::Vector3f& origin);
    1921
    2022private:
  • trunk/packages/vizservers/nanovis/RpAVTranslate.h

    r3177 r3492  
    3535#endif
    3636}
    37 #include "RpOutcome.h"
     37#include <RpOutcome.h>
    3838
    3939namespace Rappture {
  • trunk/packages/vizservers/nanovis/Texture2D.cpp

    r3452 r3492  
    1414 * ======================================================================
    1515 */
    16 
    17 #include "Texture2D.h"
    18 #include "Trace.h"
    1916#include <stdio.h>
    2017#include <assert.h>
     
    2219
    2320#include "config.h"
     21
     22#include "Texture2D.h"
     23#include "Trace.h"
    2424
    2525Texture2D::Texture2D() :
  • trunk/packages/vizservers/nanovis/Texture3D.cpp

    r3452 r3492  
    1414 * ======================================================================
    1515 */
    16 
    17 #include "Texture3D.h"
    18 #include "Trace.h"
    1916#include <stdio.h>
    2017#include <assert.h>
     
    2219
    2320#include "config.h"
     21
     22#include "Texture3D.h"
     23#include "Trace.h"
    2424
    2525Texture3D::Texture3D() :
  • trunk/packages/vizservers/nanovis/Trace.cpp

    r3452 r3492  
    88#include <stdarg.h>
    99#include <syslog.h>
     10#include <string.h>
    1011
    1112#include <GL/glew.h>
  • trunk/packages/vizservers/nanovis/TransferFunction.cpp

    r3177 r3492  
    1515 */
    1616
    17 #include "TransferFunction.h"
    1817#include <memory.h>
    1918#include <assert.h>
     19
     20#include <vrmath/Vector3f.h>
     21
     22#include "TransferFunction.h"
     23
     24using namespace vrmath;
    2025
    2126TransferFunction::TransferFunction(int size, float *data)
     
    5257
    5358void
    54 TransferFunction::sample(float fraction, float *key, int count, Vector3 *keyValue, Vector3 *ret)
     59TransferFunction::sample(float fraction, float *key, int count, Vector3f *keyValue, Vector3f *ret)
    5560{
    5661    int limit = count - 1;
  • trunk/packages/vizservers/nanovis/TransferFunction.h

    r3464 r3492  
    1717#define TRANSFER_FUNCTION_H
    1818
     19#include <vrmath/Vector3f.h>
     20
    1921#include "Texture1D.h"
    20 #include "Vector3.h"
    2122
    2223class TransferFunction
     
    6465    }
    6566
    66     static void sample(float fraction, float *key, int count, Vector3 *keyValue, Vector3 *ret);
     67    static void sample(float fraction, float *key, int count, vrmath::Vector3f *keyValue, vrmath::Vector3f *ret);
    6768
    6869    static void sample(float fraction, float *key, int count, float *keyValue, float *ret);
  • trunk/packages/vizservers/nanovis/VelocityArrowsSlice.cpp

    r3465 r3492  
    77#include <GL/gl.h>
    88
     9#include <vrmath/Vector3f.h>
    910#include <util/FilePath.h>
    1011#include <Image.h>
     
    1819
    1920using namespace nv::util;
     21using namespace vrmath;
    2022
    2123static inline float deg2rad(float deg)
     
    127129        delete [] _velocities;
    128130    }
    129     _velocities = new Vector3[_renderTargetWidth * _renderTargetHeight];
     131    _velocities = new Vector3f[_renderTargetWidth * _renderTargetHeight];
    130132
    131133    if (_vertexBufferGraphicsID != 0) {
     
    321323        glColor3f(_arrowColor.x, _arrowColor.y, _arrowColor.z);
    322324 
    323         Vector3 pos;
    324         Vector3 vel;
    325         Vector3 refVec;
    326         Vector3 blue(0, 0, 1);
    327         Vector3 red(1, 0, 0);
     325        Vector3f pos;
     326        Vector3f vel;
     327        Vector3f refVec;
     328        Vector3f blue(0, 0, 1);
     329        Vector3f red(1, 0, 0);
    328330
    329331        int index = 0, icount, jcount;
     
    360362                }
    361363                if (length > 1.0e-6) {
    362                     Vector3 vnorm = vel.normalize();
    363                     Vector3 rotationAxis = refVec.cross(vnorm);
     364                    Vector3f vnorm = vel.normalize();
     365                    Vector3f rotationAxis = refVec.cross(vnorm);
    364366                    double angle = rad2deg(acos(refVec.dot(vnorm)));
    365                     Vector3 color = blue * (1.0 - length) + red * length;
     367                    Vector3f color = blue * (1.0 - length) + red * length;
    366368                    float scale = length;
    367369                    if (scale < 0.10) scale = 0.10;
     
    450452
    451453void
    452 VelocityArrowsSlice::setVectorField(unsigned int vfGraphicsID, const Vector3& origin,
     454VelocityArrowsSlice::setVectorField(unsigned int vfGraphicsID, const Vector3f& origin,
    453455                                    float xScale, float yScale, float zScale, float max)
    454456{
     
    532534    createRenderTarget();
    533535
    534     Vector3 pos;
    535     Vector3 *pinfo = NULL;
     536    Vector3f pos;
     537    Vector3f *pinfo = NULL;
    536538    if (_renderMode == GLYPHS) {
    537539        glBindBufferARB(GL_ARRAY_BUFFER_ARB, _vertexBufferGraphicsID);
    538         pinfo = (Vector3 *)glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
     540        pinfo = (Vector3f *)glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
    539541    }
    540542
  • trunk/packages/vizservers/nanovis/VelocityArrowsSlice.h

    r2964 r3492  
    55#include <vector>
    66
     7#include <vrmath/Vector3f.h>
     8
    79#include "Texture2D.h"
    8 #include "Vector3.h"
    910#include "NvShader.h"
    1011
     
    2122    ~VelocityArrowsSlice();
    2223
    23     void setVectorField(unsigned int vfGraphicsID, const Vector3& origin,
     24    void setVectorField(unsigned int vfGraphicsID, const vrmath::Vector3f& origin,
    2425                        float xScale, float yScale, float zScale, float max);
    2526
     
    6667    }
    6768
    68     void arrowColor(const Vector3& color)
     69    void arrowColor(const vrmath::Vector3f& color)
    6970    {
    7071        _arrowColor = color;
     
    104105    int _renderTargetWidth;
    105106    int _renderTargetHeight;
    106     Vector3 *_velocities;
    107     std::vector<Vector3> _samplingPositions;
    108     Vector3 _projectionVector;
     107    vrmath::Vector3f *_velocities;
     108    std::vector<vrmath::Vector3f> _samplingPositions;
     109    vrmath::Vector3f _projectionVector;
    109110
    110111    int _tickCountForMinSizeAxis;
     
    115116    int _pointCount;
    116117
    117     Vector3 _maxVelocityScale;
    118     Vector3 _arrowColor;
     118    vrmath::Vector3f _maxVelocityScale;
     119    vrmath::Vector3f _arrowColor;
    119120
    120121    bool _enabled;
  • trunk/packages/vizservers/nanovis/Volume.cpp

    r3452 r3492  
    1616#include <memory.h>
    1717#include <assert.h>
     18#include <float.h>
     19
     20#include <vrmath/Vector4f.h>
     21#include <vrmath/Matrix4x4d.h>
    1822
    1923#include "Volume.h"
    2024#include "Trace.h"
     25
     26using namespace vrmath;
    2127
    2228bool Volume::updatePending = false;
     
    4955    _dataEnabled(true),
    5056    _outlineEnabled(true),
    51     _outlineColor(1., 1., 1.),
    5257    _volumeType(CUBIC),
    5358    _isosurface(0)
    5459{
    5560    TRACE("Enter: %dx%dx%d", _width, _height, _depth);
     61
     62    _outlineColor[0] = _outlineColor[1] = _outlineColor[2] = 1.0f;
    5663
    5764    _tex = new Texture3D(_width, _height, _depth, GL_FLOAT, GL_LINEAR, n);
     
    9097    delete _tex;
    9198}
     99
     100void Volume::getWorldSpaceBounds(Vector3f& bboxMin, Vector3f& bboxMax) const
     101{
     102    Vector3f scale = getPhysicalScaling();
     103
     104    Matrix4x4d mat;
     105    mat.makeTranslation(_location);
     106    Matrix4x4d mat2;
     107    mat2.makeScale(scale);
     108
     109    mat.multiply(mat2);
     110
     111    bboxMin.set(FLT_MAX, FLT_MAX, FLT_MAX);
     112    bboxMax.set(-FLT_MAX, -FLT_MAX, -FLT_MAX);
     113
     114    Vector3f modelMin(0, 0, 0);
     115    Vector3f modelMax(1, 1, 1);
     116
     117    Vector4f bvert[8];
     118    bvert[0] = Vector4f(modelMin.x, modelMin.y, modelMin.z, 1);
     119    bvert[1] = Vector4f(modelMax.x, modelMin.y, modelMin.z, 1);
     120    bvert[2] = Vector4f(modelMin.x, modelMax.y, modelMin.z, 1);
     121    bvert[3] = Vector4f(modelMin.x, modelMin.y, modelMax.z, 1);
     122    bvert[4] = Vector4f(modelMax.x, modelMax.y, modelMin.z, 1);
     123    bvert[5] = Vector4f(modelMax.x, modelMin.y, modelMax.z, 1);
     124    bvert[6] = Vector4f(modelMin.x, modelMax.y, modelMax.z, 1);
     125    bvert[7] = Vector4f(modelMax.x, modelMax.y, modelMax.z, 1);
     126
     127    for (int i = 0; i < 8; i++) {
     128        Vector4f worldVert = mat.transform(bvert[i]);
     129        if (worldVert.x < bboxMin.x) bboxMin.x = worldVert.x;
     130        if (worldVert.x > bboxMax.x) bboxMax.x = worldVert.x;
     131        if (worldVert.y < bboxMin.y) bboxMin.y = worldVert.y;
     132        if (worldVert.y > bboxMax.y) bboxMax.y = worldVert.y;
     133        if (worldVert.z < bboxMin.z) bboxMin.z = worldVert.z;
     134        if (worldVert.z > bboxMax.z) bboxMax.z = worldVert.z;
     135    }
     136}
  • trunk/packages/vizservers/nanovis/Volume.h

    r3463 r3492  
    1717#define VOLUME_H
    1818
     19#include <cstring>
    1920#include <string>
    2021#include <vector>
    2122
    22 #include "Color.h"
     23#include <vrmath/Vector3f.h>
     24
    2325#include "Texture3D.h"
    24 #include "Vector3.h"
    2526#include "AxisRange.h"
    2627#include "TransferFunction.h"
     
    103104    }
    104105
    105     void location(const Vector3& loc)
     106    void location(const vrmath::Vector3f& loc)
    106107    {
    107108        _location = loc;
    108109    }
    109110
    110     Vector3 location() const
     111    vrmath::Vector3f location() const
    111112    {
    112113        return _location;
     
    288289    void getOutlineColor(float *rgb);
    289290
    290     Vector3 getPhysicalScaling() const
    291     {
    292         Vector3 scale;
     291    vrmath::Vector3f getPhysicalScaling() const
     292    {
     293        vrmath::Vector3f scale;
    293294        scale.x = 1;
    294295        scale.y = yAxis.length() / xAxis.length();
     
    297298    }
    298299
     300    void getWorldSpaceBounds(vrmath::Vector3f& bboxMin,
     301                             vrmath::Vector3f& bboxMax) const;
     302 
    299303    double sampleDistanceX() const
    300304    {
     
    388392    Texture3D *_tex;            ///< OpenGL texture storing the volume
    389393
    390     Vector3 _location;
     394    vrmath::Vector3f _location;
    391395
    392396    /**
     
    398402    bool _dataEnabled;          ///< show/hide cloud of volume data
    399403    bool _outlineEnabled;       ///< show/hide outline around volume
    400     Color _outlineColor;        ///< color for outline around volume
     404    float _outlineColor[3];     ///< color for outline around volume
    401405    int _volumeType;            ///< cubic or zincblende
    402406    int _isosurface;
     
    454458Volume::setOutlineColor(float *rgb)
    455459{
    456     _outlineColor = Color(rgb[0], rgb[1], rgb[2]);
     460    memcpy(_outlineColor, rgb, sizeof(float)*3);
    457461}
    458462
     
    460464Volume::getOutlineColor(float *rgb)
    461465{
    462     _outlineColor.getRGB(rgb);
     466    memcpy(rgb, _outlineColor, sizeof(float)*3);
    463467}
    464468
  • trunk/packages/vizservers/nanovis/VolumeInterpolator.cpp

    r3452 r3492  
    77#include <stdlib.h>
    88
     9#include <vrmath/Vector3f.h>
     10
    911#include "VolumeInterpolator.h"
    1012#include "Volume.h"
    11 #include "Vector3.h"
    1213#include "Trace.h"
     14
     15using namespace vrmath;
    1316
    1417VolumeInterpolator::VolumeInterpolator() :
     
    5760        float *result = _volume->data();
    5861
    59         Vector3 normal1, normal2, normal;
     62        Vector3f normal1, normal2, normal;
    6063        for (unsigned int i = 0; i < _dataCount; ++i) {
    6164            *result = interp * (*data2 - *data1) + *data1;
    62             normal1 = (*(Vector3*)(data1 + 1) - 0.5) * 2;
    63             normal2 = (*(Vector3*)(data2 + 1) - 0.5) * 2;
     65            normal1 = (*(Vector3f*)(data1 + 1) - 0.5) * 2;
     66            normal2 = (*(Vector3f*)(data2 + 1) - 0.5) * 2;
    6467            normal = (normal2 - normal2) * interp + normal1;
    6568            normal = normal.normalize();
    6669            normal = normal * 0.5 + 0.5;
    67             *((Vector3*)(result + 1)) = normal;
     70            *((Vector3f*)(result + 1)) = normal;
    6871
    6972            result += _numComponents;
     
    132135        _numComponents = refPtr->numComponents();
    133136        _numBytes = _dataCount * _numComponents * sizeof(float);
    134         Vector3 loc = refPtr->location();
     137        Vector3f loc = refPtr->location();
    135138        _volume = new Volume(loc.x, loc.y, loc.z,
    136139                             refPtr->width(),
  • trunk/packages/vizservers/nanovis/VolumeRenderer.cpp

    r3452 r3492  
    2323#include <tcl.h>
    2424
     25#include <vrmath/Vector3f.h>
     26#include <vrmath/Matrix4x4d.h>
     27
    2528#include "nanovis.h"
    2629#include "VolumeRenderer.h"
     30#include "Plane.h"
    2731#include "ConvexPolygon.h"
    2832#include "NvStdVertexShader.h"
    2933#include "Trace.h"
     34
     35using namespace vrmath;
    3036
    3137VolumeRenderer::VolumeRenderer()
     
    142148
    143149        //volume start location
    144         Vector3 volPos = volPtr->location();
    145         Vector3 volScaling = volPtr->getPhysicalScaling();
     150        Vector3f volPos = volPtr->location();
     151        Vector3f volScaling = volPtr->getPhysicalScaling();
    146152
    147153        TRACE("VOL POS: %g %g %g",
     
    154160        double z0 = 0;
    155161
    156         Mat4x4 model_view_no_trans, model_view_trans;
    157         Mat4x4 model_view_no_trans_inverse, model_view_trans_inverse;
     162        Matrix4x4d model_view_no_trans, model_view_trans;
     163        Matrix4x4d model_view_no_trans_inverse, model_view_trans_inverse;
    158164
    159165        //initialize volume plane with world coordinates
    160         Plane volume_planes[6];
     166        nv::Plane volume_planes[6];
    161167        volume_planes[0].setCoeffs( 1,  0,  0, -x0);
    162168        volume_planes[1].setCoeffs(-1,  0,  0,  x0+1);
     
    172178        glEnable(GL_DEPTH_TEST);
    173179
    174         GLfloat mv_no_trans[16];
    175         glGetFloatv(GL_MODELVIEW_MATRIX, mv_no_trans);
    176 
    177         model_view_no_trans = Mat4x4(mv_no_trans);
     180        GLdouble mv_no_trans[16];
     181        glGetDoublev(GL_MODELVIEW_MATRIX, mv_no_trans);
     182
     183        model_view_no_trans = Matrix4x4d(mv_no_trans);
    178184        model_view_no_trans_inverse = model_view_no_trans.inverse();
    179185
     
    185191        glScalef(volScaling.x, volScaling.y, volScaling.z);
    186192
    187         GLfloat mv_trans[16];
    188         glGetFloatv(GL_MODELVIEW_MATRIX, mv_trans);
    189 
    190         model_view_trans = Mat4x4(mv_trans);
     193        GLdouble mv_trans[16];
     194        glGetDoublev(GL_MODELVIEW_MATRIX, mv_trans);
     195
     196        model_view_trans = Matrix4x4d(mv_trans);
    191197        model_view_trans_inverse = model_view_trans.inverse();
     198
     199        model_view_trans.print();
    192200
    193201        //draw volume bounding box with translation (the correct location in
     
    234242              zNear, zFar, eyeMinX, eyeMaxX, eyeMinY, eyeMaxY, z_step, n_actual_slices);
    235243
    236         Vector4 vert1, vert2, vert3, vert4;
     244        Vector4f vert1, vert2, vert3, vert4;
    237245
    238246        // Render cutplanes first with depth test enabled.  They will mark the
     
    250258            switch (axis) {
    251259            case 1:
    252                 vert1 = Vector4(offset, 0, 0, 1);
    253                 vert2 = Vector4(offset, 1, 0, 1);
    254                 vert3 = Vector4(offset, 1, 1, 1);
    255                 vert4 = Vector4(offset, 0, 1, 1);
     260                vert1 = Vector4f(offset, 0, 0, 1);
     261                vert2 = Vector4f(offset, 1, 0, 1);
     262                vert3 = Vector4f(offset, 1, 1, 1);
     263                vert4 = Vector4f(offset, 0, 1, 1);
    256264                break;
    257265            case 2:
    258                 vert1 = Vector4(0, offset, 0, 1);
    259                 vert2 = Vector4(1, offset, 0, 1);
    260                 vert3 = Vector4(1, offset, 1, 1);
    261                 vert4 = Vector4(0, offset, 1, 1);
     266                vert1 = Vector4f(0, offset, 0, 1);
     267                vert2 = Vector4f(1, offset, 0, 1);
     268                vert3 = Vector4f(1, offset, 1, 1);
     269                vert4 = Vector4f(0, offset, 1, 1);
    262270                break;
    263271            case 3:
    264272            default:
    265                 vert1 = Vector4(0, 0, offset, 1);
    266                 vert2 = Vector4(1, 0, offset, 1);
    267                 vert3 = Vector4(1, 1, offset, 1);
    268                 vert4 = Vector4(0, 1, offset, 1);
     273                vert1 = Vector4f(0, 0, offset, 1);
     274                vert2 = Vector4f(1, 0, offset, 1);
     275                vert3 = Vector4f(1, 1, offset, 1);
     276                vert4 = Vector4f(0, 1, offset, 1);
    269277                break;
    270278            }
    271279
    272             Vector4 texcoord1 = vert1;
    273             Vector4 texcoord2 = vert2;
    274             Vector4 texcoord3 = vert3;
    275             Vector4 texcoord4 = vert4;
     280            Vector4f texcoord1 = vert1;
     281            Vector4f texcoord2 = vert2;
     282            Vector4f texcoord3 = vert3;
     283            Vector4f texcoord4 = vert4;
    276284
    277285            _cutplaneShader->bind();
     
    310318        // Initialize view-aligned quads with eye space bounds of
    311319        // volume
    312         vert1 = Vector4(eyeMinX, eyeMinY, -0.5, 1);
    313         vert2 = Vector4(eyeMaxX, eyeMinY, -0.5, 1);
    314         vert3 = Vector4(eyeMaxX, eyeMaxY, -0.5, 1);
    315         vert4 = Vector4(eyeMinX, eyeMaxY, -0.5, 1);
     320        vert1 = Vector4f(eyeMinX, eyeMinY, -0.5, 1);
     321        vert2 = Vector4f(eyeMaxX, eyeMinY, -0.5, 1);
     322        vert3 = Vector4f(eyeMaxX, eyeMaxY, -0.5, 1);
     323        vert4 = Vector4f(eyeMinX, eyeMaxY, -0.5, 1);
    316324
    317325        size_t counter = 0;
     
    389397        volPtr = volumes[volume_index];
    390398
    391         Vector3 volScaling = volPtr->getPhysicalScaling();
     399        Vector3f volScaling = volPtr->getPhysicalScaling();
    392400
    393401        glPushMatrix();
     
    510518}
    511519
    512 void VolumeRenderer::getEyeSpaceBounds(const Mat4x4& mv,
     520void VolumeRenderer::getEyeSpaceBounds(const Matrix4x4d& mv,
    513521                                       double& xMin, double& xMax,
    514522                                       double& yMin, double& yMax,
     
    542550
    543551    for (int i = 0; i < 8; i++) {
    544         Vector4 eyeVert = mv.transform(Vector4(vertex[i][0],
    545                                                vertex[i][1],
    546                                                vertex[i][2],
    547                                                vertex[i][3]));
     552        Vector4f eyeVert = mv.transform(Vector4f(vertex[i][0],
     553                                                 vertex[i][1],
     554                                                 vertex[i][2],
     555                                                 vertex[i][3]));
    548556        if (eyeVert.x < xMin) xMin = eyeVert.x;
    549557        if (eyeVert.x > xMax) xMax = eyeVert.x;
  • trunk/packages/vizservers/nanovis/VolumeRenderer.h

    r3362 r3492  
    1717#define _VOLUME_RENDERER_H_
    1818
    19 #include "Mat4x4.h"
     19#include <vrmath/Matrix4x4d.h>
     20
    2021#include "Volume.h"
    2122#include "VolumeInterpolator.h"
     
    7475                         float r, float g, float b, float line_width);
    7576
    76     void getEyeSpaceBounds(const Mat4x4& mv,
     77    void getEyeSpaceBounds(const vrmath::Matrix4x4d& mv,
    7778                           double& xMin, double& xMax,
    7879                           double& yMin, double& yMax,
  • trunk/packages/vizservers/nanovis/ZincBlendeVolume.cpp

    r3362 r3492  
    1515 * ======================================================================
    1616 */
    17 
    1817#include <assert.h>
    1918
     19#include <vrmath/Vector3f.h>
     20
    2021#include "ZincBlendeVolume.h"
     22
     23using namespace vrmath;
    2124
    2225ZincBlendeVolume::ZincBlendeVolume(float x, float y, float z,
     
    2427                                   float *dataVolumeA, float *dataVolumeB,
    2528                                   double v0, double v1, double non_zeromin,
    26                                    const Vector3& cellSz) :
     29                                   const Vector3f& cellSz) :
    2730    Volume(x, y, z, w, h, d, n, dataVolumeA, v0, v1, non_zeromin),
    2831    cellSize(cellSz)
  • trunk/packages/vizservers/nanovis/ZincBlendeVolume.h

    r3362 r3492  
    1818#define _ZINCBLENDE_VOLUME_H_
    1919
     20#include <vrmath/Vector3f.h>
     21
    2022#include "Volume.h"
    2123
     
    2628                     int width, int height, int depth, int numComponents,
    2729                     float *dataVolumeA, float *dataVolumeB,
    28                      double vmin, double vmax, double non_zeromin, const Vector3& cellSize);
     30                     double vmin, double vmax, double non_zeromin, const vrmath::Vector3f& cellSize);
    2931
    3032    virtual ~ZincBlendeVolume();
    3133
    3234    Texture3D *zincblendeTex[2]; //the textures of two cubic volumes
    33     Vector3 cellSize;   //the cell size in texture space
     35    vrmath::Vector3f cellSize;  //the cell size in texture space
    3436};
    3537
  • trunk/packages/vizservers/nanovis/dxReader.cpp

    r3452 r3492  
    520520    float dz0 = -0.5*lz/lx;
    521521    if (volPtr) {
    522         volPtr->location(Vector3(dx0, dy0, dz0));
     522        volPtr->location(vrmath::Vector3f(dx0, dy0, dz0));
    523523        TRACE("Set volume location to %g %g %g", dx0, dy0, dz0);
    524524    }
  • trunk/packages/vizservers/nanovis/dxReaderCommon.cpp

    r2877 r3492  
    33#include "GradientFilter.h"
    44
    5 #include "Vector3.h"
     5#include <vrmath/Vector3f.h>
     6
    67#include "stdlib.h"
     8
     9using namespace vrmath;
    710
    811float *
     
    1114    float *data = (float *)malloc(sizeof(float) * 4 * size);
    1215
    13     Vector3 *g = (Vector3 *)gradient;
     16    Vector3f *g = (Vector3f *)gradient;
    1417
    1518    int ngen = 0, sindex = 0;
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r3478 r3492  
    4747
    4848#include <graphics/RenderContext.h>
     49#include <vrmath/Vector3f.h>
    4950
    5051#include <util/FilePath.h>
     
    8687#define SIZEOF_BMP_HEADER   54
    8788
    88 /// Indicates "up" axis
    89 enum AxisDirections {
    90     X_POS = 1,
    91     Y_POS = 2,
    92     Z_POS = 3,
    93     X_NEG = -1,
    94     Y_NEG = -2,
    95     Z_NEG = -3
    96 };
    97 
    9889#define CVT2SECS(x)  ((double)(x).tv_sec) + ((double)(x).tv_usec * 1.0e-6)
    9990
     
    176167float NanoVis::wMin = FLT_MAX;
    177168float NanoVis::wMax = -FLT_MAX;
     169vrmath::Vector3f NanoVis::sceneMin, NanoVis::sceneMax;
    178170
    179171/* FIXME: This variable is always true. */
     
    189181
    190182// Default camera location.
    191 const float def_eye_x = 0.0f;
    192 const float def_eye_y = 0.0f;
    193 const float def_eye_z = 2.5f;
     183float def_eye_x = 0.0f;
     184float def_eye_y = 0.0f;
     185float def_eye_z = 2.5f;
    194186
    195187// Image based flow visualization slice location
     
    584576
    585577    cam->z(def_eye_z / z);
     578
     579    collectBounds();
     580    cam->resetClippingRange(sceneMin, sceneMax);
     581
    586582    TRACE("set cam z to %f", cam->z());
     583}
     584
     585void
     586NanoVis::resetCamera(bool resetOrientation)
     587{
     588    TRACE("Resetting all=%d", resetOrientation ? 1 : 0);
     589
     590    collectBounds();
     591    cam->reset(sceneMin, sceneMax, resetOrientation);
     592
     593    def_eye_x = cam->x();
     594    def_eye_y = cam->y();
     595    def_eye_z = cam->z();
    587596}
    588597
     
    15701579    HeightMap::updatePending = false;
    15711580    TRACE("Leave");
     1581}
     1582
     1583void
     1584NanoVis::collectBounds(bool onlyVisible)
     1585{
     1586    if (flags & MAP_FLOWS) {
     1587        MapFlows();
     1588        grid->xAxis.setScale(xMin, xMax);
     1589        grid->yAxis.setScale(yMin, yMax);
     1590        grid->zAxis.setScale(zMin, zMax);
     1591    }
     1592
     1593    sceneMin.set(FLT_MAX, FLT_MAX, FLT_MAX);
     1594    sceneMax.set(-FLT_MAX, -FLT_MAX, -FLT_MAX);
     1595
     1596    Tcl_HashEntry *hPtr;
     1597    Tcl_HashSearch iter;
     1598    for (hPtr = Tcl_FirstHashEntry(&volumeTable, &iter); hPtr != NULL;
     1599         hPtr = Tcl_NextHashEntry(&iter)) {
     1600        Volume *vol = (Volume *)Tcl_GetHashValue(hPtr);
     1601
     1602        if (onlyVisible && !vol->visible())
     1603            continue;
     1604
     1605        vrmath::Vector3f bmin, bmax;
     1606        vol->getWorldSpaceBounds(bmin, bmax);
     1607        if (bmin.x > bmax.x)
     1608            continue;
     1609
     1610        if (sceneMin.x > bmin.x) {
     1611            sceneMin.x = bmin.x;
     1612        }
     1613        if (sceneMax.x < bmax.x) {
     1614            sceneMax.x = bmax.x;
     1615        }
     1616        if (sceneMin.y > bmin.y) {
     1617            sceneMin.y = bmin.y;
     1618        }
     1619        if (sceneMax.y < bmax.y) {
     1620            sceneMax.y = bmax.y;
     1621        }
     1622        if (sceneMin.z > bmin.z) {
     1623            sceneMin.z = bmin.z;
     1624        }
     1625        if (sceneMax.z < bmax.z) {
     1626            sceneMax.z = bmax.z;
     1627        }
     1628    }
     1629
     1630    for (hPtr = Tcl_FirstHashEntry(&heightmapTable, &iter); hPtr != NULL;
     1631         hPtr = Tcl_NextHashEntry(&iter)) {
     1632        HeightMap *heightMap = (HeightMap *)Tcl_GetHashValue(hPtr);
     1633
     1634        if (onlyVisible && !heightMap->isVisible())
     1635            continue;
     1636
     1637        vrmath::Vector3f bmin, bmax;
     1638        heightMap->getWorldSpaceBounds(bmin, bmax);
     1639        if (bmin.x > bmax.x)
     1640            continue;
     1641
     1642        if (sceneMin.x > bmin.x) {
     1643            sceneMin.x = bmin.x;
     1644        }
     1645        if (sceneMax.x < bmax.x) {
     1646            sceneMax.x = bmax.x;
     1647        }
     1648        if (sceneMin.y > bmin.y) {
     1649            sceneMin.y = bmin.y;
     1650        }
     1651        if (sceneMax.y < bmax.y) {
     1652            sceneMax.y = bmax.y;
     1653        }
     1654        if (sceneMin.z > bmin.z) {
     1655            sceneMin.z = bmin.z;
     1656        }
     1657        if (sceneMax.z < bmax.z) {
     1658            sceneMax.z = bmax.z;
     1659        }
     1660    }
     1661
     1662    vrmath::Vector3f flowMin, flowMax;
     1663    GetFlowBounds(flowMin, flowMax, onlyVisible);
     1664    if (flowMin.x < flowMax.x) {
     1665        if (sceneMin.x > flowMin.x) {
     1666            sceneMin.x = flowMin.x;
     1667        }
     1668        if (sceneMax.x < flowMax.x) {
     1669            sceneMax.x = flowMax.x;
     1670        }
     1671        if (sceneMin.y > flowMin.y) {
     1672            sceneMin.y = flowMin.y;
     1673        }
     1674        if (sceneMax.y < flowMax.y) {
     1675            sceneMax.y = flowMax.y;
     1676        }
     1677        if (sceneMin.z > flowMin.z) {
     1678            sceneMin.z = flowMin.z;
     1679        }
     1680        if (sceneMax.z < flowMax.z) {
     1681            sceneMax.z = flowMax.z;
     1682        }
     1683    }
     1684
     1685    // TODO: Get Grid bounds
     1686
     1687    if (sceneMin.x > sceneMax.x) {
     1688        sceneMin.set(-0.5, -0.5, -0.5);
     1689        sceneMax.set( 0.5,  0.5,  0.5);
     1690    }
     1691
     1692    TRACE("Scene bounds: (%g,%g,%g) - (%g,%g,%g)",
     1693          sceneMin.x, sceneMin.y, sceneMin.z,
     1694          sceneMax.x, sceneMax.y, sceneMax.z);
    15721695}
    15731696
  • trunk/packages/vizservers/nanovis/nanovis.h

    r3478 r3492  
    2828#include <iostream>
    2929
    30 #include <rappture.h>
     30#include <vrmath/Vector3f.h>
    3131
    3232#include "config.h"
     
    6969{
    7070public:
     71    enum AxisDirections {
     72        X_POS = 1,
     73        Y_POS = 2,
     74        Z_POS = 3,
     75        X_NEG = -1,
     76        Y_NEG = -2,
     77        Z_NEG = -3
     78    };
     79
    7180    enum NanoVisFlags {
    7281        REDRAW_PENDING = (1 << 0),
    73         MAP_FLOWS = (1 << 1),
    74         MAP_VOLUMES = (1 << 2),
    75         MAP_HEIGHTMAPS = (1 << 3),
     82        MAP_FLOWS = (1 << 1)
    7683    };
    7784
     
    94101    static void pan(float dx, float dy);
    95102    static void zoom(float z);
     103    static void resetCamera(bool resetOrientation = false);
    96104
    97105    static void eventuallyRedraw(unsigned int flag = 0);
     
    141149    static void DeleteFlows(Tcl_Interp *interp);
    142150    static bool MapFlows();
     151    static void GetFlowBounds(vrmath::Vector3f& min,
     152                              vrmath::Vector3f& max,
     153                              bool onlyVisible = false);
    143154    static void RenderFlows();
    144155    static void ResetFlows();
     
    169180    static double magMin, magMax;
    170181    static float xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
     182    static vrmath::Vector3f sceneMin, sceneMax;
    171183
    172184    static NvColorTableRenderer *colorTableRenderer;
     
    190202    static struct timeval startTime;           /* Start of elapsed time. */
    191203private:
     204    static void collectBounds(bool onlyVisible = false);
     205
    192206    static float _licSlice;  ///< Slice position [0,1]
    193207    static int _licAxis;     ///< Slice axis: 0:x, 1:y, 2:z
  • trunk/packages/vizservers/nanovis/vrmath/BBox.cpp

    r3467 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 */
     7
     8#include <float.h>
     9
    210#include <vrmath/BBox.h>
     11#include <vrmath/Matrix4x4f.h>
    312#include <vrmath/Vector3f.h>
     13#include <vrmath/Vector4f.h>
    414
    5 vrBBox::vrBBox()
     15using namespace vrmath;
     16
     17BBox::BBox()
    618{
    719    makeEmpty();
    820}
    921
    10 vrBBox::vrBBox(const vrBBox& bbox)
     22BBox::BBox(const BBox& bbox)
    1123{
    1224    min = bbox.min;
     
    1426}
    1527
    16 vrBBox::vrBBox(const vrVector3f& minv, const vrVector3f& maxv)
     28BBox::BBox(const Vector3f& minv, const Vector3f& maxv)
    1729{
    1830    min = minv;
     
    2032}
    2133
    22 void vrBBox::makeEmpty()
     34void BBox::makeEmpty()
    2335{
    24     float big = 1e27f;
    25     min.set(big, big, big);
    26     max.set(-big, -big, -big);
     36    min.set(FLT_MAX, FLT_MAX, FLT_MAX);
     37    max.set(-FLT_MAX, -FLT_MAX, -FLT_MAX);
    2738}
    2839
    29 bool vrBBox::isEmpty()
     40bool BBox::isEmpty()
    3041{
    3142    if ((min.x > max.x) || (min.y > max.y) || (min.z > max.z)) {
     
    3647}
    3748
    38 void vrBBox::make(const vrVector3f& center, const vrVector3f& size)
     49void BBox::make(const Vector3f& center, const Vector3f& size)
    3950{
    4051    float halfX = size.x * 0.5f, halfY = size.y * 0.5f, halfZ = size.z * 0.5f;
     
    5061}
    5162
    52 void vrBBox::extend(const vrVector3f& point)
     63void BBox::extend(const Vector3f& point)
    5364{
    5465    if (min.x > point.x) {
     
    7182}
    7283
    73 void vrBBox::extend(const vrBBox& box)
     84void BBox::extend(const BBox& box)
    7485{
    7586    if (min.x > box.min.x) min.x = box.min.x;
     
    8293}
    8394
    84 void vrBBox::transform(const vrBBox& box, const vrMatrix4x4f& mat)
     95void BBox::transform(const BBox& box, const Matrix4x4f& mat)
    8596{
    8697    float halfSizeX = (box.max.x - box.min.x) * 0.5f;
     
    92103    float centerZ = (box.max.z + box.min.z) * 0.5f;
    93104
    94     vrVector3f points[8];
     105    Vector4f points[8];
    95106
    96     points[0].set(centerX + halfSizeX, centerY + halfSizeY, centerZ + halfSizeZ);
    97     points[1].set(centerX + halfSizeX, centerY + halfSizeY, centerZ - halfSizeZ);
    98     points[2].set(centerX - halfSizeX, centerY + halfSizeY, centerZ - halfSizeZ);
    99     points[3].set(centerX - halfSizeX, centerY + halfSizeY, centerZ + halfSizeZ);
    100     points[4].set(centerX - halfSizeX, centerY - halfSizeY, centerZ + halfSizeZ);
    101     points[5].set(centerX - halfSizeX, centerY - halfSizeY, centerZ - halfSizeZ);
    102     points[6].set(centerX + halfSizeX, centerY - halfSizeY, centerZ - halfSizeZ);
    103     points[7].set(centerX + halfSizeX, centerY - halfSizeY, centerZ + halfSizeZ);
     107    points[0].set(centerX + halfSizeX, centerY + halfSizeY, centerZ + halfSizeZ, 1);
     108    points[1].set(centerX + halfSizeX, centerY + halfSizeY, centerZ - halfSizeZ, 1);
     109    points[2].set(centerX - halfSizeX, centerY + halfSizeY, centerZ - halfSizeZ, 1);
     110    points[3].set(centerX - halfSizeX, centerY + halfSizeY, centerZ + halfSizeZ, 1);
     111    points[4].set(centerX - halfSizeX, centerY - halfSizeY, centerZ + halfSizeZ, 1);
     112    points[5].set(centerX - halfSizeX, centerY - halfSizeY, centerZ - halfSizeZ, 1);
     113    points[6].set(centerX + halfSizeX, centerY - halfSizeY, centerZ - halfSizeZ, 1);
     114    points[7].set(centerX + halfSizeX, centerY - halfSizeY, centerZ + halfSizeZ, 1);
    104115
    105116    float minX, minY, minZ;
    106117    float maxX, maxY, maxZ;
    107118
    108     points[0].transform(mat, points[0]);
     119    points[0] = mat.transform(points[0]);
    109120
    110121    minX = maxX = points[0].x;
     
    113124
    114125    for (int i = 1; i < 8; i++) {
    115         points[i].transform(mat, points[i]);
     126        points[i] = mat.transform(points[i]);
    116127
    117128        if (points[i].x > maxX) maxX = points[i].x;
     
    129140}
    130141
    131 bool vrBBox::intersect(const vrBBox& box)
     142bool BBox::intersect(const BBox& box)
    132143{
    133144    if (min.x > box.max.x || max.x < box.min.x) return false;
     
    138149}
    139150
    140 bool vrBBox::intersect(const vrVector3f& point)
     151bool BBox::intersect(const Vector3f& point)
    141152{
    142153    if ((point.x < min.x) || (point.x > max.x)) return false;
  • trunk/packages/vizservers/nanovis/vrmath/BPlane.cpp

    r3470 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 */
     7
    28#include <vrmath/BPlane.h>
    39#include <vrmath/Vector3f.h>
    410#include <vrmath/LineSegment.h>
    511
    6 void vrBPlane::makePts(const vrVector3f& p1, const vrVector3f& p2, const vrVector3f& p3)
     12using namespace vrmath;
     13
     14void BPlane::makePts(const Vector3f& p1, const Vector3f& p2, const Vector3f& p3)
    715{
    8     normal.cross(p2 - p1, p3 - p1);
    9     normal.normalize();
     16    normal = cross(p2 - p1, p3 - p1);
     17    normal = normal.normalize();
    1018
    1119    point = p1;
    1220}
    1321
    14 void vrBPlane::makeNormalPt(const vrVector3f& norm, const vrVector3f& pos)
     22void BPlane::makeNormalPt(const Vector3f& norm, const Vector3f& pos)
    1523{
    1624    normal = norm;
     
    1826}
    1927
    20 bool vrBPlane::intersect(const vrLineSegment &seg, float &d) const
     28bool BPlane::intersect(const LineSegment &seg, float &d) const
    2129{
    22     // STEVE
    23     // 2005-09-07
    24        
    2530    float tu, td;
    2631
    27     tu = normal.x * (point.x - seg.pos.x) + normal.y * (point.y - seg.pos.y)
    28         + normal.z * (point.z - seg.pos.z);
     32    tu = normal.x * (point.x - seg.pos.x) +
     33         normal.y * (point.y - seg.pos.y) +
     34         normal.z * (point.z - seg.pos.z);
    2935
    30     td = normal.x * seg.dir.x + normal.y * seg.dir.y + normal.z * seg.dir.z;
     36    td = normal.x * seg.dir.x +
     37         normal.y * seg.dir.y +
     38         normal.z * seg.dir.z;
    3139
    3240    if ( td == 0.0f ) return false;
    3341
    3442    d = tu / td;
    35        
     43
    3644    return true;
    3745}
    3846
    39 float vrBPlane::distance(const vrVector3f& pos) const
     47double BPlane::distance(const Vector3f& pos) const
    4048{
    41     vrVector3f plane_point = crossPoint( pos );
     49    Vector3f plane_point = crossPoint(pos);
    4250
    43     return pos.distance( plane_point );
     51    return pos.distance(plane_point);
    4452}
    4553
    46 vrVector3f vrBPlane::crossPoint(const vrVector3f& pos) const
     54Vector3f BPlane::crossPoint(const Vector3f& pos) const
    4755{
    48     vrLineSegment seg;
     56    LineSegment seg;
    4957
    50     seg.pos = pos;
     58    seg.pos.set(pos.x, pos.y, pos.z, 1);
    5159    seg.dir = normal;
    5260
  • trunk/packages/vizservers/nanovis/vrmath/Color4f.cpp

    r3467 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 */
     7
    28#include <vrmath/Color4f.h>
    39
    4 vrColor4f::vrColor4f() :
     10using namespace vrmath;
     11
     12Color4f::Color4f() :
    513    r(0.0f), g(0.0f), b(0.0f), a(1.0f)
    614{
    715}
    816
    9 vrColor4f::vrColor4f(float r1, float g1, float b1, float a1) :
     17Color4f::Color4f(float r1, float g1, float b1, float a1) :
    1018    r(r1), g(g1), b(b1), a(a1)
    1119{
  • trunk/packages/vizservers/nanovis/vrmath/LineSegment.cpp

    r3467 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 */
     7
    28#include <vrmath/LineSegment.h>
     9#include <vrmath/Matrix4x4f.h>
    310
     11using namespace vrmath;
    412
    5 vrLineSegment::vrLineSegment():
    6     pos(0.0f, 0.0f, 0.0f), dir(0.0f, 0.0f, -1.0f), length(0.0f)
     13LineSegment::LineSegment():
     14    pos(0, 0, 0, 1), dir(0.0f, 0.0f, -1.0f), length(0.0f)
    715{
    816}
    917
    10 void vrLineSegment::transform(const vrMatrix4x4f &mat, const vrLineSegment &seg)
     18void LineSegment::transform(const Matrix4x4f &mat, const LineSegment &seg)
    1119{
    12     pos.transform(mat, seg.pos);
    13        
    14     dir.x *= length;
    15     dir.y *= length;
    16     dir.z *= length;
     20    pos = mat.transform(seg.pos);
    1721
    18     dir.transformVec(mat, seg.dir);
     22    dir *= length;
     23
     24    dir = mat.transformVec(seg.dir);
    1925    length = dir.length();
    20     dir.normalize();
     26    dir = dir.normalize();
    2127}
  • trunk/packages/vizservers/nanovis/vrmath/Makefile.in

    r3470 r3492  
    4040VRMATHLIB       = vrmath.a
    4141
     42#               BBox.o \
     43#               BPlane.o \
     44#               Color4f.o \
    4245#               Projection.o \
    4346
     
    4851                LineSegment.o \
    4952                Matrix4x4f.o \
     53                Matrix4x4d.o \
    5054                Plane.o \
    51                 Plane2.o \
    5255                Quaternion.o \
    5356                Rotation.o \
     
    8083Color4f.o: $(srcdir)/include/vrmath/Color4f.h
    8184LineSegment.o: $(srcdir)/include/vrmath/LineSegment.h
    82 Matrix4x4f.o: $(srcdir)/include/vrmath/Matrix4x4f.h $(srcdir)/include/vrmath/Vector3f.h $(srcdir)/include/vrmath/Rotation.h
     85Matrix4x4d.o: $(srcdir)/include/vrmath/Matrix4x4d.h $(srcdir)/include/vrmath/Vector3f.h $(srcdir)/include/vrmath/Vector4f.h $(srcdir)/include/vrmath/Rotation.h
     86Matrix4x4f.o: $(srcdir)/include/vrmath/Matrix4x4f.h $(srcdir)/include/vrmath/Vector3f.h $(srcdir)/include/vrmath/Vector4f.h $(srcdir)/include/vrmath/Rotation.h
    8387Plane.o: $(srcdir)/include/vrmath/Plane.h $(srcdir)/include/vrmath/Matrix4x4f.h
    84 Plane2.o: $(srcdir)/include/vrmath/Plane2.h $(srcdir)/include/vrmath/LineSegment.h
    8588Quaternion.o: $(srcdir)/include/vrmath/Quaternion.h $(srcdir)/include/vrmath/Rotation.h $(srcdir)/include/vrmath/Vector3f.h
    8689Rotation.o: $(srcdir)/include/vrmath/Quaternion.h $(srcdir)/include/vrmath/Rotation.h $(srcdir)/include/vrmath/Vector3f.h
  • trunk/packages/vizservers/nanovis/vrmath/Matrix4x4f.cpp

    r3467 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 * Author: Leif Delgass <ldelgass@purdue.edu>
     7 */
     8
    29#include <vrmath/Vector3f.h>
    310#include <vrmath/Rotation.h>
    411#include <vrmath/Matrix4x4f.h>
    512
    6 void vrMatrix4x4f::makeIdentity()
     13using namespace vrmath;
     14
     15void Matrix4x4f::makeIdentity()
    716{
    817    _data[1] = _data[2] = _data[3] = _data[4] =
     
    1221}
    1322
    14 void vrMatrix4x4f::makeTranslation(const vrVector3f& translation)
     23void Matrix4x4f::makeTranslation(const Vector3f& translation)
    1524{
    1625    _data[1] = _data[2] = _data[3] = _data[4] =
     
    2332}
    2433
    25 void vrMatrix4x4f::makeTranslation(float x, float y, float z)
     34void Matrix4x4f::makeTranslation(float x, float y, float z)
    2635{
    2736    _data[1] = _data[2] = _data[3] = _data[4] =
     
    3443}
    3544
    36 void vrMatrix4x4f::makeRotation(const vrRotation& rotation)
    37 {
    38     if (rotation.getAngle() == 0.0f ||
    39         (rotation.getX() == 0.0f &&
    40          rotation.getY() == 0.0f &&
    41          rotation.getZ() == 0.0f)) {
     45void Matrix4x4f::makeRotation(const Rotation& rotation)
     46{
     47    if (rotation.getAngle() == 0.0 ||
     48        (rotation.getX() == 0.0 &&
     49         rotation.getY() == 0.0 &&
     50         rotation.getZ() == 0.0)) {
    4251        makeIdentity();
    4352        return;
    4453    }
    4554
    46     float xAxis = rotation.getX();
    47     float yAxis = rotation.getY();
    48     float zAxis = rotation.getZ();
    49     float invLen = 1.0f / sqrt(xAxis * xAxis + yAxis * yAxis + zAxis * zAxis);
    50     float cosine = cos(rotation.getAngle());
    51     float sine = sin(rotation.getAngle());
     55    double xAxis = rotation.getX();
     56    double yAxis = rotation.getY();
     57    double zAxis = rotation.getZ();
     58    double invLen = 1.0 / sqrt(xAxis * xAxis + yAxis * yAxis + zAxis * zAxis);
     59    double cosine = cos(rotation.getAngle());
     60    double sine = sin(rotation.getAngle());
    5261
    5362    xAxis *= invLen;
     
    5564    zAxis *= invLen;
    5665
    57     float oneMinusCosine = 1.0f - cosine;
     66    double oneMinusCosine = 1.0 - cosine;
    5867
    5968    _data[3] = _data[7] = _data[11] = _data[12] = _data[13] = _data[14] = 0.0f;
    6069    _data[15] = 1.0f;
    6170
    62     _data[0] = xAxis * xAxis * oneMinusCosine + cosine;
    63     _data[1] = yAxis * xAxis * oneMinusCosine + zAxis * sine;
    64     _data[2] = xAxis * zAxis * oneMinusCosine - yAxis * sine;
    65 
    66     _data[4] = xAxis * yAxis * oneMinusCosine - zAxis * sine;
    67     _data[5] = yAxis * yAxis * oneMinusCosine + cosine;
    68     _data[6] = yAxis * zAxis * oneMinusCosine + xAxis * sine;
    69 
    70     _data[8] = xAxis * zAxis * oneMinusCosine + yAxis * sine;
    71     _data[9] = yAxis * zAxis * oneMinusCosine - xAxis * sine;
    72     _data[10] = zAxis * zAxis * oneMinusCosine + cosine;
    73 }
    74 
    75 void vrMatrix4x4f::makeRotation(float xAxis, float yAxis, float zAxis, float angle)
    76 {
    77     if (angle == 0.0f ||
    78         (xAxis == 0.0f &&
    79          yAxis == 0.0f &&
    80          zAxis == 0.0f)) {
     71    _data[0] = float(xAxis * xAxis * oneMinusCosine + cosine);
     72    _data[1] = float(yAxis * xAxis * oneMinusCosine + zAxis * sine);
     73    _data[2] = float(xAxis * zAxis * oneMinusCosine - yAxis * sine);
     74
     75    _data[4] = float(xAxis * yAxis * oneMinusCosine - zAxis * sine);
     76    _data[5] = float(yAxis * yAxis * oneMinusCosine + cosine);
     77    _data[6] = float(yAxis * zAxis * oneMinusCosine + xAxis * sine);
     78
     79    _data[8] = float(xAxis * zAxis * oneMinusCosine + yAxis * sine);
     80    _data[9] = float(yAxis * zAxis * oneMinusCosine - xAxis * sine);
     81    _data[10] = float(zAxis * zAxis * oneMinusCosine + cosine);
     82}
     83
     84void Matrix4x4f::makeRotation(double xAxis, double yAxis, double zAxis, double angle)
     85{
     86    if (angle == 0.0 ||
     87        (xAxis == 0.0 &&
     88         yAxis == 0.0 &&
     89         zAxis == 0.0)) {
    8190        makeIdentity();
    8291        return;
    8392    }
    8493
    85     float invLen = 1.0f / sqrt(xAxis * xAxis + yAxis * yAxis + zAxis * zAxis);
    86     float cosine = cos(angle);
    87     float sine = sin(angle);
     94    double invLen = 1.0 / sqrt((double)xAxis * xAxis + (double)yAxis * yAxis + (double)zAxis * zAxis);
     95    double cosine = cos(angle);
     96    double sine = sin(angle);
    8897
    8998    xAxis *= invLen;
     
    91100    zAxis *= invLen;
    92101
    93     float oneMinusCosine = 1.0f - cosine;
     102    double oneMinusCosine = 1.0 - cosine;
    94103
    95104    _data[3] = _data[7] = _data[11] = _data[12] = _data[13] = _data[14] = 0.0f;
    96105    _data[15] = 1.0f;
    97106
    98     _data[0] = xAxis * xAxis * oneMinusCosine + cosine;
    99     _data[1] = yAxis * xAxis * oneMinusCosine + zAxis * sine;
    100     _data[2] = xAxis * zAxis * oneMinusCosine - yAxis * sine;
    101 
    102     _data[4] = xAxis * yAxis * oneMinusCosine - zAxis * sine;
    103     _data[5] = yAxis * yAxis * oneMinusCosine + cosine;
    104     _data[6] = yAxis * zAxis * oneMinusCosine + xAxis * sine;
    105 
    106     _data[8] = xAxis * zAxis * oneMinusCosine + yAxis * sine;
    107     _data[9] = yAxis * zAxis * oneMinusCosine - xAxis * sine;
    108     _data[10] = zAxis * zAxis * oneMinusCosine + cosine;
    109 }
    110 
    111 void vrMatrix4x4f::makeScale(const vrVector3f& scale)
     107    _data[0] = float(xAxis * xAxis * oneMinusCosine + cosine);
     108    _data[1] = float(yAxis * xAxis * oneMinusCosine + zAxis * sine);
     109    _data[2] = float(xAxis * zAxis * oneMinusCosine - yAxis * sine);
     110
     111    _data[4] = float(xAxis * yAxis * oneMinusCosine - zAxis * sine);
     112    _data[5] = float(yAxis * yAxis * oneMinusCosine + cosine);
     113    _data[6] = float(yAxis * zAxis * oneMinusCosine + xAxis * sine);
     114
     115    _data[8] = float(xAxis * zAxis * oneMinusCosine + yAxis * sine);
     116    _data[9] = float(yAxis * zAxis * oneMinusCosine - xAxis * sine);
     117    _data[10] = float(zAxis * zAxis * oneMinusCosine + cosine);
     118}
     119
     120void Matrix4x4f::makeScale(const Vector3f& scale)
    112121{
    113122    _data[1] = _data[2] = _data[3] = _data[4] =
     
    123132}
    124133
    125 void vrMatrix4x4f::multiply(const vrMatrix4x4f& m1)
     134void Matrix4x4f::makeScale(float x, float y, float z)
     135{
     136    _data[1] = _data[2] = _data[3] = _data[4] =
     137        _data[6] = _data[7] = _data[8] = _data[9] =
     138        _data[11] = 0.0f;
     139
     140    _data[0] = x;
     141    _data[5] = y;
     142    _data[10] = z;
     143
     144    _data[15] = 1.0f;
     145    _data[12] = _data[13] = _data[14] = 0.0f;
     146}
     147
     148Vector4f
     149Matrix4x4f::transform(const Vector4f& v) const
     150{
     151    Vector4f ret;
     152    ret.x = _data[0] * v.x + _data[4] * v.y + _data[8] * v.z  + _data[12] * v.w;
     153    ret.y = _data[1] * v.x + _data[5] * v.y + _data[9] * v.z  + _data[13] * v.w;
     154    ret.z = _data[2] * v.x + _data[6] * v.y + _data[10] * v.z + _data[14] * v.w;
     155    ret.w = _data[3] * v.x + _data[7] * v.y + _data[11] * v.z + _data[15] * v.w;
     156    return ret;
     157}
     158
     159Vector3f
     160Matrix4x4f::transformVec(const Vector3f& v) const
     161{
     162    Vector3f ret;
     163    ret.x = _data[0] * v.x + _data[4] * v.y + _data[8] * v.z;
     164    ret.y = _data[1] * v.x + _data[5] * v.y + _data[9] * v.z;
     165    ret.z = _data[2] * v.x + _data[6] * v.y + _data[10] * v.z;
     166    return ret;
     167}
     168
     169Vector4f
     170Matrix4x4f::preMultiplyRowVector(const Vector4f& v) const
     171{
     172    Vector4f ret;
     173    ret.x = (_data[0]  * v.x) + (_data[1]  * v.y) + (_data[2]  * v.z) + (_data[3]  * v.w);
     174    ret.y = (_data[4]  * v.x) + (_data[5]  * v.y) + (_data[6]  * v.z) + (_data[7]  * v.w);
     175    ret.z = (_data[8]  * v.x) + (_data[9]  * v.y) + (_data[10] * v.z) + (_data[11] * v.w);
     176    ret.w = (_data[12] * v.x) + (_data[13] * v.y) + (_data[14] * v.z) + (_data[15] * v.w);
     177    return ret;
     178}
     179
     180void Matrix4x4f::multiply(const Matrix4x4f& m1)
    126181{
    127182    float mat[16];
    128     float *mat1 = (float *)m1._data;
     183    const float *mat1 = m1._data;
    129184
    130185    // 1 row
     
    173228}
    174229
    175 void vrMatrix4x4f::multiply(const vrMatrix4x4f& m1, const vrMatrix4x4f& m2)
     230void Matrix4x4f::multiply(const Matrix4x4f& m1, const Matrix4x4f& m2)
    176231{
    177232    float mat[16];
    178     float *mat1 = (float *)m1._data;
    179     float *mat2 = (float *)m2._data;
     233    const float *mat1 = m1._data;
     234    const float *mat2 = m2._data;
    180235
    181236    // 1 row
     
    223278}
    224279
    225 void vrMatrix4x4f::multiplyFast(const vrMatrix4x4f& m1, const vrMatrix4x4f& m2)
    226 {
    227     float *mat1 = (float *)m1._data;
    228     float *mat2 = (float *)m2._data;
     280void Matrix4x4f::multiplyFast(const Matrix4x4f& m1, const Matrix4x4f& m2)
     281{
     282    const float *mat1 = m1._data;
     283    const float *mat2 = m2._data;
    229284
    230285    // 1 row
     
    269324}
    270325
    271 void vrMatrix4x4f::getRotation(vrRotation& rotation)
    272 {
    273     float c = (_data[0] + _data[5] + _data[10] - 1.0f) * 0.5f;
     326void Matrix4x4f::getRotation(Rotation& rotation)
     327{
     328    double c = (_data[0] + _data[5] + _data[10] - 1.0) * 0.5;
    274329
    275330    rotation.setAxis(_data[6] - _data[9], _data[8] - _data[2], _data[1] - _data[4]);
    276331
    277     float len = sqrt(rotation.getX() * rotation.getX() +
    278                      rotation.getY() * rotation.getY() + rotation.getZ() * rotation.getZ());
    279 
    280     float s = 0.5f * len;
    281 
    282     rotation.setAngle((float)atan2(s, c));
    283 
    284     if ( rotation.getX() == 0.0f && rotation.getY() == 0.0f && rotation.getZ() == 0.0f ) {
    285         rotation.set(0.0f, 1.0f, 0.0f, 0.0f);
     332    double len = sqrt(rotation.getX() * rotation.getX() +
     333                      rotation.getY() * rotation.getY() +
     334                      rotation.getZ() * rotation.getZ());
     335
     336    double s = 0.5 * len;
     337
     338    rotation.setAngle(atan2(s, c));
     339
     340    if (rotation.getX() == 0.0 &&
     341        rotation.getY() == 0.0 &&
     342        rotation.getZ() == 0.0) {
     343        rotation.set(0, 1, 0, 0);
    286344    } else {
    287         len = 1.0f / len;
    288         rotation.setAxis(rotation.getX() * len, rotation.getY() * len, rotation.getZ() * len);
     345        len = 1.0 / len;
     346        rotation.setAxis(rotation.getX() * len,
     347                         rotation.getY() * len,
     348                         rotation.getZ() * len);
    289349    }
    290350}
    291351
    292 void vrMatrix4x4f::invert()
     352void Matrix4x4f::invert()
    293353{
    294354    float det =
     
    438498}
    439499
    440 void vrMatrix4x4f::invert(const vrMatrix4x4f& mat)
     500void Matrix4x4f::invert(const Matrix4x4f& mat)
    441501{
    442502    float *data = (float *)mat._data;
     
    588648}
    589649
    590 void vrMatrix4x4f::invertFast(const vrMatrix4x4f& mat)
     650void Matrix4x4f::invertFast(const Matrix4x4f& mat)
    591651{
    592652    float *srcData = (float *)mat._data;
     
    734794}
    735795
    736 void vrMatrix4x4f::transpose()
     796void Matrix4x4f::transpose()
    737797{
    738798    float m[16];
     
    761821}
    762822
    763 void vrMatrix4x4f::transposeFast(const vrMatrix4x4f& mat)
     823void Matrix4x4f::transposeFast(const Matrix4x4f& mat)
    764824{
    765825    _data[0] = mat._data[0];
     
    784844}
    785845
    786 void vrMatrix4x4f::transpose(const vrMatrix4x4f& mat)
     846void Matrix4x4f::transpose(const Matrix4x4f& mat)
    787847{
    788848    float m[16];
     
    811871}
    812872
    813 void vrMatrix4x4f::set(double* m)
     873void Matrix4x4f::setDouble(double *m)
    814874{
    815875    for (int i = 0; i < 16; ++i) {
     
    818878}
    819879
    820 void vrMatrix4x4f::multiply(const vrMatrix4x4f& mat1, const vrVector3f& position)
    821 {
    822     vrMatrix4x4f mat;
     880void Matrix4x4f::multiply(const Matrix4x4f& mat1, const Vector3f& position)
     881{
     882    Matrix4x4f mat;
    823883    mat.makeTranslation(position);
    824884    multiply(mat1, mat);
    825885}
    826886
    827 void vrMatrix4x4f::multiply(const vrMatrix4x4f& mat1, const vrRotation& rotation)
    828 {
    829     vrMatrix4x4f mat;
     887void Matrix4x4f::multiply(const Matrix4x4f& mat1, const Rotation& rotation)
     888{
     889    Matrix4x4f mat;
    830890    mat.makeRotation(rotation);
    831891    multiply(mat1, mat);
    832892}
    833893
    834 void vrMatrix4x4f::multiply(const vrVector3f& position, const vrMatrix4x4f& mat1)
    835 {
    836     vrMatrix4x4f mat;
     894void Matrix4x4f::multiply(const Vector3f& position, const Matrix4x4f& mat1)
     895{
     896    Matrix4x4f mat;
    837897    mat.makeTranslation(position);
    838898    multiply(mat, mat1);
    839899}
    840900
    841 void vrMatrix4x4f::multiply(const vrRotation& rotation, const vrMatrix4x4f& mat1)
    842 {
    843     vrMatrix4x4f mat;
     901void Matrix4x4f::multiply(const Rotation& rotation, const Matrix4x4f& mat1)
     902{
     903    Matrix4x4f mat;
    844904    mat.makeRotation(rotation);
    845905    multiply(mat, mat1);
    846906}
    847907
    848 void vrMatrix4x4f::makeVecRotVec(const vrVector3f& vec1, const vrVector3f& vec2)
    849 {
    850     vrVector3f axis;
    851     axis.cross(vec1, vec2);
     908void Matrix4x4f::makeVecRotVec(const Vector3f& vec1, const Vector3f& vec2)
     909{
     910    Vector3f axis = cross(vec1, vec2);
    852911
    853912    float angle = atan2(axis.length(), vec1.dot(vec2));
    854     if (axis.normalize() == 0.0f) {
    855         makeIdentity();
    856     } else {
    857         makeRotation(axis.x, axis.y, axis.z, angle);
    858     }
    859 }
    860 
    861 void vrMatrix4x4f::multiplyScale(const vrMatrix4x4f& mat1, const vrVector3f& scale)
    862 {
    863     vrMatrix4x4f mat;
     913    axis = axis.normalize();
     914    makeRotation(axis.x, axis.y, axis.z, angle);
     915}
     916
     917void Matrix4x4f::multiplyScale(const Matrix4x4f& mat1, const Vector3f& scale)
     918{
     919    Matrix4x4f mat;
    864920    mat.makeScale(scale);
    865921    multiply(mat1, mat);
    866922}
    867923
    868 void vrMatrix4x4f::multiplyScale(const vrVector3f& scale, const vrMatrix4x4f& mat1)
    869 {
    870     vrMatrix4x4f mat;
     924void Matrix4x4f::multiplyScale(const Vector3f& scale, const Matrix4x4f& mat1)
     925{
     926    Matrix4x4f mat;
    871927    mat.makeScale(scale);
    872928    multiply(mat, mat1);
  • trunk/packages/vizservers/nanovis/vrmath/Plane.cpp

    r3470 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 */
     7
    28#include <vrmath/Plane.h>
    39#include <vrmath/Matrix4x4f.h>
    410
    5 void vrPlane::transform(vrMatrix4x4f& mat)
     11using namespace vrmath;
     12
     13void Plane::transform(Matrix4x4f& mat)
    614{
    7     vrVector4f v(normal.x, normal.y, normal.z, distance);
     15    Vector4f v(normal.x, normal.y, normal.z, distance);
    816    float* m = mat.get();
    917
  • trunk/packages/vizservers/nanovis/vrmath/Projection.cpp

    r3470 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 */
    27
    38#include <math.h>
    49#include <memory.h>
    510
     11using namespace vrmath;
     12
    613#if 0
    7 vrVector3f vrCalcNormal(const vrVector3f& v1, const vrVector3f& v2, const vrVector3f& v3)
     14Vector3f calcNormal(const Vector3f& v1, const Vector3f& v2, const Vector3f& v3)
    815{
    9     vrVector3f temp;
     16    Vector3f temp;
    1017
    1118    float a[3], b[3];
  • trunk/packages/vizservers/nanovis/vrmath/Quaternion.cpp

    r3470 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 /**
    3  * Quaternion code by BLACKAXE / kolor aka Laurent Schmalen
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
    44 *
    5  * I have changed names according to my naming rules
     5 * Author: Insoo Woo <iwoo@purdue.edu>
    66 */
    77
     
    1818#endif
    1919
    20 vrQuaternion::vrQuaternion() :
     20using namespace vrmath;
     21
     22Quaternion::Quaternion() :
    2123    x(1.0f), y(0.0f), z(0.0f), w(0.0f)
    2224{
    2325}
    2426
    25 vrQuaternion::vrQuaternion(const vrRotation& rot)
     27Quaternion::Quaternion(const Rotation& rot)
    2628{
    2729    set(rot);
    2830}
    2931
    30 vrQuaternion::vrQuaternion(float x1, float y1, float z1, float w1) :
     32Quaternion::Quaternion(double x1, double y1, double z1, double w1) :
    3133    x(x1), y(y1), z(z1), w(w1)
    3234{
    3335}
    3436
    35 const vrQuaternion& vrQuaternion::normalize()
     37Quaternion& Quaternion::normalize()
    3638{
    37     float norme = sqrt(w*w + x*x + y*y + z*z);
    38     if (norme == 0.0) {
     39    double n = sqrt(w*w + x*x + y*y + z*z);
     40    if (n == 0.0) {
    3941        w = 1.0;
    40         x = y = z = 0.0f;
     42        x = y = z = 0.0;
    4143    } else {
    42         float recip = 1.0f/norme;
     44        double recip = 1.0/n;
    4345        w *= recip;
    4446        x *= recip;
     
    5052}
    5153
    52 const vrQuaternion& vrQuaternion::set(const vrRotation& rot)
     54const Quaternion& Quaternion::set(const Rotation& rot)
    5355{
    54 #if 0
    55     float omega, s, c;
    56 
    57     s = sqrt(rot.x*rot.x + rot.y*rot.y + rot.z*rot.z);
    58 
    59     if (fabs(s) > FLT_EPSILON) {
    60         c = 1.0/s;
    61         float rot_x = rot.x * c;
    62         float rot_y = rot.y * c;
    63         float rot_z = rot.z * c;
    64 
    65         omega = -0.5f * rot.angle;
    66         s = (float)sin(omega);
    67         x = s*rot_x;
    68         y = s*rot_y;
    69         z = s*rot_z;
    70         w = (float)cos(omega);
    71     } else {
    72         x = y = 0.0f;
    73         z = 0.0f;
    74         w = 1.0f;
    75     }
    76 
    77     normalize();
    78 
    79     return *this;
    80 #endif
    81     vrVector3f q(rot.x, rot.y, rot.z);
     56    Vector3f q(rot.x, rot.y, rot.z);
    8257    q.normalize();
    83     float s = (float)sin(rot.angle * 0.5);
     58    double s = sin(rot.angle * 0.5);
    8459    x = s * q.x;
    8560    y = s * q.y;
    8661    z = s * q.z;
    87     w = (float)cos(rot.angle * 0.5f);
     62    w = cos(rot.angle * 0.5);
    8863
    8964    return *this;
    9065}
    9166
    92 void vrQuaternion::slerp(const vrQuaternion &a,const vrQuaternion &b, const float t)
     67void Quaternion::slerp(const Quaternion &a,const Quaternion &b, double t)
    9368{
    94 #if 0
    95     float omega, cosom, sinom, sclp, sclq;
    96     cosom = a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w;
    97 
    98     if ((1.0f+cosom) > FLT_EPSILON) {
    99         if ((1.0f-cosom) > FLT_EPSILON) {
    100             omega = acos(cosom);
    101             sinom = sin(omega);
    102             sclp = sin((1.0f-t)*omega) / sinom;
    103             sclq = sin(t*omega) / sinom;
    104         } else {
    105             sclp = 1.0f - t;
    106             sclq = t;
    107         }
    108 
    109         x = sclp*a.x + sclq*b.x;
    110         y = sclp*a.y + sclq*b.y;
    111         z = sclp*a.z + sclq*b.z;
    112         w = sclp*a.w + sclq*b.w;
    113     } else {
    114         x =-a.y;
    115         y = a.x;
    116         z =-a.w;
    117         w = a.z;
    118 
    119         sclp = sin((1.0f-t) * PI * 0.5);
    120         sclq = sin(t * PI * 0.5);
    121 
    122         x = sclp*a.x + sclq*b.x;
    123         y = sclp*a.y + sclq*b.y;
    124         z = sclp*a.z + sclq*b.z;
    125     }
    126 #endif
    12769    double alpha, beta;
    12870    double cosom = a.x * b.x + a.y * b.y +
     
    13173    bool flip = (cosom < 0.0);
    13274    if (flip) cosom = -cosom;
    133     if ((1.0 - cosom) > 0.00001f) {
     75    if ((1.0 - cosom) > 0.00001) {
    13476        double omega = acos(cosom);
    13577        double sinom = sin(omega);
     
    13779        beta = sin(t * omega) / sinom;
    13880    } else {
    139         alpha = 1.0f - t;
     81        alpha = 1.0 - t;
    14082        beta = t;
    14183    }
    14284
    14385    if (flip) beta = -beta;
    144     x = (float) (alpha * a.x + beta * b.x);
    145     y = (float) (alpha * a.y + beta * b.y);
    146     z = (float) (alpha * a.z + beta * b.z);
    147     w = (float) (alpha * a.w + beta * b.w);
     86    x = alpha * a.x + beta * b.x;
     87    y = alpha * a.y + beta * b.y;
     88    z = alpha * a.z + beta * b.z;
     89    w = alpha * a.w + beta * b.w;
    14890}
  • trunk/packages/vizservers/nanovis/vrmath/Rotation.cpp

    r3467 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 */
     7
    28#include <math.h>
    39
     
    612#include <vrmath/Quaternion.h>
    713
    8 void vrRotation::set(const vrVector3f &vec1, const vrVector3f &vec2)
     14using namespace vrmath;
     15
     16void Rotation::set(const Vector3f &vec1, const Vector3f &vec2)
    917{
    1018    if (vec1 == vec2) {
     
    1624    }
    1725
    18     vrVector3f cross;
    19     cross.cross(vec1, vec2);
     26    Vector3f perp = cross(vec1, vec2);
    2027
    21     float ang = atan2(cross.length(), vec1.dot(vec2));
     28    float ang = atan2(perp.length(), vec1.dot(vec2));
    2229
    23     cross.normalize();
     30    perp = perp.normalize();
    2431
    25     x = cross.x;
    26     y = cross.y;
    27     z = cross.z;
     32    x = perp.x;
     33    y = perp.y;
     34    z = perp.z;
    2835    angle = ang;
    2936}
    3037
    31 void vrRotation::set(const vrQuaternion& quat)
     38void Rotation::set(const Quaternion& quat)
    3239{
    3340    //if (quat.w > 1) quat.normalize();
     
    5057}
    5158
    52 vrQuaternion vrRotation::getQuaternion() const
     59Quaternion Rotation::getQuaternion() const
    5360{
    54     vrQuaternion result;
     61    Quaternion result;
    5562
    5663    result.w = cos(angle / 2.0);
  • trunk/packages/vizservers/nanovis/vrmath/Vector2f.cpp

    r3467 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #include <cstdlib>
    3 #include <cmath>
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 */
    47
    58#include <vrmath/Vector2f.h>
  • trunk/packages/vizservers/nanovis/vrmath/Vector3f.cpp

    r3467 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 */
     7
    28#include <vrmath/Vector3f.h>
    3 #include <vrmath/Matrix4x4f.h>
    49
    5 void vrVector3f::transform(const vrMatrix4x4f& m, const vrVector3f& v)
    6 {
    7     const float *mat = m.get();
    8 
    9     set(mat[0] * v.x + mat[4] * v.y + mat[8] * v.z + mat[12],
    10         mat[1] * v.x + mat[5] * v.y + mat[9] * v.z + mat[13],
    11         mat[2] * v.x + mat[6] * v.y + mat[10] * v.z + mat[14]);
    12 }
    13 
    14 void vrVector3f::transformVec(const vrMatrix4x4f& m, const vrVector3f& v)
    15 {
    16     const float *mat = m.get();
    17 
    18     set(mat[0] * v.x + mat[4] * v.y + mat[8] * v.z,
    19         mat[1] * v.x + mat[5] * v.y + mat[9] * v.z,
    20         mat[2] * v.x + mat[6] * v.y + mat[10] * v.z);
    21 }
  • trunk/packages/vizservers/nanovis/vrmath/Vector4f.cpp

    r3467 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 */
     7
    28#include <vrmath/Vector4f.h>
    3 #include <vrmath/Matrix4x4f.h>
    4 
    5 void vrVector4f::mult( const vrMatrix4x4f& mat, const vrVector4f& vector)
    6 {
    7     const float *m = mat.get();
    8     x = vector.x*m[0]+vector.y*m[4]+vector.z*m[8]+vector.w*m[12];
    9     y = vector.x*m[1]+vector.y*m[5]+vector.z*m[9]+vector.w*m[13];
    10     z = vector.x*m[2]+vector.y*m[6]+vector.z*m[10]+vector.w*m[14];
    11     w = vector.x*m[3]+vector.y*m[7]+vector.z*m[11]+vector.w*m[15];   
    12 }
    13 
    14 void vrVector4f::mult(const vrMatrix4x4f& mat)
    15 {
    16     vrVector4f vector(x, y, z, w);
    17     const float *m = mat.get();
    18 
    19     x = vector.x*m[0]+vector.y*m[4]+vector.z*m[8]+vector.w*m[12];
    20     y = vector.x*m[1]+vector.y*m[5]+vector.z*m[9]+vector.w*m[13];
    21     z = vector.x*m[2]+vector.y*m[6]+vector.z*m[10]+vector.w*m[14];
    22     w = vector.x*m[3]+vector.y*m[7]+vector.z*m[11]+vector.w*m[15];   
    23 }
    24 
    25 void vrVector4f::transform(const vrVector4f& v, const vrMatrix4x4f& mat)
    26 {
    27     vrVector4f vector(x, y, z, w);
    28     const float *m = mat.get();
    29     x = vector.x * m[0] + vector.y*m[4]+vector.z*m[8]+vector.w*m[12];
    30     y = vector.x * m[1] + vector.y*m[5]+vector.z*m[9]+vector.w*m[13];
    31     z = vector.x*m[2]+vector.y*m[6]+vector.z*m[10]+vector.w*m[14];
    32     w = vector.x*m[3]+vector.y*m[7]+vector.z*m[11]+vector.w*m[15];
    33 
    34 }
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/BBox.h

    r3470 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 */
    27#ifndef VRBBOX_H
    38#define VRBBOX_H
     
    510#include <vrmath/Vector3f.h>
    611
    7 class vrMatrix4x4f;
     12namespace vrmath {
    813
    9 class vrBBox
     14class Matrix4x4f;
     15
     16class BBox
    1017{
    1118public:
     
    1320     * @brief constructor
    1421     */
    15     vrBBox();
     22    BBox();
    1623
    1724    /**
     
    1926     * @param bbox bounding box
    2027     */
    21     vrBBox(const vrBBox& bbox);
     28    BBox(const BBox& bbox);
    2229
    2330    /**
     
    2633     * @param max maximum point of the bounding box
    2734     */
    28     vrBBox(const vrVector3f& min, const vrVector3f& max);
     35    BBox(const Vector3f& min, const Vector3f& max);
    2936
    3037    /**
     
    3845     * @param size the size of bounding box
    3946     */
    40     void make(const vrVector3f& center, const vrVector3f& size);
     47    void make(const Vector3f& center, const Vector3f& size);
    4148
    4249    /**
     
    4855     * @brief extend the bounding box by a point
    4956     */
    50     void extend(const vrVector3f& point);
     57    void extend(const Vector3f& point);
    5158
    5259    /**
    5360     * @brief extend the bounding box by a bbox
    5461     */
    55     void extend(const vrBBox& bbox);
     62    void extend(const BBox& bbox);
    5663
    5764    /**
    5865     * @brief transform a bounding box with an matrix and set the bounding box
    5966     */
    60     void transform(const vrBBox& box, const vrMatrix4x4f& mat);
     67    void transform(const BBox& box, const Matrix4x4f& mat);
    6168
    6269    /**
    6370     * @brief check if the bounding box intersect with a box
    6471     */
    65     bool intersect(const vrBBox& box);
     72    bool intersect(const BBox& box);
    6673
    6774    /**
    6875     * @brief check if the bounding box intersect with a point
    6976     */
    70     bool intersect(const vrVector3f& point);
     77    bool intersect(const Vector3f& point);
    7178
    7279    float getRadius() const;
    73     vrVector3f getCenter() const;
    74     vrVector3f getSize() const;
     80    Vector3f getCenter() const;
     81    Vector3f getSize() const;
    7582
    76     vrVector3f min;
    77     vrVector3f max;
     83    Vector3f min;
     84    Vector3f max;
    7885};
    7986
    80 inline float vrBBox::getRadius() const
     87inline float BBox::getRadius() const
    8188{
    8289    return max.distance( min ) * 0.5f;
    8390}
    8491
    85 inline vrVector3f vrBBox::getCenter() const
     92inline Vector3f BBox::getCenter() const
    8693{
    87     vrVector3f temp;
     94    Vector3f temp;
    8895    temp.x = (max.x+ min.x) * 0.5f;
    8996    temp.y = (max.y + min.y) * 0.5f;
     
    9299}
    93100
    94 inline vrVector3f  vrBBox::getSize() const
     101inline Vector3f  BBox::getSize() const
    95102{
    96     vrVector3f temp;
     103    Vector3f temp;
    97104    temp.x = max.x - min.x;
    98105    temp.y = max.y - min.y;
     
    101108}
    102109
     110}
     111
    103112#endif
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/BPlane.h

    r3470 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 /** \class vrBPlane vrBPlane.h <vrmath/vrBPlane.h>
    3  *  \author Insoo Woo(iwoo@purdue.edu), Sung-Ye Kim (inside@purdue.edu)
    4  *  \author PhD research assistants in PURPL at Purdue University 
    5  *  \version 1.0
    6  *  \date    Nov. 2006-2007
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 * Author: Sung-Ye Kim <inside@purdue.edu>
    77 */
    88#ifndef VRBPLANE_H
     
    1111#include <vrmath/Vector3f.h>
    1212
    13 class vrLineSegment;
     13namespace vrmath {
    1414
    15 class vrBPlane
     15class LineSegment;
     16
     17class BPlane
    1618{
    1719public:
    18     void makePts(const vrVector3f& pt1, const vrVector3f& pt2, const vrVector3f& pt3);
     20    void makePts(const Vector3f& pt1, const Vector3f& pt2, const Vector3f& pt3);
    1921
    20     void makeNormalPt(const vrVector3f& norm, const vrVector3f& pos);
     22    void makeNormalPt(const Vector3f& norm, const Vector3f& pos);
    2123
    22     bool intersect(const vrLineSegment &seg, float &d) const;
     24    bool intersect(const LineSegment &seg, float &d) const;
    2325
    24     float distance(const vrVector3f& point) const;
     26    double distance(const Vector3f& point) const;
    2527
    26     vrVector3f crossPoint(const vrVector3f& point) const;
     28    Vector3f crossPoint(const Vector3f& point) const;
    2729
    28     vrVector3f normal;
    29     vrVector3f point;
     30    Vector3f normal;
     31    Vector3f point;
    3032};
    3133
     34}
     35
    3236#endif
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/Color4f.h

    r3470 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 */
    27#ifndef VRCOLOR4F_H
    38#define VRCOLOR4F_H
    49
    5 class vrColor4f
     10namespace vrmath {
     11
     12class Color4f
    613{
    714public:
    815    float r, g, b, a;
    916
    10     vrColor4f();
     17    Color4f();
    1118
    12     vrColor4f(float r1, float g1, float b1, float a1 = 0);
     19    Color4f(float r1, float g1, float b1, float a1 = 0);
    1320
    14     vrColor4f(const vrColor4f& col) :
     21    Color4f(const Color4f& col) :
    1522        r(col.r), g(col.g), b(col.b), a(col.a)
    1623    {}
    1724
    18     friend bool operator==(const vrColor4f col1, const vrColor4f& col2);
    19     friend bool operator!=(const vrColor4f col1, const vrColor4f& col2);
     25    friend bool operator==(const Color4f col1, const Color4f& col2);
     26    friend bool operator!=(const Color4f col1, const Color4f& col2);
    2027};
    2128
    22 inline bool operator==(const vrColor4f col1, const vrColor4f& col2)
     29inline bool operator==(const Color4f col1, const Color4f& col2)
    2330{
    2431    return ((col1.r == col2.r) && (col1.g == col2.g) && (col1.b == col2.b));
    2532}
    2633
    27 inline bool operator!=(const vrColor4f col1, const vrColor4f& col2)
     34inline bool operator!=(const Color4f col1, const Color4f& col2)
    2835{
    2936    return ((col1.r != col2.r) || (col1.g != col2.g) || (col1.b != col2.b));
    3037}
    3138
     39}
     40
    3241#endif
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/LineSegment.h

    r3470 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 /** \class vrLineSegment vrLineSegment.h <vrmath/vrLineSegment.h>
    3  *  \author Insoo Woo(iwoo@purdue.edu), Sung-Ye Kim (inside@purdue.edu)
    4  *  \author PhD research assistants in PURPL at Purdue University 
    5  *  \version 1.0
    6  *  \date    Nov. 2006-2007
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 * Author: Sung-Ye Kim <inside@purdue.edu>
    77 */
    88#ifndef VRLINESEGMENT_H
     
    1010
    1111#include <vrmath/Vector3f.h>
     12#include <vrmath/Vector4f.h>
    1213
    13 class vrMatrix4x4f;
     14namespace vrmath {
    1415
    15 class vrLineSegment
     16class Matrix4x4f;
     17
     18class LineSegment
    1619{
    1720public:
    18     vrLineSegment();
     21    LineSegment();
    1922
    2023    /// Return the point
    21     vrVector3f getPoint(float d) const;
     24    Vector3f getPoint(float d) const;
    2225
    2326    /// Transfrom the line segment using mat
    24     void transform(const vrMatrix4x4f &transMat, const vrLineSegment &seg);
     27    void transform(const Matrix4x4f &transMat, const LineSegment &seg);
    2528
    2629    /// The position of the line segment
    27     vrVector3f pos;
     30    Vector4f pos;
    2831
    2932    /// The direction of the line segment
    30     vrVector3f dir;
     33    Vector3f dir;
    3134
    3235    /// The length of the line segment
     
    3437};
    3538
    36 inline vrVector3f vrLineSegment::getPoint(float d) const
     39inline Vector3f LineSegment::getPoint(float d) const
    3740{
    38     return vrVector3f(pos.x + d * dir.x, pos.y + d * dir.y, pos.z + d * dir.z);
     41    return Vector3f(pos.x + d * dir.x, pos.y + d * dir.y, pos.z + d * dir.z);
     42}
     43
    3944}
    4045
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/Matrix4x4f.h

    r3470 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #ifndef VRMATRIX4X4_H
    3 #define VRMATRIX4X4_H
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 */
     7#ifndef VRMATRIX4X4F_H
     8#define VRMATRIX4X4F_H
    49
    510#include <memory.h>
    611
    712#include <vrmath/Vector3f.h>
     13#include <vrmath/Vector4f.h>
    814
    9 class vrRotation;
     15#include "Trace.h"
    1016
    11 class vrMatrix4x4f
     17namespace vrmath {
     18
     19class Rotation;
     20
     21class Matrix4x4f
    1222{
    1323public:
    14     vrMatrix4x4f()
     24    Matrix4x4f()
    1525    {
    1626        makeIdentity();
     27    }
     28
     29    Matrix4x4f(float *m)
     30    {
     31        set(m);
    1732    }
    1833
     
    2540     * @brief make a translation matrix
    2641     */
    27     void makeTranslation(const vrVector3f& translation);
     42    void makeTranslation(const Vector3f& translation);
    2843
    2944    /**
     
    3550     * @brief make a rotation matrix
    3651     */
    37     void makeRotation(const vrRotation& rotation);
     52    void makeRotation(const Rotation& rotation);
    3853
    3954    /**
    4055     * @brief Make a rotation matrix
    4156     */
    42     void makeRotation(float x, float y, float z, float angle);
     57    void makeRotation(double x, double y, double z, double angle);
    4358
    44     void makeVecRotVec(const vrVector3f& vec1, const vrVector3f& vec2);
     59    void makeVecRotVec(const Vector3f& vec1, const Vector3f& vec2);
    4560
    4661    /**
    4762     * @brief make a scale matrix
    4863     */
    49     void makeScale(const vrVector3f& scale);
    50     void makeTR(const vrVector3f& translation, const vrRotation& rotation);
    51     void makeTRS(const vrVector3f& translation, const vrRotation& rotation, const vrVector3f& scale);
     64    void makeScale(const Vector3f& scale);
    5265
    53     void multiply(const vrMatrix4x4f& mat1, const vrMatrix4x4f& mat2);
     66    void makeScale(float x, float y, float z);
    5467
    55     void multiply(const vrMatrix4x4f& mat1, const vrVector3f& position);
    56     void multiplyScale(const vrMatrix4x4f& mat, const vrVector3f& scale);
    57     void multiply(const vrMatrix4x4f& mat1, const vrRotation& rotation);
    58     void multiply(const vrVector3f& position, const vrMatrix4x4f& mat1);
    59     void multiply(const vrRotation& rotation, const vrMatrix4x4f& mat1);
    60     void multiplyScale(const vrVector3f& scale, const vrMatrix4x4f& mat);
     68    void makeTR(const Vector3f& translation, const Rotation& rotation);
     69    void makeTRS(const Vector3f& translation, const Rotation& rotation, const Vector3f& scale);
    6170
    62     void multiply(const vrMatrix4x4f& mat1);
    63     void multiplyFast(const vrMatrix4x4f& mat1, const vrMatrix4x4f& mat2);
     71    Vector4f transform(const Vector4f& v) const;
     72    Vector3f transformVec(const Vector3f& v) const;
     73
     74    Vector4f preMultiplyRowVector(const Vector4f& v) const;
     75
     76    void multiply(const Matrix4x4f& mat1, const Matrix4x4f& mat2);
     77
     78    void multiply(const Matrix4x4f& mat1, const Vector3f& position);
     79    void multiplyScale(const Matrix4x4f& mat, const Vector3f& scale);
     80    void multiply(const Matrix4x4f& mat1, const Rotation& rotation);
     81    void multiply(const Vector3f& position, const Matrix4x4f& mat1);
     82    void multiply(const Rotation& rotation, const Matrix4x4f& mat1);
     83    void multiplyScale(const Vector3f& scale, const Matrix4x4f& mat);
     84
     85    void multiply(const Matrix4x4f& mat1);
     86    void multiplyFast(const Matrix4x4f& mat1, const Matrix4x4f& mat2);
    6487
    6588    void invert();
    66     void invert(const vrMatrix4x4f& mat);
    67     void invertFast(const vrMatrix4x4f& mat);
     89    void invert(const Matrix4x4f& mat);
     90    void invertFast(const Matrix4x4f& mat);
    6891
    6992    void transpose();
    70     void transpose(const vrMatrix4x4f& mat);
    71     void transposeFast(const vrMatrix4x4f& mat);
     93    void transpose(const Matrix4x4f& mat);
     94    void transposeFast(const Matrix4x4f& mat);
    7295       
    73     void getTranslation(vrVector3f& vector);
    74     void getRotation(vrRotation& rotation);
     96    void getTranslation(Vector3f& vector);
     97    void getRotation(Rotation& rotation);
    7598
    7699    /**
     
    96119     * @param m float matrix values
    97120     */
    98     void set(double *m);
     121    void setDouble(double *m);
     122
     123    void print() const;
    99124
    100125private:
     126    /**
     127     * \brief Column-major array (like OpenGL)
     128     */
    101129    float _data[16];
    102130};
    103131
    104 inline const float *vrMatrix4x4f::get() const
     132inline const float *Matrix4x4f::get() const
    105133{
    106134    return _data;
    107135}
    108136
    109 inline float *vrMatrix4x4f::get()
     137inline float *Matrix4x4f::get()
    110138{
    111139    return _data;
    112140}
    113141
    114 inline void vrMatrix4x4f::set(float *m)
     142inline void Matrix4x4f::set(float *m)
    115143{
    116144    memcpy(_data, m, sizeof(float) * 16);
    117145}
    118146
    119 inline void vrMatrix4x4f::getTranslation(vrVector3f& translation)
     147inline void Matrix4x4f::getTranslation(Vector3f& translation)
    120148{
    121149    translation.set(_data[12], _data[13], _data[14]);
    122150}
    123151
    124 inline void vrMatrix4x4f::makeTRS(const vrVector3f& translation,
    125                                   const vrRotation& rotation,
    126                                   const vrVector3f& scale)
     152inline void Matrix4x4f::makeTRS(const Vector3f& translation,
     153                                const Rotation& rotation,
     154                                const Vector3f& scale)
    127155{
    128     vrMatrix4x4f mat;
     156    Matrix4x4f mat;
    129157    mat.makeTR(translation, rotation);
    130158       
     
    134162}
    135163
    136 inline void vrMatrix4x4f::makeTR(const vrVector3f& translation,
    137                                  const vrRotation& rotation)
     164inline void Matrix4x4f::makeTR(const Vector3f& translation,
     165                               const Rotation& rotation)
    138166{
    139167    makeRotation(rotation);
     
    144172}
    145173
     174inline void Matrix4x4f::print() const
     175{
     176    TRACE("% 8.6f % 8.6f % 8.6f % 8.6f", _data[0], _data[4], _data[8 ], _data[12]);
     177    TRACE("% 8.6f % 8.6f % 8.6f % 8.6f", _data[1], _data[5], _data[9 ], _data[13]);
     178    TRACE("% 8.6f % 8.6f % 8.6f % 8.6f", _data[2], _data[6], _data[10], _data[14]);
     179    TRACE("% 8.6f % 8.6f % 8.6f % 8.6f", _data[3], _data[7], _data[11], _data[15]);
     180}
     181
     182}
    146183#endif
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/Plane.h

    r3470 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 /** \class vrPlane vrPlane.h <vrmath/vrPlane.h>
    3  *  \author Insoo Woo(iwoo@purdue.edu), Sung-Ye Kim (inside@purdue.edu)
    4  *  \author PhD research assistants in PURPL at Purdue University 
    5  *  \version 1.0
    6  *  \date    Nov. 2006-2007
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 * Author: Sung-Ye Kim <inside@purdue.edu>
    77 */
    88#ifndef VRPLANE_H
     
    1212#include <vrmath/Vector3f.h>
    1313
    14 class vrMatrix4x4f;
     14namespace vrmath {
    1515
    16 class vrPlane
     16class Matrix4x4f;
     17
     18class Plane
    1719{
    1820public:
    19     bool intersect(const vrVector3f& p1, const vrVector3f& p2, vrVector3f& intersectPoint) const;
    20     bool intersect(const vrVector3f& p1, const vrVector3f& p2, vrVector4f& intersectPoint) const;
    21     void transform(vrMatrix4x4f& mat);
     21    bool intersect(const Vector3f& p1, const Vector3f& p2, Vector3f& intersectPoint) const;
     22    bool intersect(const Vector3f& p1, const Vector3f& p2, Vector4f& intersectPoint) const;
     23    void transform(Matrix4x4f& mat);
    2224
    2325    /// normal vector
    24     vrVector3f normal;
     26    Vector3f normal;
    2527
    2628    /// @brief the distance from the origin
     
    2830};
    2931
    30 inline bool vrPlane::intersect(const vrVector3f& p1, const vrVector3f& p2, vrVector3f& intersectPoint) const
     32inline bool Plane::intersect(const Vector3f& p1, const Vector3f& p2, Vector3f& intersectPoint) const
    3133{
    3234    // http://astronomy.swin.edu.au/pbourke/geometry/planeline/
     
    4850}
    4951
    50 inline bool vrPlane::intersect(const vrVector3f& p1, const vrVector3f& p2, vrVector4f& intersectPoint) const
     52inline bool Plane::intersect(const Vector3f& p1, const Vector3f& p2, Vector4f& intersectPoint) const
    5153{
    5254    // http://astronomy.swin.edu.au/pbourke/geometry/planeline/
     
    6870}
    6971
     72}
     73
    7074#endif
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/Projection.h

    r3470 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
     4 *
     5 * Author: Insoo Woo <iwoo@purdue.edu>
     6 */
    27#ifndef VRPROJECTION_H
    38#define VRPROJECTION_H
     9
     10namespace vrmath {
    411
    512extern int
     
    1320perspective(float fovy, float aspect, float zNear, float zFar, float *matrix);
    1421
     22}
     23
    1524#endif
    1625
  • trunk/packages/vizservers/nanovis/vrmath/include/vrmath/Quaternion.h

    r3470 r3492  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 /**
    3  * Quaternion code by BLACKAXE / kolor aka Laurent Schmalen
    4  * Use for commercial is strictly prohibited
     2/*
     3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
    54 *
    6  * I (Insoo Woo) have changed names according to my naming rules
     5 * Author: Insoo Woo <iwoo@purdue.edu>
    76 */
    87#ifndef VRQUATERNION_H
    98#define VRQUATERNION_H
    109
    11 class vrRotation;
     10namespace vrmath {