source: nanovis/trunk/VolumeRenderer.h @ 4897

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

Nanovis refactoring to fix problems with scaling and multiple results.
Do rendering in world space to properly place and scale multiple data sets.
Also fix flows to reduce resets of animations. More work toward removing
Cg dependency. Fix panning to convert viewport coords to world coords.

  • Property svn:eol-style set to native
File size: 3.1 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 */
8#ifndef NV_VOLUME_RENDERER_H
9#define NV_VOLUME_RENDERER_H
10
11#include <vrmath/Vector3f.h>
12#include <vrmath/Vector4f.h>
13#include <vrmath/Matrix4x4d.h>
14
15#include "Volume.h"
16#include "VolumeInterpolator.h"
17#include "RegularVolumeShader.h"
18#include "ZincBlendeVolumeShader.h"
19#include "StdVertexShader.h"
20
21namespace nv {
22
23class VolumeRenderer
24{
25public:
26    VolumeRenderer();
27
28    ~VolumeRenderer();
29
30    /// render all enabled volumes
31    void renderAll();
32
33    void specular(float val);
34
35    void diffuse(float val);
36
37    void clearAnimatedVolumeInfo()
38    {
39        _volumeInterpolator->clearAll();
40    }
41
42    void addAnimatedVolume(Volume* volume)
43    {
44        _volumeInterpolator->addVolume(volume);
45    }
46
47    void startVolumeAnimation()
48    {
49        _volumeInterpolator->start();
50    }
51
52    void stopVolumeAnimation()
53    {
54        _volumeInterpolator->stop();
55    }
56
57    VolumeInterpolator* getVolumeInterpolator()
58    {
59        return _volumeInterpolator;
60    }
61
62private:
63    void initShaders();
64
65    void activateVolumeShader(Volume *vol, 
66                              vrmath::Vector4f& objPlaneS,
67                              vrmath::Vector4f& objPlaneT,
68                              vrmath::Vector4f& objPlaneR,
69                              bool sliceMode, float sampleRatio);
70
71    void deactivateVolumeShader();
72
73    static void drawBoundingBox(float x0, float y0, float z0,
74                                float x1, float y1, float z1,
75                                float r, float g, float b, float line_width);
76
77    static void getEyeSpaceBounds(const vrmath::Vector3f& worldMin,
78                                  const vrmath::Vector3f& worldMax,
79                                  const vrmath::Matrix4x4d& mv,
80                                  vrmath::Vector3f& eyeMin,
81                                  vrmath::Vector3f& eyeMax);
82
83    VolumeInterpolator *_volumeInterpolator;
84
85    /**
86     * Shader for single slice cutplane render
87     */
88    Shader *_cutplaneShader;
89
90    /**
91     * Shader for rendering a single cubic volume
92     */
93    RegularVolumeShader *_regularVolumeShader;
94
95    /**
96     * Shader for rendering a single zincblende orbital.  A
97     * simulation contains S, P, D and SS, total of 4 orbitals. A full
98     * rendering requires 4 zincblende orbital volumes.  A zincblende orbital
99     * volume is decomposed into two "interlocking" cubic volumes and passed
100     * to the shader.  We render each orbital with its own independent
101     * transfer functions then blend the result.
102     *
103     * The engine is already capable of rendering multiple volumes and combine
104     * them. Thus, we just invoke this shader on S, P, D and SS orbitals with
105     * different transfor functions. The result is a multi-orbital rendering.
106     * This is equivalent to rendering 4 unrelated data sets occupying the
107     * same space.
108     */
109    ZincBlendeVolumeShader *_zincBlendeShader;
110
111    /**
112     * standard vertex shader
113     */
114    StdVertexShader *_stdVertexShader;
115};
116
117}
118
119#endif
Note: See TracBrowser for help on using the repository browser.