source: nanovis/tags/1.1.1/FlowParticles.cpp @ 5049

Last change on this file since 5049 was 4612, checked in by ldelgass, 10 years ago

merge r3597 from trunk

  • 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/Vector4f.h>
15
16#include "nanovis.h"        // For NMESH
17#include "FlowParticles.h"
18#include "Flow.h"
19#include "Trace.h"
20
21using namespace vrmath;
22
23FlowParticles::FlowParticles(const char *name) :
24    _name(name),
25    _renderer(new NvParticleRenderer(NMESH, NMESH))
26{
27    _sv.position.value = 0.0f;
28    _sv.position.flags = RELPOS;
29    _sv.position.axis = 0; // X_AXIS
30    _sv.color.r = _sv.color.g = _sv.color.b = _sv.color.a = 1.0f;
31    _sv.isHidden = false;
32    _sv.particleSize = 1.2;
33}
34
35FlowParticles::~FlowParticles()
36{
37    TRACE("Deleting renderer");
38    if (_renderer != NULL) {
39        delete _renderer;
40    }
41    TRACE("Freeing switches");
42    Rappture::FreeSwitches(_switches, &_sv, 0);
43}
44
45void
46FlowParticles::render()
47{
48    TRACE("Particles '%s' axis: %d pos: %g rel pos: %g",
49          _name.c_str(), _sv.position.axis, _sv.position.value,
50          Flow::getRelativePosition(&_sv.position));
51
52    _renderer->setPos(Flow::getRelativePosition(&_sv.position));
53    _renderer->setAxis(_sv.position.axis);
54    assert(_renderer->active());
55    _renderer->render();
56}
57
58void
59FlowParticles::configure()
60{
61    _renderer->setPos(Flow::getRelativePosition(&_sv.position));
62    _renderer->setColor(Vector4f(_sv.color.r,
63                                 _sv.color.g,
64                                 _sv.color.b,
65                                 _sv.color.a));
66    _renderer->particleSize(_sv.particleSize);
67    _renderer->setAxis(_sv.position.axis);
68    _renderer->active(!_sv.isHidden);
69}
Note: See TracBrowser for help on using the repository browser.