GteFluid3InitializeSource.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
13 #include <Graphics/GteTexture3.h>
14 
15 namespace gte
16 {
17 
18 class GraphicsEngine;
19 
21 {
22 public:
23  // Construction. The source density consists of a density producer
24  // (increase density) and a density consumer (decrease density). Each
25  // has a location, a variance from that location, and an amplitude.
26  // The source velocity (impulse) is generated from gravity, a single
27  // wind source, and randomly generated vortices. Each vortex is
28  // selected with a random location, a variance from that location, and
29  // an amplitude for the impulse.
30  Fluid3InitializeSource(std::shared_ptr<ProgramFactory> const& factory,
31  int xSize, int ySize, int zSize, int numXThreads, int numYThreads, int numZThreads,
32  std::shared_ptr<ConstantBuffer> const& parameters);
33 
34  // Member access. The texels are (velocity.xyz, density).
35  inline std::shared_ptr<Texture3> const& GetSource() const;
36 
37  // Compute the source density and source velocity for the fluid
38  // simulation.
39  void Execute(std::shared_ptr<GraphicsEngine> const& engine);
40 
41 private:
42  enum { NUM_VORTICES = 1024 };
43 
44  struct Vortex
45  {
49  };
50 
51  struct External
52  {
54  gte::Vector4<float> densityPData; // (variance, amplitude, *, *)
56  gte::Vector4<float> densityCData; // (variance, amplitude, *, *)
59  };
60 
61  int mNumXGroups, mNumYGroups, mNumZGroups;
62  std::shared_ptr<ComputeProgram> mGenerateVortex;
63  std::shared_ptr<ComputeProgram> mInitializeSource;
64  std::shared_ptr<ConstantBuffer> mVortex;
65  std::shared_ptr<ConstantBuffer> mExternal;
66  std::shared_ptr<Texture3> mVelocity0;
67  std::shared_ptr<Texture3> mVelocity1;
68  std::shared_ptr<Texture3> mSource;
69 
70  // Shader source code as strings.
75  static std::string const* msGenerateSource[ProgramFactory::PF_NUM_API];
76  static std::string const* msInitializeSource[ProgramFactory::PF_NUM_API];
77 };
78 
79 inline std::shared_ptr<Texture3> const& Fluid3InitializeSource::GetSource() const
80 {
81  return mSource;
82 }
83 
84 }
std::shared_ptr< Texture3 > mVelocity1
std::shared_ptr< ComputeProgram > mInitializeSource
static std::string const msGLSLInitializeSource
static std::string const msHLSLInitializeSource
std::shared_ptr< ConstantBuffer > mVortex
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
std::shared_ptr< Texture3 > mVelocity0
static std::string const msHLSLGenerateSource
std::shared_ptr< Texture3 > mSource
std::shared_ptr< Texture3 > const & GetSource() const
std::shared_ptr< ComputeProgram > mGenerateVortex
std::shared_ptr< ConstantBuffer > mExternal
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63
static std::string const msGLSLGenerateSource


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:59