KiCad PCB EDA Suite
CPLASTICNORMAL Class Reference

#include <cmaterial.h>

Inheritance diagram for CPLASTICNORMAL:
CPROCEDURALGENERATOR

Public Member Functions

 CPLASTICNORMAL ()
 
 CPLASTICNORMAL (float aScale)
 
virtual ~CPLASTICNORMAL ()
 
SFVEC3F Generate (const RAY &aRay, const HITINFO &aHitInfo) const override
 Generate - Generates a 3D vector based on the ray and hit information depending on the implementation. More...
 

Private Attributes

float m_scale
 

Detailed Description

Definition at line 148 of file cmaterial.h.

Constructor & Destructor Documentation

◆ CPLASTICNORMAL() [1/2]

CPLASTICNORMAL::CPLASTICNORMAL ( )
inline

Definition at line 151 of file cmaterial.h.

152  {
153  m_scale = 1.0f;
154  }

References m_scale.

◆ CPLASTICNORMAL() [2/2]

CPLASTICNORMAL::CPLASTICNORMAL ( float  aScale)

Definition at line 246 of file cmaterial.cpp.

247 {
248  m_scale = 1.0f / aScale;
249 }

References m_scale.

◆ ~CPLASTICNORMAL()

virtual CPLASTICNORMAL::~CPLASTICNORMAL ( )
inlinevirtual

Definition at line 158 of file cmaterial.h.

159  {
160  }

Member Function Documentation

◆ Generate()

SFVEC3F CPLASTICNORMAL::Generate ( const RAY aRay,
const HITINFO aHitInfo 
) const
overridevirtual

Generate - Generates a 3D vector based on the ray and hit information depending on the implementation.

Parameters
aRaythe camera ray that hits the object
aHitInfothe hit information
Returns
the result of the procedural

Implements CPROCEDURALGENERATOR.

Definition at line 252 of file cmaterial.cpp.

253 {
254  const SFVEC3F hitPos = aHitInfo.m_HitPoint * m_scale;
255 
256  const float noise1 = s_perlinNoise.noise( hitPos.x * 1.0f,
257  hitPos.y * 1.1f,
258  hitPos.z * 1.2f ) - 0.5f;
259 
260  const float noise2 = s_perlinNoise.noise( hitPos.x * 1.3f,
261  hitPos.y * 1.0f,
262  hitPos.z * 1.5f ) - 0.5f;
263 
264  const float noise3 = s_perlinNoise.noise( hitPos.x * 1.0f,
265  hitPos.y * 1.0f,
266  hitPos.z * 1.8f ) - 0.5f;
267 
268  const float distanceReduction = 1.0f / ( aHitInfo.m_tHit + 0.5f );
269 
270  return SFVEC3F( noise1, noise2, noise3 ) * SFVEC3F( distanceReduction );
271 }
float m_tHit
( 4) distance
Definition: hitinfo.h:43
SFVEC3F m_HitPoint
(12) hit position
Definition: hitinfo.h:49
static PerlinNoise s_perlinNoise
Definition: cmaterial.cpp:157
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
float noise(float x, float y, float z) const

References HITINFO::m_HitPoint, m_scale, HITINFO::m_tHit, PerlinNoise::noise(), and s_perlinNoise.

Member Data Documentation

◆ m_scale

float CPLASTICNORMAL::m_scale
private

Definition at line 166 of file cmaterial.h.

Referenced by CPLASTICNORMAL(), and Generate().


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