Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
8e7bc566
Commit
8e7bc566
authored
Mar 10, 2015
by
unknown
Committed by
jean-pierre charras
Mar 10, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3d viewer: fix current shading issues with some models.
parent
f87577ca
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
180 additions
and
81 deletions
+180
-81
3d_canvas.cpp
3d-viewer/3d_canvas.cpp
+1
-1
3d_draw.cpp
3d-viewer/3d_draw.cpp
+3
-10
3d_frame.cpp
3d-viewer/3d_frame.cpp
+16
-6
3d_mesh_model.cpp
3d-viewer/3d_mesh_model.cpp
+143
-59
3d_mesh_model.h
3d-viewer/3d_mesh_model.h
+3
-0
3d_toolbar.cpp
3d-viewer/3d_toolbar.cpp
+10
-3
3d_viewer_id.h
3d-viewer/3d_viewer_id.h
+2
-1
info3d_visu.h
3d-viewer/info3d_visu.h
+2
-1
No files found.
3d-viewer/3d_canvas.cpp
View file @
8e7bc566
...
@@ -563,7 +563,7 @@ void EDA_3D_CANVAS::InitGL()
...
@@ -563,7 +563,7 @@ void EDA_3D_CANVAS::InitGL()
void
EDA_3D_CANVAS
::
SetLights
()
void
EDA_3D_CANVAS
::
SetLights
()
{
{
// activate light. the source is above the xy plane, at source_pos
// activate light. the source is above the xy plane, at source_pos
GLfloat
source_pos
[
4
]
=
{
0.0
,
0.0
,
3
0.0
,
0.0
};
GLfloat
source_pos
[
4
]
=
{
0.0
,
0.0
,
100
0.0
,
0.0
};
GLfloat
light_color
[
4
];
// color of lights (RGBA values)
GLfloat
light_color
[
4
];
// color of lights (RGBA values)
light_color
[
3
]
=
1.0
;
light_color
[
3
]
=
1.0
;
...
...
3d-viewer/3d_draw.cpp
View file @
8e7bc566
...
@@ -343,14 +343,7 @@ void EDA_3D_CANVAS::Redraw()
...
@@ -343,14 +343,7 @@ void EDA_3D_CANVAS::Redraw()
glClearDepth
(
1.0
);
glClearDepth
(
1.0
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
|
GL_STENCIL_BUFFER_BIT
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
|
GL_STENCIL_BUFFER_BIT
);
if
(
isEnabled
(
FL_RENDER_SMOOTH
)
)
{
glShadeModel
(
GL_SMOOTH
);
glShadeModel
(
GL_SMOOTH
);
}
else
{
glShadeModel
(
GL_FLAT
);
}
// Draw background
// Draw background
glMatrixMode
(
GL_PROJECTION
);
glMatrixMode
(
GL_PROJECTION
);
...
...
3d-viewer/3d_frame.cpp
View file @
8e7bc566
...
@@ -54,7 +54,8 @@ static const wxChar keyShowRealisticMode[] = wxT( "ShowRealisticMode" );
...
@@ -54,7 +54,8 @@ static const wxChar keyShowRealisticMode[] = wxT( "ShowRealisticMode" );
static
const
wxChar
keyRenderShadows
[]
=
wxT
(
"Render_Shadows"
);
static
const
wxChar
keyRenderShadows
[]
=
wxT
(
"Render_Shadows"
);
static
const
wxChar
keyRenderRemoveHoles
[]
=
wxT
(
"Render_RemoveHoles"
);
static
const
wxChar
keyRenderRemoveHoles
[]
=
wxT
(
"Render_RemoveHoles"
);
static
const
wxChar
keyRenderTextures
[]
=
wxT
(
"Render_Textures"
);
static
const
wxChar
keyRenderTextures
[]
=
wxT
(
"Render_Textures"
);
static
const
wxChar
keyRenderSmooth
[]
=
wxT
(
"Render_Smooth"
);
static
const
wxChar
keyRenderSmoothNormals
[]
=
wxT
(
"Render_Smooth_Normals"
);
static
const
wxChar
keyRenderUseModelNormals
[]
=
wxT
(
"Render_Use_Model_Normals"
);
static
const
wxChar
keyRenderMaterial
[]
=
wxT
(
"Render_Material"
);
static
const
wxChar
keyRenderMaterial
[]
=
wxT
(
"Render_Material"
);
static
const
wxChar
keyShowAxis
[]
=
wxT
(
"ShowAxis"
);
static
const
wxChar
keyShowAxis
[]
=
wxT
(
"ShowAxis"
);
...
@@ -247,8 +248,11 @@ void EDA_3D_FRAME::LoadSettings( wxConfigBase* aCfg )
...
@@ -247,8 +248,11 @@ void EDA_3D_FRAME::LoadSettings( wxConfigBase* aCfg )
aCfg
->
Read
(
keyRenderTextures
,
&
tmp
,
false
);
aCfg
->
Read
(
keyRenderTextures
,
&
tmp
,
false
);
prms
.
SetFlag
(
FL_RENDER_TEXTURES
,
tmp
);
prms
.
SetFlag
(
FL_RENDER_TEXTURES
,
tmp
);
aCfg
->
Read
(
keyRenderSmooth
,
&
tmp
,
false
);
aCfg
->
Read
(
keyRenderSmoothNormals
,
&
tmp
,
false
);
prms
.
SetFlag
(
FL_RENDER_SMOOTH
,
tmp
);
prms
.
SetFlag
(
FL_RENDER_SMOOTH_NORMALS
,
tmp
);
aCfg
->
Read
(
keyRenderUseModelNormals
,
&
tmp
,
false
);
prms
.
SetFlag
(
FL_RENDER_USE_MODEL_NORMALS
,
tmp
);
aCfg
->
Read
(
keyRenderMaterial
,
&
tmp
,
false
);
aCfg
->
Read
(
keyRenderMaterial
,
&
tmp
,
false
);
prms
.
SetFlag
(
FL_RENDER_MATERIAL
,
tmp
);
prms
.
SetFlag
(
FL_RENDER_MATERIAL
,
tmp
);
...
@@ -312,7 +316,8 @@ void EDA_3D_FRAME::SaveSettings( wxConfigBase* aCfg )
...
@@ -312,7 +316,8 @@ void EDA_3D_FRAME::SaveSettings( wxConfigBase* aCfg )
aCfg
->
Write
(
keyRenderShadows
,
prms
.
GetFlag
(
FL_RENDER_SHADOWS
)
);
aCfg
->
Write
(
keyRenderShadows
,
prms
.
GetFlag
(
FL_RENDER_SHADOWS
)
);
aCfg
->
Write
(
keyRenderRemoveHoles
,
prms
.
GetFlag
(
FL_RENDER_SHOW_HOLES_IN_ZONES
)
);
aCfg
->
Write
(
keyRenderRemoveHoles
,
prms
.
GetFlag
(
FL_RENDER_SHOW_HOLES_IN_ZONES
)
);
aCfg
->
Write
(
keyRenderTextures
,
prms
.
GetFlag
(
FL_RENDER_TEXTURES
)
);
aCfg
->
Write
(
keyRenderTextures
,
prms
.
GetFlag
(
FL_RENDER_TEXTURES
)
);
aCfg
->
Write
(
keyRenderSmooth
,
prms
.
GetFlag
(
FL_RENDER_SMOOTH
)
);
aCfg
->
Write
(
keyRenderSmoothNormals
,
prms
.
GetFlag
(
FL_RENDER_SMOOTH_NORMALS
)
);
aCfg
->
Write
(
keyRenderUseModelNormals
,
prms
.
GetFlag
(
FL_RENDER_USE_MODEL_NORMALS
)
);
aCfg
->
Write
(
keyRenderMaterial
,
prms
.
GetFlag
(
FL_RENDER_MATERIAL
)
);
aCfg
->
Write
(
keyRenderMaterial
,
prms
.
GetFlag
(
FL_RENDER_MATERIAL
)
);
aCfg
->
Write
(
keyShowAxis
,
prms
.
GetFlag
(
FL_AXIS
)
);
aCfg
->
Write
(
keyShowAxis
,
prms
.
GetFlag
(
FL_AXIS
)
);
...
@@ -488,8 +493,13 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
...
@@ -488,8 +493,13 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
NewDisplay
(
GL_ID_TECH_LAYERS
);
NewDisplay
(
GL_ID_TECH_LAYERS
);
return
;
return
;
case
ID_MENU3D_FL_RENDER_SMOOTH
:
case
ID_MENU3D_FL_RENDER_SMOOTH_NORMALS
:
GetPrm3DVisu
().
SetFlag
(
FL_RENDER_SMOOTH
,
isChecked
);
GetPrm3DVisu
().
SetFlag
(
FL_RENDER_SMOOTH_NORMALS
,
isChecked
);
NewDisplay
();
return
;
case
ID_MENU3D_FL_RENDER_USE_MODEL_NORMALS
:
GetPrm3DVisu
().
SetFlag
(
FL_RENDER_USE_MODEL_NORMALS
,
isChecked
);
NewDisplay
();
NewDisplay
();
return
;
return
;
...
...
3d-viewer/3d_mesh_model.cpp
View file @
8e7bc566
...
@@ -40,6 +40,7 @@ S3D_MESH::S3D_MESH()
...
@@ -40,6 +40,7 @@ S3D_MESH::S3D_MESH()
isPerFaceNormalsComputed
=
false
;
isPerFaceNormalsComputed
=
false
;
isPointNormalizedComputed
=
false
;
isPointNormalizedComputed
=
false
;
isPerPointNormalsComputed
=
false
;
isPerPointNormalsComputed
=
false
;
isPerVertexNormalsVerified
=
false
;
m_Materials
=
NULL
;
m_Materials
=
NULL
;
childs
.
clear
();
childs
.
clear
();
...
@@ -91,10 +92,7 @@ void S3D_MESH::openGL_Render()
...
@@ -91,10 +92,7 @@ void S3D_MESH::openGL_Render()
//DBG( printf( "openGL_Render" ) );
//DBG( printf( "openGL_Render" ) );
bool
useMaterial
=
g_Parm_3D_Visu
.
GetFlag
(
FL_RENDER_MATERIAL
);
bool
useMaterial
=
g_Parm_3D_Visu
.
GetFlag
(
FL_RENDER_MATERIAL
);
bool
smoothShapes
=
g_Parm_3D_Visu
.
IsRealisticMode
()
bool
smoothShapes
=
g_Parm_3D_Visu
.
IsRealisticMode
()
&&
g_Parm_3D_Visu
.
GetFlag
(
FL_RENDER_SMOOTH
);
&&
g_Parm_3D_Visu
.
GetFlag
(
FL_RENDER_SMOOTH_NORMALS
);
if
(
m_Materials
)
m_Materials
->
SetOpenGLMaterial
(
0
,
useMaterial
);
if
(
m_CoordIndex
.
size
()
==
0
)
if
(
m_CoordIndex
.
size
()
==
0
)
return
;
return
;
...
@@ -109,19 +107,23 @@ void S3D_MESH::openGL_Render()
...
@@ -109,19 +107,23 @@ void S3D_MESH::openGL_Render()
calcPointNormalized
();
calcPointNormalized
();
calcPerFaceNormals
();
calcPerFaceNormals
();
if
(
m_PerVertexNormalsNormalized
.
size
()
==
0
)
{
if
(
smoothShapes
)
if
(
smoothShapes
)
{
if
(
(
m_PerVertexNormalsNormalized
.
size
()
>
0
)
&&
g_Parm_3D_Visu
.
GetFlag
(
FL_RENDER_USE_MODEL_NORMALS
)
)
perVertexNormalsVerify_and_Repair
();
else
calcPerPointNormals
();
calcPerPointNormals
();
}
}
for
(
unsigned
int
idx
=
0
;
idx
<
m_CoordIndex
.
size
();
idx
++
)
for
(
unsigned
int
idx
=
0
;
idx
<
m_CoordIndex
.
size
();
idx
++
)
{
{
if
(
m_MaterialIndex
.
size
()
>
1
)
if
(
m_MaterialIndex
.
size
()
==
0
)
{
m_Materials
->
SetOpenGLMaterial
(
0
,
useMaterial
);
else
if
(
m_Materials
)
if
(
m_Materials
)
m_Materials
->
SetOpenGLMaterial
(
m_MaterialIndex
[
idx
],
useMaterial
);
m_Materials
->
SetOpenGLMaterial
(
m_MaterialIndex
[
idx
],
useMaterial
);
}
switch
(
m_CoordIndex
[
idx
].
size
()
)
switch
(
m_CoordIndex
[
idx
].
size
()
)
...
@@ -138,18 +140,25 @@ void S3D_MESH::openGL_Render()
...
@@ -138,18 +140,25 @@ void S3D_MESH::openGL_Render()
}
}
if
(
m_PerVertexNormalsNormalized
.
size
()
>
0
)
if
(
smoothShapes
)
{
if
(
(
m_PerVertexNormalsNormalized
.
size
()
>
0
)
&&
g_Parm_3D_Visu
.
GetFlag
(
FL_RENDER_USE_MODEL_NORMALS
)
)
{
{
for
(
unsigned
int
ii
=
0
;
ii
<
m_CoordIndex
[
idx
].
size
();
ii
++
)
for
(
unsigned
int
ii
=
0
;
ii
<
m_CoordIndex
[
idx
].
size
();
ii
++
)
{
{
glm
::
vec3
normal
=
m_PerVertexNormalsNormalized
[
m_NormalIndex
[
idx
][
ii
]];
glm
::
vec3
normal
=
m_PerVertexNormalsNormalized
[
m_NormalIndex
[
idx
][
ii
]];
glNormal3fv
(
&
normal
.
x
);
glNormal3fv
(
&
normal
.
x
);
// Flag error vertices
if
((
normal
.
x
==
0.0
)
&&
(
normal
.
y
==
0.0
)
&&
(
normal
.
z
==
0.0
))
glColor3f
(
1.0
,
0.0
,
0.0
);
glm
::
vec3
point
=
m_Point
[
m_CoordIndex
[
idx
][
ii
]];
glm
::
vec3
point
=
m_Point
[
m_CoordIndex
[
idx
][
ii
]];
glVertex3fv
(
&
point
.
x
);
glVertex3fv
(
&
point
.
x
);
}
}
}
}
else
if
(
smoothShapes
)
else
{
{
std
::
vector
<
glm
::
vec3
>
normals_list
;
std
::
vector
<
glm
::
vec3
>
normals_list
;
normals_list
=
m_PerFaceVertexNormals
[
idx
];
normals_list
=
m_PerFaceVertexNormals
[
idx
];
...
@@ -159,23 +168,43 @@ void S3D_MESH::openGL_Render()
...
@@ -159,23 +168,43 @@ void S3D_MESH::openGL_Render()
glm
::
vec3
normal
=
normals_list
[
ii
];
glm
::
vec3
normal
=
normals_list
[
ii
];
glNormal3fv
(
&
normal
.
x
);
glNormal3fv
(
&
normal
.
x
);
// Flag error vertices
if
((
normal
.
x
==
0.0
)
&&
(
normal
.
y
==
0.0
)
&&
(
normal
.
z
==
0.0
))
glColor3f
(
1.0
,
0.0
,
0.0
);
glm
::
vec3
point
=
m_Point
[
m_CoordIndex
[
idx
][
ii
]];
glm
::
vec3
point
=
m_Point
[
m_CoordIndex
[
idx
][
ii
]];
glVertex3fv
(
&
point
.
x
);
glVertex3fv
(
&
point
.
x
);
}
}
}
}
}
else
else
{
{
// Flat
// Flat
if
(
m_PerFaceNormalsNormalized
.
size
()
>
0
)
{
glm
::
vec3
normal
=
m_PerFaceNormalsNormalized
[
idx
];
glm
::
vec3
normal
=
m_PerFaceNormalsNormalized
[
idx
];
for
(
unsigned
int
ii
=
0
;
ii
<
m_CoordIndex
[
idx
].
size
();
ii
++
)
for
(
unsigned
int
ii
=
0
;
ii
<
m_CoordIndex
[
idx
].
size
();
ii
++
)
{
{
glNormal3fv
(
&
normal
.
x
);
glNormal3fv
(
&
normal
.
x
);
// Flag error vertices
if
((
normal
.
x
==
0.0
)
&&
(
normal
.
y
==
0.0
)
&&
(
normal
.
z
==
0.0
))
glColor3f
(
1.0
,
0.0
,
0.0
);
glm
::
vec3
point
=
m_Point
[
m_CoordIndex
[
idx
][
ii
]];
glm
::
vec3
point
=
m_Point
[
m_CoordIndex
[
idx
][
ii
]];
glVertex3fv
(
&
point
.
x
);
glVertex3fv
(
&
point
.
x
);
}
}
}
}
else
{
for
(
unsigned
int
ii
=
0
;
ii
<
m_CoordIndex
[
idx
].
size
();
ii
++
)
{
glm
::
vec3
point
=
m_Point
[
m_CoordIndex
[
idx
][
ii
]];
glVertex3fv
(
&
point
.
x
);
}
}
}
glEnd
();
glEnd
();
}
}
...
@@ -184,6 +213,68 @@ void S3D_MESH::openGL_Render()
...
@@ -184,6 +213,68 @@ void S3D_MESH::openGL_Render()
}
}
void
S3D_MESH
::
perVertexNormalsVerify_and_Repair
()
{
if
(
isPerVertexNormalsVerified
==
true
)
return
;
isPerVertexNormalsVerified
=
true
;
//DBG( printf( "perVertexNormalsVerify_and_Repair\n" ) );
for
(
unsigned
int
idx
=
0
;
idx
<
m_PerVertexNormalsNormalized
.
size
();
idx
++
)
{
glm
::
vec3
normal
=
m_PerVertexNormalsNormalized
[
idx
];
if
(
(
normal
.
x
==
1.0
)
&&
((
normal
.
y
!=
0.0
)
||
(
normal
.
z
!=
0.0
))
)
{
normal
.
y
=
0.0
;
normal
.
z
=
0.0
;
}
else
if
(
(
normal
.
y
==
1.0
)
&&
((
normal
.
x
!=
0.0
)
||
(
normal
.
z
!=
0.0
))
)
{
normal
.
x
=
0.0
;
normal
.
z
=
0.0
;
}
else
if
(
(
normal
.
z
==
1.0
)
&&
((
normal
.
x
!=
0.0
)
||
(
normal
.
y
!=
0.0
))
)
{
normal
.
x
=
0.0
;
normal
.
y
=
0.0
;
}
else
if
(
(
normal
.
x
<
FLT_EPSILON
)
&&
(
normal
.
x
>
-
FLT_EPSILON
)
)
{
normal
.
x
=
0.0
;
}
else
if
(
(
normal
.
y
<
FLT_EPSILON
)
&&
(
normal
.
y
>
-
FLT_EPSILON
)
)
{
normal
.
y
=
0.0
;
}
else
if
(
(
normal
.
z
<
FLT_EPSILON
)
&&
(
normal
.
z
>
-
FLT_EPSILON
)
)
{
normal
.
z
=
0.0
;
}
float
l
=
glm
::
length
(
normal
);
if
(
l
>
FLT_EPSILON
)
// avoid division by zero
{
normal
=
normal
/
l
;
}
else
{
//DBG( printf( "idx:%u\n", idx ) );
}
m_PerVertexNormalsNormalized
[
idx
]
=
normal
;
}
}
void
S3D_MESH
::
calcPointNormalized
()
void
S3D_MESH
::
calcPointNormalized
()
{
{
//DBG( printf( "calcPointNormalized\n" ) );
//DBG( printf( "calcPointNormalized\n" ) );
...
@@ -193,13 +284,10 @@ void S3D_MESH::calcPointNormalized()
...
@@ -193,13 +284,10 @@ void S3D_MESH::calcPointNormalized()
isPointNormalizedComputed
=
true
;
isPointNormalizedComputed
=
true
;
if
(
m_PerVertexNormalsNormalized
.
size
()
>
0
)
return
;
m_PointNormalized
.
clear
();
m_PointNormalized
.
clear
();
float
biggerPoint
=
0.0
f
;
float
biggerPoint
=
0.0
f
;
for
(
unsigned
int
i
=
0
;
i
<
m_Point
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
m_Point
.
size
();
i
++
)
{
{
if
(
fabs
(
m_Point
[
i
].
x
)
>
biggerPoint
)
if
(
fabs
(
m_Point
[
i
].
x
)
>
biggerPoint
)
biggerPoint
=
fabs
(
m_Point
[
i
].
x
);
biggerPoint
=
fabs
(
m_Point
[
i
].
x
);
...
@@ -245,20 +333,17 @@ void S3D_MESH::calcPerFaceNormals()
...
@@ -245,20 +333,17 @@ void S3D_MESH::calcPerFaceNormals()
isPerFaceNormalsComputed
=
true
;
isPerFaceNormalsComputed
=
true
;
if
(
m_PerVertexNormalsNormalized
.
size
()
>
0
)
return
;
bool
haveAlreadyNormals_from_model_file
=
false
;
bool
haveAlreadyNormals_from_model_file
=
false
;
if
(
m_PerFaceNormalsNormalized
.
size
()
>
0
)
if
(
(
m_PerFaceNormalsNormalized
.
size
()
>
0
)
&&
g_Parm_3D_Visu
.
GetFlag
(
FL_RENDER_USE_MODEL_NORMALS
)
)
haveAlreadyNormals_from_model_file
=
true
;
haveAlreadyNormals_from_model_file
=
true
;
else
m_PerFaceNormalsNormalized
.
clear
();
m_PerFaceNormalsRaw
.
clear
();
m_PerFaceNormalsRaw
.
clear
();
m_PerFaceSquaredArea
.
clear
();
m_PerFaceSquaredArea
.
clear
();
//DBG( printf("m_CoordIndex.size %u\n", m_CoordIndex.size()) );
//DBG( printf("m_PointNormalized.size %u\n", m_PointNormalized.size()) );
// There are no points defined for the coordIndex
// There are no points defined for the coordIndex
if
(
m_PointNormalized
.
size
()
==
0
)
if
(
m_PointNormalized
.
size
()
==
0
)
{
{
...
@@ -273,13 +358,6 @@ void S3D_MESH::calcPerFaceNormals()
...
@@ -273,13 +358,6 @@ void S3D_MESH::calcPerFaceNormals()
glm
::
vec3
v1
=
m_PointNormalized
[
m_CoordIndex
[
idx
][
1
]];
glm
::
vec3
v1
=
m_PointNormalized
[
m_CoordIndex
[
idx
][
1
]];
glm
::
vec3
v2
=
m_PointNormalized
[
m_CoordIndex
[
idx
][
m_CoordIndex
[
idx
].
size
()
-
1
]];
glm
::
vec3
v2
=
m_PointNormalized
[
m_CoordIndex
[
idx
][
m_CoordIndex
[
idx
].
size
()
-
1
]];
/*
// !TODO: improove and check what is best to calc the normal (check what have more resolution)
glm::vec3 v0 = m_Point[m_CoordIndex[idx][0]];
glm::vec3 v1 = m_Point[m_CoordIndex[idx][1]];
glm::vec3 v2 = m_Point[m_CoordIndex[idx][m_CoordIndex[idx].size() - 1]];
*/
glm
::
vec3
cross_prod
;
glm
::
vec3
cross_prod
;
/*
/*
...
@@ -317,11 +395,11 @@ void S3D_MESH::calcPerFaceNormals()
...
@@ -317,11 +395,11 @@ void S3D_MESH::calcPerFaceNormals()
}
}
else
else
{
{
//
Cannot calc normal
//
DBG( printf( "Cannot calc normal idx: %u", idx ) );
if
(
(
cross_prod
.
x
>
cross_prod
.
y
)
&&
(
cross_prod
.
x
>
cross_prod
.
z
)
)
if
(
(
cross_prod
.
x
>
cross_prod
.
y
)
&&
(
cross_prod
.
x
>
cross_prod
.
z
)
)
{
{
cross_prod
.
x
=
1
.0
;
cross_prod
.
x
=
0
.0
;
cross_prod
.
y
=
0
.0
;
cross_prod
.
y
=
1
.0
;
cross_prod
.
z
=
0.0
;
cross_prod
.
z
=
0.0
;
}
}
else
if
(
(
cross_prod
.
y
>
cross_prod
.
x
)
&&
(
cross_prod
.
y
>
cross_prod
.
z
)
)
else
if
(
(
cross_prod
.
y
>
cross_prod
.
x
)
&&
(
cross_prod
.
y
>
cross_prod
.
z
)
)
...
@@ -355,9 +433,6 @@ void S3D_MESH::calcPerPointNormals()
...
@@ -355,9 +433,6 @@ void S3D_MESH::calcPerPointNormals()
isPerPointNormalsComputed
=
true
;
isPerPointNormalsComputed
=
true
;
if
(
m_PerVertexNormalsNormalized
.
size
()
>
0
)
return
;
m_PerFaceVertexNormals
.
clear
();
m_PerFaceVertexNormals
.
clear
();
// Pre-allocate space for the entire vector of vertex normals so we can do parallel writes
// Pre-allocate space for the entire vector of vertex normals so we can do parallel writes
...
@@ -389,9 +464,18 @@ void S3D_MESH::calcPerPointNormals()
...
@@ -389,9 +464,18 @@ void S3D_MESH::calcPerPointNormals()
//if A != B { // ignore self
//if A != B { // ignore self
if
(
each_face_A_idx
!=
each_face_B_idx
)
if
(
each_face_A_idx
!=
each_face_B_idx
)
{
{
if
(
(
m_CoordIndex
[
each_face_B_idx
][
0
]
==
vertexIndex
)
bool
addThisVertex
=
false
;
||
(
m_CoordIndex
[
each_face_B_idx
][
1
]
==
vertexIndex
)
||
(
m_CoordIndex
[
each_face_B_idx
][
2
]
==
vertexIndex
)
)
for
(
unsigned
int
ii
=
0
;
ii
<
m_CoordIndex
[
each_face_B_idx
].
size
();
ii
++
)
{
if
(
m_CoordIndex
[
each_face_B_idx
][
ii
]
==
vertexIndex
)
{
addThisVertex
=
true
;
break
;
}
}
if
(
addThisVertex
)
{
{
glm
::
vec3
vector_face_B
=
m_PerFaceNormalsNormalized
[
each_face_B_idx
];
glm
::
vec3
vector_face_B
=
m_PerFaceNormalsNormalized
[
each_face_B_idx
];
...
...
3d-viewer/3d_mesh_model.h
View file @
8e7bc566
...
@@ -95,6 +95,9 @@ private:
...
@@ -95,6 +95,9 @@ private:
bool
isPerPointNormalsComputed
;
bool
isPerPointNormalsComputed
;
void
calcPerPointNormals
();
void
calcPerPointNormals
();
bool
isPerVertexNormalsVerified
;
void
perVertexNormalsVerify_and_Repair
();
};
};
...
...
3d-viewer/3d_toolbar.cpp
View file @
8e7bc566
...
@@ -175,10 +175,14 @@ void EDA_3D_FRAME::CreateMenuBar()
...
@@ -175,10 +175,14 @@ void EDA_3D_FRAME::CreateMenuBar()
_
(
"Apply a grid/cloud textures to Board, Solder Mask and Silkscreen"
),
_
(
"Apply a grid/cloud textures to Board, Solder Mask and Silkscreen"
),
KiBitmap
(
green_xpm
),
wxITEM_CHECK
);
KiBitmap
(
green_xpm
),
wxITEM_CHECK
);
AddMenuItem
(
renderOptionsMenu
,
ID_MENU3D_FL_RENDER_SMOOTH
,
AddMenuItem
(
renderOptionsMenu
,
ID_MENU3D_FL_RENDER_SMOOTH
_NORMALS
,
_
(
"Render Smooth Normals"
),
_
(
"Render Smooth Normals"
),
KiBitmap
(
green_xpm
),
wxITEM_CHECK
);
KiBitmap
(
green_xpm
),
wxITEM_CHECK
);
AddMenuItem
(
renderOptionsMenu
,
ID_MENU3D_FL_RENDER_USE_MODEL_NORMALS
,
_
(
"Use Model Normals"
),
KiBitmap
(
green_xpm
),
wxITEM_CHECK
);
AddMenuItem
(
renderOptionsMenu
,
ID_MENU3D_FL_RENDER_MATERIAL
,
AddMenuItem
(
renderOptionsMenu
,
ID_MENU3D_FL_RENDER_MATERIAL
,
_
(
"Render Material Properties"
),
_
(
"Render Material Properties"
),
KiBitmap
(
green_xpm
),
wxITEM_CHECK
);
KiBitmap
(
green_xpm
),
wxITEM_CHECK
);
...
@@ -287,8 +291,11 @@ void EDA_3D_FRAME::SetMenuBarOptionsState()
...
@@ -287,8 +291,11 @@ void EDA_3D_FRAME::SetMenuBarOptionsState()
item
=
menuBar
->
FindItem
(
ID_MENU3D_FL_RENDER_TEXTURES
);
item
=
menuBar
->
FindItem
(
ID_MENU3D_FL_RENDER_TEXTURES
);
item
->
Check
(
GetPrm3DVisu
().
GetFlag
(
FL_RENDER_TEXTURES
)
);
item
->
Check
(
GetPrm3DVisu
().
GetFlag
(
FL_RENDER_TEXTURES
)
);
item
=
menuBar
->
FindItem
(
ID_MENU3D_FL_RENDER_SMOOTH
);
item
=
menuBar
->
FindItem
(
ID_MENU3D_FL_RENDER_SMOOTH_NORMALS
);
item
->
Check
(
GetPrm3DVisu
().
GetFlag
(
FL_RENDER_SMOOTH
)
);
item
->
Check
(
GetPrm3DVisu
().
GetFlag
(
FL_RENDER_SMOOTH_NORMALS
)
);
item
=
menuBar
->
FindItem
(
ID_MENU3D_FL_RENDER_USE_MODEL_NORMALS
);
item
->
Check
(
GetPrm3DVisu
().
GetFlag
(
FL_RENDER_USE_MODEL_NORMALS
)
);
item
=
menuBar
->
FindItem
(
ID_MENU3D_FL_RENDER_MATERIAL
);
item
=
menuBar
->
FindItem
(
ID_MENU3D_FL_RENDER_MATERIAL
);
item
->
Check
(
GetPrm3DVisu
().
GetFlag
(
FL_RENDER_MATERIAL
)
);
item
->
Check
(
GetPrm3DVisu
().
GetFlag
(
FL_RENDER_MATERIAL
)
);
...
...
3d-viewer/3d_viewer_id.h
View file @
8e7bc566
...
@@ -49,7 +49,8 @@ enum id_3dview_frm
...
@@ -49,7 +49,8 @@ enum id_3dview_frm
ID_MENU3D_FL_RENDER_SHADOWS
,
ID_MENU3D_FL_RENDER_SHADOWS
,
ID_MENU3D_FL_RENDER_SHOW_HOLES_IN_ZONES
,
ID_MENU3D_FL_RENDER_SHOW_HOLES_IN_ZONES
,
ID_MENU3D_FL_RENDER_TEXTURES
,
ID_MENU3D_FL_RENDER_TEXTURES
,
ID_MENU3D_FL_RENDER_SMOOTH
,
ID_MENU3D_FL_RENDER_SMOOTH_NORMALS
,
ID_MENU3D_FL_RENDER_USE_MODEL_NORMALS
,
ID_MENU3D_FL_RENDER_MATERIAL
,
ID_MENU3D_FL_RENDER_MATERIAL
,
ID_END_COMMAND_3D
,
ID_END_COMMAND_3D
,
...
...
3d-viewer/info3d_visu.h
View file @
8e7bc566
...
@@ -75,7 +75,8 @@ enum DISPLAY3D_FLG {
...
@@ -75,7 +75,8 @@ enum DISPLAY3D_FLG {
FL_RENDER_SHADOWS
,
FL_RENDER_SHADOWS
,
FL_RENDER_SHOW_HOLES_IN_ZONES
,
FL_RENDER_SHOW_HOLES_IN_ZONES
,
FL_RENDER_TEXTURES
,
FL_RENDER_TEXTURES
,
FL_RENDER_SMOOTH
,
FL_RENDER_SMOOTH_NORMALS
,
FL_RENDER_USE_MODEL_NORMALS
,
FL_RENDER_MATERIAL
,
FL_RENDER_MATERIAL
,
FL_LAST
FL_LAST
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment