git-svn-id: svn://db.shs.com.ru/libs@613 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -99,10 +99,11 @@ protected:
|
|||||||
|
|
||||||
class Map {
|
class Map {
|
||||||
public:
|
public:
|
||||||
Map() {bitmap_id = 0; color_amount = 1.f; color_offset = 0.f; animation_frame_rate = -1.f;}
|
Map() {bitmap_id = 0; color_amount = 1.f; color_offset = 0.f; animation_frame_rate = -1.f; bitmap_scale = QPointF(1., 1.);}
|
||||||
QString bitmap_path;
|
QString bitmap_path;
|
||||||
GLuint bitmap_id;
|
GLuint bitmap_id;
|
||||||
QPointF bitmap_offset;
|
QPointF bitmap_offset;
|
||||||
|
QPointF bitmap_scale;
|
||||||
float color_amount;
|
float color_amount;
|
||||||
float color_offset;
|
float color_offset;
|
||||||
QString animation;
|
QString animation;
|
||||||
@@ -138,7 +139,7 @@ public:
|
|||||||
|
|
||||||
inline QDataStream & operator <<(QDataStream & s, const Map & m) {
|
inline QDataStream & operator <<(QDataStream & s, const Map & m) {
|
||||||
ChunkStream cs;
|
ChunkStream cs;
|
||||||
cs << cs.chunk(1, m.bitmap_path) << cs.chunk(2, m.color_amount) << cs.chunk(3, m.color_offset) << cs.chunk(4, m.animation) << cs.chunk(5, m.animation_frame_rate);
|
cs.add(1, m.bitmap_path).add(2, m.color_amount).add(3, m.color_offset).add(4, m.animation).add(5, m.animation_frame_rate).add(6, m.bitmap_scale);
|
||||||
s << cs.data(); return s;
|
s << cs.data(); return s;
|
||||||
}
|
}
|
||||||
inline QDataStream & operator >>(QDataStream & s, Map & m) {
|
inline QDataStream & operator >>(QDataStream & s, Map & m) {
|
||||||
@@ -150,6 +151,7 @@ inline QDataStream & operator >>(QDataStream & s, Map & m) {
|
|||||||
case 3: m.color_offset = cs.getData<float>(); break;
|
case 3: m.color_offset = cs.getData<float>(); break;
|
||||||
case 4: m.animation = cs.getData<QString>(); break;
|
case 4: m.animation = cs.getData<QString>(); break;
|
||||||
case 5: m.animation_frame_rate = cs.getData<float>(); break;
|
case 5: m.animation_frame_rate = cs.getData<float>(); break;
|
||||||
|
case 6: m.bitmap_scale = cs.getData<QPointF>(); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
@@ -157,9 +159,9 @@ inline QDataStream & operator >>(QDataStream & s, Map & m) {
|
|||||||
|
|
||||||
inline QDataStream & operator <<(QDataStream & s, const Material & m) {
|
inline QDataStream & operator <<(QDataStream & s, const Material & m) {
|
||||||
ChunkStream cs;
|
ChunkStream cs;
|
||||||
cs << cs.chunk(1, m.name) << cs.chunk(2, m.color_diffuse) << cs.chunk(3, m.color_specular) << cs.chunk(4, m.color_self_illumination)
|
cs.add(1, m.name).add(2, m.color_diffuse).add(3, m.color_specular).add(4, m.color_self_illumination)
|
||||||
<< cs.chunk(5, m.transparency) << cs.chunk(6, m.reflectivity) << cs.chunk(7, m.glass) << cs.chunk(8, m.map_diffuse) << cs.chunk(9, m.map_normal)
|
.add(5, m.transparency).add(6, m.reflectivity).add(7, m.glass).add(8, m.map_diffuse).add(9, m.map_normal)
|
||||||
<< cs.chunk(10, m.map_relief) << cs.chunk(11, m.map_specular) << cs.chunk(12, m.map_specularity) << cs.chunk(13, m.map_self_illumination);
|
.add(10, m.map_relief).add(11, m.map_specular).add(12, m.map_specularity).add(13, m.map_self_illumination);
|
||||||
s << qCompress(cs.data()); return s;
|
s << qCompress(cs.data()); return s;
|
||||||
}
|
}
|
||||||
inline QDataStream & operator >>(QDataStream & s, Material & m) {
|
inline QDataStream & operator >>(QDataStream & s, Material & m) {
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ const char qgl_structs[] =
|
|||||||
"struct QGLMap {\n"
|
"struct QGLMap {\n"
|
||||||
" float offset;\n"
|
" float offset;\n"
|
||||||
" float amount;\n"
|
" float amount;\n"
|
||||||
|
" vec2 scale;\n"
|
||||||
" sampler2D map;\n"
|
" sampler2D map;\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
"struct QGLMaterial {\n"
|
"struct QGLMaterial {\n"
|
||||||
@@ -174,6 +175,7 @@ void setUniformMap(QOpenGLShaderProgram * prog, QString map_name, const Map & ma
|
|||||||
if (!prog->isLinked()) return;
|
if (!prog->isLinked()) return;
|
||||||
prog->setUniformValue(("qgl_Material." + map_name + ".offset").toLatin1().constData(), map.color_offset);
|
prog->setUniformValue(("qgl_Material." + map_name + ".offset").toLatin1().constData(), map.color_offset);
|
||||||
prog->setUniformValue(("qgl_Material." + map_name + ".amount").toLatin1().constData(), map.color_amount);
|
prog->setUniformValue(("qgl_Material." + map_name + ".amount").toLatin1().constData(), map.color_amount);
|
||||||
|
prog->setUniformValue(("qgl_Material." + map_name + ".scale").toLatin1().constData(), map.bitmap_scale);
|
||||||
prog->setUniformValue(("qgl_Material." + map_name + ".map").toLatin1().constData(), map.bitmap_id > 0 ? channel : def_channel);
|
prog->setUniformValue(("qgl_Material." + map_name + ".map").toLatin1().constData(), map.bitmap_id > 0 ? channel : def_channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ void MaterialMapEditor::setMap(const Map & m) {
|
|||||||
active = false;
|
active = false;
|
||||||
ui->sliderAmount->setValue(m.color_amount);
|
ui->sliderAmount->setValue(m.color_amount);
|
||||||
ui->sliderOffset->setValue(m.color_offset);
|
ui->sliderOffset->setValue(m.color_offset);
|
||||||
|
ui->spinScaleX->setValue(m.bitmap_scale.x());
|
||||||
|
ui->spinScaleY->setValue(m.bitmap_scale.y());
|
||||||
ui->linePath->setProperty("GLpath", m.bitmap_path); ui->linePath->setText(QFileInfo(m.bitmap_path).fileName());
|
ui->linePath->setProperty("GLpath", m.bitmap_path); ui->linePath->setText(QFileInfo(m.bitmap_path).fileName());
|
||||||
updateIcon();
|
updateIcon();
|
||||||
active = true;
|
active = true;
|
||||||
@@ -65,6 +67,8 @@ Map MaterialMapEditor::map() {
|
|||||||
Map m;
|
Map m;
|
||||||
m.color_amount = ui->sliderAmount->value();
|
m.color_amount = ui->sliderAmount->value();
|
||||||
m.color_offset = ui->sliderOffset->value();
|
m.color_offset = ui->sliderOffset->value();
|
||||||
|
m.bitmap_scale.setX(ui->spinScaleX->value());
|
||||||
|
m.bitmap_scale.setY(ui->spinScaleY->value());
|
||||||
m.bitmap_path = ui->linePath->property("GLpath").toString();
|
m.bitmap_path = ui->linePath->property("GLpath").toString();
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,15 +6,21 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>509</width>
|
<width>587</width>
|
||||||
<height>74</height>
|
<height>138</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="spacing">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
@@ -36,15 +42,17 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="buttonClear">
|
<widget class="QToolButton" name="buttonClear">
|
||||||
<property name="text">
|
<property name="icon">
|
||||||
<string>X</string>
|
<iconset resource="../qad/utils/qad_utils.qrc">
|
||||||
|
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="buttonSelect">
|
<widget class="QToolButton" name="buttonSelect">
|
||||||
<property name="text">
|
<property name="icon">
|
||||||
<string>^</string>
|
<iconset resource="../qad/application/qad_application.qrc">
|
||||||
|
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -60,10 +68,10 @@
|
|||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="SpinSlider" name="sliderAmount">
|
<widget class="SpinSlider" name="sliderAmount">
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<double>-10.000000000000000</double>
|
<double>-1.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>10.000000000000000</double>
|
<double>1.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<double>1.000000000000000</double>
|
<double>1.000000000000000</double>
|
||||||
@@ -77,6 +85,12 @@
|
|||||||
<property name="pageStep">
|
<property name="pageStep">
|
||||||
<double>0.200000000000000</double>
|
<double>0.200000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="spinMinimum">
|
||||||
|
<double>-99.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="spinMaximum">
|
||||||
|
<double>99.000000000000000</double>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
@@ -89,10 +103,10 @@
|
|||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="SpinSlider" name="sliderOffset">
|
<widget class="SpinSlider" name="sliderOffset">
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<double>-10.000000000000000</double>
|
<double>-1.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>10.000000000000000</double>
|
<double>1.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="decimals">
|
<property name="decimals">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
@@ -103,8 +117,96 @@
|
|||||||
<property name="pageStep">
|
<property name="pageStep">
|
||||||
<double>0.200000000000000</double>
|
<double>0.200000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="spinMinimum">
|
||||||
|
<double>-99.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="spinMaximum">
|
||||||
|
<double>99.000000000000000</double>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0" colspan="2">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Scale X:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDoubleSpinBox" name="spinScaleX">
|
||||||
|
<property name="singleStep">
|
||||||
|
<double>0.100000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>1.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Preferred</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Scale Y:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDoubleSpinBox" name="spinScaleY">
|
||||||
|
<property name="singleStep">
|
||||||
|
<double>0.100000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>1.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>1</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -121,7 +223,10 @@
|
|||||||
<header>iconedlabel.h</header>
|
<header>iconedlabel.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../qad/utils/qad_utils.qrc"/>
|
||||||
|
<include location="../qad/application/qad_application.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>linePath</sender>
|
<sender>linePath</sender>
|
||||||
@@ -130,8 +235,8 @@
|
|||||||
<slot>mapChanged()</slot>
|
<slot>mapChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>175</x>
|
<x>471</x>
|
||||||
<y>19</y>
|
<y>22</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>99</x>
|
<x>99</x>
|
||||||
@@ -171,6 +276,38 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>spinScaleX</sender>
|
||||||
|
<signal>valueChanged(double)</signal>
|
||||||
|
<receiver>MaterialMapEditor</receiver>
|
||||||
|
<slot>mapChanged()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>377</x>
|
||||||
|
<y>104</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>332</x>
|
||||||
|
<y>164</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>spinScaleY</sender>
|
||||||
|
<signal>valueChanged(double)</signal>
|
||||||
|
<receiver>MaterialMapEditor</receiver>
|
||||||
|
<slot>mapChanged()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>519</x>
|
||||||
|
<y>110</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>493</x>
|
||||||
|
<y>164</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<slots>
|
<slots>
|
||||||
<slot>mapChanged()</slot>
|
<slot>mapChanged()</slot>
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ void main(void) {
|
|||||||
//float logz = log(pos.w * C + 1.) * FC;
|
//float logz = log(pos.w * C + 1.) * FC;
|
||||||
vec4 dc = qgl_FragColor;
|
vec4 dc = qgl_FragColor;
|
||||||
vec2 tc = qgl_FragTexture.xy;
|
vec2 tc = qgl_FragTexture.xy;
|
||||||
float hei = dot(texture(qgl_Material.map_relief.map, tc).rgb, luma) * qgl_Material.map_relief.amount + qgl_Material.map_relief.offset;
|
float hei = dot(texture(qgl_Material.map_relief.map, tc * qgl_Material.map_relief.scale).rgb, luma) * qgl_Material.map_relief.amount + qgl_Material.map_relief.offset;
|
||||||
|
|
||||||
vec3 n, dn, bn;
|
vec3 n, dn, bn;
|
||||||
dn = texture(qgl_Material.map_normal.map, tc).rgb - vec3(0.5, 0.5, 1.);
|
dn = texture(qgl_Material.map_normal.map, tc * qgl_Material.map_normal.scale).rgb - vec3(0.5, 0.5, 1.);
|
||||||
dn = dn * qgl_Material.map_normal.amount + qgl_Material.map_normal.offset;
|
dn = dn * qgl_Material.map_normal.amount + qgl_Material.map_normal.offset;
|
||||||
dn.y = -dn.y;
|
dn.y = -dn.y;
|
||||||
dn = TBN * dn;
|
dn = TBN * dn;
|
||||||
@@ -31,15 +31,15 @@ void main(void) {
|
|||||||
bn = normalize(qgl_NormalMatrix * binormal);
|
bn = normalize(qgl_NormalMatrix * binormal);
|
||||||
//n = dn;
|
//n = dn;
|
||||||
|
|
||||||
dc *= texture(qgl_Material.map_diffuse.map, tc) * qgl_Material.map_diffuse.amount + qgl_Material.map_diffuse.offset;
|
dc *= texture(qgl_Material.map_diffuse.map, tc * qgl_Material.map_diffuse.scale) * qgl_Material.map_diffuse.amount + qgl_Material.map_diffuse.offset;
|
||||||
|
|
||||||
vec4 spec = texture(qgl_Material.map_specular.map, tc) * qgl_Material.map_specular.amount + qgl_Material.map_specular.offset;
|
vec4 spec = texture(qgl_Material.map_specular.map, tc * qgl_Material.map_specular.scale) * qgl_Material.map_specular.amount + qgl_Material.map_specular.offset;
|
||||||
spec *= qgl_Material.color_specular;
|
spec *= qgl_Material.color_specular;
|
||||||
float specularity = dot(texture(qgl_Material.map_specularity.map, tc).rgb, luma) * qgl_Material.map_specularity.amount + qgl_Material.map_specularity.offset;
|
float specularity = dot(texture(qgl_Material.map_specularity.map, tc * qgl_Material.map_specularity.scale).rgb, luma) * qgl_Material.map_specularity.amount + qgl_Material.map_specularity.offset;
|
||||||
specularity = clamp(specularity, 0.05, 0.99);
|
specularity = clamp(specularity, 0.05, 0.99);
|
||||||
float reflectivity = qgl_Material.reflectivity;//dot(texture(qgl_Material.map_specularity.map, tc).rgb, luma) * qgl_Material.map_specularity.amount + qgl_Material.map_specularity.offset;
|
float reflectivity = qgl_Material.reflectivity;//dot(texture(qgl_Material.map_specularity.map, tc).rgb, luma) * qgl_Material.map_specularity.amount + qgl_Material.map_specularity.offset;
|
||||||
reflectivity = clamp(reflectivity, 0., 1.);
|
reflectivity = clamp(reflectivity, 0., 1.);
|
||||||
vec4 self = texture(qgl_Material.map_self_illumination.map, tc) * qgl_Material.map_self_illumination.amount + qgl_Material.map_self_illumination.offset;
|
vec4 self = texture(qgl_Material.map_self_illumination.map, tc * qgl_Material.map_self_illumination.scale) * qgl_Material.map_self_illumination.amount + qgl_Material.map_self_illumination.offset;
|
||||||
self *= qgl_Material.color_self_illumination;
|
self *= qgl_Material.color_self_illumination;
|
||||||
|
|
||||||
vec3 speed = pos.xyz/pos.w - ppos.xyz/ppos.w;
|
vec3 speed = pos.xyz/pos.w - ppos.xyz/ppos.w;
|
||||||
|
|||||||
Reference in New Issue
Block a user