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 79 of file material.h.

Constructor & Destructor Documentation

◆ COPPER_NORMAL() [1/2]

COPPER_NORMAL::COPPER_NORMAL ( )
inline

Definition at line 82 of file material.h.

83  {
84  m_board_normal_generator = nullptr;
85  m_scale = 1.0f;
86  }
float m_scale
Definition: material.h:98
const MATERIAL_GENERATOR * m_board_normal_generator
Definition: material.h:97

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 168 of file material.cpp.

169 {
170  m_board_normal_generator = aBoardNormalGenerator;
171  m_scale = 1.0f / aScale;
172 }
float m_scale
Definition: material.h:98
const MATERIAL_GENERATOR * m_board_normal_generator
Definition: material.h:97

References m_board_normal_generator, and m_scale.

◆ ~COPPER_NORMAL()

virtual COPPER_NORMAL::~COPPER_NORMAL ( )
inlinevirtual

Definition at line 90 of file material.h.

91  {
92  }

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 175 of file material.cpp.

176 {
178  {
179  const SFVEC3F boardNormal = m_board_normal_generator->Generate( aRay, aHitInfo );
180 
181  SFVEC3F hitPos = aHitInfo.m_HitPoint * m_scale;
182 
183  const float noise =
184  ( s_perlinNoise.noise( hitPos.x + boardNormal.y + aRay.m_Origin.x * 0.2f,
185  hitPos.y + boardNormal.x ) - 0.5f ) * 2.0f;
186 
187  float scratchPattern =
188  ( s_perlinNoise.noise( noise + hitPos.x / 100.0f, hitPos.y * 100.0f ) - 0.5f );
189 
190  const float x = scratchPattern * 0.14f;
191  const float y = (noise + noise * scratchPattern) * 0.14f;
192 
193  return SFVEC3F( x, y, - ( x + y ) ) + boardNormal * 0.25f;
194  }
195  else
196  {
197  return SFVEC3F( 0.0f );
198  }
199 }
float m_scale
Definition: material.h:98
SFVEC3F m_HitPoint
(12) hit position
Definition: hitinfo.h:49
static PerlinNoise s_perlinNoise
Definition: material.cpp:140
SFVEC3F m_Origin
Definition: ray.h:69
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
const MATERIAL_GENERATOR * m_board_normal_generator
Definition: material.h:97
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 97 of file material.h.

Referenced by COPPER_NORMAL(), and Generate().

◆ m_scale

float COPPER_NORMAL::m_scale
private

Definition at line 98 of file material.h.

Referenced by COPPER_NORMAL(), and Generate().


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