KiCad PCB EDA Suite
COPPER_NORMAL Class Reference

Procedural generation of the copper normals. More...

#include <material.h>

Inheritance diagram for COPPER_NORMAL:
MATERIAL_GENERATOR

Public Member Functions

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

Private Attributes

const MATERIAL_GENERATORm_board_normal_generator
 
float m_scale
 

Detailed Description

Procedural generation of the copper normals.

Definition at line 75 of file material.h.

Constructor & Destructor Documentation

◆ COPPER_NORMAL() [1/2]

COPPER_NORMAL::COPPER_NORMAL ( )
inline

Definition at line 78 of file material.h.

79  {
80  m_board_normal_generator = nullptr;
81  m_scale = 1.0f;
82  }
float m_scale
Definition: material.h:94
const MATERIAL_GENERATOR * m_board_normal_generator
Definition: material.h:93

References m_board_normal_generator, and m_scale.

◆ COPPER_NORMAL() [2/2]

COPPER_NORMAL::COPPER_NORMAL ( float  aScale,
const MATERIAL_GENERATOR aBoardNormalGenerator 
)

Definition at line 164 of file material.cpp.

165 {
166  m_board_normal_generator = aBoardNormalGenerator;
167  m_scale = 1.0f / aScale;
168 }
float m_scale
Definition: material.h:94
const MATERIAL_GENERATOR * m_board_normal_generator
Definition: material.h:93

References m_board_normal_generator, and m_scale.

◆ ~COPPER_NORMAL()

virtual COPPER_NORMAL::~COPPER_NORMAL ( )
inlinevirtual

Definition at line 86 of file material.h.

87  {
88  }

Member Function Documentation

◆ Generate()

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

Generate 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 MATERIAL_GENERATOR.

Definition at line 171 of file material.cpp.

172 {
174  {
175  const SFVEC3F boardNormal = m_board_normal_generator->Generate( aRay, aHitInfo );
176 
177  SFVEC3F hitPos = aHitInfo.m_HitPoint * m_scale;
178 
179  const float noise =
180  ( s_perlinNoise.noise( hitPos.x + boardNormal.y + aRay.m_Origin.x * 0.2f,
181  hitPos.y + boardNormal.x ) - 0.5f ) * 2.0f;
182 
183  float scratchPattern =
184  ( s_perlinNoise.noise( noise + hitPos.x / 100.0f, hitPos.y * 100.0f ) - 0.5f );
185 
186  const float x = scratchPattern * 0.14f;
187  const float y = (noise + noise * scratchPattern) * 0.14f;
188 
189  return SFVEC3F( x, y, - ( x + y ) ) + boardNormal * 0.25f;
190  }
191  else
192  {
193  return SFVEC3F( 0.0f );
194  }
195 }
float m_scale
Definition: material.h:94
SFVEC3F m_HitPoint
(12) hit position
Definition: hitinfo.h:44
static PerlinNoise s_perlinNoise
Definition: material.cpp:136
SFVEC3F m_Origin
Definition: ray.h:64
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
const MATERIAL_GENERATOR * m_board_normal_generator
Definition: material.h:93
float noise(float x, float y, float z) const
virtual SFVEC3F Generate(const RAY &aRay, const HITINFO &aHitInfo) const =0
Generate a 3D vector based on the ray and hit information depending on the implementation.

References MATERIAL_GENERATOR::Generate(), m_board_normal_generator, HITINFO::m_HitPoint, RAY::m_Origin, m_scale, PerlinNoise::noise(), and s_perlinNoise.

Member Data Documentation

◆ m_board_normal_generator

const MATERIAL_GENERATOR* COPPER_NORMAL::m_board_normal_generator
private

Definition at line 93 of file material.h.

Referenced by COPPER_NORMAL(), and Generate().

◆ m_scale

float COPPER_NORMAL::m_scale
private

Definition at line 94 of file material.h.

Referenced by COPPER_NORMAL(), and Generate().


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