diff options
Diffstat (limited to 'scene/resources/texture.h')
-rw-r--r-- | scene/resources/texture.h | 100 |
1 files changed, 87 insertions, 13 deletions
diff --git a/scene/resources/texture.h b/scene/resources/texture.h index 281a33929c..e535f7544a 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -39,12 +39,9 @@ #include "core/resource.h" #include "scene/resources/curve.h" #include "scene/resources/gradient.h" +#include "servers/camera_server.h" #include "servers/visual_server.h" -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ - class Texture : public Resource { GDCLASS(Texture, Resource); @@ -238,7 +235,6 @@ public: }; class ResourceFormatLoaderStreamTexture : public ResourceFormatLoader { - GDCLASS(ResourceFormatLoaderStreamTexture, ResourceFormatLoader) public: virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL); virtual void get_recognized_extensions(List<String> *p_extensions) const; @@ -293,6 +289,49 @@ public: AtlasTexture(); }; +class Mesh; + +class MeshTexture : public Texture { + + GDCLASS(MeshTexture, Texture); + RES_BASE_EXTENSION("meshtex"); + + Ref<Texture> base_texture; + Ref<Mesh> mesh; + Size2i size; + +protected: + static void _bind_methods(); + +public: + virtual int get_width() const; + virtual int get_height() const; + virtual RID get_rid() const; + + virtual bool has_alpha() const; + + virtual void set_flags(uint32_t p_flags); + virtual uint32_t get_flags() const; + + void set_mesh(const Ref<Mesh> &p_mesh); + Ref<Mesh> get_mesh() const; + + void set_image_size(const Size2 &p_size); + Size2 get_image_size() const; + + void set_base_texture(const Ref<Texture> &p_texture); + Ref<Texture> get_base_texture() const; + + virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>()) const; + virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>()) const; + virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = true) const; + virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const; + + bool is_pixel_opaque(int p_x, int p_y) const; + + MeshTexture(); +}; + class LargeTexture : public Texture { GDCLASS(LargeTexture, Texture); @@ -426,7 +465,7 @@ VARIANT_ENUM_CAST(CubeMap::Storage) class TextureLayered : public Resource { - GDCLASS(TextureLayered, Resource) + GDCLASS(TextureLayered, Resource); public: enum Flags { @@ -478,7 +517,8 @@ VARIANT_ENUM_CAST(TextureLayered::Flags) class Texture3D : public TextureLayered { - GDCLASS(Texture3D, TextureLayered) + GDCLASS(Texture3D, TextureLayered); + public: Texture3D() : TextureLayered(true) {} @@ -486,14 +526,14 @@ public: class TextureArray : public TextureLayered { - GDCLASS(TextureArray, TextureLayered) + GDCLASS(TextureArray, TextureLayered); + public: TextureArray() : TextureLayered(false) {} }; class ResourceFormatLoaderTextureLayered : public ResourceFormatLoader { - GDCLASS(ResourceFormatLoaderTextureLayered, ResourceFormatLoader) public: enum Compression { COMPRESSION_LOSSLESS, @@ -509,7 +549,7 @@ public: class CurveTexture : public Texture { - GDCLASS(CurveTexture, Texture) + GDCLASS(CurveTexture, Texture); RES_BASE_EXTENSION("curvetex") private: @@ -557,7 +597,7 @@ public: //VARIANT_ENUM_CAST( Texture::CubeMapSide ); class GradientTexture : public Texture { - GDCLASS(GradientTexture, Texture) + GDCLASS(GradientTexture, Texture); public: struct Point { @@ -602,7 +642,7 @@ public: }; class ProxyTexture : public Texture { - GDCLASS(ProxyTexture, Texture) + GDCLASS(ProxyTexture, Texture); private: RID proxy; @@ -629,7 +669,7 @@ public: }; class AnimatedTexture : public Texture { - GDCLASS(AnimatedTexture, Texture) + GDCLASS(AnimatedTexture, Texture); //use readers writers lock for this, since its far more times read than written to RWLock *rw_lock; @@ -697,4 +737,38 @@ public: ~AnimatedTexture(); }; +class CameraTexture : public Texture { + GDCLASS(CameraTexture, Texture); + +private: + int camera_feed_id; + CameraServer::FeedImage which_feed; + +protected: + static void _bind_methods(); + +public: + virtual int get_width() const; + virtual int get_height() const; + virtual RID get_rid() const; + virtual bool has_alpha() const; + + virtual void set_flags(uint32_t p_flags); + virtual uint32_t get_flags() const; + + virtual Ref<Image> get_data() const; + + void set_camera_feed_id(int p_new_id); + int get_camera_feed_id() const; + + void set_which_feed(CameraServer::FeedImage p_which); + CameraServer::FeedImage get_which_feed() const; + + void set_camera_active(bool p_active); + bool get_camera_active() const; + + CameraTexture(); + ~CameraTexture(); +}; + #endif |