12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #ifndef OPEN_SIMPLEX_NOISE_H
- #define OPEN_SIMPLEX_NOISE_H
- #include "core/image.h"
- #include "core/reference.h"
- #include "scene/resources/texture.h"
- #include "thirdparty/misc/open-simplex-noise.h"
- class OpenSimplexNoise : public Resource {
- GDCLASS(OpenSimplexNoise, Resource)
- OBJ_SAVE_TYPE(OpenSimplexNoise);
- osn_context contexts[6];
- int seed;
- float persistence;
- int octaves;
- float period;
- float lacunarity;
- public:
- OpenSimplexNoise();
- ~OpenSimplexNoise();
- void _init_seeds();
- void set_seed(int seed);
- int get_seed();
- void set_octaves(int p_octaves);
- int get_octaves() const { return octaves; }
- void set_period(float p_period);
- float get_period() const { return period; }
- void set_persistence(float p_persistence);
- float get_persistence() const { return persistence; }
- void set_lacunarity(float p_lacunarity);
- float get_lacunarity() const { return lacunarity; }
- Ref<Image> get_image(int p_width, int p_height);
- Ref<Image> get_seamless_image(int p_size);
- float get_noise_2d(float x, float y);
- float get_noise_3d(float x, float y, float z);
- float get_noise_4d(float x, float y, float z, float w);
- _FORCE_INLINE_ float _get_octave_noise_2d(int octave, float x, float y) { return open_simplex_noise2(&(contexts[octave]), x, y); }
- _FORCE_INLINE_ float _get_octave_noise_3d(int octave, float x, float y, float z) { return open_simplex_noise3(&(contexts[octave]), x, y, z); }
- _FORCE_INLINE_ float _get_octave_noise_4d(int octave, float x, float y, float z, float w) { return open_simplex_noise4(&(contexts[octave]), x, y, z, w); }
-
- _FORCE_INLINE_ float get_noise_2dv(Vector2 v) { return get_noise_2d(v.x, v.y); }
- _FORCE_INLINE_ float get_noise_3dv(Vector3 v) { return get_noise_3d(v.x, v.y, v.z); }
- protected:
- static void _bind_methods();
- };
- #endif
|