// // Water surface simulation based on hydrostatic pressure equations. This is an implementation of the // technique described in the paper "Dynamic Simulation of Splashing Fluids" by James F. O'Brien and // Jessica K. Hodgins (from Proceedings of Computer Animation 1995, Geneva). // // (C) 2003 Yann Lombard // // Include this header into your host application to get access to the water solver functionality. // For usage notes, please look into solver.cpp #ifndef SOLVER_H_INCLUDED #define SOLVER_H_INCLUDED /* The water simulator class. */ class CWaterSolver { private: int p_xres; // x grid resolution int p_yres; // y grid resolution int p_area; // total grid area float p_colarea; // the base area of a single column in the grid float p_hscale; // height scale or amplitude float p_cacc; // constant acceleration factor float p_cforce; // constant force factor float *p_ColHeight; // Pointer to the user specified heightfield float *p_ColVolume; // Array of xres*yres columns, containing water volume float *p_VPipes; // Vertical connection pipes float *p_HPipes; // Horizontcal connection pipes float *p_LPipes; // Left diagonal connection pipes float *p_RPipes; // Right diagonal connection pipes void p_ComputePipeFlows(); void p_UpdateVolumes(); public: CWaterSolver(int xsize, int ysize, float hscale, float *HeightMap); ~CWaterSolver(); void Simulate(); void ApplyForce(int x, int y, float magnitude); }; #endif