1 /*************************************************************************/
2 /*  reflection_probe.h                                                   */
3 /*************************************************************************/
4 /*                       This file is part of:                           */
5 /*                           GODOT ENGINE                                */
6 /*                      https://godotengine.org                          */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */
9 /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */
10 /*                                                                       */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the       */
13 /* "Software"), to deal in the Software without restriction, including   */
14 /* without limitation the rights to use, copy, modify, merge, publish,   */
15 /* distribute, sublicense, and/or sell copies of the Software, and to    */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions:                                             */
18 /*                                                                       */
19 /* The above copyright notice and this permission notice shall be        */
20 /* included in all copies or substantial portions of the Software.       */
21 /*                                                                       */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
29 /*************************************************************************/
30 
31 #ifndef REFLECTIONPROBE_H
32 #define REFLECTIONPROBE_H
33 
34 #include "scene/3d/visual_instance.h"
35 #include "scene/resources/sky.h"
36 #include "scene/resources/texture.h"
37 #include "servers/visual_server.h"
38 
39 class ReflectionProbe : public VisualInstance {
40 	GDCLASS(ReflectionProbe, VisualInstance);
41 
42 public:
43 	enum UpdateMode {
44 		UPDATE_ONCE,
45 		UPDATE_ALWAYS,
46 	};
47 
48 private:
49 	RID probe;
50 	float intensity;
51 	float max_distance;
52 	Vector3 extents;
53 	Vector3 origin_offset;
54 	bool box_projection;
55 	bool enable_shadows;
56 	bool interior;
57 	Color interior_ambient;
58 	float interior_ambient_energy;
59 	float interior_ambient_probe_contribution;
60 
61 	uint32_t cull_mask;
62 	UpdateMode update_mode;
63 
64 protected:
65 	static void _bind_methods();
66 	void _validate_property(PropertyInfo &property) const;
67 
68 public:
69 	void set_intensity(float p_intensity);
70 	float get_intensity() const;
71 
72 	void set_interior_ambient(Color p_ambient);
73 	Color get_interior_ambient() const;
74 
75 	void set_interior_ambient_energy(float p_energy);
76 	float get_interior_ambient_energy() const;
77 
78 	void set_interior_ambient_probe_contribution(float p_contribution);
79 	float get_interior_ambient_probe_contribution() const;
80 
81 	void set_max_distance(float p_distance);
82 	float get_max_distance() const;
83 
84 	void set_extents(const Vector3 &p_extents);
85 	Vector3 get_extents() const;
86 
87 	void set_origin_offset(const Vector3 &p_extents);
88 	Vector3 get_origin_offset() const;
89 
90 	void set_as_interior(bool p_enable);
91 	bool is_set_as_interior() const;
92 
93 	void set_enable_box_projection(bool p_enable);
94 	bool is_box_projection_enabled() const;
95 
96 	void set_enable_shadows(bool p_enable);
97 	bool are_shadows_enabled() const;
98 
99 	void set_cull_mask(uint32_t p_layers);
100 	uint32_t get_cull_mask() const;
101 
102 	void set_update_mode(UpdateMode p_mode);
103 	UpdateMode get_update_mode() const;
104 
105 	virtual AABB get_aabb() const;
106 	virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
107 
108 	ReflectionProbe();
109 	~ReflectionProbe();
110 };
111 
112 VARIANT_ENUM_CAST(ReflectionProbe::UpdateMode);
113 
114 #endif // REFLECTIONPROBE_H
115