Changeset 5516


Ignore:
Timestamp:
May 15, 2015 12:31:44 AM (9 years ago)
Author:
ldelgass
Message:

Merge trunk version of OrientationIndicator? (scaling/translation)

Location:
nanovis/branches/1.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • nanovis/branches/1.2/OrientationIndicator.cpp

    r5498 r5516  
    1010#include <GL/glu.h>
    1111
     12#include <vrmath/Vector3f.h>
     13
    1214#include "OrientationIndicator.h"
    1315
     16using namespace vrmath;
    1417using namespace nv;
    1518
     
    1821    _visible(true),
    1922    _lineWidth(1.f),
    20     _quadric(gluNewQuadric())
     23    _quadric(gluNewQuadric()),
     24    _position(0,0,0),
     25    _scale(1,1,1)
    2126{
    2227}
     
    3742        return;
    3843
     44    glMatrixMode(GL_MODELVIEW);
     45    glPushMatrix();
     46    glTranslatef(_position.x, _position.y, _position.z);
     47    float scale = _scale.x;
     48    if (scale == 0 || _scale.y < scale) scale = _scale.y;
     49    if (scale == 0 || _scale.z < scale) scale = _scale.z;
     50    glScalef(scale, scale, scale);
     51
    3952    glPushAttrib(GL_ENABLE_BIT | GL_LINE_BIT);
    4053
     
    4861        glLineWidth(_lineWidth);
    4962        glDisable(GL_LIGHTING);
    50         glColor3f(1, 0, 0);
    51         glBegin(GL_LINES);
    52         glVertex3f(0, 0, 0);
    53         glVertex3f(0.5f, 0, 0);
    54         glEnd();
    55         glColor3f(0, 1, 0);
    56         glBegin(GL_LINES);
    57         glVertex3f(0, 0, 0);
    58         glVertex3f(0, 0.5f, 0);
    59         glEnd();
    60         glColor3f(0, 0, 1);
    61         glBegin(GL_LINES);
    62         glVertex3f(0, 0, 0);
    63         glVertex3f(0, 0, 0.5f);
    64         glEnd();
     63        if (_scale.x > 0) {
     64            glColor3f(1, 0, 0);
     65            glBegin(GL_LINES);
     66            glVertex3f(0, 0, 0);
     67            glVertex3f(0.5f, 0, 0);
     68            glEnd();
     69        }
     70        if (_scale.y > 0) {
     71            glColor3f(0, 1, 0);
     72            glBegin(GL_LINES);
     73            glVertex3f(0, 0, 0);
     74            glVertex3f(0, 0.5f, 0);
     75            glEnd();
     76        }
     77        if (_scale.z > 0) {
     78            glColor3f(0, 0, 1);
     79            glBegin(GL_LINES);
     80            glVertex3f(0, 0, 0);
     81            glVertex3f(0, 0, 0.5f);
     82            glEnd();
     83        }
    6584    }
    6685        break;
     
    7291        glEnable(GL_LIGHTING);
    7392        glEnable(GL_LIGHT0);
     93        glEnable(GL_NORMALIZE);
    7494
    7595        // X
    76         glColor3f(1, 0, 0);
    77         glPushMatrix();
    78         glRotatef(90, 0, 1, 0);
    79         gluCylinder(qobj, 0.01, 0.01, 0.3, segments, 1);
    80         glPopMatrix();
     96        if (_scale.x > 0) {
     97            glColor3f(1, 0, 0);
     98            glPushMatrix();
     99            glRotatef(90, 0, 1, 0);
     100            gluCylinder(qobj, 0.01, 0.01, 0.3, segments, 1);
     101            glPopMatrix();
    81102
    82         glPushMatrix();
    83         glTranslatef(0.3, 0., 0.);
    84         glRotatef(90, 0, 1, 0);
    85         gluCylinder(qobj, 0.02, 0.0, 0.06, segments, 1);
    86         glPopMatrix();
     103            glPushMatrix();
     104            glTranslatef(0.3, 0., 0.);
     105            glRotatef(90, 0, 1, 0);
     106            gluCylinder(qobj, 0.02, 0.0, 0.06, segments, 1);
     107            glPopMatrix();
     108        }
    87109
    88110        // Y
    89         glColor3f(0, 1, 0);
    90         glPushMatrix();
    91         glRotatef(-90, 1, 0, 0);
    92         gluCylinder(qobj, 0.01, 0.01, 0.3, segments, 1);
    93         glPopMatrix();
     111        if (_scale.y > 0) {
     112            glColor3f(0, 1, 0);
     113            glPushMatrix();
     114            glRotatef(-90, 1, 0, 0);
     115            gluCylinder(qobj, 0.01, 0.01, 0.3, segments, 1);
     116            glPopMatrix();
    94117
    95         glPushMatrix();
    96         glTranslatef(0., 0.3, 0.);
    97         glRotatef(-90, 1, 0, 0);
    98         gluCylinder(qobj, 0.02, 0.0, 0.06, segments, 1);
    99         glPopMatrix();
     118            glPushMatrix();
     119            glTranslatef(0., 0.3, 0.);
     120            glRotatef(-90, 1, 0, 0);
     121            gluCylinder(qobj, 0.02, 0.0, 0.06, segments, 1);
     122            glPopMatrix();
     123        }
    100124
    101125        // Z
    102         glColor3f(0, 0, 1);
    103         glPushMatrix();
    104         gluCylinder(qobj, 0.01, 0.01, 0.3, segments, 1);
    105         glPopMatrix();
     126        if (_scale.z > 0) {
     127            glColor3f(0, 0, 1);
     128            glPushMatrix();
     129            gluCylinder(qobj, 0.01, 0.01, 0.3, segments, 1);
     130            glPopMatrix();
    106131
    107         glPushMatrix();
    108         glTranslatef(0., 0., 0.3);
    109         gluCylinder(qobj, 0.02, 0.0, 0.06, segments, 1);
    110         glPopMatrix();
     132            glPushMatrix();
     133            glTranslatef(0., 0., 0.3);
     134            gluCylinder(qobj, 0.02, 0.0, 0.06, segments, 1);
     135            glPopMatrix();
     136        }
    111137    }
    112138        break;
     
    116142   
    117143    glPopAttrib();
     144    glPopMatrix();
    118145}
  • nanovis/branches/1.2/OrientationIndicator.h

    r5498 r5516  
    55 * Author: Leif Delgass <ldelgass@purdue.edu>
    66 */
    7 #ifndef ORIENTATION_INDICATOR_H
    8 #define ORIENTATION_INDICATOR_H
     7#ifndef NV_ORIENTATION_INDICATOR_H
     8#define NV_ORIENTATION_INDICATOR_H
     9
     10#include <vrmath/Vector3f.h>
    911
    1012namespace nv {
     13
    1114class OrientationIndicator
    1215{
     
    3437    }
    3538
     39    void setPosition(const vrmath::Vector3f& pos)
     40    {
     41        _position = pos;
     42    }
     43
     44    void setScale(const vrmath::Vector3f& scale)
     45    {
     46        _scale = scale;
     47    }
     48
    3649private:
    3750    Representation _rep;
     
    3952    float _lineWidth;
    4053    void *_quadric;
     54
     55    vrmath::Vector3f _position;
     56    vrmath::Vector3f _scale;
    4157};
     58
    4259}
    4360
Note: See TracChangeset for help on using the changeset viewer.