Lagrangian Liquid Simulation
Master Thesis project on simulation of liquids using Lagrangian approach and SPH
include/Environment.h
Go to the documentation of this file.
00001 #ifndef ENVIRONMENT_H
00002 #define ENVIRONMENT_H
00003 
00004 #include <vector>
00005 
00006 #include "ngl/Transformation.h"
00007 #include "ngl/TransformStack.h"
00008 #include "ngl/Obj.h"
00009 #include "ngl/Vector.h"
00010 
00011 #include "ShaderLibrary.h"
00012 #include "Particle.h"
00013 #include "Capsule.h"
00014 #include "Integration.h"
00015 
00025 
00026 class Environment
00027 {
00028 public:
00030     Environment();
00031 
00033     ~Environment();
00034 
00036     void loadGeometry();
00037 
00043     void draw
00044             (
00045                 ngl::TransformStack _txStack,
00046                 ShaderLibrary* io_sman,
00047                 const std::string _boundaryShader,
00048                 const std::string _obstacleShader
00049             );
00050 
00056     void checkAndResolveCollision
00057             (
00058                 Particle& io_currentParticle,
00059                 bool& o_hitBoundary,
00060                 bool& o_hitRBD,
00061                 const bool _fromRBD
00062             );
00063 
00065     void updateObstacles(Integration* _integration);
00066 
00068     std::vector<std::vector<ngl::Vector> > getBoundaryPositionList();
00069 
00071     std::vector<std::string> getBoundaryNameList();
00072 
00074     std::vector<std::vector<ngl::Vector> > getSpherePositionList();
00075 
00077     std::vector<std::string> getSphereNameList();
00078 
00080     std::vector<std::vector<ngl::Vector> > getCapsulePositionList();
00081 
00083     std::vector<std::string> getCapsuleNameList();
00084 
00086     inline std::vector<Particle>& getSphereObstacleList() { return m_sphereObstacleList; }
00087 
00089     inline std::vector<Capsule>& getCapsuleObstacleList() { return m_capsuleObstacleList; }
00090 
00091 
00093     inline bool getObstacleEnabled() const { return m_obstacleEnabled; }
00094 
00096     inline ngl::Vector getBoundaryDimension() const { return m_boundaryDimension; }
00097 
00099     inline ngl::Vector getBoundaryPosition() const { return m_boundaryPosition; }
00100 
00102     inline bool getBoundaryBoundTop() const { return m_boundaryBoundTop; }
00103 
00105     inline ngl::Real getBoundaryRestitutionCoefficientForFluid() const { return m_boundaryRestitutionCoefficientForFluid; }
00106 
00108     inline ngl::Real getBoundaryRestitutionCoefficientForRBD() const { return m_boundaryRestitutionCoefficientForRBD; }
00109 
00111     inline ngl::Real getObstacleRestitutionCoefficient() const { return m_obstacleRestitutionCoefficient; }
00112 
00114     inline int getCapsuleResolution() const { return m_capsuleResolution; }
00115 
00117     inline bool getPeriodicWallEnabled() const { return m_periodicWallEnabled; }
00118 
00120     inline ngl::Real getPeriodicWallMaxAmplitude() const { return m_periodicWallMaxAmplitude; }
00121 
00123     inline ngl::Real getPeriodicWallSpeed() const { return m_periodicWallSpeed; }
00124 
00126     inline ngl::Real getAngleOfPeriodicWall() const { return m_angleOfPeriodicWall; }
00127 
00129     inline ngl::Real getPeriodicWallAngleIncrement() const { return m_periodicWallAngleIncrement; }
00130 
00131 
00132 
00135     inline void setObstacleEnabled(const bool _v) { m_obstacleEnabled = _v; }
00136 
00139     inline void setBoundaryDimension(const ngl::Vector _v)
00140     {
00141         m_boundaryDimension = _v;
00142         delete m_boundaryBBox;
00143         m_boundaryBBox = new ngl::BBox(m_boundaryPosition, m_boundaryDimension.m_x, m_boundaryDimension.m_y, m_boundaryDimension.m_z);
00144     }
00145 
00148     inline void setBoundaryPosition(ngl::Vector _v) { m_boundaryPosition = _v; m_boundaryBBox->setCenter(_v); }
00149 
00152     inline void setBoundaryBoundTop(const bool _v) { m_boundaryBoundTop = _v; }
00153 
00156     inline void setBoundaryRestitutionCoefficientForFluid(const ngl::Real _v) { m_boundaryRestitutionCoefficientForFluid = _v; }
00157 
00160     inline void setBoundaryRestitutionCoefficientForRBD(const ngl::Real _v) { m_boundaryRestitutionCoefficientForRBD = _v; }
00161 
00164     inline void setObstacleRestitutionCoefficient(const ngl::Real _v) { m_obstacleRestitutionCoefficient = _v; }
00165 
00168     inline void setCapsuleResolution(const int _v) { m_capsuleResolution = _v; }
00169 
00172     inline void setPeriodicWallEnabled(const bool _v) { m_periodicWallEnabled = _v; }
00173 
00176     inline void setPeriodicWallMaxAmplitude(const ngl::Real _v) { m_periodicWallMaxAmplitude = _v; }
00177 
00180     inline void setPeriodicWallSpeed(const ngl::Real _v) { m_periodicWallSpeed = _v; }
00181 
00184     inline void setAngleOfPeriodicWall(const ngl::Real _v) { m_angleOfPeriodicWall = _v; }
00185 
00188     inline void setPeriodicWallAngleIncrement(const ngl::Real _v) { m_periodicWallAngleIncrement = _v; }
00189 
00190 
00191 private:
00193     bool m_obstacleEnabled;
00194 
00196     ngl::Vector m_boundaryDimension;
00197 
00199     ngl::Vector m_boundaryPosition;
00200 
00202     ngl::BBox* m_boundaryBBox;
00203 
00205     bool m_boundaryBoundTop;
00206 
00208     ngl::Real m_boundaryRestitutionCoefficientForFluid;
00209 
00211     ngl::Real m_boundaryRestitutionCoefficientForRBD;
00212 
00214     ngl::Real m_obstacleRestitutionCoefficient;
00215 
00217     std::vector<Particle> m_sphereObstacleList;
00218 
00220     std::vector<Capsule> m_capsuleObstacleList;
00221 
00223     int m_capsuleResolution;
00224 
00226     bool m_periodicWallEnabled;
00227 
00229     ngl::Real m_periodicWallMaxAmplitude;
00230 
00232     ngl::Real m_periodicWallSpeed;
00233 
00235     ngl::Real m_angleOfPeriodicWall;
00236 
00238     ngl::Real m_periodicWallAngleIncrement;
00239 
00240 
00241 
00242 private:
00246     bool checkAndResolveCollisionWithObstacle
00247                     (
00248                         Particle& io_currentParticle,
00249                         Particle& _obstacle
00250                     );
00251 
00255     bool checkAndResolveCollisionWithObstacle
00256                     (
00257                         Particle& io_currentParticle,
00258                         Capsule& _obstacle
00259                     );
00260 
00264     bool checkAndResolveCollisionWithBoundary
00265                     (
00266                         Particle& io_currentParticle,
00267                         const bool _fromRBD
00268                     );
00269 
00276     void resolveCollision
00277                     (
00278                         Particle& io_currentParticle,
00279                         const ngl::Vector _contactPoint,
00280                         const ngl::Vector _normal,
00281                         const ngl::Real _penetrationDepth,
00282                         const ngl::Real _restitutionCoefficient
00283                     );
00284 
00286     void updatePeriodicBoundingBox();
00287 };
00288 
00289 #endif // ENVIRONMENT_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator