Commit 145e814e authored by Mike Kremer's avatar Mike Kremer
Browse files

Added radius text field to light source widget.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9126 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 87c12ced
......@@ -260,7 +260,7 @@ void LightNode::draw(GLState& _state, DrawModes::DrawMode /*_drawMode*/) {
ACG::Vec3f p = ACG::Vec3f(light_.realPosition_[0],
light_.realPosition_[1],
light_.realPosition_[2]);
ACG::Vec3d spot = light_.realSpotDirection_;
ACG::Vec3d spotDir = light_.realSpotDirection_;
ACG::Vec4f c = light_.ambientColor() * light_.brightness_;
// Backup variables
......@@ -270,7 +270,7 @@ void LightNode::draw(GLState& _state, DrawModes::DrawMode /*_drawMode*/) {
GLUquadricObj* quadric = gluNewQuadric();
// Origin
_state.push_modelview_matrix ();
_state.push_modelview_matrix();
// Transform to light origin and direction
_state.translate(p[0], p[1], p[2]);
......@@ -291,7 +291,7 @@ void LightNode::draw(GLState& _state, DrawModes::DrawMode /*_drawMode*/) {
// Rotate into light direction
ACG::Vec3d z = ACG::Vec3d(0.0f, 0.0f, 1.0f);
ACG::Vec3d spot = light_.spotDirection();
ACG::Vec3d spot = spotDir;
float angle = acos((z | spot)/(z.norm()*spot.norm()));
angle = angle*360/(2*M_PI);
ACG::Vec3d rA = z % spot;
......@@ -394,7 +394,7 @@ void LightNode::setParameters(GLenum _index, LightSource& _light)
d[1]*_light.brightness_,
d[2]*_light.brightness_,
d[3]*_light.brightness_};
Vec4f& s = _light.specularColor_;
GLfloat specular[4] = {s[0]*_light.brightness_,
s[1]*_light.brightness_,
......
......@@ -92,6 +92,8 @@ LightWidget::LightWidget( ACG::SceneGraph::BaseNode* _node, QWidget *parent)
connect(specularR,SIGNAL(editingFinished()),this,SLOT(specularChanged()));
connect(specularG,SIGNAL(editingFinished()),this,SLOT(specularChanged()));
connect(specularB,SIGNAL(editingFinished()),this,SLOT(specularChanged()));
connect(radius,SIGNAL(editingFinished()),this,SLOT(radiusChanged()));
}
void LightWidget::showEvent ( QShowEvent * event )
......@@ -141,6 +143,8 @@ void LightWidget::showEvent ( QShowEvent * event )
brightness->setSliderPosition((int)(light_->brightness()*100));
radius->setText(QString::number(light_->radius()));
// Allow updates
updatingWidgets_ = false;
......@@ -221,6 +225,17 @@ void LightWidget::brightnessChanged(int _newValue) {
updated();
}
void LightWidget::radiusChanged() {
// Block if we currently update the widgets or if we dont get the object
if (updatingWidgets_ || !getObject() )
return;
light_->radius(radius->text().toDouble());
updated();
}
void LightWidget::spotChanged() {
// Block if we currently update the widgets or if we dont get the object
if (updatingWidgets_ || !getObject() )
......
......@@ -65,6 +65,9 @@ class DLLEXPORT LightWidget : public QDialog, public Ui::LightWidgetBase
/// Brightness value has changed
void brightnessChanged(int _newValue);
/// Light radius has changed
void radiusChanged();
/// Spot direction changed
void spotChanged();
......
......@@ -6,450 +6,508 @@
<rect>
<x>0</x>
<y>0</y>
<width>277</width>
<height>636</height>
<width>312</width>
<height>711</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="directional">
<property name="toolTip">
<string>Directional Light source or lightsource with position</string>
</property>
<property name="text">
<string>Directional Light Source</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="fixedPosition">
<property name="toolTip">
<string>Light source fixed relatively to the viewer</string>
</property>
<property name="text">
<string>Fixed Position/Direction</string>
</property>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Position</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="6" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Y</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>X</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Z</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="xpos"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="ypos"/>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="zpos"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Direction</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_8">
<item row="1" column="0">
<widget class="QLineEdit" name="xdir"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>X</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="ydir"/>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Y</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="zdir"/>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Z</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Spot</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_9">
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>X</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLineEdit" name="spotx"/>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Y</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="spoty"/>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Z</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="spotz"/>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label_25">
<property name="text">
<string>Direction</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<widget class="QCheckBox" name="directional">
<property name="geometry">
<rect>
<x>4</x>
<y>4</y>
<width>176</width>
<height>23</height>
</rect>
</property>
<property name="toolTip">
<string>Directional Light source or lightsource with position</string>
</property>
<property name="text">
<string>Directional Light Source</string>
</property>
</widget>
<widget class="QCheckBox" name="fixedPosition">
<property name="geometry">
<rect>
<x>4</x>
<y>31</y>
<width>172</width>
<height>23</height>
</rect>
</property>
<property name="toolTip">
<string>Light source fixed relatively to the viewer</string>
</property>
<property name="text">
<string>Fixed Position/Direction</string>
</property>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>291</width>
<height>621</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Position</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="6" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Y</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>X</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Z</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="xpos"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="ypos"/>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="zpos"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
</widget>
<widget class="QWidget" name="page_2">
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>4</x>
<y>4</y>
<width>261</width>
<height>90</height>
</rect>
</property>
<property name="title">
<string>Parameters</string>
<string>Direction</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_8">
<item row="1" column="0">
<widget class="QLineEdit" name="xdir"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>X</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="ydir"/>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Y</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="zdir"/>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Z</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="SpotGroup">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Spot</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_9">
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Angle</string>
<string>X</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="angle"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<widget class="QLineEdit" name="spotx"/>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Exponent</string>
<string>Y</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="exponent"/>
<widget class="QLineEdit" name="spoty"/>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Z</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="spotz"/>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label_25">
<property name="text">
<string>Direction</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>Colors</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Brightness</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="brightness">
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
<property name="value">
<number>100</number>
</property>
<property name="sliderPosition">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Ambient</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="0">
<widget class="QLineEdit" name="ambientR"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="ambientG"/>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="ambientB"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>R</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_15">
<property name="text">
<string>G</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_16">
<property name="text">
<string>B</string>
</property>