1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * Copyright (c) 2004-2013 HUBzero Foundation, LLC |
---|
4 | * |
---|
5 | */ |
---|
6 | #include "NvParticleAdvectionShader.h" |
---|
7 | |
---|
8 | NvParticleAdvectionShader::NvParticleAdvectionShader() : |
---|
9 | _velocityVolumeID(0), |
---|
10 | _scale(1.0f, 1.0f, 1.0f), |
---|
11 | _max(1.0f), |
---|
12 | _timeStep(0.0005f), |
---|
13 | _mode(1) |
---|
14 | { |
---|
15 | init(); |
---|
16 | } |
---|
17 | |
---|
18 | NvParticleAdvectionShader::~NvParticleAdvectionShader() |
---|
19 | { |
---|
20 | } |
---|
21 | |
---|
22 | void NvParticleAdvectionShader::init() |
---|
23 | { |
---|
24 | loadFragmentProgram("update_pos.cg", "main"); |
---|
25 | } |
---|
26 | |
---|
27 | void |
---|
28 | NvParticleAdvectionShader::bind(unsigned int texID, unsigned int initPosTexID) |
---|
29 | { |
---|
30 | setFPTextureParameter("pos_tex", texID); |
---|
31 | setFPTextureParameter("init_pos_tex", initPosTexID); |
---|
32 | setFPTextureParameter("vel_tex", _velocityVolumeID); |
---|
33 | |
---|
34 | setFPParameter1f("timestep", _timeStep); |
---|
35 | setFPParameter1f("max", _max); |
---|
36 | setFPParameter1f("mode", _mode); |
---|
37 | setFPParameter3f("scale", _scale.x, _scale.y, _scale.z); |
---|
38 | |
---|
39 | NvShader::bind(); |
---|
40 | } |
---|
41 | |
---|
42 | void |
---|
43 | NvParticleAdvectionShader::unbind() |
---|
44 | { |
---|
45 | disableFPTextureParameter("pos_tex"); |
---|
46 | disableFPTextureParameter("init_pos_tex"); |
---|
47 | disableFPTextureParameter("vel_tex"); |
---|
48 | |
---|
49 | NvShader::unbind(); |
---|
50 | } |
---|