KiCad PCB EDA Suite
CPLASTICSHINENORMAL Class Reference

#include <cmaterial.h>

Inheritance diagram for CPLASTICSHINENORMAL:
CPROCEDURALGENERATOR

Public Member Functions

 CPLASTICSHINENORMAL ()
 
 CPLASTICSHINENORMAL (float aScale)
 
virtual ~CPLASTICSHINENORMAL ()
 
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 171 of file cmaterial.h.

Constructor & Destructor Documentation

◆ CPLASTICSHINENORMAL() [1/2]

CPLASTICSHINENORMAL::CPLASTICSHINENORMAL ( )
inline

Definition at line 174 of file cmaterial.h.

175  {
176  m_scale = 1.0f;
177  }

References m_scale.

◆ CPLASTICSHINENORMAL() [2/2]

CPLASTICSHINENORMAL::CPLASTICSHINENORMAL ( float  aScale)

Definition at line 274 of file cmaterial.cpp.

275 {
276  m_scale = 1.0f / aScale;
277 }

References m_scale.

◆ ~CPLASTICSHINENORMAL()

virtual CPLASTICSHINENORMAL::~CPLASTICSHINENORMAL ( )
inlinevirtual

Definition at line 181 of file cmaterial.h.

182  {
183  }

Member Function Documentation

◆ Generate()

SFVEC3F CPLASTICSHINENORMAL::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 280 of file cmaterial.cpp.

281 {
282  const SFVEC3F hitPos = aHitInfo.m_HitPoint * m_scale;
283 
284  const float noise1 = s_perlinNoise.noise( hitPos.x * 0.01f,
285  hitPos.y * 0.01f,
286  hitPos.z * 0.01f ) - 0.5f;
287 
288  const float noise2 = s_perlinNoise.noise( hitPos.x * 1.0f,
289  hitPos.y * 1.0f,
290  hitPos.z * 1.6f ) - 0.5f;
291 
292  float noise3 = s_perlinNoise.noise( hitPos.x * 1.5f,
293  hitPos.y * 1.5f,
294  hitPos.z * 1.0f ) - 0.5f;
295  noise3 = noise3 * noise3 * noise3;
296 
297  return SFVEC3F( noise1, noise2, noise3 ) * SFVEC3F( 0.1f, 0.2f, 1.0f );
298 }
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, PerlinNoise::noise(), and s_perlinNoise.

Member Data Documentation

◆ m_scale

float CPLASTICSHINENORMAL::m_scale
private

Definition at line 189 of file cmaterial.h.

Referenced by CPLASTICSHINENORMAL(), and Generate().


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