Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CGoGN
CGoGN
Commits
e616076c
Commit
e616076c
authored
Jul 22, 2011
by
Maire Nicolas
Browse files
Merge branch 'master' of cgogn:~cgogn/CGoGN
parents
24437f2d
b36a3172
Changes
6
Hide whitespace changes
Inline
Side-by-side
include/Geometry/matrix.h
View file @
e616076c
...
...
@@ -120,6 +120,9 @@ class Matrix
// Matrix / Scalar multiplication
Matrix
<
M
,
N
,
T
>
operator
*
(
T
s
)
const
;
// Matrix / Scalar division
Matrix
<
M
,
N
,
T
>
operator
/
(
T
s
)
const
;
/**********************************************/
/* UTILITY FUNCTIONS */
/**********************************************/
...
...
include/Geometry/matrix.hpp
View file @
e616076c
...
...
@@ -299,6 +299,16 @@ Matrix<M,N,T> Matrix<M,N,T>::operator*(T s) const
return
res
;
}
template
<
unsigned
int
M
,
unsigned
int
N
,
typename
T
>
Matrix
<
M
,
N
,
T
>
Matrix
<
M
,
N
,
T
>::
operator
/
(
T
s
)
const
{
Matrix
<
M
,
N
,
T
>
res
;
for
(
unsigned
int
i
=
0
;
i
<
M
;
++
i
)
for
(
unsigned
int
j
=
0
;
j
<
N
;
++
j
)
res
(
i
,
j
)
=
m_data
[
i
][
j
]
/
s
;
return
res
;
}
/**********************************************/
/* UTILITY FUNCTIONS */
/**********************************************/
...
...
include/Utils/frameManipulator.h
View file @
e616076c
...
...
@@ -182,28 +182,11 @@ public:
*/
void
lockPicking
(
unsigned
int
axis
);
/// lock translations for picking only
void
lockPickingTranslations
();
/// lock rotations for picking only
void
lockPickingRotations
();
/// lock scales for picking only
void
lockPickingScales
();
/**
* unlock an axis (only for pinking)
*/
void
unlockPicking
(
unsigned
int
axis
);
/// unlock translations for picking only
void
unlockPickingTranslations
();
/// unlock rotations for picking only
void
unlockPickingRotations
();
/// unlock scales for picking only
void
unlockPickingScales
();
/**
* is an axis locked (only for pinking)
*/
...
...
@@ -234,9 +217,6 @@ public:
*/
void
scale
(
unsigned
int
axis
,
float
sc
);
/**
* get the matrix transformation
*/
...
...
include/Utils/pickables.h
View file @
e616076c
...
...
@@ -429,7 +429,7 @@ public:
* @param par number of parallels
* @param mer number of meridians
*/
IcoSphere
(
unsigned
int
sub
=
1
);
IcoSphere
(
unsigned
int
sub
=
5
);
/**
...
...
src/Utils/frameManipulator.cpp
View file @
e616076c
...
...
@@ -135,12 +135,15 @@ FrameManipulator::FrameManipulator():
void
FrameManipulator
::
setSize
(
float
radius
)
{
m_scaleRendering
=
radius
;
if
(
m_scaleRendering
>
0.0
f
)
m_scaleRendering
=
radius
;
}
void
FrameManipulator
::
addSize
(
float
radius
)
{
m_scaleRendering
+=
radius
;
if
(
m_scaleRendering
<=
0.0
f
)
m_scaleRendering
-=
radius
;
}
float
FrameManipulator
::
getSize
()
...
...
@@ -186,10 +189,17 @@ void FrameManipulator::draw()
glDrawArrays
(
GL_TRIANGLE_STRIP
,
4
*
nb_segments
+
4
,
2
*
nb_segments
+
2
);
}
if
((
!
m_locked_axis
[
CENTER
])
&&
(
m_highlighted
==
CENTER
))
{
glLineWidth
(
6.0
f
);
m_shader
->
setColor
(
Geom
::
Vec4f
(
1.0
f
,
1.0
f
,
0.0
f
,
0.0
f
));
glDrawArrays
(
GL_LINES
,
6
*
nb_segments
+
6
,
6
);
}
else
{
if
(
!
m_locked_axis
[
Xs
])
{
if
((
m_highlighted
==
CENTER
)
||
(
m_highlighted
==
Xs
)
)
if
(
m_highlighted
==
Xs
)
{
glLineWidth
(
6.0
f
);
m_shader
->
setColor
(
Geom
::
Vec4f
(
1.0
f
,
1.0
f
,
0.0
f
,
0.0
f
));
...
...
@@ -204,7 +214,7 @@ void FrameManipulator::draw()
if
(
!
m_locked_axis
[
Ys
])
{
if
((
m_highlighted
==
CENTER
)
||
(
m_highlighted
==
Ys
)
)
if
(
m_highlighted
==
Ys
)
{
glLineWidth
(
6.0
f
);
m_shader
->
setColor
(
Geom
::
Vec4f
(
1.0
f
,
1.0
f
,
0.0
f
,
0.0
f
));
...
...
@@ -219,7 +229,7 @@ void FrameManipulator::draw()
if
(
!
m_locked_axis
[
Zs
])
{
if
((
m_highlighted
==
CENTER
)
||
(
m_highlighted
==
Zs
)
)
if
(
m_highlighted
==
Zs
)
{
glLineWidth
(
6.0
f
);
m_shader
->
setColor
(
Geom
::
Vec4f
(
1.0
f
,
1.0
f
,
0.0
f
,
0.0
f
));
...
...
@@ -231,6 +241,8 @@ void FrameManipulator::draw()
}
glDrawArrays
(
GL_LINES
,
6
*
nb_segments
+
10
,
2
);
}
}
if
(
!
m_locked_axis
[
Xt
])
{
...
...
@@ -312,13 +324,17 @@ unsigned int FrameManipulator::pick(const Geom::Vec3f& PP, const Geom::Vec3f& VV
// intersection possible between line and frame (10% margin)?
float
dist2
=
Geom
::
squaredDistanceLine2Point
<
Geom
::
Vec3f
>
(
P
,
V
,
V
*
V
,
origin
);
if
(
dist2
>
(
1.05
))
float
distMax
=
std
::
max
(
m_lengthAxes
[
0
],
std
::
max
(
m_lengthAxes
[
1
],
m_lengthAxes
[
2
]));
distMax
*=
3.6
f
;
distMax
=
std
::
max
(
distMax
,
1.0
f
+
ring_half_width
);
if
(
dist2
>
distMax
*
distMax
)
return
NONE
;
// click on center
if
(
dist2
<
0.02
f
*
0.02
f
)
{
// if (! m_locked_axis[CENTER])
if
(
axisPickable
(
CENTER
))
return
CENTER
;
else
...
...
@@ -384,42 +400,57 @@ unsigned int FrameManipulator::pick(const Geom::Vec3f& PP, const Geom::Vec3f& VV
if
(
axisPickable
(
Xt
)
||
axisPickable
(
Xs
))
{
Geom
::
Vec3f
PX
(
1.0
f
,
0.0
f
,
0.0
f
);
Geom
::
Vec3f
PX
(
3.6
f
*
m_lengthAxes
[
0
]
,
0.0
f
,
0.0
f
);
dist_target
[
0
]
=
sqrt
(
Geom
::
squaredDistanceLine2Seg
(
P
,
V
,
V
*
V
,
origin
,
PX
))
;
if
(
fabs
(
dist_target
[
0
])
<
0.02
f
)
{
if
(
(
Qz
-
origin
).
norm
()
>
m_lengthAxes
[
0
]
)
if
(
axisPickable
(
Xt
)
&&
!
axisPickable
(
Xs
)
)
dist_cam
[
0
]
=
(
P
-
PX
)
*
(
P
-
PX
);
else
dist_cam
[
6
]
=
(
P
-
origin
)
*
(
P
-
origin
);
{
if
(
Qz
.
norm
()
>
m_lengthAxes
[
0
])
dist_cam
[
0
]
=
(
P
-
PX
)
*
(
P
-
PX
);
else
dist_cam
[
6
]
=
P
*
P
;
}
}
}
if
(
axisPickable
(
Yt
)
||
axisPickable
(
Ys
))
{
Geom
::
Vec3f
PY
(
0.0
f
,
1.0
f
,
0.0
f
);
Geom
::
Vec3f
PY
(
0.0
f
,
3.6
f
*
m_lengthAxes
[
1
]
,
0.0
f
);
dist_target
[
1
]
=
sqrt
(
Geom
::
squaredDistanceLine2Seg
(
P
,
V
,
V
*
V
,
origin
,
PY
))
;
if
(
fabs
(
dist_target
[
1
])
<
0.02
f
)
if
(
fabs
(
dist_target
[
1
])
<
0.02
f
)
{
if
(
(
Qz
-
origin
).
norm
()
>
m_lengthAxes
[
1
]
)
if
(
axisPickable
(
Yt
)
&&
!
axisPickable
(
Ys
)
)
dist_cam
[
1
]
=
(
P
-
PY
)
*
(
P
-
PY
);
else
dist_cam
[
7
]
=
(
P
-
origin
)
*
(
P
-
origin
);
{
if
(
Qz
.
norm
()
>
m_lengthAxes
[
1
])
dist_cam
[
1
]
=
(
P
-
PY
)
*
(
P
-
PY
);
else
dist_cam
[
7
]
=
P
*
P
;
}
}
}
if
(
axisPickable
(
Zt
)
||
axisPickable
(
Zs
))
{
Geom
::
Vec3f
PZ
(
0.0
f
,
0.0
f
,
1.0
f
);
Geom
::
Vec3f
PZ
(
0.0
f
,
0.0
f
,
3.6
f
*
m_lengthAxes
[
2
]
);
dist_target
[
2
]
=
sqrt
(
Geom
::
squaredDistanceLine2Seg
(
P
,
V
,
V
*
V
,
origin
,
PZ
));
if
(
fabs
(
dist_target
[
2
])
<
0.02
f
)
{
if
(
(
Qx
-
origin
).
norm
()
>
m_lengthAxes
[
2
]
)
if
(
axisPickable
(
Zt
)
&&
!
axisPickable
(
Zs
)
)
dist_cam
[
2
]
=
(
P
-
PZ
)
*
(
P
-
PZ
);
else
dist_cam
[
8
]
=
(
P
-
origin
)
*
(
P
-
origin
);
{
if
(
Qx
.
norm
()
>
m_lengthAxes
[
2
])
dist_cam
[
2
]
=
(
P
-
PZ
)
*
(
P
-
PZ
);
else
dist_cam
[
8
]
=
P
*
P
;
}
}
}
...
...
@@ -482,7 +513,7 @@ void FrameManipulator::setLengthAxes()
ind
+=
7
;
positions
[
ind
]
=
0.23
f
*
sc2
;
ind
++
;
if
(
m_locked_axis
[
Xs
])
if
(
(
m_locked_axis
[
Xs
])
&&
(
m_highlighted
!=
CENTER
))
positions
[
ind
]
=
0.0
f
;
else
positions
[
ind
]
=
0.27
f
*
sc0
;
...
...
@@ -503,7 +534,7 @@ void FrameManipulator::setLengthAxes()
positions
[
ind
]
=
le
;
ind
+=
4
;
if
(
m_locked_axis
[
Ys
])
if
(
(
m_locked_axis
[
Ys
])
&&
(
m_highlighted
!=
CENTER
))
positions
[
ind
]
=
0.0
f
;
else
positions
[
ind
]
=
0.27
f
*
sc1
;
...
...
@@ -524,7 +555,7 @@ void FrameManipulator::setLengthAxes()
positions
[
ind
]
=
le
;
ind
+=
4
;
if
(
m_locked_axis
[
Zs
])
if
(
(
m_locked_axis
[
Zs
])
&&
(
m_highlighted
!=
CENTER
))
positions
[
ind
]
=
0.0
f
;
else
positions
[
ind
]
=
0.27
f
*
sc2
;
...
...
src/Utils/pickables.cpp
View file @
e616076c
...
...
@@ -112,6 +112,7 @@ void Pickable::draw()
Utils
::
GLSLShader
::
updateCurrentMatrices
();
m_drawable
->
draw
();
Utils
::
GLSLShader
::
currentTransfo
()
=
store
;
Utils
::
GLSLShader
::
updateCurrentMatrices
();
}
...
...
@@ -310,6 +311,10 @@ Sphere::Sphere(unsigned int par, unsigned int mer)
void
Sphere
::
changeTopo
(
unsigned
int
parp
,
unsigned
int
mer
)
{
if
(
parp
<
2
)
parp
=
2
;
if
(
mer
<
2
)
mer
=
2
;
// to obtain right number of slice
unsigned
int
par
=
parp
-
1
;
...
...
@@ -438,6 +443,11 @@ Cone::Cone(unsigned int par, unsigned int mer)
void
Cone
::
changeTopo
(
unsigned
int
par
,
unsigned
int
mer
)
{
if
(
par
<
2
)
par
=
2
;
if
(
mer
<
2
)
mer
=
2
;
unsigned
int
merfactor
=
1
;
if
(
mer
<
8
)
...
...
@@ -558,10 +568,14 @@ Cylinder::Cylinder(unsigned int par, unsigned int mer)
void
Cylinder
::
changeTopo
(
unsigned
int
parp
,
unsigned
int
mer
)
{
if
(
parp
<
2
)
parp
=
2
;
if
(
mer
<
2
)
mer
=
2
;
// to obtain right number of slice (with almost same code as sphere)
unsigned
int
par
=
parp
+
1
;
unsigned
int
merfactor
=
1
;
if
(
mer
<
8
)
...
...
@@ -865,6 +879,8 @@ void IcoSphere::subdivide(std::vector<unsigned int>& triangles, std::vector<Geom
void
IcoSphere
::
changeTopo
(
unsigned
int
sub
)
{
if
(
sub
<
2
)
sub
=
2
;
int
subd
=
int
(
log
(
sub
/
2
)
/
log
(
2.0
))
-
1
;
if
(
subd
<
0
)
subd
=
0
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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