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*/) { ...@@ -260,7 +260,7 @@ void LightNode::draw(GLState& _state, DrawModes::DrawMode /*_drawMode*/) {
ACG::Vec3f p = ACG::Vec3f(light_.realPosition_[0], ACG::Vec3f p = ACG::Vec3f(light_.realPosition_[0],
light_.realPosition_[1], light_.realPosition_[1],
light_.realPosition_[2]); light_.realPosition_[2]);
ACG::Vec3d spot = light_.realSpotDirection_; ACG::Vec3d spotDir = light_.realSpotDirection_;
ACG::Vec4f c = light_.ambientColor() * light_.brightness_; ACG::Vec4f c = light_.ambientColor() * light_.brightness_;
// Backup variables // Backup variables
...@@ -270,7 +270,7 @@ void LightNode::draw(GLState& _state, DrawModes::DrawMode /*_drawMode*/) { ...@@ -270,7 +270,7 @@ void LightNode::draw(GLState& _state, DrawModes::DrawMode /*_drawMode*/) {
GLUquadricObj* quadric = gluNewQuadric(); GLUquadricObj* quadric = gluNewQuadric();
// Origin // Origin
_state.push_modelview_matrix (); _state.push_modelview_matrix();
// Transform to light origin and direction // Transform to light origin and direction
_state.translate(p[0], p[1], p[2]); _state.translate(p[0], p[1], p[2]);
...@@ -291,7 +291,7 @@ void LightNode::draw(GLState& _state, DrawModes::DrawMode /*_drawMode*/) { ...@@ -291,7 +291,7 @@ void LightNode::draw(GLState& _state, DrawModes::DrawMode /*_drawMode*/) {
// Rotate into light direction // Rotate into light direction
ACG::Vec3d z = ACG::Vec3d(0.0f, 0.0f, 1.0f); 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())); float angle = acos((z | spot)/(z.norm()*spot.norm()));
angle = angle*360/(2*M_PI); angle = angle*360/(2*M_PI);
ACG::Vec3d rA = z % spot; ACG::Vec3d rA = z % spot;
...@@ -394,7 +394,7 @@ void LightNode::setParameters(GLenum _index, LightSource& _light) ...@@ -394,7 +394,7 @@ void LightNode::setParameters(GLenum _index, LightSource& _light)
d[1]*_light.brightness_, d[1]*_light.brightness_,
d[2]*_light.brightness_, d[2]*_light.brightness_,
d[3]*_light.brightness_}; d[3]*_light.brightness_};
Vec4f& s = _light.specularColor_; Vec4f& s = _light.specularColor_;
GLfloat specular[4] = {s[0]*_light.brightness_, GLfloat specular[4] = {s[0]*_light.brightness_,
s[1]*_light.brightness_, s[1]*_light.brightness_,
......
...@@ -92,6 +92,8 @@ LightWidget::LightWidget( ACG::SceneGraph::BaseNode* _node, QWidget *parent) ...@@ -92,6 +92,8 @@ LightWidget::LightWidget( ACG::SceneGraph::BaseNode* _node, QWidget *parent)
connect(specularR,SIGNAL(editingFinished()),this,SLOT(specularChanged())); connect(specularR,SIGNAL(editingFinished()),this,SLOT(specularChanged()));
connect(specularG,SIGNAL(editingFinished()),this,SLOT(specularChanged())); connect(specularG,SIGNAL(editingFinished()),this,SLOT(specularChanged()));
connect(specularB,SIGNAL(editingFinished()),this,SLOT(specularChanged())); connect(specularB,SIGNAL(editingFinished()),this,SLOT(specularChanged()));
connect(radius,SIGNAL(editingFinished()),this,SLOT(radiusChanged()));
} }
void LightWidget::showEvent ( QShowEvent * event ) void LightWidget::showEvent ( QShowEvent * event )
...@@ -141,6 +143,8 @@ void LightWidget::showEvent ( QShowEvent * event ) ...@@ -141,6 +143,8 @@ void LightWidget::showEvent ( QShowEvent * event )
brightness->setSliderPosition((int)(light_->brightness()*100)); brightness->setSliderPosition((int)(light_->brightness()*100));
radius->setText(QString::number(light_->radius()));
// Allow updates // Allow updates
updatingWidgets_ = false; updatingWidgets_ = false;
...@@ -221,6 +225,17 @@ void LightWidget::brightnessChanged(int _newValue) { ...@@ -221,6 +225,17 @@ void LightWidget::brightnessChanged(int _newValue) {
updated(); 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() { void LightWidget::spotChanged() {
// Block if we currently update the widgets or if we dont get the object // Block if we currently update the widgets or if we dont get the object
if (updatingWidgets_ || !getObject() ) if (updatingWidgets_ || !getObject() )
......
...@@ -65,6 +65,9 @@ class DLLEXPORT LightWidget : public QDialog, public Ui::LightWidgetBase ...@@ -65,6 +65,9 @@ class DLLEXPORT LightWidget : public QDialog, public Ui::LightWidgetBase
/// Brightness value has changed /// Brightness value has changed
void brightnessChanged(int _newValue); void brightnessChanged(int _newValue);
/// Light radius has changed
void radiusChanged();
/// Spot direction changed /// Spot direction changed
void spotChanged(); void spotChanged();
......
This diff is collapsed.
...@@ -583,6 +583,7 @@ void DataControlPlugin::slotEditLight() { ...@@ -583,6 +583,7 @@ void DataControlPlugin::slotEditLight() {
if(light == 0) return; if(light == 0) return;
LightWidget* widget = new LightWidget( light->lightNode() ); LightWidget* widget = new LightWidget( light->lightNode() );
widget->setWindowFlags(Qt::WindowStaysOnTopHint);
widget->show(); 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