KiCad PCB EDA Suite
ctriangle.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
5  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 
34 #ifndef _CTRIANGLE_H_
35 #define _CTRIANGLE_H_
36 
37 #include "cobject.h"
38 
42 class CTRIANGLE : public COBJECT
43 {
44 
45 public:
46  CTRIANGLE( const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3 );
47 
48  CTRIANGLE( const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3,
49  const SFVEC3F &aFaceNormal );
50 
51  CTRIANGLE( const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3,
52  const SFVEC3F &aN1, const SFVEC3F &aN2, const SFVEC3F &aN3 );
53 
54  void SetColor( const SFVEC3F &aColor );
55 
56  void SetColor( const SFVEC3F &aVC0, const SFVEC3F &aVC1, const SFVEC3F &aVC2 );
57 
58  void SetColor( unsigned int aFaceColorRGBA );
59 
60  void SetColor( unsigned int aVertex1ColorRGBA,
61  unsigned int aVertex2ColorRGBA,
62  unsigned int aVertex3ColorRGBA );
63 
64  void SetUV( const SFVEC2F &aUV1, const SFVEC2F &aUV2, const SFVEC2F &aUV3 );
65 
66  // Imported from COBJECT
67  bool Intersect( const RAY &aRay, HITINFO &aHitInfo ) const override;
68  bool IntersectP(const RAY &aRay , float aMaxDistance ) const override;
69  bool Intersects( const CBBOX &aBBox ) const override;
70  SFVEC3F GetDiffuseColor( const HITINFO &aHitInfo ) const override;
71 
72 private:
73  void pre_calc_const();
74 
75 private:
76  SFVEC3F m_normal[3]; // 36
77  SFVEC3F m_vertex[3]; // 36
78  SFVEC3F m_n; // 12
79  SFVEC2F m_uv[3]; // 24
80  unsigned int m_vertexColorRGBA[3]; // 12
81  float m_nu, m_nv, m_nd; // 12
82  unsigned int m_k; // 4
83  float m_bnu, m_bnv; // 8
84  float m_cnu, m_cnv; // 8
85  // 152 bytes (max 160 == 5 * 32)
86 };
87 
88 #endif // _CTRIANGLE_H_
float m_bnu
Definition: ctriangle.h:83
bool Intersect(const RAY &aRay, HITINFO &aHitInfo) const override
Functions Intersect.
Definition: ctriangle.cpp:217
SFVEC3F m_n
Definition: ctriangle.h:78
SFVEC2F m_uv[3]
Definition: ctriangle.h:79
float m_nd
Definition: ctriangle.h:81
unsigned int m_vertexColorRGBA[3]
Definition: ctriangle.h:80
float m_nv
Definition: ctriangle.h:81
bool IntersectP(const RAY &aRay, float aMaxDistance) const override
Functions Intersect for shadow test.
Definition: ctriangle.cpp:272
bool Intersects(const CBBOX &aBBox) const override
Function Intersects.
Definition: ctriangle.cpp:316
Definition: ray.h:43
void SetColor(const SFVEC3F &aColor)
Definition: ctriangle.cpp:161
float m_bnv
Definition: ctriangle.h:83
SFVEC3F m_vertex[3]
Definition: ctriangle.h:77
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
void pre_calc_const()
Definition: ctriangle.cpp:37
CTRIANGLE(const SFVEC3F &aV1, const SFVEC3F &aV2, const SFVEC3F &aV3)
Definition: ctriangle.cpp:101
unsigned int m_k
Definition: ctriangle.h:82
float m_cnu
Definition: ctriangle.h:84
SFVEC3F GetDiffuseColor(const HITINFO &aHitInfo) const override
Definition: ctriangle.cpp:323
A triangle object.
Definition: ctriangle.h:42
Stores the hit information of a ray with a point on the surface of a object.
Definition: hitinfo.h:40
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
void SetUV(const SFVEC2F &aUV1, const SFVEC2F &aUV2, const SFVEC2F &aUV3)
Definition: ctriangle.cpp:205
SFVEC3F m_normal[3]
Definition: ctriangle.h:76
float m_cnv
Definition: ctriangle.h:84
Class CBBOX manages a bounding box defined by two SFVEC3F min max points.
Definition: cbbox.h:40
float m_nu
Definition: ctriangle.h:81