Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00019 * All rights reserved. 00020 * 00021 * Contributors: Matt Ebb 00022 * 00023 * ***** END GPL LICENSE BLOCK ***** 00024 */ 00025 00026 #ifndef BKE_OCEAN_H 00027 #define BKE_OCEAN_H 00028 00029 #ifdef __cplusplus 00030 extern "C" { 00031 #endif 00032 00033 typedef struct OceanResult { 00034 float disp[3]; 00035 float normal[3]; 00036 float foam; 00037 00038 /* raw eigenvalues/vectors */ 00039 float Jminus; 00040 float Jplus; 00041 float Eminus[3]; 00042 float Eplus[3]; 00043 } OceanResult; 00044 00045 00046 typedef struct OceanCache { 00047 struct ImBuf **ibufs_disp; 00048 struct ImBuf **ibufs_foam; 00049 struct ImBuf **ibufs_norm; 00050 00051 const char *bakepath; 00052 const char *relbase; 00053 00054 /* precalculated for time range */ 00055 float *time; 00056 00057 /* constant for time range */ 00058 float wave_scale; 00059 float chop_amount; 00060 float foam_coverage; 00061 float foam_fade; 00062 00063 int start; 00064 int end; 00065 int duration; 00066 int resolution_x; 00067 int resolution_y; 00068 00069 int baked; 00070 } OceanCache; 00071 00072 00073 #define OCEAN_NOT_CACHED 0 00074 #define OCEAN_CACHING 1 00075 #define OCEAN_CACHED 2 00076 00077 00078 struct Ocean *BKE_add_ocean(void); 00079 void BKE_free_ocean_data(struct Ocean *oc); 00080 void BKE_free_ocean(struct Ocean *oc); 00081 00082 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, 00083 float alignment, float depth, float time, short do_height_field, short do_chop, short do_normals, short do_jacobian, int seed); 00084 void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount); 00085 00086 /* sampling the ocean surface */ 00087 float BKE_ocean_jminus_to_foam(float jminus, float coverage); 00088 void BKE_ocean_eval_uv(struct Ocean * oc, struct OceanResult *ocr, float u, float v); 00089 void BKE_ocean_eval_uv_catrom(struct Ocean * oc, struct OceanResult *ocr, float u, float v); 00090 void BKE_ocean_eval_xz(struct Ocean * oc, struct OceanResult *ocr, float x, float z); 00091 void BKE_ocean_eval_xz_catrom(struct Ocean * oc, struct OceanResult *ocr, float x, float z); 00092 void BKE_ocean_eval_ij(struct Ocean * oc, struct OceanResult *ocr, int i, int j); 00093 00094 00095 /* ocean cache handling */ 00096 struct OceanCache *BKE_init_ocean_cache(const char *bakepath, const char *relbase, 00097 int start, int end, float wave_scale, 00098 float chop_amount, float foam_coverage, float foam_fade, int resolution); 00099 void BKE_simulate_ocean_cache(struct OceanCache *och, int frame); 00100 00101 void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(void *, float progress, int *cancel), void *update_cb_data); 00102 void BKE_ocean_cache_eval_uv(struct OceanCache *och, struct OceanResult *ocr, int f, float u, float v); 00103 void BKE_ocean_cache_eval_ij(struct OceanCache *och, struct OceanResult *ocr, int f, int i, int j); 00104 00105 void BKE_free_ocean_cache(struct OceanCache *och); 00106 #ifdef __cplusplus 00107 } 00108 #endif 00109 00110 #endif