KiCad PCB EDA Suite
XY_PLANE Class Reference

A plane that is parallel to XY plane. More...

#include <plane_3d.h>

Inheritance diagram for XY_PLANE:
OBJECT_3D

Public Member Functions

 XY_PLANE (const BBOX_3D &aBBox)
 
 XY_PLANE (SFVEC3F aCenterPoint, float aXSize, float aYSize)
 
void SetColor (SFVEC3F aObjColor)
 
bool Intersect (const RAY &aRay, HITINFO &aHitInfo) const override
 
bool IntersectP (const RAY &aRay, float aMaxDistance) const override
 
bool Intersects (const BBOX_3D &aBBox) const override
 
SFVEC3F GetDiffuseColor (const HITINFO &aHitInfo) const override
 
const void SetBoardItem (BOARD_ITEM *aBoardItem)
 
BOARD_ITEMGetBoardItem () const
 
void SetMaterial (const MATERIAL *aMaterial)
 
const MATERIALGetMaterial () const
 
float GetModelTransparency () const
 
void SetModelTransparency (float aModelTransparency)
 
const BBOX_3DGetBBox () const
 
const SFVEC3FGetCentroid () const
 

Protected Attributes

BBOX_3D m_bbox
 
SFVEC3F m_centroid
 
OBJECT_3D_TYPE m_obj_type
 
const MATERIALm_material
 
BOARD_ITEMm_boardItem
 
float m_modelTransparency
 

Private Attributes

SFVEC3F m_centerPoint
 
float m_xsize
 
float m_ysize
 
float m_xsize_inv2
 
float m_ysize_inv2
 
SFVEC3F m_diffusecolor
 

Detailed Description

A plane that is parallel to XY plane.

Definition at line 37 of file plane_3d.h.

Constructor & Destructor Documentation

◆ XY_PLANE() [1/2]

XY_PLANE::XY_PLANE ( const BBOX_3D aBBox)
explicit

Definition at line 32 of file plane_3d.cpp.

33 {
34  m_centerPoint = aBBox.GetCenter();
36 
37  m_bbox.Reset();
38  m_bbox.Set( aBBox );
39  m_xsize = aBBox.GetExtent().x;
40  m_ysize = aBBox.GetExtent().y;
41  m_xsize_inv2 = 1.0f / ( 2.0f * m_xsize );
42  m_ysize_inv2 = 1.0f / ( 2.0f * m_ysize );
43 }
const SFVEC3F GetExtent() const
Definition: bbox_3d.cpp:145
float m_ysize
Definition: plane_3d.h:59
OBJECT_3D(OBJECT_3D_TYPE aObjType)
Definition: object_3d.cpp:41
float m_xsize
Definition: plane_3d.h:58
SFVEC3F GetCenter() const
Return the center point of the bounding box.
Definition: bbox_3d.cpp:132
BBOX_3D m_bbox
Definition: object_3d.h:97
float m_ysize_inv2
Definition: plane_3d.h:61
SFVEC3F m_centerPoint
Definition: plane_3d.h:57
void Set(const SFVEC3F &aPbMin, const SFVEC3F &aPbMax)
Set bounding box with new parameters.
Definition: bbox_3d.cpp:68
SFVEC3F m_centroid
Definition: object_3d.h:98
float m_xsize_inv2
Definition: plane_3d.h:60
void Reset()
Reset the bounding box to zero and de-initialize it.
Definition: bbox_3d.cpp:95

References BBOX_3D::GetCenter(), BBOX_3D::GetExtent(), OBJECT_3D::m_bbox, m_centerPoint, OBJECT_3D::m_centroid, m_xsize, m_xsize_inv2, m_ysize, m_ysize_inv2, BBOX_3D::Reset(), BBOX_3D::Set(), and XYPLANE.

◆ XY_PLANE() [2/2]

XY_PLANE::XY_PLANE ( SFVEC3F  aCenterPoint,
float  aXSize,
float  aYSize 
)
Parameters
aCenterPoint= position of the center of the plane
aXSize= size by X axis
aYSize= size by Y axis

Definition at line 46 of file plane_3d.cpp.

48 {
49  m_centerPoint = aCenterPoint;
50  m_xsize = aXSize;
51  m_ysize = aYSize;
52  m_xsize_inv2 = 1.0f / ( 2.0f * aXSize );
53  m_ysize_inv2 = 1.0f / ( 2.0f * aYSize );
54  m_bbox.Set( SFVEC3F( aCenterPoint.x - aXSize / 2.0f, aCenterPoint.y - aYSize / 2.0f,
55  aCenterPoint.z ),
56  SFVEC3F( aCenterPoint.x + aXSize / 2.0f, aCenterPoint.y + aYSize / 2.0f,
57  aCenterPoint.z ) );
58  m_centroid = aCenterPoint;
59 }
float m_ysize
Definition: plane_3d.h:59
OBJECT_3D(OBJECT_3D_TYPE aObjType)
Definition: object_3d.cpp:41
float m_xsize
Definition: plane_3d.h:58
BBOX_3D m_bbox
Definition: object_3d.h:97
float m_ysize_inv2
Definition: plane_3d.h:61
SFVEC3F m_centerPoint
Definition: plane_3d.h:57
void Set(const SFVEC3F &aPbMin, const SFVEC3F &aPbMax)
Set bounding box with new parameters.
Definition: bbox_3d.cpp:68
SFVEC3F m_centroid
Definition: object_3d.h:98
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
float m_xsize_inv2
Definition: plane_3d.h:60

References OBJECT_3D::m_bbox, m_centerPoint, OBJECT_3D::m_centroid, m_xsize, m_xsize_inv2, m_ysize, m_ysize_inv2, BBOX_3D::Set(), and XYPLANE.

Member Function Documentation

◆ GetBBox()

const BBOX_3D& OBJECT_3D::GetBBox ( ) const
inlineinherited

Definition at line 92 of file object_3d.h.

92 { return m_bbox; }
BBOX_3D m_bbox
Definition: object_3d.h:97

References OBJECT_3D::m_bbox.

Referenced by CONTAINER_3D_BASE::Add(), and BVH_PBRT::Intersect().

◆ GetBoardItem()

BOARD_ITEM* OBJECT_3D::GetBoardItem ( ) const
inlineinherited

Definition at line 56 of file object_3d.h.

56 { return m_boardItem; }
BOARD_ITEM * m_boardItem
Definition: object_3d.h:102

References OBJECT_3D::m_boardItem.

Referenced by RENDER_3D_RAYTRACE::IntersectBoardItem().

◆ GetCentroid()

const SFVEC3F& OBJECT_3D::GetCentroid ( ) const
inlineinherited

Definition at line 94 of file object_3d.h.

94 { return m_centroid; }
SFVEC3F m_centroid
Definition: object_3d.h:98

References OBJECT_3D::m_centroid.

◆ GetDiffuseColor()

SFVEC3F XY_PLANE::GetDiffuseColor ( const HITINFO aHitInfo) const
overridevirtual

Implements OBJECT_3D.

Definition at line 121 of file plane_3d.cpp.

122 {
123  return m_diffusecolor;
124 }
SFVEC3F m_diffusecolor
Definition: plane_3d.h:62

References m_diffusecolor.

◆ GetMaterial()

const MATERIAL* OBJECT_3D::GetMaterial ( ) const
inlineinherited

Definition at line 64 of file object_3d.h.

64 { return m_material; }
const MATERIAL * m_material
Definition: object_3d.h:100

References OBJECT_3D::m_material.

Referenced by BVH_PBRT::IntersectP(), and RENDER_3D_RAYTRACE::shadeHit().

◆ GetModelTransparency()

float OBJECT_3D::GetModelTransparency ( ) const
inlineinherited

Definition at line 65 of file object_3d.h.

65 { return m_modelTransparency; }
float m_modelTransparency
Definition: object_3d.h:106

References OBJECT_3D::m_modelTransparency.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ Intersect()

bool XY_PLANE::Intersect ( const RAY aRay,
HITINFO aHitInfo 
) const
overridevirtual
Returns
true if the aRay intersects the object.

Implements OBJECT_3D.

Definition at line 62 of file plane_3d.cpp.

63 {
64  const float t = ( m_centerPoint.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
65 
66  if( ( t < FLT_EPSILON ) || ( t >= aHitInfo.m_tHit ) )
67  return false;
68 
69  const float vSU = t * aRay.m_Dir.x + aRay.m_Origin.x - m_centerPoint.x;
70 
71  if( (vSU < -m_xsize) || (vSU > m_xsize) )
72  return false;
73 
74  const float vSV = t * aRay.m_Dir.y + aRay.m_Origin.y - m_centerPoint.y;
75 
76  if( ( vSV < -m_ysize ) || ( vSV > m_ysize ) )
77  return false;
78 
79  aHitInfo.m_tHit = t;
80  aHitInfo.m_HitPoint = aRay.at( t );
81  aHitInfo.pHitObject = this;
82 
83  if( aRay.m_dirIsNeg[2] )
84  aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f, 1.0f );
85  else
86  aHitInfo.m_HitNormal = SFVEC3F( 0.0f, 0.0f,-1.0f );
87 
88  m_material->Generate( aHitInfo.m_HitNormal, aRay, aHitInfo );
89 
90  return true;
91 }
void Generate(SFVEC3F &aNormal, const RAY &aRay, const HITINFO &aHitInfo) const
Definition: material.cpp:89
float m_ysize
Definition: plane_3d.h:59
float m_tHit
( 4) distance
Definition: hitinfo.h:38
SFVEC3F at(float t) const
Definition: ray.h:84
float m_xsize
Definition: plane_3d.h:58
SFVEC3F m_InvDir
Definition: ray.h:70
SFVEC3F m_HitPoint
(12) hit position
Definition: hitinfo.h:44
unsigned int m_dirIsNeg[3]
Definition: ray.h:75
SFVEC3F m_centerPoint
Definition: plane_3d.h:57
const MATERIAL * m_material
Definition: object_3d.h:100
const OBJECT_3D * pHitObject
( 4) Object that was hitted
Definition: hitinfo.h:40
SFVEC3F m_Dir
Definition: ray.h:67
SFVEC3F m_Origin
Definition: ray.h:64
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
SFVEC3F m_HitNormal
(12) normal at the hit point
Definition: hitinfo.h:37

References RAY::at(), MATERIAL::Generate(), m_centerPoint, RAY::m_Dir, RAY::m_dirIsNeg, HITINFO::m_HitNormal, HITINFO::m_HitPoint, RAY::m_InvDir, OBJECT_3D::m_material, RAY::m_Origin, HITINFO::m_tHit, m_xsize, m_ysize, and HITINFO::pHitObject.

◆ IntersectP()

bool XY_PLANE::IntersectP ( const RAY aRay,
float  aMaxDistance 
) const
overridevirtual
Parameters
aMaxDistanceis the maximum distance of the test.
Returns
true if aRay intersects the object.

Implements OBJECT_3D.

Definition at line 94 of file plane_3d.cpp.

95 {
96  const float t = ( m_centerPoint.z - aRay.m_Origin.z ) * aRay.m_InvDir.z;
97 
98  if( ( t < FLT_EPSILON ) || ( t >= aMaxDistance ) )
99  return false;
100 
101  const float vSU = t * aRay.m_Dir.x + aRay.m_Origin.x - m_centerPoint.x;
102 
103  if( ( vSU < -m_xsize ) || ( vSU > m_xsize ) )
104  return false;
105 
106  const float vSV = t * aRay.m_Dir.y + aRay.m_Origin.y - m_centerPoint.y;
107 
108  if( ( vSV < -m_ysize ) || ( vSV > m_ysize ) )
109  return false;
110 
111  return true;
112 }
float m_ysize
Definition: plane_3d.h:59
float m_xsize
Definition: plane_3d.h:58
SFVEC3F m_InvDir
Definition: ray.h:70
SFVEC3F m_centerPoint
Definition: plane_3d.h:57
SFVEC3F m_Dir
Definition: ray.h:67
SFVEC3F m_Origin
Definition: ray.h:64

References m_centerPoint, RAY::m_Dir, RAY::m_InvDir, RAY::m_Origin, m_xsize, and m_ysize.

◆ Intersects()

bool XY_PLANE::Intersects ( const BBOX_3D aBBox) const
overridevirtual
Returns
true if this object intersects aBBox.

Implements OBJECT_3D.

Definition at line 115 of file plane_3d.cpp.

116 {
117  return m_bbox.Intersects( aBBox );
118 }
BBOX_3D m_bbox
Definition: object_3d.h:97
bool Intersects(const BBOX_3D &aBBox) const
Test if a bounding box intersects this box.
Definition: bbox_3d.cpp:218

References BBOX_3D::Intersects(), and OBJECT_3D::m_bbox.

◆ SetBoardItem()

const void OBJECT_3D::SetBoardItem ( BOARD_ITEM aBoardItem)
inlineinherited

Definition at line 55 of file object_3d.h.

55 { m_boardItem = aBoardItem; }
BOARD_ITEM * m_boardItem
Definition: object_3d.h:102

References OBJECT_3D::m_boardItem.

Referenced by RENDER_3D_RAYTRACE::addModels().

◆ SetColor()

void XY_PLANE::SetColor ( SFVEC3F  aObjColor)
inline

Definition at line 49 of file plane_3d.h.

49 { m_diffusecolor = aObjColor; }
SFVEC3F m_diffusecolor
Definition: plane_3d.h:62

References m_diffusecolor.

Referenced by RENDER_3D_RAYTRACE::createObject().

◆ SetMaterial()

void OBJECT_3D::SetMaterial ( const MATERIAL aMaterial)
inlineinherited

Definition at line 58 of file object_3d.h.

59  {
60  m_material = aMaterial;
61  m_modelTransparency = aMaterial->GetTransparency(); // Default transparency is from material
62  }
float GetTransparency() const
Definition: material.h:273
float m_modelTransparency
Definition: object_3d.h:106
const MATERIAL * m_material
Definition: object_3d.h:100

References MATERIAL::GetTransparency(), OBJECT_3D::m_material, and OBJECT_3D::m_modelTransparency.

Referenced by RENDER_3D_RAYTRACE::addModels(), RENDER_3D_RAYTRACE::createItemsFromContainer(), RENDER_3D_RAYTRACE::createObject(), RENDER_3D_RAYTRACE::insertHole(), and RENDER_3D_RAYTRACE::Reload().

◆ SetModelTransparency()

void OBJECT_3D::SetModelTransparency ( float  aModelTransparency)
inlineinherited

Definition at line 66 of file object_3d.h.

67  {
68  m_modelTransparency = aModelTransparency;
69  }
float m_modelTransparency
Definition: object_3d.h:106

References OBJECT_3D::m_modelTransparency.

Referenced by RENDER_3D_RAYTRACE::addModels().

Member Data Documentation

◆ m_bbox

◆ m_boardItem

BOARD_ITEM* OBJECT_3D::m_boardItem
protectedinherited

◆ m_centerPoint

SFVEC3F XY_PLANE::m_centerPoint
private

Definition at line 57 of file plane_3d.h.

Referenced by Intersect(), IntersectP(), and XY_PLANE().

◆ m_centroid

◆ m_diffusecolor

SFVEC3F XY_PLANE::m_diffusecolor
private

Definition at line 62 of file plane_3d.h.

Referenced by GetDiffuseColor(), and SetColor().

◆ m_material

◆ m_modelTransparency

float OBJECT_3D::m_modelTransparency
protectedinherited

◆ m_obj_type

OBJECT_3D_TYPE OBJECT_3D::m_obj_type
protectedinherited

Definition at line 99 of file object_3d.h.

Referenced by OBJECT_3D::OBJECT_3D().

◆ m_xsize

float XY_PLANE::m_xsize
private

Definition at line 58 of file plane_3d.h.

Referenced by Intersect(), IntersectP(), and XY_PLANE().

◆ m_xsize_inv2

float XY_PLANE::m_xsize_inv2
private

Definition at line 60 of file plane_3d.h.

Referenced by XY_PLANE().

◆ m_ysize

float XY_PLANE::m_ysize
private

Definition at line 59 of file plane_3d.h.

Referenced by Intersect(), IntersectP(), and XY_PLANE().

◆ m_ysize_inv2

float XY_PLANE::m_ysize_inv2
private

Definition at line 61 of file plane_3d.h.

Referenced by XY_PLANE().


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