Support Forum       G3D Web Page     
Public Member Functions | List of all members
G3D::Component< Color, Image > Class Template Reference

Common code for G3D::Component1, G3D::Component3, and G3D::Component4. More...

Public Member Functions

 Component (const shared_ptr< MapComponent< Image > > &map=shared_ptr< MapComponent< Image > >())
 Assumes a map of nullptr if not specified. More...
 
 Component (const shared_ptr< Image > &map)
 
 Component (const shared_ptr< Texture > &map)
 
const shared_ptr< Image > & image () const
 Causes the image to be created by downloading from GPU if necessary. More...
 
bool isBlack () const
 Says nothing about the alpha channel. More...
 
const Color & max () const
 Largest value per color channel. More...
 
const Color & mean () const
 Average value per color channel. More...
 
const Color & min () const
 Smallest value per color channel. More...
 
bool nonUnitAlpha () const
 Returns true if there is non-unit alpha. More...
 
bool notBlack () const
 Says nothing about the alpha channel. More...
 
bool operator== (const Component< Color, Image > &other) const
 
Color sample (const Vector2 &pos) const
 Return map sampled at. More...
 
void setStorage (ImageStorage s) const
 Does not change storage if the map is nullptr. More...
 
const shared_ptr< Texture > & texture () const
 Causes the texture to be created by uploading from CPU if necessary. More...
 

Detailed Description

template<class Color, class Image>
class G3D::Component< Color, Image >

Common code for G3D::Component1, G3D::Component3, and G3D::Component4.

Product of a constant and an image.

The image may be stored on either the GPU (G3D::Texture) or CPU (G3D::Map2D subclass), and both factors are optional. The details of this class are rarely needed to use UniversalMaterial, since it provides constructors from all combinations of data types.

Supports only floating point image formats because bilinear sampling of them is about 9x faster than sampling int formats.

Constructor & Destructor Documentation

◆ Component() [1/3]

template<class Color, class Image>
G3D::Component< Color, Image >::Component ( const shared_ptr< MapComponent< Image > > &  map = shared_ptr<MapComponent<Image> >())
inline

Assumes a map of nullptr if not specified.

◆ Component() [2/3]

template<class Color, class Image>
G3D::Component< Color, Image >::Component ( const shared_ptr< Image > &  map)
inline

◆ Component() [3/3]

template<class Color, class Image>
G3D::Component< Color, Image >::Component ( const shared_ptr< Texture > &  map)
inline

Member Function Documentation

◆ image()

template<class Color, class Image>
const shared_ptr<Image>& G3D::Component< Color, Image >::image ( ) const
inline

Causes the image to be created by downloading from GPU if necessary.

◆ isBlack()

template<class Color, class Image>
bool G3D::Component< Color, Image >::isBlack ( ) const
inline

◆ max()

template<class Color, class Image>
const Color& G3D::Component< Color, Image >::max ( ) const
inline

Largest value per color channel.

Referenced by G3D::Component< Color3, Image3 >::isBlack().

◆ mean()

template<class Color, class Image>
const Color& G3D::Component< Color, Image >::mean ( ) const
inline

Average value per color channel.

◆ min()

template<class Color, class Image>
const Color& G3D::Component< Color, Image >::min ( ) const
inline

Smallest value per color channel.

Referenced by G3D::Component< Color3, Image3 >::nonUnitAlpha().

◆ nonUnitAlpha()

template<class Color, class Image>
bool G3D::Component< Color, Image >::nonUnitAlpha ( ) const
inline

Returns true if there is non-unit alpha.

◆ notBlack()

template<class Color, class Image>
bool G3D::Component< Color, Image >::notBlack ( ) const
inline

Says nothing about the alpha channel.

◆ operator==()

template<class Color, class Image>
bool G3D::Component< Color, Image >::operator== ( const Component< Color, Image > &  other) const
inline

◆ sample()

template<class Color, class Image>
Color G3D::Component< Color, Image >::sample ( const Vector2 pos) const
inline

Return map sampled at.

Parameters
pos.Optimized to only perform as many operations as needed.

If the component contains a texture map that has not been converted to a CPU image, that conversion is performed. Because that process is not threadsafe, when using sample() in a multithreaded environment, first invoke setStorage(COPY_TO_CPU) on every Component from a single thread to prime the CPU data structures.

Coordinates are normalized; will be scaled by the image width and height automatically.

◆ setStorage()

template<class Color, class Image>
void G3D::Component< Color, Image >::setStorage ( ImageStorage  s) const
inline

Does not change storage if the map is nullptr.

◆ texture()

template<class Color, class Image>
const shared_ptr<Texture>& G3D::Component< Color, Image >::texture ( ) const
inline

Causes the texture to be created by uploading from CPU if necessary.


documentation generated on Wed Nov 24 2021 08:01:54 using doxygen 1.8.15