KiCad PCB EDA Suite
Loading...
Searching...
No Matches
triangle_3d.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 <[email protected]>
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 _TRIANGLE_H_
35#define _TRIANGLE_H_
36
37#include "object_3d.h"
38
42class TRIANGLE : public OBJECT_3D
43{
44public:
45 TRIANGLE( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3 );
46
47 TRIANGLE( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3,
48 const SFVEC3F& aFaceNormal );
49
50 TRIANGLE( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3,
51 const SFVEC3F& aN1, const SFVEC3F& aN2, const SFVEC3F& aN3 );
52
53 void SetColor( const SFVEC3F& aColor );
54
55 void SetColor( const SFVEC3F& aVC0, const SFVEC3F& aVC1, const SFVEC3F& aVC2 );
56
57 void SetColor( unsigned int aFaceColorRGBA );
58
59 void SetColor( unsigned int aVertex1ColorRGBA, unsigned int aVertex2ColorRGBA,
60 unsigned int aVertex3ColorRGBA );
61
62 void SetUV( const SFVEC2F& aUV1, const SFVEC2F& aUV2, const SFVEC2F& aUV3 );
63
64 bool Intersect( const RAY& aRay, HITINFO& aHitInfo ) const override;
65 bool IntersectP(const RAY& aRay, float aMaxDistance ) const override;
66 bool Intersects( const BBOX_3D& aBBox ) const override;
67 SFVEC3F GetDiffuseColor( const HITINFO& aHitInfo ) const override;
68
69private:
70 void pre_calc_const();
71
72 SFVEC3F m_normal[3]; // 36
73 SFVEC3F m_vertex[3]; // 36
74 SFVEC3F m_n; // 12
75 SFVEC2F m_uv[3]; // 24
76 unsigned int m_vertexColorRGBA[3]; // 12
77 float m_nu, m_nv, m_nd; // 12
78 unsigned int m_k; // 4
79 float m_bnu, m_bnv; // 8
80 float m_cnu, m_cnv; // 8
81 // 152 bytes (max 160 == 5 * 32)
82};
83
84#endif // _TRIANGLE_H_
A triangle object.
Definition: triangle_3d.h:43
void SetUV(const SFVEC2F &aUV1, const SFVEC2F &aUV2, const SFVEC2F &aUV3)
float m_cnv
Definition: triangle_3d.h:80
float m_nu
Definition: triangle_3d.h:77
float m_cnu
Definition: triangle_3d.h:80
SFVEC2F m_uv[3]
Definition: triangle_3d.h:75
float m_bnv
Definition: triangle_3d.h:79
float m_nd
Definition: triangle_3d.h:77
float m_nv
Definition: triangle_3d.h:77
SFVEC3F GetDiffuseColor(const HITINFO &aHitInfo) const override
bool IntersectP(const RAY &aRay, float aMaxDistance) const override
bool Intersects(const BBOX_3D &aBBox) const override
SFVEC3F m_normal[3]
Definition: triangle_3d.h:72
unsigned int m_vertexColorRGBA[3]
Definition: triangle_3d.h:76
void SetColor(const SFVEC3F &aColor)
SFVEC3F m_vertex[3]
Definition: triangle_3d.h:73
SFVEC3F m_n
Definition: triangle_3d.h:74
bool Intersect(const RAY &aRay, HITINFO &aHitInfo) const override
void pre_calc_const()
Definition: triangle_3d.cpp:34
float m_bnu
Definition: triangle_3d.h:79
unsigned int m_k
Definition: triangle_3d.h:78
Manage a bounding box defined by two SFVEC3F min max points.
Definition: bbox_3d.h:43
Stores the hit information of a ray with a point on the surface of a object.
Definition: hitinfo.h:36
Definition: ray.h:63
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44