Commit cce1e8d4 authored by Maire Nicolas's avatar Maire Nicolas

Rajout d'une option zigzag dans un des presets animés.

parent c208a805
......@@ -447,6 +447,7 @@ void Clipping::slot_pushButton_applyAnimatedClippingPreset()
double size = (double)m_bb.maxSize()*0.1;
int axis = 0;
bool facing = false;
bool zigzag = false;
if (inputValues(VarDbl(centerStartX - 100.0, centerStartX + 100.0, centerStartX, "Center Start X",
VarDbl(centerStartY - 100.0, centerStartY + 100.0, centerStartY, "Center Start Y",
VarDbl(centerStartZ - 100.0, centerStartZ + 100.0, centerStartZ, "Center Start Z",
......@@ -455,11 +456,12 @@ void Clipping::slot_pushButton_applyAnimatedClippingPreset()
VarDbl(centerEndZ - 100.0, centerEndZ + 100.0, centerEndZ, "Center End Z",
VarDbl(size - 100.0, size + 100.0, size, "Size",
VarSlider(0, 2, axis, "Axis",
VarBool(facing, "Facing"
))))))))), "Preset Setup"))
VarBool(facing, "Facing",
VarBool(zigzag, "Zigzag"
)))))))))), "Preset Setup"))
preset = new Utils::ClippingPresetAnimatedDualPlanes(
Geom::Vec3f((float)centerStartX, (float)centerStartY, (float)centerStartZ), Geom::Vec3f((float)centerEndX, (float)centerEndY, (float)centerEndZ),
(float)size, axis, facing);
(float)size, axis, facing, zigzag);
animatedPreset = preset;
}
......
......@@ -127,9 +127,10 @@ public :
* @param size distance between planes
* @param axis axis on which planes are aligned (0 for x, 1 for y, 2 for z)
* @param facing true means having facing planes
* @param zigzag true to enable zigzag mode
*/
ClippingPresetAnimatedDualPlanes(
Geom::Vec3f centerStart, Geom::Vec3f centerEnd, float size, int axis, bool facing);
Geom::Vec3f centerStart, Geom::Vec3f centerEnd, float size, int axis, bool facing, bool zigzag);
/**
* runs the animation some steps further
......@@ -148,6 +149,9 @@ private :
/// end point of the animation
Geom::Vec3f m_endPoint;
/// zigzag mode ?
bool m_zigzag;
};
......
......@@ -65,13 +65,14 @@ void ClippingPresetAnimated::apply(ClippingShader* clipShader, std::vector<unsig
ClippingPresetAnimatedDualPlanes::ClippingPresetAnimatedDualPlanes(
Geom::Vec3f centerStart, Geom::Vec3f centerEnd, float size, int axis, bool facing)
Geom::Vec3f centerStart, Geom::Vec3f centerEnd, float size, int axis, bool facing, bool zigzag)
{
// Store the animation settings
m_dirVec = centerEnd - centerStart;
m_dirVec.normalize();
m_startPoint = centerStart;
m_endPoint = centerEnd;
m_zigzag = zigzag;
// Correct axis if necessary
if ((axis < 0) || (axis > 2))
......@@ -123,10 +124,29 @@ void ClippingPresetAnimatedDualPlanes::step(unsigned int amount)
// Update animation parameter value
m_animParam += (float)amount * m_animationOneStepIncrement * m_animationSpeedFactor;
while (m_animParam < 0.0f)
m_animParam += 1.0f;
while (m_animParam > 1.0f)
m_animParam -= 1.0f;
if (!m_zigzag)
{
while (m_animParam < 0.0f)
m_animParam += 1.0f;
while (m_animParam > 1.0f)
m_animParam -= 1.0f;
}
else
{
while ( (m_animParam < 0.0f) || (m_animParam > 1.0f) )
{
if (m_animParam < 0.0f)
{
m_animParam = -m_animParam;
m_animationOneStepIncrement = -m_animationOneStepIncrement;
}
else if (m_animParam > 1.0f)
{
m_animParam = 1.0f - (m_animParam - 1.0f);
m_animationOneStepIncrement = -m_animationOneStepIncrement;
}
}
}
// Calculate new center
Geom::Vec3f newCenter = (1.0f - m_animParam)*m_startPoint + m_animParam*m_endPoint;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment