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