1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | #include <R2/R2FilePath.h> |
---|
3 | #include <Trace.h> |
---|
4 | #include "NvParticleAdvectionShader.h" |
---|
5 | #include <global.h> |
---|
6 | |
---|
7 | NvParticleAdvectionShader::NvParticleAdvectionShader() : |
---|
8 | _velocityVolumeID(0), |
---|
9 | _scale(1.0f, 1.0f, 1.0f), |
---|
10 | _max(1.0f), |
---|
11 | _timeStep(0.005f) |
---|
12 | { |
---|
13 | _mode = 1; |
---|
14 | init(); |
---|
15 | } |
---|
16 | |
---|
17 | NvParticleAdvectionShader::~NvParticleAdvectionShader() |
---|
18 | { |
---|
19 | } |
---|
20 | |
---|
21 | void NvParticleAdvectionShader::init() |
---|
22 | { |
---|
23 | _cgFP = LoadCgSourceProgram(g_context, "update_pos.cg", CG_PROFILE_FP30, |
---|
24 | "main"); |
---|
25 | _posTimestepParam = cgGetNamedParameter(_cgFP, "timestep"); |
---|
26 | _maxParam = cgGetNamedParameter(_cgFP, "max"); |
---|
27 | _velTexParam = cgGetNamedParameter(_cgFP, "vel_tex"); |
---|
28 | _posTexParam = cgGetNamedParameter(_cgFP, "pos_tex"); |
---|
29 | //_tfTexParam = cgGetNamedParameter(_cgFP, "tf_tex"); |
---|
30 | _initPosTexParam = cgGetNamedParameter(_cgFP, "init_pos_tex"); |
---|
31 | _scaleParam = cgGetNamedParameter(_cgFP, "scale"); |
---|
32 | _modeParam = cgGetNamedParameter(_cgFP, "mode"); |
---|
33 | } |
---|
34 | |
---|
35 | //void NvParticleAdvectionShader::bind(unsigned int texID, unsigned int tfTexID, unsigned int initPosTexID) |
---|
36 | |
---|
37 | void |
---|
38 | NvParticleAdvectionShader::bind(unsigned int texID, unsigned int initPosTexID) |
---|
39 | { |
---|
40 | cgGLBindProgram(_cgFP); |
---|
41 | cgGLSetParameter1f(_posTimestepParam, _timeStep); |
---|
42 | cgGLSetParameter1f(_maxParam, _max); |
---|
43 | cgGLSetParameter1f(_modeParam, _mode); |
---|
44 | cgGLSetParameter3f(_scaleParam, _scale.x, _scale.y, _scale.z); |
---|
45 | cgGLSetTextureParameter(_velTexParam, _velocityVolumeID); |
---|
46 | cgGLEnableTextureParameter(_velTexParam); |
---|
47 | |
---|
48 | //cgGLSetTextureParameter(_tfTexParam, tfTexID); |
---|
49 | //cgGLEnableTextureParameter(_tfTexParam); |
---|
50 | |
---|
51 | cgGLSetTextureParameter(_posTexParam, texID); |
---|
52 | cgGLEnableTextureParameter(_posTexParam); |
---|
53 | |
---|
54 | cgGLSetTextureParameter(_initPosTexParam, initPosTexID); |
---|
55 | cgGLEnableTextureParameter(_initPosTexParam); |
---|
56 | |
---|
57 | cgGLEnableProfile(CG_PROFILE_FP30); |
---|
58 | } |
---|