KiCad PCB EDA Suite
CPLASTICNORMAL Class Reference

#include <cmaterial.h>

Inheritance diagram for CPLASTICNORMAL:
CPROCEDURALGENERATOR

Public Member Functions

 CPLASTICNORMAL ()
 
 CPLASTICNORMAL (float aScale)
 
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

PerlinNoise m_perlin
 
float m_scale
 

Detailed Description

Definition at line 109 of file cmaterial.h.

Constructor & Destructor Documentation

CPLASTICNORMAL::CPLASTICNORMAL ( )
inline

Definition at line 112 of file cmaterial.h.

References m_scale.

113  {
114  m_scale = 1.0f;
115  }
CPLASTICNORMAL::CPLASTICNORMAL ( float  aScale)

Definition at line 222 of file cmaterial.cpp.

References m_scale.

223 {
224  m_scale = 1.0f / aScale;
225 }

Member Function Documentation

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 228 of file cmaterial.cpp.

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

229 {
230  const SFVEC3F hitPos = aHitInfo.m_HitPoint * m_scale;
231 
232  const float noise1 = m_perlin.noise( hitPos.x * 1.0f,
233  hitPos.y * 1.0f,
234  hitPos.z * 1.0f ) - 0.5f;
235 
236  const float noise2 = m_perlin.noise( hitPos.x * 1.5f,
237  hitPos.y * 1.5f,
238  hitPos.z * 2.0f ) - 0.5f;
239 
240  const float noise3 = m_perlin.noise( hitPos.x * 2.0f,
241  hitPos.y * 2.0f,
242  hitPos.z * 2.0f ) - 0.5f;
243 
244  return SFVEC3F( noise1 * noise2 * noise3 * 4.00f,
245  noise1 * expf(noise2) * noise3 * 4.00f,
246  noise3 * noise3 * 1.00f );
247 }
SFVEC3F m_HitPoint
(12) hit position
Definition: hitinfo.h:49
PerlinNoise m_perlin
Definition: cmaterial.h:123
float noise(float x, float y, float z) const
Definition: PerlinNoise.cpp:97
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47

Member Data Documentation

PerlinNoise CPLASTICNORMAL::m_perlin
private

Definition at line 123 of file cmaterial.h.

Referenced by Generate().

float CPLASTICNORMAL::m_scale
private

Definition at line 124 of file cmaterial.h.

Referenced by CPLASTICNORMAL(), and Generate().


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