source: trunk/packages/vizservers/nanovis/FlowParticles.cpp @ 3627

Last change on this file since 3627 was 3627, checked in by ldelgass, 7 years ago

Use vrmath::Color4f for color where appropriate

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
4 *
5 * Authors:
6 *   Wei Qiao <qiaow@purdue.edu>
7 *   Insoo Woo <iwoo@purdue.edu>
8 *   George A. Howlett <gah@purdue.edu>
9 *   Leif Delgass <ldelgass@purdue.edu>
10 */
11
12#include <assert.h>
13
14#include <vrmath/Color4f.h>
15
16#include "nanovis.h"        // For NMESH
17#include "FlowParticles.h"
18#include "Flow.h"
19#include "Trace.h"
20
21using namespace nv;
22using namespace vrmath;
23
24FlowParticles::FlowParticles(const char *name) :
25    _name(name),
26    _renderer(new ParticleRenderer(NMESH, NMESH))
27{
28    _sv.position.value = 0.0f;
29    _sv.position.flags = RELPOS;
30    _sv.position.axis = 0; // X_AXIS
31    _sv.color.r = _sv.color.g = _sv.color.b = _sv.color.a = 1.0f;
32    _sv.isHidden = false;
33    _sv.particleSize = 1.2;
34}
35
36FlowParticles::~FlowParticles() 
37{
38    TRACE("Deleting renderer");
39    if (_renderer != NULL) {
40        delete _renderer;
41    }
42    TRACE("Freeing switches");
43    Rappture::FreeSwitches(_switches, &_sv, 0);
44}
45
46void
47FlowParticles::render() 
48{
49    TRACE("Particles '%s' axis: %d pos: %g rel pos: %g",
50          _name.c_str(), _sv.position.axis, _sv.position.value,
51          Flow::getRelativePosition(&_sv.position));
52
53    _renderer->setPos(Flow::getRelativePosition(&_sv.position));
54    _renderer->setAxis(_sv.position.axis);
55    assert(_renderer->active());
56    _renderer->render();
57}
58
59void 
60FlowParticles::configure() 
61{
62    _renderer->setPos(Flow::getRelativePosition(&_sv.position));
63    _renderer->setColor(Color4f(_sv.color.r,
64                                _sv.color.g,
65                                _sv.color.b, 
66                                _sv.color.a));
67    _renderer->particleSize(_sv.particleSize);
68    _renderer->setAxis(_sv.position.axis);
69    _renderer->active(!_sv.isHidden);
70}
Note: See TracBrowser for help on using the repository browser.