relief map support, small refactoring, shadow bias now based on geometry normal
This commit is contained in:
@@ -36,9 +36,14 @@ PrimitiveEditor::PrimitiveEditor(QWidget * parent): QWidget(parent), ui(new Ui::
|
||||
#endif
|
||||
editors[Plane] << ui->widgetWidth;
|
||||
editors[Plane] << ui->widgetLength;
|
||||
editors[Plane] << ui->widgetSegmentsW;
|
||||
editors[Plane] << ui->widgetSegmentsL;
|
||||
editors[Cube] << ui->widgetWidth;
|
||||
editors[Cube] << ui->widgetLength;
|
||||
editors[Cube] << ui->widgetHeight;
|
||||
editors[Cube] << ui->widgetSegmentsW;
|
||||
editors[Cube] << ui->widgetSegmentsL;
|
||||
editors[Cube] << ui->widgetSegmentsH;
|
||||
editors[Ellipsoid] << ui->widgetRadius1;
|
||||
editors[Ellipsoid] << ui->widgetSegments;
|
||||
editors[Ellipsoid] << ui->widgetSegments2;
|
||||
@@ -86,18 +91,40 @@ void PrimitiveEditor::assignQGLView(QGLView * v) {
|
||||
}
|
||||
|
||||
|
||||
ObjectBase * PrimitiveEditor::createCurrent() {
|
||||
if (!view) return nullptr;
|
||||
QVariantList params;
|
||||
Mesh * m = createMesh(params);
|
||||
if (!m) return nullptr;
|
||||
ObjectBase * o = new ObjectBase(m);
|
||||
o->setColor(ui->colorButton->color());
|
||||
o->setName(ui->comboPrimitives->currentText());
|
||||
o->setProperty("primitive", params);
|
||||
view->scene()->addObject(o);
|
||||
view->scene()->selectObject(o);
|
||||
delete m;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
Mesh * PrimitiveEditor::createMesh(QVariantList & params) {
|
||||
Mesh * m = 0;
|
||||
PrimitiveType pt = (PrimitiveType)ui->comboPrimitives->currentIndex();
|
||||
params << pt;
|
||||
switch (pt) {
|
||||
case Plane:
|
||||
m = Primitive::plane(ui->spinWidth->value(), ui->spinLength->value());
|
||||
params << ui->spinWidth->value() << ui->spinLength->value();
|
||||
m = Primitive::plane(ui->spinWidth->value(), ui->spinLength->value(), ui->spinSegmentsW->value(), ui->spinSegmentsL->value());
|
||||
params << ui->spinWidth->value() << ui->spinLength->value() << ui->spinSegmentsW->value() << ui->spinSegmentsL->value();
|
||||
break;
|
||||
case Cube:
|
||||
m = Primitive::cube(ui->spinWidth->value(), ui->spinLength->value(), ui->spinHeight->value());
|
||||
params << ui->spinWidth->value() << ui->spinLength->value() << ui->spinHeight->value();
|
||||
m = Primitive::cube(ui->spinWidth->value(),
|
||||
ui->spinLength->value(),
|
||||
ui->spinHeight->value(),
|
||||
ui->spinSegmentsW->value(),
|
||||
ui->spinSegmentsL->value(),
|
||||
ui->spinSegmentsH->value());
|
||||
params << ui->spinWidth->value() << ui->spinLength->value() << ui->spinHeight->value() << ui->spinSegmentsW->value()
|
||||
<< ui->spinSegmentsL->value() << ui->spinSegmentsH->value();
|
||||
break;
|
||||
case Ellipsoid:
|
||||
m = Primitive::ellipsoid(ui->spinSegments->value(), ui->spinSegments2->value(), ui->spinRadius->value(), ui->spinAngle->value());
|
||||
@@ -155,11 +182,16 @@ void PrimitiveEditor::selectionChanged() {
|
||||
case Plane:
|
||||
ui->spinWidth->setValue(vl.takeFirst().toDouble());
|
||||
ui->spinLength->setValue(vl.takeFirst().toDouble());
|
||||
if (!vl.isEmpty()) ui->spinSegmentsW->setValue(vl.takeFirst().toInt());
|
||||
if (!vl.isEmpty()) ui->spinSegmentsL->setValue(vl.takeFirst().toInt());
|
||||
break;
|
||||
case Cube:
|
||||
ui->spinWidth->setValue(vl.takeFirst().toDouble());
|
||||
ui->spinLength->setValue(vl.takeFirst().toDouble());
|
||||
ui->spinHeight->setValue(vl.takeFirst().toDouble());
|
||||
if (!vl.isEmpty()) ui->spinSegmentsW->setValue(vl.takeFirst().toInt());
|
||||
if (!vl.isEmpty()) ui->spinSegmentsL->setValue(vl.takeFirst().toInt());
|
||||
if (!vl.isEmpty()) ui->spinSegmentsH->setValue(vl.takeFirst().toInt());
|
||||
break;
|
||||
case Ellipsoid:
|
||||
ui->spinSegments->setValue(vl.takeFirst().toDouble());
|
||||
@@ -191,8 +223,8 @@ void PrimitiveEditor::selectionChanged() {
|
||||
ui->spinAngle->setValue(vl.takeFirst().toDouble());
|
||||
break;
|
||||
}
|
||||
ui->flipNormals->setChecked(vl.takeFirst().toBool());
|
||||
ui->colorButton->setColor(vl.takeFirst().value<QColor>());
|
||||
if (!vl.isEmpty()) ui->flipNormals->setChecked(vl.takeFirst().toBool());
|
||||
if (!vl.isEmpty()) ui->colorButton->setColor(vl.takeFirst().value<QColor>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,17 +247,7 @@ void PrimitiveEditor::replaceMesh() {
|
||||
|
||||
|
||||
void PrimitiveEditor::on_buttonAdd_clicked() {
|
||||
if (!view) return;
|
||||
QVariantList params;
|
||||
Mesh * m = createMesh(params);
|
||||
if (!m) return;
|
||||
ObjectBase * o = new ObjectBase(m);
|
||||
o->setColor(ui->colorButton->color());
|
||||
o->setName(ui->comboPrimitives->currentText());
|
||||
o->setProperty("primitive", params);
|
||||
view->scene()->addObject(o);
|
||||
view->scene()->selectObject(o);
|
||||
delete m;
|
||||
createCurrent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -49,6 +49,8 @@ public:
|
||||
|
||||
void assignQGLView(QGLView * v);
|
||||
|
||||
ObjectBase * createCurrent();
|
||||
|
||||
protected:
|
||||
Mesh * createMesh(QVariantList & params);
|
||||
void showEditors();
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>360</width>
|
||||
<height>536</height>
|
||||
<width>499</width>
|
||||
<height>697</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -134,6 +134,120 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widgetSegmentsW" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Segments W:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinSegmentsW">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widgetSegmentsL" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Segments L:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinSegmentsL">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widgetSegmentsH" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_13">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>Segments H:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinSegmentsH">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widgetRadius1" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
@@ -437,8 +551,8 @@
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>330</x>
|
||||
<y>84</y>
|
||||
<x>498</x>
|
||||
<y>109</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>369</x>
|
||||
@@ -453,8 +567,8 @@
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>334</x>
|
||||
<y>116</y>
|
||||
<x>498</x>
|
||||
<y>147</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>366</x>
|
||||
@@ -469,8 +583,8 @@
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>332</x>
|
||||
<y>144</y>
|
||||
<x>498</x>
|
||||
<y>299</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>370</x>
|
||||
@@ -485,8 +599,8 @@
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>334</x>
|
||||
<y>186</y>
|
||||
<x>498</x>
|
||||
<y>337</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>371</x>
|
||||
@@ -501,8 +615,8 @@
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>335</x>
|
||||
<y>210</y>
|
||||
<x>391</x>
|
||||
<y>377</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>372</x>
|
||||
@@ -517,8 +631,8 @@
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>329</x>
|
||||
<y>246</y>
|
||||
<x>498</x>
|
||||
<y>415</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>370</x>
|
||||
@@ -533,8 +647,8 @@
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>336</x>
|
||||
<y>284</y>
|
||||
<x>498</x>
|
||||
<y>453</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>372</x>
|
||||
@@ -550,7 +664,7 @@
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>70</x>
|
||||
<y>344</y>
|
||||
<y>532</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>370</x>
|
||||
@@ -581,8 +695,8 @@
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>271</x>
|
||||
<y>285</y>
|
||||
<x>498</x>
|
||||
<y>500</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>179</x>
|
||||
@@ -590,6 +704,54 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>spinSegmentsW</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>PrimitiveEditor</receiver>
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>465</x>
|
||||
<y>173</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>511</x>
|
||||
<y>164</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>spinSegmentsL</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>PrimitiveEditor</receiver>
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>462</x>
|
||||
<y>208</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>520</x>
|
||||
<y>206</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>spinSegmentsH</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>PrimitiveEditor</receiver>
|
||||
<slot>replaceMesh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>468</x>
|
||||
<y>251</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>563</x>
|
||||
<y>251</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>replaceMesh()</slot>
|
||||
|
||||
Reference in New Issue
Block a user