-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwater.h
96 lines (66 loc) · 1.84 KB
/
water.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// -*- C++ -*-
//
#ifndef __WATER_H__
#define __WATER_H__
#include "scene/2d/node_2d.h"
#include "scene/2d/area_2d.h"
#include "scene/2d/canvas_modulate.h"
#include "scene/resources/shape_2d.h"
#include "scene/resources/rectangle_shape_2d.h"
#include "scene/resources/texture.h"
#include "scene/resources/color_ramp.h"
class WaterColumn : public Area2D {
OBJ_TYPE(WaterColumn, Area2D);
public:
WaterColumn(const Vector2&, const Vector2& delta, const Vector2& drag);
void update(float& tension, float& damping) ;
void body_enter_shape ( int body_id, Object* body, int body_shape, int area_shape );
float target_height_;
float height_ ;
float speed_ ;
Vector2 drag_ ;
protected:
static void _bind_methods();
};
class Water : public Node2D {
OBJ_TYPE(Water, Node2D);
public:
Water();
void _notification(int p_what);
// Size in x must be a multiple of resolution
void set_size(const Rect2&value);
Rect2 get_size() const;
// Size of the simulation grid
void set_resolution(const uint32_t&value);
uint32_t get_resolution() const;
void set_color(const Color&value);
Color get_color() const;
/**
* Physical Parameters
*/
void set_tension(const float& value);
float get_tension() const;
void set_damping(const float&value);
float get_damping() const;
void set_spread(const float&value);
float get_spread() const;
void set_drag(const Vector2&value);
Vector2 get_drag() const;
void set_texture(const Ref<Texture>& p_texture);
Ref<Texture> get_texture() const;
protected:
static void _bind_methods();
Vector<WaterColumn*> columns_;
Rect2 rect_ ;
uint32_t ncols_ ;
uint32_t resolution_ ;
Color color_;
float damping_ ;
float tension_ ;
float spread_ ;
Vector2 drag_ ;
Ref<Texture> texture;
bool size_changed_ ;
void _update() ;
};
#endif