From 11c83d843206648a33bcc8b4d754577ec0a51d2a Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Sun, 13 Nov 2011 12:17:27 +0000 Subject: Ocean Sim modifier patch by Matt Ebb, Hamed Zaghaghi This adds a new Modifier "Ocean" to simulate large-scale wave motion. Details can be found in the wiki documentation [1], the project homepage [2] and the patch tracker [3] The modifier is disabled by default for now. To enable it, the WITH_OCEANSIM (cmake) / WITH_BF_OCEANSIM (scons) flags have to be set. The code depends on fftw3, so this also has to be enabled. [1] http://wiki.blender.org/index.php/Doc:2.6/Manual/Modifiers/Simulation/Ocean [2] http://www.savetheoceansim.com [3] http://projects.blender.org/tracker/?group_id=9&atid=127&func=detail&aid=28338 --- source/blender/blenkernel/BKE_ocean.h | 108 ++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 source/blender/blenkernel/BKE_ocean.h (limited to 'source/blender/blenkernel/BKE_ocean.h') diff --git a/source/blender/blenkernel/BKE_ocean.h b/source/blender/blenkernel/BKE_ocean.h new file mode 100644 index 00000000000..c1f228fe186 --- /dev/null +++ b/source/blender/blenkernel/BKE_ocean.h @@ -0,0 +1,108 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * Contributors: Matt Ebb + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef BKE_OCEAN_H +#define BKE_OCEAN_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OceanResult { + float disp[3]; + float normal[3]; + float foam; + + /* raw eigenvalues/vectors */ + float Jminus; + float Jplus; + float Eminus[3]; + float Eplus[3]; +} OceanResult; + + +typedef struct OceanCache { + struct ImBuf **ibufs_disp; + struct ImBuf **ibufs_foam; + struct ImBuf **ibufs_norm; + + char *bakepath; + + /* precalculated for time range */ + float *time; + + /* constant for time range */ + float wave_scale; + float chop_amount; + float foam_coverage; + float foam_fade; + + int start; + int end; + int duration; + int resolution_x; + int resolution_y; + + int baked; +} OceanCache; + + +#define OCEAN_NOT_CACHED 0 +#define OCEAN_CACHING 1 +#define OCEAN_CACHED 2 + + +struct Ocean *BKE_add_ocean(void); +void BKE_free_ocean_data(struct Ocean *oc); +void BKE_free_ocean(struct Ocean *oc); + +void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, float l, float A, float w, float damp, + float alignment, float depth, float time, short do_height_field, short do_chop, short do_normals, short do_jacobian, int seed); +void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount); + +/* sampling the ocean surface */ +float BKE_ocean_jminus_to_foam(float jminus, float coverage); +void BKE_ocean_eval_uv(struct Ocean * oc, struct OceanResult *ocr, float u, float v); +void BKE_ocean_eval_uv_catrom(struct Ocean * oc, struct OceanResult *ocr, float u, float v); +void BKE_ocean_eval_xz(struct Ocean * oc, struct OceanResult *ocr, float x, float z); +void BKE_ocean_eval_xz_catrom(struct Ocean * oc, struct OceanResult *ocr, float x, float z); +void BKE_ocean_eval_ij(struct Ocean * oc, struct OceanResult *ocr, int i, int j); + + +/* ocean cache handling */ +struct OceanCache *BKE_init_ocean_cache(char *bakepath, int start, int end, float wave_scale, + float chop_amount, float foam_coverage, float foam_fade, int resolution); +void BKE_simulate_ocean_cache(struct OceanCache *och, int frame); + +void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(void *, float progress, int *cancel), void *update_cb_data); +void BKE_ocean_cache_eval_uv(struct OceanCache *och, struct OceanResult *ocr, int f, float u, float v); +void BKE_ocean_cache_eval_ij(struct OceanCache *och, struct OceanResult *ocr, int f, int i, int j); + +void BKE_free_ocean_cache(struct OceanCache *och); +#ifdef __cplusplus +} +#endif + +#endif -- cgit v1.2.3