KiCad PCB EDA Suite
CMETALBRUSHEDNORMAL Class Reference

#include <cmaterial.h>

Inheritance diagram for CMETALBRUSHEDNORMAL:
CPROCEDURALGENERATOR

Public Member Functions

 CMETALBRUSHEDNORMAL ()
 
 CMETALBRUSHEDNORMAL (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 148 of file cmaterial.h.

Constructor & Destructor Documentation

CMETALBRUSHEDNORMAL::CMETALBRUSHEDNORMAL ( )
inline

Definition at line 151 of file cmaterial.h.

References m_scale.

152  {
153  m_scale = 1.0f;
154  }
CMETALBRUSHEDNORMAL::CMETALBRUSHEDNORMAL ( float  aScale)

Definition at line 276 of file cmaterial.cpp.

References m_scale.

277 {
278  m_scale = 1.0f / aScale;
279 }

Member Function Documentation

SFVEC3F CMETALBRUSHEDNORMAL::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 282 of file cmaterial.cpp.

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

283 {
284  const SFVEC3F hitPos = aHitInfo.m_HitPoint * m_scale;
285 
286  const SFVEC3F hitPosRelative = hitPos - glm::floor( hitPos );
287 
288  const float noiseX = (m_perlin.noise( hitPos.x * (60.0f),
289  hitPos.y * 1.0f,
290  hitPos.z * 1.0f ) - 0.5f);
291 
292  const float noiseY = (m_perlin.noise( hitPos.x * 1.0f,
293  hitPos.y * (60.0f),
294  hitPos.z * 1.0f ) - 0.5f);
295 
296  const float noise2 = (m_perlin.noise( hitPos.x * 1.0f,
297  hitPos.y * 1.0f,
298  hitPos.z * 1.0f ) - 0.5f);
299 
300  const float noise3X = (m_perlin.noise( hitPos.x * (80.0f + noise2 * 0.5f),
301  hitPos.y * 0.5f,
302  hitPos.z * 0.5f ) - 0.5f );
303 
304  const float noise3Y = (m_perlin.noise( hitPos.x * 0.5f,
305  hitPos.y * (80.0f + noise2 * 0.5f),
306  hitPos.z * 0.5f ) - 0.5f );
307 
308  // http://www.fooplot.com/#W3sidHlwZSI6MCwiZXEiOiIoKHgtZmxvb3IoeCkpK3Npbih4KSleMyIsImNvbG9yIjoiIzAwMDAwMCJ9LHsidHlwZSI6MTAwMCwid2luZG93IjpbIi02LjcxNDAwMDAxOTAzMDA3NyIsIjcuMjQ0NjQzNjkyOTY5NzM5IiwiLTMuMTU1NTUyNjAxNDUyNTg4IiwiNS40MzQzODE5OTA1NDczMDY1Il0sInNpemUiOls2NDQsMzk0XX1d
309  // ((x - floor(x))+sin(x))^3
310 
311  float sawX = (hitPosRelative.x + glm::sin( 10.0f * hitPos.x + 5.0f * noise2 + Fast_RandFloat() ) );
312  sawX = sawX * sawX * sawX;
313 
314  float sawY = (hitPosRelative.y + glm::sin( 10.0f * hitPos.y + 5.0f * noise2 + Fast_RandFloat() ) );
315  sawY = sawY * sawY * sawY;
316 
317  float xOut = sawX * noise3X * 0.17f + noiseX * 0.25f + noise3X * 0.57f;
318  float yOut = sawY * noise3Y * 0.17f + noiseY * 0.25f + noise3Y * 0.57f;
319 
320  const float outLowFreqNoise = noise2 * 0.05f;
321 
322  return SFVEC3F( xOut + outLowFreqNoise,
323  yOut + outLowFreqNoise,
324  0.0f + outLowFreqNoise );
325 }
float Fast_RandFloat()
Definition: 3d_fastmath.cpp:45
SFVEC3F m_HitPoint
(12) hit position
Definition: hitinfo.h:49
PerlinNoise m_perlin
Definition: cmaterial.h:162
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 CMETALBRUSHEDNORMAL::m_perlin
private

Definition at line 162 of file cmaterial.h.

Referenced by Generate().

float CMETALBRUSHEDNORMAL::m_scale
private

Definition at line 163 of file cmaterial.h.

Referenced by CMETALBRUSHEDNORMAL(), and Generate().


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