Commit 2b0a7d41 authored by Maire Nicolas's avatar Maire Nicolas

Gestion du clipping 'inverse' par sphère avec rayon négatif.

Gestion du et/ou clipping, et ajout de l'option dans l'interface Qt de stage_shader.
parent 0c2544c8
......@@ -163,12 +163,6 @@ void StageShader::slot_doubleSpinBox_PlaneOrigin(double c)
}
}
void StageShader::slot_doubleSpinBox_ColorAttenuationFactor(double c)
{
m_shader->setClipColorAttenuationFactor((float)c);
updateGL();
}
void StageShader::slot_doubleSpinBox_GridDisplaySize(double c)
{
m_shader->setClipPlanesDisplaySize((float)c);
......@@ -206,7 +200,7 @@ void StageShader::slot_pushButton_addSphere()
std::string indexStr;
std::stringstream ss;
ss << (dock.comboBox_PlaneIndex->count() + 1);
ss << (dock.comboBox_SphereIndex->count() + 1);
indexStr = ss.str();
std::string str = "Sphere " + indexStr;
......@@ -287,6 +281,25 @@ void StageShader::slot_doubleSpinBox_SphereGridColor(double c)
updateGL();
}
void StageShader::slot_doubleSpinBox_ColorAttenuationFactor(double c)
{
m_shader->setClipColorAttenuationFactor((float)c);
updateGL();
}
void StageShader::slot_horizontalSlider_ClippingMode(int i)
{
if (i == 0)
m_shader->setClipMode(Utils::ClippingShader::CLIPPING_MODE_AND);
else if (i == 1)
m_shader->setClipMode(Utils::ClippingShader::CLIPPING_MODE_OR);
dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
updateGLMatrices();
}
void StageShader::button_compile()
{
QString st1 = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->vertexEdit->toPlainText();
......@@ -351,7 +364,6 @@ void StageShader::initGUI()
setCallBack(dock.doubleSpinBox_PlaneOriginy, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_PlaneOrigin(double)));
setCallBack(dock.doubleSpinBox_PlaneOriginz, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_PlaneOrigin(double)));
setCallBack(dock.doubleSpinBox_ColorAttenuationFactor, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_ColorAttenuationFactor(double)));
setCallBack(dock.doubleSpinBox_GridDisplaySize, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_GridDisplaySize(double)));
setCallBack(dock.spinBox_GridResolutionX, SIGNAL(valueChanged(int)), SLOT(slot_spinBox_GridResolutionX(int)));
setCallBack(dock.spinBox_GridResolutionY, SIGNAL(valueChanged(int)), SLOT(slot_spinBox_GridResolutionY(int)));
......@@ -364,7 +376,6 @@ void StageShader::initGUI()
dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
dock.doubleSpinBox_ColorAttenuationFactor->setValue(m_shader->getClipColorAttenuationFactor());
dock.doubleSpinBox_GridDisplaySize->setValue(m_shader->getClipPlanesDisplaySize());
dock.spinBox_GridResolutionX->setValue(m_shader->getClipPlanesDisplayXRes());
dock.spinBox_GridResolutionY->setValue(m_shader->getClipPlanesDisplayYRes());
......@@ -399,6 +410,18 @@ void StageShader::initGUI()
dock.doubleSpinBox_SphereGridColorG->setValue(spheresCol[1]);
dock.doubleSpinBox_SphereGridColorB->setValue(spheresCol[2]);
setCallBack(dock.doubleSpinBox_ColorAttenuationFactor, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_ColorAttenuationFactor(double)));
setCallBack(dock.horizontalSlider_ClippingMode, SIGNAL(valueChanged(int)), SLOT(slot_horizontalSlider_ClippingMode(int)));
dock.doubleSpinBox_ColorAttenuationFactor->setValue(m_shader->getClipColorAttenuationFactor());
Utils::ClippingShader::clippingMode clipMode = m_shader->getClipMode();
if (clipMode == Utils::ClippingShader::CLIPPING_MODE_AND)
dock.horizontalSlider_ClippingMode->setValue(0);
else if (clipMode == Utils::ClippingShader::CLIPPING_MODE_OR)
dock.horizontalSlider_ClippingMode->setValue(1);
}
void StageShader::cb_Open()
......
......@@ -133,7 +133,6 @@ public slots:
void slot_doubleSpinBox_PlaneVec2(double c);
void slot_doubleSpinBox_PlaneOrigin(double c);
void slot_doubleSpinBox_ColorAttenuationFactor(double c);
void slot_doubleSpinBox_GridDisplaySize(double c);
void slot_spinBox_GridResolutionX(int i);
void slot_spinBox_GridResolutionY(int i);
......@@ -151,6 +150,9 @@ public slots:
void slot_spinBox_SphereGridResolutionY(int i);
void slot_doubleSpinBox_SphereGridColor(double c);
void slot_doubleSpinBox_ColorAttenuationFactor(double c);
void slot_horizontalSlider_ClippingMode(int i);
void button_compile();
};
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>424</width>
<height>534</height>
<height>501</height>
</rect>
</property>
<property name="allowedAreas">
......@@ -34,7 +34,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget_3">
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_Object">
<attribute name="title">
......@@ -201,9 +201,9 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_Clipping">
<widget class="QWidget" name="tab_PlaneClipping">
<attribute name="title">
<string>Plane Clipping</string>
<string>Plane Clip</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
......@@ -219,7 +219,7 @@
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout_12">
<item row="3" column="2">
<item row="2" column="2">
<widget class="QDoubleSpinBox" name="doubleSpinBox_GridColorG">
<property name="maximum">
<double>1.000000000000000</double>
......@@ -229,59 +229,42 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="1" column="0">
<widget class="QLabel" name="label_GridResolution">
<property name="text">
<string>Res.</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_ColorAttenuationFactor">
<property name="text">
<string>Color Att.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="1" column="1">
<widget class="QSpinBox" name="spinBox_GridResolutionX">
<property name="maximum">
<number>200</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_ColorAttenuationFactor">
<property name="singleStep">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_GridColor">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_GridDisplaySize">
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="0" column="0">
<widget class="QLabel" name="label_GridSize">
<property name="text">
<string>Size</string>
</property>
</widget>
</item>
<item row="3" column="3">
<item row="2" column="3">
<widget class="QDoubleSpinBox" name="doubleSpinBox_GridColorB">
<property name="maximum">
<double>1.000000000000000</double>
......@@ -291,7 +274,7 @@
</property>
</widget>
</item>
<item row="3" column="1">
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_GridColorR">
<property name="maximum">
<double>1.000000000000000</double>
......@@ -301,7 +284,7 @@
</property>
</widget>
</item>
<item row="2" column="2">
<item row="1" column="2">
<widget class="QSpinBox" name="spinBox_GridResolutionY">
<property name="maximum">
<number>200</number>
......@@ -523,9 +506,9 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<widget class="QWidget" name="tab_SphereClipping">
<attribute name="title">
<string>Sphere Clipping</string>
<string>Sphere Clip</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
......@@ -742,6 +725,51 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_GlobalClipping">
<attribute name="title">
<string>Global Clip</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<layout class="QGridLayout" name="gridLayout_15">
<item row="0" column="0">
<widget class="QLabel" name="label_ColorAttenuationFactor">
<property name="text">
<string>Color Att.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_ColorAttenuationFactor">
<property name="singleStep">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_ClippingMode">
<property name="text">
<string>Clipping Mode</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="horizontalSlider_ClippingMode">
<property name="maximum">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
......
......@@ -72,6 +72,8 @@ void Stage_shader_number_two::initGUI()
setCallBack( dock.slider_normalsSize, SIGNAL(valueChanged(int)), SLOT(slot_normalsSize(int)) ) ;
setCallBack(dock.doubleSpinBox_color_attenuation, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_ColorAttenuationFactor(double)));
dock.doubleSpinBox_color_attenuation->setValue(m_phongShader->getClipColorAttenuationFactor());
}
void Stage_shader_number_two::cb_initGL()
......@@ -118,6 +120,8 @@ void Stage_shader_number_two::cb_initGL()
registerShader(m_simpleColorShader) ;
registerShader(m_pointSprite) ;
m_phongShader->insertClippingCode();
m_phongShader->setClipPlanesCount(1);
}
......
......@@ -389,6 +389,9 @@ private:
public:
/// enum used to choose which clipping mode to use
enum clippingMode { CLIPPING_MODE_AND, CLIPPING_MODE_OR };
/**
* insert clipping instructions into shader source code
* @warning this function is designed for shaders which *do not* use a geometry shader
......@@ -404,6 +407,15 @@ public:
/// get the color attenuation factor for clipping
float getClipColorAttenuationFactor();
/*
* set the clipping mode
* @param clipMode clipping mode
*/
void setClipMode(clippingMode clipMode);
/// get the clipping mode
clippingMode getClipMode();
private:
/// to control clipping code has been inserted before clipping objects have been added
......@@ -415,6 +427,9 @@ private:
/// color attenuation factor uniform id
GLint m_unif_clipColorAttenuationFactor;
/// clipping mode
clippingMode m_clipMode;
/***********************************************
*
......
......@@ -107,8 +107,8 @@ public:
private:
/// processed shader name stored for log purpose
std::string m_shaderName;
/// processed shader name stored for log purpose
std::string m_shaderName;
/// modified version of the original vertex shader source code
std::string m_vShaderMutation;
......
......@@ -57,6 +57,7 @@ ClippingShader::ClippingShader()
// Initialize default global clipping variables
m_hasClippingCodeBeenInserted = false;
m_clipColorAttenuationFactor = 1.0;
m_clipMode = CLIPPING_MODE_AND;
}
ClippingShader::~ClippingShader()
......@@ -77,63 +78,66 @@ ClippingShader::~ClippingShader()
void ClippingShader::setClipPlanesCount(int planesCount)
{
// Check if the clipping code has been inserted into shader
if (errorRaiseClippingCodeNotInserted(!m_hasClippingCodeBeenInserted, "ClippingShader::setClipPlanesCount"))
return;
if (planesCount != getClipPlanesCount())
{
// Check if the clipping code has been inserted into shader
if (errorRaiseClippingCodeNotInserted(!m_hasClippingCodeBeenInserted, "ClippingShader::setClipPlanesCount"))
return;
// Check if the given clipping planes count is valid
if (errorRaiseParameterIsNotPositive((planesCount < 0), "ClippingShader::setClipPlanesCount", "planesCount"))
return;
// Check if the given clipping planes count is valid
if (errorRaiseParameterIsNotPositive((planesCount < 0), "ClippingShader::setClipPlanesCount", "planesCount"))
return;
// Shader name string
std::string shaderName = m_nameVS + "/" + m_nameFS + "/" + m_nameGS;
// Shader name string
std::string shaderName = m_nameVS + "/" + m_nameFS + "/" + m_nameGS;
// Use a shader mutator
ShaderMutator SM(shaderName, getVertexShaderSrc(), getFragmentShaderSrc());
// Use a shader mutator
ShaderMutator SM(shaderName, getVertexShaderSrc(), getFragmentShaderSrc());
// Modify the clip planes count constant in both shader
SM.changeIntConstantValue(ShaderMutator::VERTEX_SHADER, "CLIP_PLANES_COUNT", planesCount);
SM.changeIntConstantValue(ShaderMutator::FRAGMENT_SHADER, "CLIP_PLANES_COUNT", planesCount);
// Modify the clip planes count constant in both shader
SM.changeIntConstantValue(ShaderMutator::VERTEX_SHADER, "CLIP_PLANES_COUNT", planesCount);
SM.changeIntConstantValue(ShaderMutator::FRAGMENT_SHADER, "CLIP_PLANES_COUNT", planesCount);
// Reload both shaders
reloadVertexShaderFromMemory(SM.getModifiedVertexShaderSrc().c_str());
reloadFragmentShaderFromMemory(SM.getModifiedFragmentShaderSrc().c_str());
// Reload both shaders
reloadVertexShaderFromMemory(SM.getModifiedVertexShaderSrc().c_str());
reloadFragmentShaderFromMemory(SM.getModifiedFragmentShaderSrc().c_str());
// Previous planes count
int previousPlanesCount = getClipPlanesCount();
// Previous planes count
int previousPlanesCount = getClipPlanesCount();
// Resize the planes arrays to the right size
m_clipPlanes.resize((size_t)planesCount);
m_clipPlanesEquations.resize(4*(size_t)planesCount, 0.0);
// Resize the planes arrays to the right size
m_clipPlanes.resize((size_t)planesCount);
m_clipPlanesEquations.resize(4*(size_t)planesCount, 0.0);
// Resize the planes drawers array to the right size, and create/destroy objects
if (planesCount > previousPlanesCount)
{
m_clipPlanesDrawers.resize((size_t)planesCount, NULL);
for (int i = previousPlanesCount; i < planesCount; i++)
m_clipPlanesDrawers[i] = new Drawer;
}
else
{
//for (int i = planesCount; i < previousPlanesCount; i++)
//delete m_clipPlanesDrawers[i]; // TODO : Bug dans drawer, crash le prochain affichage
m_clipPlanesDrawers.resize((size_t)planesCount);
}
// Resize the planes drawers array to the right size, and create/destroy objects
if (planesCount > previousPlanesCount)
{
m_clipPlanesDrawers.resize((size_t)planesCount, NULL);
for (int i = previousPlanesCount; i < planesCount; i++)
m_clipPlanesDrawers[i] = new Drawer;
}
else
{
//for (int i = planesCount; i < previousPlanesCount; i++)
//delete m_clipPlanesDrawers[i]; // TODO : Bug dans drawer, crash le prochain affichage
m_clipPlanesDrawers.resize((size_t)planesCount);
}
// Set default parameters values for new planes
if (planesCount > previousPlanesCount)
{
Geom::Vec3f defaultFirstVec (1.0, 0.0, 0.0);
Geom::Vec3f defaultSecondVec (0.0, 1.0, 0.0);
Geom::Vec3f defaultOrigin (0.0, 0.0, 0.0);
// Set default parameters values for new planes
if (planesCount > previousPlanesCount)
{
Geom::Vec3f defaultFirstVec (1.0, 0.0, 0.0);
Geom::Vec3f defaultSecondVec (0.0, 1.0, 0.0);
Geom::Vec3f defaultOrigin (0.0, 0.0, 0.0);
for (int i = previousPlanesCount; i < planesCount; i++)
setClipPlaneParamsAll(defaultFirstVec, defaultSecondVec, defaultOrigin, i);
}
for (int i = previousPlanesCount; i < planesCount; i++)
setClipPlaneParamsAll(defaultFirstVec, defaultSecondVec, defaultOrigin, i);
}
// Recompile shaders (automatically calls updateClippingUniforms)
recompile();
// Recompile shaders (automatically calls updateClippingUniforms)
recompile();
}
}
int ClippingShader::getClipPlanesCount()
......@@ -476,62 +480,65 @@ void ClippingShader::updateClipPlanesVBOs()
void ClippingShader::setClipSpheresCount(int spheresCount)
{
// Check if the clipping code has been inserted into shader
if (errorRaiseClippingCodeNotInserted(!m_hasClippingCodeBeenInserted, "ClippingShader::setClipSpheresCount"))
return;
if (spheresCount != getClipSpheresCount())
{
// Check if the clipping code has been inserted into shader
if (errorRaiseClippingCodeNotInserted(!m_hasClippingCodeBeenInserted, "ClippingShader::setClipSpheresCount"))
return;
// Check if the given clipping spheres count is valid
if (errorRaiseParameterIsNotPositive((spheresCount < 0), "ClippingShader::setClipSpheresCount", "spheresCount"))
return;
// Check if the given clipping spheres count is valid
if (errorRaiseParameterIsNotPositive((spheresCount < 0), "ClippingShader::setClipSpheresCount", "spheresCount"))
return;
// Shader name string
std::string shaderName = m_nameVS + "/" + m_nameFS + "/" + m_nameGS;
// Shader name string
std::string shaderName = m_nameVS + "/" + m_nameFS + "/" + m_nameGS;
// Use a shader mutator
ShaderMutator SM(shaderName, getVertexShaderSrc(), getFragmentShaderSrc());
// Use a shader mutator
ShaderMutator SM(shaderName, getVertexShaderSrc(), getFragmentShaderSrc());
// Modify the clip spheres count constant in both shader
SM.changeIntConstantValue(ShaderMutator::VERTEX_SHADER, "CLIP_SPHERES_COUNT", spheresCount);
SM.changeIntConstantValue(ShaderMutator::FRAGMENT_SHADER, "CLIP_SPHERES_COUNT", spheresCount);
// Modify the clip spheres count constant in both shader
SM.changeIntConstantValue(ShaderMutator::VERTEX_SHADER, "CLIP_SPHERES_COUNT", spheresCount);
SM.changeIntConstantValue(ShaderMutator::FRAGMENT_SHADER, "CLIP_SPHERES_COUNT", spheresCount);
// Reload both shaders
reloadVertexShaderFromMemory(SM.getModifiedVertexShaderSrc().c_str());
reloadFragmentShaderFromMemory(SM.getModifiedFragmentShaderSrc().c_str());
// Reload both shaders
reloadVertexShaderFromMemory(SM.getModifiedVertexShaderSrc().c_str());
reloadFragmentShaderFromMemory(SM.getModifiedFragmentShaderSrc().c_str());
// Previous spheres count
int previousSpheresCount = getClipSpheresCount();
// Previous spheres count
int previousSpheresCount = getClipSpheresCount();
// Resize the spheres arrays to the right size
m_clipSpheres.resize((size_t)spheresCount);
m_clipSpheresCentersAndRadiuses.resize(4*(size_t)spheresCount, 0.0);
// Resize the spheres arrays to the right size
m_clipSpheres.resize((size_t)spheresCount);
m_clipSpheresCentersAndRadiuses.resize(4*(size_t)spheresCount, 0.0);
// Resize the spheres drawers array to the right size, and create/destroy objects
if (spheresCount > previousSpheresCount)
{
m_clipSpheresDrawers.resize((size_t)spheresCount, NULL);
for (int i = previousSpheresCount; i < spheresCount; i++)
m_clipSpheresDrawers[i] = new Drawer;
}
else
{
//for (int i = spheresCount; i < previousSpheresCount; i++)
//delete m_clipSpheresDrawers[i]; // TODO : Bug dans drawer, crash le prochain affichage
m_clipSpheresDrawers.resize((size_t)spheresCount);
}
// Resize the spheres drawers array to the right size, and create/destroy objects
if (spheresCount > previousSpheresCount)
{
m_clipSpheresDrawers.resize((size_t)spheresCount, NULL);
for (int i = previousSpheresCount; i < spheresCount; i++)
m_clipSpheresDrawers[i] = new Drawer;
}
else
{
//for (int i = spheresCount; i < previousSpheresCount; i++)
//delete m_clipSpheresDrawers[i]; // TODO : Bug dans drawer, crash le prochain affichage
m_clipSpheresDrawers.resize((size_t)spheresCount);
}
// Set default parameters values for new spheres
if (spheresCount > previousSpheresCount)
{
Geom::Vec3f defaultCenter (0.0, 0.0, 0.0);
float defaultRadius = 10.0;
// Set default parameters values for new spheres
if (spheresCount > previousSpheresCount)
{
Geom::Vec3f defaultCenter (0.0, 0.0, 0.0);
float defaultRadius = 10.0;
for (int i = previousSpheresCount; i < spheresCount; i++)
setClipSphereParamsAll(defaultCenter, defaultRadius, i);
}
for (int i = previousSpheresCount; i < spheresCount; i++)
setClipSphereParamsAll(defaultCenter, defaultRadius, i);
}
// Recompile shaders (automatically calls updateClippingUniforms)
recompile();
// Recompile shaders (automatically calls updateClippingUniforms)
recompile();
}
}
int ClippingShader::getClipSpheresCount()
......@@ -711,54 +718,77 @@ void ClippingShader::updateClipSphereVBO(int sphereIndex)
m_clipSpheresDisplayColor[1],
m_clipSpheresDisplayColor[2]);
m_clipSpheresDrawers[sphereIndex]->begin(GL_LINES);
// Sphere segments and rings subdivisions
const int segSubdivs = 100;
const int ringsSubdivs = 100;
// Compute angle displacement steps
float dTheta = 0.0;
if (m_clipSpheresDisplayXRes != 0)
dTheta = 2 * M_PI / (float)m_clipSpheresDisplayXRes;
dTheta = 2.0 * M_PI / (float)m_clipSpheresDisplayXRes;
float dPhi = 0.0;
if (m_clipSpheresDisplayYRes != 0)
dPhi = M_PI / (float)m_clipSpheresDisplayYRes;
// Draw the sphere in wireframe
// Compute angle displacement steps for subdivisions
float dSegSubdiv = M_PI / (float)segSubdivs;
float dRingsSubdiv = 2.0 * M_PI / (float)ringsSubdivs;
// Draw the segments of the sphere
for (size_t i = 0; i < m_clipSpheresDisplayXRes; i++)
{
for (size_t j = 0; j < m_clipSpheresDisplayYRes; j++)
m_clipSpheresDrawers[sphereIndex]->begin(GL_LINE_STRIP);
for (size_t j = 0; j < segSubdivs + 1; j++)
{
// Compute 3 points according to the parametric equation of the sphere
Geom::Vec3f p1 (
cos(i*dTheta) * sin(j*dPhi),
sin(i*dTheta) * sin(j*dPhi),
cos(j*dPhi));
Geom::Vec3f p2 (
cos((i+1)*dTheta) * sin(j*dPhi),
sin((i+1)*dTheta) * sin(j*dPhi),
cos(j*dPhi));
Geom::Vec3f p3 (
cos(i*dTheta) * sin((j+1)*dPhi),
sin(i*dTheta) * sin((j+1)*dPhi),
cos((j+1)*dPhi));
// Compute a point on the current subdivision according to the parametric equation of the sphere
Geom::Vec3f point (
cos(i*dTheta) * sin(j*dSegSubdiv),
sin(i*dTheta) * sin(j*dSegSubdiv),
cos(j*dSegSubdiv));
// Scale with the radius
p1 *= m_clipSpheres[sphereIndex].radius;
p2 *= m_clipSpheres[sphereIndex].radius;
p3 *= m_clipSpheres[sphereIndex].radius;
point *= m_clipSpheres[sphereIndex].radius;
// Translate to the center
p1 += m_clipSpheres[sphereIndex].center;
p2 += m_clipSpheres[sphereIndex].center;
p3 += m_clipSpheres[sphereIndex].center;
// Draw two lines with the 3 points
m_clipSpheresDrawers[sphereIndex]->vertex(p1);
m_clipSpheresDrawers[sphereIndex]->vertex(p2);
m_clipSpheresDrawers[sphereIndex]->vertex(p1);
m_clipSpheresDrawers[sphereIndex]->vertex(p3);