GteFluid2InitializeSource.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/GteTexture2.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  Fluid2InitializeSource(std::shared_ptr<ProgramFactory> const& factory,
31  int xSize, int ySize, int numXThreads, int numYThreads,
32  std::shared_ptr<ConstantBuffer> const& parameters);
33 
34  // Member access. The texels are (velocity.x, velocity.y, 0, density).
35  // The third component is unused in the simulation (a 3D simulation will
36  // store velocity.z in this component).
37  inline std::shared_ptr<Texture2> const& GetSource() const;
38 
39  // Compute the source density and source velocity for the fluid
40  // simulation.
41  void Execute(std::shared_ptr<GraphicsEngine> const& engine);
42 
43 private:
44  enum { NUM_VORTICES = 1024 };
45 
46  struct Vortex
47  {
49  };
50 
51  struct External
52  {
57  };
58 
59  int mNumXGroups, mNumYGroups;
60  std::shared_ptr<ComputeProgram> mGenerateVortex;
61  std::shared_ptr<ComputeProgram> mInitializeSource;
62  std::shared_ptr<ConstantBuffer> mVortex;
63  std::shared_ptr<ConstantBuffer> mExternal;
64  std::shared_ptr<Texture2> mVelocity0;
65  std::shared_ptr<Texture2> mVelocity1;
66  std::shared_ptr<Texture2> mSource;
67 
68  // Shader source code as strings.
73  static std::string const* msGenerateSource[ProgramFactory::PF_NUM_API];
74  static std::string const* msInitializeSource[ProgramFactory::PF_NUM_API];
75 };
76 
77 inline std::shared_ptr<Texture2> const& Fluid2InitializeSource::GetSource() const
78 {
79  return mSource;
80 }
81 
82 }
static std::string const msHLSLInitializeSource
static std::string const msGLSLGenerateSource
std::shared_ptr< Texture2 > mVelocity0
static std::string const msHLSLGenerateSource
std::shared_ptr< ConstantBuffer > mExternal
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
std::shared_ptr< Texture2 > mSource
std::shared_ptr< ConstantBuffer > mVortex
std::shared_ptr< ComputeProgram > mInitializeSource
std::shared_ptr< ComputeProgram > mGenerateVortex
static std::string const msGLSLInitializeSource
std::shared_ptr< Texture2 > const & GetSource() const
std::shared_ptr< Texture2 > mVelocity1
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63


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