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;
......
......@@ -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,16 +6,22 @@
<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="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>
......@@ -23,9 +29,15 @@
<string>Directional Light Source</string>
</property>
</widget>
</item>
<item>
<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>
......@@ -33,7 +45,16 @@
<string>Fixed Position/Direction</string>
</property>
</widget>
</item>
<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">
......@@ -96,9 +117,15 @@
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<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>Direction</string>
</property>
......@@ -148,13 +175,17 @@
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<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>
......@@ -214,6 +245,12 @@
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Parameters</string>
</property>
......@@ -248,7 +285,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6">
<widget class="QGroupBox" name="ColorGroup">
<property name="title">
<string>Colors</string>
</property>
......@@ -437,19 +474,40 @@
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
<string>Misc</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>117</height>
</size>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QGridLayout" name="gridLayout_10" columnminimumwidth="5,0">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item row="0" column="1">
<widget class="QLineEdit" name="radius">
<property name="toolTip">
<string>Determines the light source's radius. Note: This does not affect the standard OpenGL rendering.</string>
</property>
<property name="whatsThis">
<string>Determines the light source's radius. Note: This does not affect the standard OpenGL rendering.</string>
</property>
</spacer>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string>Radius</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
......
......@@ -583,6 +583,7 @@ void DataControlPlugin::slotEditLight() {
if(light == 0) return;
LightWidget* widget = new LightWidget( light->lightNode() );
widget->setWindowFlags(Qt::WindowStaysOnTopHint);
widget->show();
}
}
......
Supports Markdown
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