ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
MaterialMask Class Reference

Combines two materials using a shape as a mask. More...

#include <MaterialMask.h>

Inheritance diagram for MaterialMask:
Collaboration diagram for MaterialMask:

Public Member Functions

 MaterialMask (Material *materialShape, Material *materialOuter, Shape *shape)
 Constructs a MaterialMask with given materials and shape.
 
void SetOpacity (float opacity)
 Sets the opacity of the mask effect.
 
floatGetOpacityReference ()
 Provides a reference to the opacity value.
 
RGBColor GetRGB (const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override
 Retrieves the color at a specific position based on the mask.
 
- Public Member Functions inherited from Material
virtual ~Material ()=default
 Virtual destructor for proper cleanup in derived classes.
 

Private Attributes

MaterialmaterialShape
 The material rendered inside the mask shape.
 
MaterialmaterialOuter
 The material rendered outside the mask shape.
 
Shapeshape
 Defines the masked area for blending the materials.
 
float opacity = 1.0f
 Controls the opacity of the mask effect.
 

Additional Inherited Members

- Public Types inherited from Material
enum  Method {
  Base , Add , Subtract , Multiply ,
  Divide , Darken , Lighten , Screen ,
  Overlay , SoftLight , Replace , EfficientMask ,
  Bypass
}
 Defines blending methods for combining colors. More...
 

Detailed Description

Combines two materials using a shape as a mask.

The MaterialMask class provides functionality to blend two materials—one within a defined shape and another for the outer region. Opacity can be adjusted for blending effects.

Definition at line 26 of file MaterialMask.h.

Constructor & Destructor Documentation

◆ MaterialMask()

MaterialMask ( Material materialShape,
Material materialOuter,
Shape shape 
)

Constructs a MaterialMask with given materials and shape.

Parameters
materialShapePointer to the material rendered within the shape.
materialOuterPointer to the material rendered outside the shape.
shapePointer to the shape used as the mask.

Definition at line 3 of file MaterialMask.cpp.

References materialOuter, materialShape, and shape.

Member Function Documentation

◆ GetOpacityReference()

float * GetOpacityReference ( )

Provides a reference to the opacity value.

Useful for dynamically modifying opacity during runtime.

Returns
Pointer to the opacity value.

Definition at line 13 of file MaterialMask.cpp.

References opacity.

Referenced by StrawberryAnimation::LinkEasyEase().

◆ GetRGB()

RGBColor GetRGB ( const Vector3D position,
const Vector3D normal,
const Vector3D uvw 
)
overridevirtual

Retrieves the color at a specific position based on the mask.

Determines if the position lies within the mask shape and blends the materials accordingly.

Parameters
positionThe 3D position to sample the color.
normalThe normal vector at the position.
uvwUVW coordinates at the position.
Returns
The blended RGB color based on the mask and materials.

Implements Material.

Definition at line 17 of file MaterialMask.cpp.

References Mathematics::Constrain(), Material::GetRGB(), RGBColor::InterpolateColors(), Shape::IsInShape(), materialOuter, materialShape, opacity, shape, Vector3D::X, and Vector3D::Y.

◆ SetOpacity()

void SetOpacity ( float  opacity)

Sets the opacity of the mask effect.

Parameters
opacityThe opacity value (0.0 to 1.0).

Definition at line 9 of file MaterialMask.cpp.

References opacity.

Referenced by GalaxyAnimation::Update().

Member Data Documentation

◆ materialOuter

Material* materialOuter
private

The material rendered outside the mask shape.

Definition at line 29 of file MaterialMask.h.

Referenced by GetRGB(), and MaterialMask().

◆ materialShape

Material* materialShape
private

The material rendered inside the mask shape.

Definition at line 28 of file MaterialMask.h.

Referenced by GetRGB(), and MaterialMask().

◆ opacity

float opacity = 1.0f
private

Controls the opacity of the mask effect.

Definition at line 31 of file MaterialMask.h.

Referenced by GetOpacityReference(), GetRGB(), and SetOpacity().

◆ shape

Shape* shape
private

Defines the masked area for blending the materials.

Definition at line 30 of file MaterialMask.h.

Referenced by GetRGB(), and MaterialMask().


The documentation for this class was generated from the following files: