3#include <NDEVR/ImageFactory.h>
4#include <NDEVR/VectorFunctions.h>
5#include <NDEVR/RGBColor.h>
6#include <NDEVR/INIInterface.h>
122 ,
m_pixels(4 * raster_info.pixel_size[X] * raster_info.pixel_size[Y], 255)
211 return location[Y] *
m_raster_info.pixel_size[X] + location[X];
265 if (weight != Constant<uint08>::Max)
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
A specification of upper and lower bounds in N-dimensions.
The equivelent of std::vector but with a bit more control.
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Contains methods for easily reading and writing to an INI file including efficient casting,...
void addOption(const StringView &label, Resource< Vector< t_dims, t_type > > &mem_loc)
Registers a Vector Resource option that will be read/written by the factory.
INIInterface()
Constructs an INIInterface with no default INI file.
void addImageUncompressed(const StringView &id, const Buffer< uint01 > &uncompressed, bool clear_other)
Adds an uncompressed (raw ARGB) image to the cache.
static ImageFactory & DefaultFactory()
Returns the singleton default ImageFactory instance.
Base class for painting pixels at a time into a 2D texture.
MaterialRasterBase(const RasterInfo &raster_info)
Constructs the base raster with the given raster configuration.
virtual void addPixelInfo(const RGBColor &pixel, const Vector< 2, fltp08 > &location, uint04 weight)=0
Adds a single pixel color at a normalized floating-point location with a weight.
RasterInfo m_raster_info
The raster configuration settings.
virtual void addPixelInfo(const Vector< 4, fltp04 > &pixel, const Vector< 2, fltp08 > &location, uint08 weight)=0
Adds a single pixel as a normalized float RGBA vector at a normalized location with a weight.
virtual void addImageBuffer(const Buffer< uint01 > &pixels, const Vector< 2, uint04 > &size, const Matrix< fltp08 > &camera_matrix)=0
Adds an entire image buffer to the raster, mapping pixels through a camera matrix.
virtual void addPixelInfo(const Vector< 4, fltp04 > &pixel, const Vector< 2, uint04 > &location, uint08 weight)=0
Adds a single pixel as a normalized float RGBA vector at an integer pixel location with a weight.
virtual StringView imageID() const =0
Returns the identifier string of the underlying image resource.
virtual void addPixelInfo(const RGBColor &pixel, const Vector< 2, uint04 > &location, uint08 weight)=0
Adds a single pixel color at an integer pixel location with a weight.
virtual void updateImage()=0
Commits accumulated pixel data to the underlying image.
Creates rasters for converting points and directions into 2D images.
static void SetDefaultMaterialRasterFactory(MaterialRasterFactory *factory)
Sets the default MaterialRasterFactory used by CreateRaster.
static MaterialRasterFactory * s_default_raster_factory
The singleton default factory used by CreateRaster.
static MaterialRasterBase * CreateRaster(const String &image_id, const RasterInfo &info)
Creates a MaterialRasterBase using the default factory implementation.
virtual MaterialRasterBase * createRaster(const String &image_id, const RasterInfo &info)=0
Creates a MaterialRasterBase instance.
void addPixelInfo(const Vector< 4, fltp04 > &pixel, const Vector< 2, uint04 > &location, uint08 weight) override
Adds pixel color data (as normalized floats) at an integer pixel location with a weight.
String m_image_id
The unique identifier for this raster's image resource.
void addPixelInfo(const RGBColor &pixel, const Vector< 2, fltp08 > &location, uint04 weight) override
Adds pixel color data at a normalized floating-point location with a given weight.
Buffer< uint08 > m_color_channel_average_count
Total accumulated weight per pixel (divisor for averaging).
Buffer< Vector< 3, uint08 > > m_color_channels
Accumulated weighted RGB color values per pixel (used for averaging).
void addPixelInfo(const RGBColor &pixel, const Vector< 2, uint04 > &location, uint08 weight) override
Adds pixel color data at an integer pixel location with a given weight.
virtual void updateImage() override
Commits accumulated pixel data to the image by averaging color channels, then uploads the result to t...
Buffer< uint01 > m_pixels
Raw RGBA pixel buffer (4 bytes per pixel) uploaded to the ImageFactory.
Vector< 2, uint04 > convertLocation(const Vector< 2, fltp08 > &location) const
Converts a normalized [0,1] floating-point location to an integer pixel coordinate,...
static uint04 Weight(const Vertex< 2, fltp08 > &location, fltp08 y_dist)
Computes a pixel contribution weight based on distance from the raster center.
void addPixelInfo(const Vector< 4, fltp04 > &pixel, const Vector< 2, fltp08 > &location, uint08 weight) override
Adds pixel color data (as normalized floats) at a normalized location with a weight.
MaterialRaster(const String &image_id, const RasterInfo &raster_info)
Constructs a MaterialRaster with a given image identifier and raster configuration.
Bounds< 2, uint04 > m_update_bounds
Bounding box of pixels that have been modified since the last update.
virtual void clearRaster()
Resets all accumulated color channel data and average counts to zero.
StringView imageID() const override
Returns the image identifier for this raster.
virtual void addImageBuffer(const Buffer< uint01 > &pixels, const Vector< 2, uint04 > &size, const Matrix< fltp08 > &camera_matrix) override
Adds an entire image buffer to the raster, mapping pixels through a camera matrix.
uint04 convertToIndex(const Vector< 2, uint04 > &location) const
Converts a 2D pixel coordinate to a linear buffer index.
virtual void setUnsetColor(RGBColor color)
Sets a fallback color for all pixels within the update bounds that have not received any pixel data (...
Templated logic for doing matrix multiplication.
Represents a color in the RGB space with optional alpha transparency.
static const uint01 r_pos
The index of the red channel in the RGBA color struct.
static const uint01 g_pos
The index of the green channel in the RGBA color struct.
static const uint01 b_pos
The index of the blue channel in the RGBA color struct.
The core String View class for the NDEVR API.
The core String class for the NDEVR API.
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
constexpr decltype(auto) as() const
Returns the vector as a new time of vector.
constexpr t_type magnitudeSquared() const
Vectors are commonly used to model forces such as wind, sea current, gravity, and electromagnetism.
A point in N-dimensional space, used primarily for spatial location information.
The primary namespace for the NDEVR SDK.
constexpr t_type getMax(const t_type &left, const t_type &right)
Finds the max of the given arguments using the > operator The only requirement is that t_type have > ...
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
@ DEGREES
Angle measured in degrees (0 to 360 for a full circle).
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Stores information for painting pixels at a time into a 2D texture used with MaterialRaster.
Vector< 2, Angle< fltp08 > > angle_offset
Angular offset applied to the camera drape direction.
fltp08 radial_distortion_scale
Scale factor applied to radial distortion correction.
RasterInfo()
Default constructor.
uint04 side_crop
Number of pixels to crop from each side of the source image.
Vector< 2, uint04 > pixel_size
The width and height of the raster texture in pixels.
bool isEnabled() const
Checks whether the raster is enabled and has a valid (non-zero) pixel size.
RasterInfo(const File &ini_file)
Constructs a RasterInfo from an INI configuration file.
Vector< 2, Angle< fltp08 > > camera_drape_move_angle
The angular range used when draping camera imagery onto the raster.
virtual void getINI(INIFactory &factory) override
Serializes or deserializes raster settings to/from an INI file via the factory.
bool is_enabled
Whether rasterization is currently enabled.
fltp08 radial_distortion_offset
Offset applied to radial distortion correction.