[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bcalligra=5D_krita/plugins/filters/phongbumpmap=3A_C?=
From: José_Luis_Vergara <pentalis () gmail ! com>
Date: 2011-06-30 20:39:10
Message-ID: 20110630203910.4B866A60C9 () git ! kde ! org
[Download RAW message or body]
Git commit 4f8c56569d5b0c9173cd03fc1cd0409424a8b77d by José Luis Vergara.
Committed on 26/06/2011 at 05:20.
Pushed by jlvergara into branch 'master'.
Completely refactor Phong Bumpmap, phase 1: one file per class
o Delete the messy "1 file for everything" phongbumpmap.cpp and .h files
o Move its contents to properly named classes
o Add a kis_ prefix to files that are relevant to all of Krita
o Change the Krita prefix of the Plugin exported to Kis
o Delete the bazillion unnecesary includes in this filter
M +3 -1 krita/plugins/filters/phongbumpmap/CMakeLists.txt
D +0 -56 krita/plugins/filters/phongbumpmap/constants.h
A +137 -0 krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_config_widget.cpp \
[License: GPL (v2+)] A +68 -0 \
krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_config_widget.h \
[License: GPL (v2+)] A +193 -0 \
krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_filter.cpp [License: GPL \
(v2+)] A +57 -0 krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_filter.h \
[License: GPL (v2+)] A +38 -0 \
krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_plugin.cpp [License: GPL \
(v2+)] A +33 -0 krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_plugin.h \
[License: GPL (v2+)] A +55 -0 \
krita/plugins/filters/phongbumpmap/phong_bumpmap_constants.h [License: GPL \
(v2+)] M +1 -1 krita/plugins/filters/phongbumpmap/phong_pixel_processor.h
D +0 -427 krita/plugins/filters/phongbumpmap/phongbumpmap.cpp
D +0 -125 krita/plugins/filters/phongbumpmap/phongbumpmap.h
http://commits.kde.org/calligra/4f8c56569d5b0c9173cd03fc1cd0409424a8b77d
diff --git a/krita/plugins/filters/phongbumpmap/CMakeLists.txt \
b/krita/plugins/filters/phongbumpmap/CMakeLists.txt index ffbde23..b263313 100644
--- a/krita/plugins/filters/phongbumpmap/CMakeLists.txt
+++ b/krita/plugins/filters/phongbumpmap/CMakeLists.txt
@@ -1,5 +1,7 @@
set(kritaphongbumpmap_PART_SRCS
- phongbumpmap.cpp
+ kis_phong_bumpmap_plugin.cpp
+ kis_phong_bumpmap_config_widget.cpp
+ kis_phong_bumpmap_filter.cpp
phong_pixel_processor.cpp
)
diff --git a/krita/plugins/filters/phongbumpmap/constants.h \
b/krita/plugins/filters/phongbumpmap/constants.h deleted file mode 100644
index 8687324..0000000
--- a/krita/plugins/filters/phongbumpmap/constants.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2010 José Luis Vergara <pentalis@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-
-#ifndef CONSTANTS_H
-#define CONSTANTS_H
-
-/*
-* Illuminants were renamed to Light Sources in the GUI
-*/
-const quint8 PHONG_TOTAL_ILLUMINANTS = 4;
-const QString PHONG_HEIGHT_CHANNEL = "heightChannel";
-const QString PHONG_ILLUMINANT_IS_ENABLED[] =
-{"illuminantIsEnabled0",
-"illuminantIsEnabled1",
-"illuminantIsEnabled2",
-"illuminantIsEnabled3"};
-const QString PHONG_ILLUMINANT_COLOR[] =
-{"illuminantColor0",
-"illuminantColor1",
-"illuminantColor2",
-"illuminantColor3"};
-const QString PHONG_ILLUMINANT_AZIMUTH[] =
-{"Azimuth0",
-"Azimuth1",
-"Azimuth2",
-"Azimuth3"};
-const QString PHONG_ILLUMINANT_INCLINATION[] =
-{"Inclination0",
-"Inclination1",
-"Inclination2",
-"Inclination3"};
-const QString PHONG_AMBIENT_REFLECTIVITY = "ambientReflectivity";
-const QString PHONG_DIFFUSE_REFLECTIVITY = "diffuseReflectivity";
-const QString PHONG_SPECULAR_REFLECTIVITY = "specularReflectivity";
-const QString PHONG_SHINYNESS_EXPONENT = "shinynessExponent";
-const QString PHONG_DIFFUSE_REFLECTIVITY_IS_ENABLED = \
"diffuseReflectivityIsEnabled";
-const QString PHONG_SPECULAR_REFLECTIVITY_IS_ENABLED = \
"specularReflectivityIsEnabled";
-//const QString PHONG_SHINYNESS_EXPONENT_IS_ENABLED = "shinynessExponentIsEnabled";
-
-#endif
diff --git a/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_config_widget.cpp \
b/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_config_widget.cpp new file \
mode 100644 index 0000000..3cb1e61
--- /dev/null
+++ b/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_config_widget.cpp
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2010-2011 José Luis Vergara <pentalis@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "kis_phong_bumpmap_config_widget.h"
+#include <filter/kis_filter_configuration.h>
+#include <QtGui>
+#include "phong_bumpmap_constants.h"
+#include "KoChannelInfo.h"
+#include "KoColorSpace.h"
+
+KisPhongBumpmapConfigWidget::KisPhongBumpmapConfigWidget(const KisPaintDeviceSP dev, \
const KisImageWSP image, QWidget * parent, Qt::WFlags f) + \
: KisConfigWidget(parent, f) + , m_device(dev)
+ , m_image(image)
+{
+ Q_ASSERT(m_device);
+ m_page = new KisPhongBumpmapWidget(this);
+
+ connect(m_page->azimuthDial1, SIGNAL(valueChanged(int)), \
m_page->azimuthSpinBox1, SLOT(setValue(int))); + connect(m_page->azimuthDial2, \
SIGNAL(valueChanged(int)), m_page->azimuthSpinBox2, SLOT(setValue(int))); + \
connect(m_page->azimuthDial3, SIGNAL(valueChanged(int)), m_page->azimuthSpinBox3, \
SLOT(setValue(int))); + connect(m_page->azimuthDial4, SIGNAL(valueChanged(int)), \
m_page->azimuthSpinBox4, SLOT(setValue(int))); + connect(m_page->azimuthSpinBox1, \
SIGNAL(valueChanged(int)), m_page->azimuthDial1, SLOT(setValue(int))); + \
connect(m_page->azimuthSpinBox2, SIGNAL(valueChanged(int)), m_page->azimuthDial2, \
SLOT(setValue(int))); + connect(m_page->azimuthSpinBox3, \
SIGNAL(valueChanged(int)), m_page->azimuthDial3, SLOT(setValue(int))); + \
connect(m_page->azimuthSpinBox4, SIGNAL(valueChanged(int)), m_page->azimuthDial4, \
SLOT(setValue(int))); +
+ connect(m_page->diffuseReflectivityCheckBox, SIGNAL(toggled(bool)),
+ m_page->diffuseReflectivityKisDoubleSliderSpinBox, \
SLOT(setEnabled(bool))); + connect(m_page->specularReflectivityCheckBox, \
SIGNAL(toggled(bool)), + \
m_page->specularReflectivityKisDoubleSliderSpinBox, SLOT(setEnabled(bool))); + \
connect(m_page->specularReflectivityCheckBox, SIGNAL(toggled(bool)), + \
m_page->shinynessExponentKisSliderSpinBox, SLOT(setEnabled(bool))); + \
connect(m_page->specularReflectivityCheckBox, SIGNAL(toggled(bool)), + \
m_page->shinynessExponentLabel, SLOT(setEnabled(bool))); +
+ QVBoxLayout * l = new QVBoxLayout(this);
+ Q_CHECK_PTR(l);
+
+ l->addWidget(m_page);
+
+ /* fill in the channel chooser */
+ QList<KoChannelInfo *> channels = m_device->colorSpace()->channels();
+ for (quint8 ch = 0; ch < m_device->colorSpace()->colorChannelCount(); ch++)
+ m_page->heightChannelComboBox->addItem(channels.at(ch)->name());
+
+
+}
+
+void KisPhongBumpmapConfigWidget::setConfiguration(const KisPropertiesConfiguration \
* config) +{
+ QVariant tempcolor;
+ m_page->ambientReflectivityKisDoubleSliderSpinBox->setValue( \
config->getDouble(PHONG_AMBIENT_REFLECTIVITY) ); + \
m_page->diffuseReflectivityKisDoubleSliderSpinBox->setValue( \
config->getDouble(PHONG_DIFFUSE_REFLECTIVITY) ); + \
m_page->specularReflectivityKisDoubleSliderSpinBox->setValue( \
config->getDouble(PHONG_SPECULAR_REFLECTIVITY) ); + \
m_page->shinynessExponentKisSliderSpinBox->setValue( \
config->getInt(PHONG_SHINYNESS_EXPONENT) ); + \
m_page->diffuseReflectivityCheckBox->setChecked( \
config->getBool(PHONG_DIFFUSE_REFLECTIVITY_IS_ENABLED) ); + \
m_page->specularReflectivityCheckBox->setChecked( \
config->getBool(PHONG_SPECULAR_REFLECTIVITY_IS_ENABLED) ); + // Indexes are off by \
1 simply because arrays start at 0 and the GUI naming scheme started at 1 + \
m_page->lightSourceGroupBox1->setChecked( \
config->getBool(PHONG_ILLUMINANT_IS_ENABLED[0]) ); + \
m_page->lightSourceGroupBox2->setChecked( \
config->getBool(PHONG_ILLUMINANT_IS_ENABLED[1]) ); + \
m_page->lightSourceGroupBox3->setChecked( \
config->getBool(PHONG_ILLUMINANT_IS_ENABLED[2]) ); + \
m_page->lightSourceGroupBox4->setChecked( \
config->getBool(PHONG_ILLUMINANT_IS_ENABLED[3]) ); + \
config->getProperty(PHONG_ILLUMINANT_COLOR[0], tempcolor); + \
m_page->lightKColorCombo1->setColor(tempcolor.value<QColor>()); + \
config->getProperty(PHONG_ILLUMINANT_COLOR[1], tempcolor); + \
m_page->lightKColorCombo2->setColor(tempcolor.value<QColor>()); + \
config->getProperty(PHONG_ILLUMINANT_COLOR[2], tempcolor); + \
m_page->lightKColorCombo3->setColor(tempcolor.value<QColor>()); + \
config->getProperty(PHONG_ILLUMINANT_COLOR[3], tempcolor); + \
m_page->lightKColorCombo4->setColor(tempcolor.value<QColor>()); + \
m_page->azimuthSpinBox1->setValue( config->getDouble(PHONG_ILLUMINANT_AZIMUTH[0]) ); \
+ m_page->azimuthSpinBox2->setValue( \
config->getDouble(PHONG_ILLUMINANT_AZIMUTH[1]) ); + \
m_page->azimuthSpinBox3->setValue( config->getDouble(PHONG_ILLUMINANT_AZIMUTH[2]) ); \
+ m_page->azimuthSpinBox4->setValue( \
config->getDouble(PHONG_ILLUMINANT_AZIMUTH[3]) ); + \
m_page->inclinationSpinBox1->setValue( \
config->getDouble(PHONG_ILLUMINANT_INCLINATION[0]) ); + \
m_page->inclinationSpinBox2->setValue( \
config->getDouble(PHONG_ILLUMINANT_INCLINATION[1]) ); + \
m_page->inclinationSpinBox3->setValue( \
config->getDouble(PHONG_ILLUMINANT_INCLINATION[2]) ); + \
m_page->inclinationSpinBox4->setValue( \
config->getDouble(PHONG_ILLUMINANT_INCLINATION[3]) ); +
+ if (!config) return;
+}
+
+KisPropertiesConfiguration* KisPhongBumpmapConfigWidget::configuration() const
+{
+ KisFilterConfiguration * config = new KisFilterConfiguration("phongbumpmap", 2);
+ config->setProperty(PHONG_HEIGHT_CHANNEL, \
m_page->heightChannelComboBox->currentText()); + \
config->setProperty(PHONG_AMBIENT_REFLECTIVITY, \
m_page->ambientReflectivityKisDoubleSliderSpinBox->value()); + \
config->setProperty(PHONG_DIFFUSE_REFLECTIVITY, \
m_page->diffuseReflectivityKisDoubleSliderSpinBox->value()); + \
config->setProperty(PHONG_SPECULAR_REFLECTIVITY, \
m_page->specularReflectivityKisDoubleSliderSpinBox->value()); + \
config->setProperty(PHONG_SHINYNESS_EXPONENT, \
m_page->shinynessExponentKisSliderSpinBox->value()); + \
config->setProperty(PHONG_DIFFUSE_REFLECTIVITY_IS_ENABLED, \
m_page->diffuseReflectivityCheckBox->isChecked()); + \
config->setProperty(PHONG_SPECULAR_REFLECTIVITY_IS_ENABLED, \
m_page->specularReflectivityCheckBox->isChecked()); + \
//config->setProperty(PHONG_SHINYNESS_EXPONENT_IS_ENABLED, \
m_page->specularReflectivityCheckBox->isChecked()); + // Indexes are off by 1 \
simply because arrays start at 0 and the GUI naming scheme started at 1 + \
config->setProperty(PHONG_ILLUMINANT_IS_ENABLED[0], \
m_page->lightSourceGroupBox1->isChecked()); + \
config->setProperty(PHONG_ILLUMINANT_IS_ENABLED[1], \
m_page->lightSourceGroupBox2->isChecked()); + \
config->setProperty(PHONG_ILLUMINANT_IS_ENABLED[2], \
m_page->lightSourceGroupBox3->isChecked()); + \
config->setProperty(PHONG_ILLUMINANT_IS_ENABLED[3], \
m_page->lightSourceGroupBox4->isChecked()); + \
config->setProperty(PHONG_ILLUMINANT_COLOR[0], m_page->lightKColorCombo1->color()); + \
config->setProperty(PHONG_ILLUMINANT_COLOR[1], m_page->lightKColorCombo2->color()); + \
config->setProperty(PHONG_ILLUMINANT_COLOR[2], m_page->lightKColorCombo3->color()); + \
config->setProperty(PHONG_ILLUMINANT_COLOR[3], m_page->lightKColorCombo4->color()); + \
config->setProperty(PHONG_ILLUMINANT_AZIMUTH[0], m_page->azimuthSpinBox1->value()); + \
config->setProperty(PHONG_ILLUMINANT_AZIMUTH[1], m_page->azimuthSpinBox2->value()); + \
config->setProperty(PHONG_ILLUMINANT_AZIMUTH[2], m_page->azimuthSpinBox3->value()); + \
config->setProperty(PHONG_ILLUMINANT_AZIMUTH[3], m_page->azimuthSpinBox4->value()); + \
config->setProperty(PHONG_ILLUMINANT_INCLINATION[0], \
m_page->inclinationSpinBox1->value()); + \
config->setProperty(PHONG_ILLUMINANT_INCLINATION[1], \
m_page->inclinationSpinBox2->value()); + \
config->setProperty(PHONG_ILLUMINANT_INCLINATION[2], \
m_page->inclinationSpinBox3->value()); + \
config->setProperty(PHONG_ILLUMINANT_INCLINATION[3], \
m_page->inclinationSpinBox4->value()); +
+ // Read configuration
+ QMap<QString, QVariant> rofl = QMap<QString, QVariant>(config->getProperties());
+
+ QMap<QString, QVariant>::const_iterator i;
+ for (i = rofl.constBegin(); i != rofl.constEnd(); ++i)
+ qDebug() << i.key() << ":" << i.value();
+
+ return config;
+}
+
diff --git a/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_config_widget.h \
b/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_config_widget.h new file mode \
100644 index 0000000..2447f66
--- /dev/null
+++ b/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_config_widget.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2010-2011 José Luis Vergara <pentalis@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KIS_PHONG_BUMPMAP_CONFIG_WIDGET_H
+#define KIS_PHONG_BUMPMAP_CONFIG_WIDGET_H
+
+#include "ui_wdgphongbumpmap.h"
+#include "kis_paint_device.h"
+#include "kis_config_widget.h"
+
+class KisNodeModel;
+
+class KisPhongBumpmapWidget : public QWidget, public Ui::WdgPhongBumpmap
+{
+ Q_OBJECT
+
+public:
+ KisPhongBumpmapWidget(QWidget *parent) : QWidget(parent)
+ {
+ setupUi(this);
+
+ ambientReflectivityKisDoubleSliderSpinBox -> setRange(0, 1, 2);
+ diffuseReflectivityKisDoubleSliderSpinBox -> setRange(0, 1, 2);
+ specularReflectivityKisDoubleSliderSpinBox -> setRange(0, 1, 2);
+ shinynessExponentKisSliderSpinBox -> setRange(1, 200);
+
+ ambientReflectivityKisDoubleSliderSpinBox -> setValue(0.1);
+ diffuseReflectivityKisDoubleSliderSpinBox -> setValue(0.5);
+ specularReflectivityKisDoubleSliderSpinBox -> setValue(0.5);
+ shinynessExponentKisSliderSpinBox -> setValue(40);
+ }
+};
+
+class KisPhongBumpmapConfigWidget : public KisConfigWidget
+{
+
+ Q_OBJECT
+
+public:
+ KisPhongBumpmapConfigWidget(const KisPaintDeviceSP dev, const KisImageWSP image, \
QWidget * parent, Qt::WFlags f = 0); + virtual ~KisPhongBumpmapConfigWidget() {}
+
+ void setConfiguration(const KisPropertiesConfiguration* config);
+ KisPropertiesConfiguration* configuration() const;
+
+ KisPhongBumpmapWidget * m_page;
+
+private:
+ KisPaintDeviceSP m_device;
+ KisImageWSP m_image;
+};
+
+#endif //KIS_PHONG_BUMPMAP_CONFIG_WIDGET_H
diff --git a/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_filter.cpp \
b/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_filter.cpp new file mode \
100644 index 0000000..035d61b
--- /dev/null
+++ b/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_filter.cpp
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2010-2011 José Luis Vergara <pentalis@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "kis_phong_bumpmap_filter.h"
+#include "kis_phong_bumpmap_config_widget.h"
+#include "phong_pixel_processor.h"
+
+#include "kis_paint_device.h"
+#include "kis_config_widget.h"
+#include "kis_math_toolbox.h"
+#include "KoColorSpaceRegistry.h"
+#include <filter/kis_filter_configuration.h>
+#include "kis_iterator_ng.h"
+
+void KisFilterPhongBumpmap::process(KisPaintDeviceSP device,
+ const QRect& applyRect,
+ const KisFilterConfiguration* config,
+ KoUpdater* /*progressUpdater*/
+ ) const
+{
+#ifdef __GNUC__
+ #warning TODO: implement progress updater for phong bumpmap
+#endif
+
+ // Benchmark
+ QTime timer, timerE;
+
+ QString userChosenHeightChannel = config->getString(PHONG_HEIGHT_CHANNEL, \
"FAIL"); +
+ if (userChosenHeightChannel == "FAIL") {
+ qDebug("FIX YOUR FILTER");
+ return;
+ }
+
+ //Bypass stuff lol
+ userChosenHeightChannel = "Red";
+
+ timer.start();
+
+ KoChannelInfo* m_heightChannel = 0;
+
+ foreach (KoChannelInfo* channel, device->colorSpace()->channels()) {
+ if (userChosenHeightChannel == channel->name())
+ m_heightChannel = channel;
+ }
+
+ QRect inputArea = applyRect;
+ inputArea.adjust(-1, -1, 1, 1);
+ QRect outputArea = inputArea.adjusted(1, 1, -1, -1);
+
+ quint32 posup;
+ quint32 posdown;
+ quint32 posleft;
+ quint32 posright;
+ QRect tileLimits;
+
+ QColor I; //Reflected light
+
+ //======================================
+ //======Preparation paraphlenalia=======
+ //======================================
+
+ //Hardcoded facts about Phong Bumpmap: it _will_ generate an RGBA16 bumpmap
+ const quint32 PIXELS_OF_OUTPUT_AREA = abs(outputArea.width() * \
outputArea.height()); + const quint8 BYTE_DEPTH_OF_BUMPMAP = 2; //16 bits per \
channel + const quint8 CHANNEL_COUNT_OF_BUMPMAP = 4; //RGBA
+ const quint32 BYTES_TO_FILL_BUMPMAP_AREA = PIXELS_OF_OUTPUT_AREA * \
BYTE_DEPTH_OF_BUMPMAP * CHANNEL_COUNT_OF_BUMPMAP; + QVector<quint8> \
bumpmap(BYTES_TO_FILL_BUMPMAP_AREA); + quint8* bumpmapDataPointer = \
bumpmap.data(); + const quint8 PIXEL_SIZE = BYTE_DEPTH_OF_BUMPMAP * \
CHANNEL_COUNT_OF_BUMPMAP; +
+ //qDebug("Tiempo de total preparacion: %d ms", timer.restart());
+
+ PhongPixelProcessor tileRenderer(config);
+ quint32 ki = m_heightChannel->index();
+
+ //======================================
+ //===============RENDER=================
+ //======================================
+
+ QVector<PtrToDouble> toDoubleFuncPtr(device->colorSpace()->channels().count());
+ KisMathToolbox* mathToolbox = \
KisMathToolboxRegistry::instance()->value(device->colorSpace()->mathToolboxId().id());
+ if (!mathToolbox->getToDoubleChannelPtr(device->colorSpace()->channels(), \
toDoubleFuncPtr)) + return;
+
+ KisHLineIteratorSP iterator;
+ quint32 curPixel = 0;
+
+ iterator = device->createHLineIteratorNG(inputArea.x(),
+ inputArea.y(),
+ inputArea.width()
+ );
+
+ curPixel = 0;
+
+ for (qint32 srcRow = 0; srcRow < inputArea.height(); ++srcRow)
+ {
+ do
+ {
+ const quint8* data = iterator->rawData();
+ //tileRenderer.realheightmap[curPixel] = (double)*data;
+
+ tileRenderer.realheightmap[curPixel] = toDoubleFuncPtr[ki](data, \
device->colorSpace()->channels()[ki]->pos()); +
+ curPixel++;
+ }
+ while (iterator->nextPixel());
+ iterator->nextRow();
+ }
+
+ const int tileHeightMinus1 = inputArea.width() - 1;
+ const int tileWidthMinus1 = inputArea.height() - 1;
+
+ // Foreach INNER pixel in tile
+ for (int y = 1; y < tileHeightMinus1; ++y) {
+ for (int x = 1; x < tileWidthMinus1; ++x) {
+ posup = (y + 1) * inputArea.width() + x;
+ posdown = (y - 1) * inputArea.width() + x;
+ posleft = y * inputArea.width() + x - 1;
+ posright = y * inputArea.width() + x + 1;
+
+ memcpy(bumpmapDataPointer,
+ tileRenderer.testingHeightmapIlluminatePixel(posup, posdown, \
posleft, posright).data(), + PIXEL_SIZE);
+ bumpmapDataPointer += PIXEL_SIZE;
+ }
+ }
+
+ KisPaintDeviceSP bumpmapPaintDevice = new \
KisPaintDevice(KoColorSpaceRegistry::instance()->rgb16()); + \
bumpmapPaintDevice->writeBytes(bumpmap.data(), outputArea.x(), outputArea.y(), \
outputArea.width(), outputArea.height()); + \
bumpmapPaintDevice->convertTo(device->colorSpace()); + \
device->makeCloneFrom(bumpmapPaintDevice, bumpmapPaintDevice->extent()); // THIS \
COULD BE BUG GY +}
+
+
+
+KisFilterPhongBumpmap::KisFilterPhongBumpmap()
+ : KisFilter(KoID("phongbumpmap", i18n("PhongBumpmap")), \
KisFilter::categoryMap(), i18n("&PhongBumpmap...")) +{
+ setColorSpaceIndependence(TO_LAB16);
+ setSupportsPainting(true);
+ setSupportsIncrementalPainting(true);
+}
+
+
+KisFilterConfiguration* KisFilterPhongBumpmap::factoryConfiguration(const \
KisPaintDeviceSP) const +{
+ KisFilterConfiguration* config = new KisFilterConfiguration(id(), 0);
+ return config;
+}
+
+QRect KisFilterPhongBumpmap::neededRect(const QRect &rect, const \
KisFilterConfiguration* /*config*/) const +{
+ return rect.adjusted(-2, -2, 2, 2);
+}
+
+QRect KisFilterPhongBumpmap::changedRect(const QRect &rect, const \
KisFilterConfiguration* /*config*/) const +{
+ return rect.adjusted(-2, -2, 2, 2);
+}
+
+
+
+
+
+
+KisConfigWidget * KisFilterPhongBumpmap::createConfigurationWidget(QWidget* parent, \
const KisPaintDeviceSP dev, const KisImageWSP image) const +{
+ KisPhongBumpmapConfigWidget * w = new KisPhongBumpmapConfigWidget(dev, image, \
parent); +
+ //KisLightSource* newlight = new KisLightSource(QColor(0, 255, 255, 255), 0, 90, \
w->m_page->lightStage); +
+ //QObject::connect(newlight, SIGNAL(moved()), w->m_page->lightStage, \
SLOT(update())); +
+ return w;
+}
+
+
diff --git a/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_filter.h \
b/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_filter.h new file mode 100644
index 0000000..05a5c1a
--- /dev/null
+++ b/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_filter.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2010 Dmitry Kazakov <dimula73@gmail.com>
+ * Copyright (c) 2010-2011 José Luis Vergara <pentalis@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KIS_PHONG_BUMPMAP_FILTER_H
+#define KIS_PHONG_BUMPMAP_FILTER_H
+
+#include <kis_types.h>
+#include <filter/kis_filter.h>
+
+/**
+ * This class is an implementation of the phong illumination model.
+ * It uses a heightmap as an input mesh (normally taken from 1
+ * channel of a colorspace) to achieve a bumpmapping effect with
+ * multiple illumination sources.
+ */
+class KisFilterPhongBumpmap : public KisFilter
+{
+public:
+ KisFilterPhongBumpmap();
+
+public:
+ using KisFilter::process;
+
+ void process(KisPaintDeviceSP device,
+ const QRect& applyRect,
+ const KisFilterConfiguration* config,
+ KoUpdater* progressUpdater
+ ) const;
+
+ QRect neededRect(const QRect &rect, const KisFilterConfiguration* config) const;
+ QRect changedRect(const QRect &rect, const KisFilterConfiguration* config) \
const; +
+ bool supportsAdjustmentLayers() const {
+ return false;
+ }
+
+ virtual KisConfigWidget * createConfigurationWidget(QWidget* parent, const \
KisPaintDeviceSP dev, const KisImageWSP image = 0) const; + virtual \
KisFilterConfiguration* factoryConfiguration(const KisPaintDeviceSP) const; +};
+
+#endif //KIS_PHONG_BUMPMAP_FILTER_H
\ No newline at end of file
diff --git a/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_plugin.cpp \
b/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_plugin.cpp new file mode \
100644 index 0000000..b6ee21d
--- /dev/null
+++ b/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_plugin.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010-2011 José Luis Vergara <pentalis@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "kis_phong_bumpmap_plugin.h"
+#include "kis_phong_bumpmap_filter.h"
+
+#include <kpluginfactory.h>
+#include <filter/kis_filter_registry.h>
+
+K_PLUGIN_FACTORY (KisPhongBumpmapFactory, registerPlugin<KisPhongBumpmapPlugin>();)
+K_EXPORT_PLUGIN (KisPhongBumpmapFactory("krita"))
+
+KisPhongBumpmapPlugin::KisPhongBumpmapPlugin(QObject *parent, const QVariantList &)
+ : QObject(parent)
+{
+ KisFilterRegistry::instance()->add(new KisFilterPhongBumpmap());
+}
+
+KisPhongBumpmapPlugin::~KisPhongBumpmapPlugin()
+{
+}
+
+#include "kis_phong_bumpmap_plugin.moc"
diff --git a/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_plugin.h \
b/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_plugin.h new file mode 100644
index 0000000..46de297
--- /dev/null
+++ b/krita/plugins/filters/phongbumpmap/kis_phong_bumpmap_plugin.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2010-2011 José Luis Vergara <pentalis@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KIS_PHONG_BUMPMAP_PLUGIN_H
+#define KIS_PHONG_BUMPMAP_PLUGIN_H
+
+#include <QObject>
+#include <QVariantList>
+
+class KisPhongBumpmapPlugin : public QObject
+{
+ Q_OBJECT
+public:
+ KisPhongBumpmapPlugin(QObject *parent, const QVariantList &);
+ virtual ~KisPhongBumpmapPlugin();
+};
+
+#endif //KIS_PHONG_BUMPMAP_PLUGIN_H
\ No newline at end of file
diff --git a/krita/plugins/filters/phongbumpmap/phong_bumpmap_constants.h \
b/krita/plugins/filters/phongbumpmap/phong_bumpmap_constants.h new file mode 100644
index 0000000..67fe945
--- /dev/null
+++ b/krita/plugins/filters/phongbumpmap/phong_bumpmap_constants.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2010 José Luis Vergara <pentalis@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef CONSTANTS_H
+#define CONSTANTS_H
+
+/*
+* Illuminants were renamed to Light Sources in the GUI
+*/
+const quint8 PHONG_TOTAL_ILLUMINANTS = 4;
+const QString PHONG_HEIGHT_CHANNEL = "heightChannel";
+const QString PHONG_ILLUMINANT_IS_ENABLED[] =
+{"illuminantIsEnabled0",
+"illuminantIsEnabled1",
+"illuminantIsEnabled2",
+"illuminantIsEnabled3"};
+const QString PHONG_ILLUMINANT_COLOR[] =
+{"illuminantColor0",
+"illuminantColor1",
+"illuminantColor2",
+"illuminantColor3"};
+const QString PHONG_ILLUMINANT_AZIMUTH[] =
+{"Azimuth0",
+"Azimuth1",
+"Azimuth2",
+"Azimuth3"};
+const QString PHONG_ILLUMINANT_INCLINATION[] =
+{"Inclination0",
+"Inclination1",
+"Inclination2",
+"Inclination3"};
+const QString PHONG_AMBIENT_REFLECTIVITY = "ambientReflectivity";
+const QString PHONG_DIFFUSE_REFLECTIVITY = "diffuseReflectivity";
+const QString PHONG_SPECULAR_REFLECTIVITY = "specularReflectivity";
+const QString PHONG_SHINYNESS_EXPONENT = "shinynessExponent";
+const QString PHONG_DIFFUSE_REFLECTIVITY_IS_ENABLED = \
"diffuseReflectivityIsEnabled"; +const QString PHONG_SPECULAR_REFLECTIVITY_IS_ENABLED \
= "specularReflectivityIsEnabled"; +//const QString \
PHONG_SHINYNESS_EXPONENT_IS_ENABLED = "shinynessExponentIsEnabled"; +
+#endif
diff --git a/krita/plugins/filters/phongbumpmap/phong_pixel_processor.h \
b/krita/plugins/filters/phongbumpmap/phong_pixel_processor.h index 5dbd010..55a7243 \
100644
--- a/krita/plugins/filters/phongbumpmap/phong_pixel_processor.h
+++ b/krita/plugins/filters/phongbumpmap/phong_pixel_processor.h
@@ -24,7 +24,7 @@
#include <QPair>
#include <QMap>
-#include "constants.h"
+#include "phong_bumpmap_constants.h"
#include "kis_properties_configuration.h"
#include <KoChannelInfo.h>
diff --git a/krita/plugins/filters/phongbumpmap/phongbumpmap.cpp \
b/krita/plugins/filters/phongbumpmap/phongbumpmap.cpp deleted file mode 100644
index 6ba90dc..0000000
--- a/krita/plugins/filters/phongbumpmap/phongbumpmap.cpp
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * Copyright (c) 2010 Dmitry Kazakov <dimula73@gmail.com>
- * Copyright (c) 2010-2011 José Luis Vergara <pentalis@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "phongbumpmap.h"
-
-#include <stdlib.h>
-
-#include <QButtonGroup>
-#include <QComboBox>
-#include <QCheckBox>
-#include <QHBoxLayout>
-#include <QLayout>
-#include <QLineEdit>
-#include <QPoint>
-#include <QPushButton>
-#include <QString>
-
-#include <kcomponentdata.h>
-#include <kpluginfactory.h>
-#include <kiconloader.h>
-#include <klocale.h>
-#include <kmessagebox.h>
-#include <knuminput.h>
-#include <kstandarddirs.h>
-
-#include <KoColorTransformation.h>
-#include <KoIntegerMaths.h>
-#include <KoProgressUpdater.h>
-#include <KoUpdater.h>
-#include <KoDocumentSectionView.h>
-
-#include <kis_debug.h>
-#include <kis_doc2.h>
-#include <filter/kis_filter_registry.h>
-#include <kis_global.h>
-#include <kis_image.h>
-#include <kis_iterators_pixel.h>
-#include <kis_layer.h>
-#include <kis_selection.h>
-#include <kis_types.h>
-#include <filter/kis_filter_configuration.h>
-#include <kis_paint_device.h>
-#include <kis_processing_information.h>
-#include <kis_node_model.h>
-
-#include <QPixmap>
-#include <QImage>
-#include <QDebug>
-#include <QTime>
-#include <QVector3D>
-#include <QVector>
-#include <cmath>
-#include <iostream>
-
-#include <time.h>
-
-#include <KoColorSpaceRegistry.h>
-#include <colorprofiles/KoDummyColorProfile.h>
-
-#include <QColor>
-
-#include <opengl/kis_opengl.h>
-/*
-#include <../../extensions/impasto/kis_fresh_start_color_space.h>
-#include <../../extensions/impasto/kis_fresh_start_color_space.cpp>
-*/
-
-#include "kdebug.h"
-#include <kis_painter.h>
-
-#include <kis_iterator_ng.h>
-#include "kis_math_toolbox.h"
-
-K_PLUGIN_FACTORY(KritaPhongBumpmapFactory, registerPlugin<KritaPhongBumpmap>();)
-K_EXPORT_PLUGIN(KritaPhongBumpmapFactory("krita"))
-
-
-KritaPhongBumpmap::KritaPhongBumpmap(QObject *parent, const QVariantList &)
- : QObject(parent)
-{
- KisFilterRegistry::instance()->add(new KisFilterPhongBumpmap());
-}
-
-KritaPhongBumpmap::~KritaPhongBumpmap()
-{
-}
-
-void KisFilterPhongBumpmap::process(KisPaintDeviceSP device,
- const QRect& applyRect,
- const KisFilterConfiguration* config,
- KoUpdater* /*progressUpdater*/
- ) const
-{
-#ifdef __GNUC__
- #warning TODO: implement progress updater for phong bumpmap
-#endif
-
- // Benchmark
- QTime timer, timerE;
-
- QString userChosenHeightChannel = config->getString(PHONG_HEIGHT_CHANNEL, \
"FAIL");
-
- if (userChosenHeightChannel == "FAIL") {
- qDebug("FIX YOUR FILTER");
- return;
- }
-
- //Bypass stuff lol
- userChosenHeightChannel = "Red";
-
- timer.start();
-
- KoChannelInfo* m_heightChannel = 0;
-
- foreach (KoChannelInfo* channel, device->colorSpace()->channels()) {
- if (userChosenHeightChannel == channel->name())
- m_heightChannel = channel;
- }
-
- qDebug("Tiempo de preparacion: %d ms", timer.restart());
-
- QRect inputArea = applyRect;
- inputArea.adjust(-1, -1, 1, 1);
- QRect outputArea = inputArea.adjusted(1, 1, -1, -1);
- //QRect outputArea(dstInfo.topLeft().x()+1, dstInfo.topLeft().y()+1, \
size.width()-1, size.height()-1);
-
- //qDebug() << "inputArea: " << inputArea << srcInfo.topLeft();
- //qDebug() << "outputArea: " << outputArea << dstInfo.topLeft();
- quint32 posup;
- quint32 posdown;
- quint32 posleft;
- quint32 posright;
- QRect tileLimits;
-
- QColor I; //Reflected light
-
- //======================================
- //======Preparation paraphlenalia=======
- //======================================
-/*
- QImage bumpmap(outputArea.width(), outputArea.height(), QImage::Format_RGB32);
- bumpmap.fill(0);
-
- QRgb** bumpmapByteLines = new QRgb*[bumpmap.height()];
-
- for (int yIndex = 0; yIndex < bumpmap.height(); yIndex++)
- bumpmapByteLines[yIndex] = (QRgb *) bumpmap.scanLine(yIndex);
-*/
- //Hardcoded facts about Phong Bumpmap: it _will_ generate an RGBA16 bumpmap
- const quint32 PIXELS_OF_OUTPUT_AREA = abs(outputArea.width() * \
outputArea.height());
- const quint8 BYTE_DEPTH_OF_BUMPMAP = 2; //16 bits per channel
- const quint8 CHANNEL_COUNT_OF_BUMPMAP = 4; //RGBA
- const quint32 BYTES_TO_FILL_BUMPMAP_AREA = PIXELS_OF_OUTPUT_AREA * \
BYTE_DEPTH_OF_BUMPMAP * CHANNEL_COUNT_OF_BUMPMAP;
- QVector<quint8> bumpmap(BYTES_TO_FILL_BUMPMAP_AREA);
- quint8* bumpmapDataPointer = bumpmap.data();
- const quint8 PIXEL_SIZE = BYTE_DEPTH_OF_BUMPMAP * CHANNEL_COUNT_OF_BUMPMAP;
-
- //qDebug("Tiempo de total preparacion: %d ms", timer.restart());
-
- PhongPixelProcessor tileRenderer(config);
- quint32 ki = m_heightChannel->index();
-
- //======================================
- //===============RENDER=================
- //======================================
-
- qDebug() << "Canary1";
-
- QVector<PtrToDouble> toDoubleFuncPtr(device->colorSpace()->channels().count());
- KisMathToolbox* mathToolbox = \
KisMathToolboxRegistry::instance()->value(device->colorSpace()->mathToolboxId().id());
- if (!mathToolbox->getToDoubleChannelPtr(device->colorSpace()->channels(), \
toDoubleFuncPtr))
- return;
-
- KisHLineIteratorSP iterator;
- quint32 curPixel = 0;
-
- iterator = device->createHLineIteratorNG(inputArea.x(),
- inputArea.y(),
- inputArea.width()
- );
-
- curPixel = 0;
-
- for (qint32 srcRow = 0; srcRow < inputArea.height(); ++srcRow)
- {
- do
- {
- const quint8* data = iterator->rawData();
- //tileRenderer.realheightmap[curPixel] = (double)*data;
-
- tileRenderer.realheightmap[curPixel] = toDoubleFuncPtr[ki](data, \
device->colorSpace()->channels()[ki]->pos());
-
- curPixel++;
- }
- while (iterator->nextPixel());
- iterator->nextRow();
- }
-
- qDebug() << "Canary2";
-
- const int TILE_WIDTH_MINUS_1 = inputArea.width() - 1;
- const int TILE_HEIGHT_MINUS_1 = inputArea.height() - 1;
-
- for (int y = 1; y < TILE_HEIGHT_MINUS_1; y++) {
- for (int x = 1; x < TILE_WIDTH_MINUS_1; x++) {
- // ^^^ Foreach INNER pixel in tile
-
- posup = (y + 1) * inputArea.width() + x;
- posdown = (y - 1) * inputArea.width() + x;
- posleft = y * inputArea.width() + x - 1;
- posright = y * inputArea.width() + x + 1;
-
- memcpy(bumpmapDataPointer,
- tileRenderer.testingHeightmapIlluminatePixel(posup, posdown, \
posleft, posright).data(),
- PIXEL_SIZE);
-
- bumpmapDataPointer += PIXEL_SIZE;
- }
- }
- /*
- for (int x = 1; x < TILE_WIDTH_MINUS_1; x++) {
- for (int y = 1; y < TILE_HEIGHT_MINUS_1; y++) {
- // ^^^ Foreach INNER pixel in tile
-
- posup = (y + 1) * inputArea.width() + x;
- posdown = (y - 1) * inputArea.width() + x;
- posleft = y * inputArea.width() + x - 1;
- posright = y * inputArea.width() + x + 1;
-
- // TODO BUG
- memcpy(bumpmapDataPointer,
- tileRenderer.testingHeightmapIlluminatePixel(posup, posdown, \
posleft, posright).data(),
- PIXEL_SIZE);
-
- bumpmapDataPointer += PIXEL_SIZE;
- }
- }
- */
- qDebug() << "Canary3";
-
- qDebug("Tiempo de calculo: %d ms", timer.restart());
-
- KisPaintDeviceSP bumpmapPaintDevice = new \
KisPaintDevice(KoColorSpaceRegistry::instance()->rgb16());
- bumpmapPaintDevice->writeBytes(bumpmap.data(), outputArea.x(), outputArea.y(), \
outputArea.width(), outputArea.height());
- bumpmapPaintDevice->convertTo(device->colorSpace());
- device->makeCloneFrom(bumpmapPaintDevice, bumpmapPaintDevice->extent()); // \
THIS COULD BE BUG GY
-
- qDebug("Tiempo deconversion: %d ms", timer.elapsed());
-}
-
-
-
-KisFilterPhongBumpmap::KisFilterPhongBumpmap()
- : KisFilter(KoID("phongbumpmap", i18n("PhongBumpmap")), \
KisFilter::categoryMap(), i18n("&PhongBumpmap..."))
-{
- setColorSpaceIndependence(TO_LAB16);
- setSupportsPainting(true);
- setSupportsIncrementalPainting(true);
-}
-
-
-KisFilterConfiguration* KisFilterPhongBumpmap::factoryConfiguration(const \
KisPaintDeviceSP) const
-{
- KisFilterConfiguration* config = new KisFilterConfiguration(id(), 0);
- return config;
-}
-
-QRect KisFilterPhongBumpmap::neededRect(const QRect &rect, const \
KisFilterConfiguration* /*config*/) const
-{
- return rect.adjusted(-2, -2, 2, 2);
-}
-
-QRect KisFilterPhongBumpmap::changedRect(const QRect &rect, const \
KisFilterConfiguration* /*config*/) const
-{
- return rect.adjusted(-2, -2, 2, 2);
-}
-
-
-
-
-
-
-KisConfigWidget * KisFilterPhongBumpmap::createConfigurationWidget(QWidget* parent, \
const KisPaintDeviceSP dev, const KisImageWSP image) const
-{
- KisPhongBumpmapConfigWidget * w = new KisPhongBumpmapConfigWidget(dev, image, \
parent);
-
- return w;
-}
-
-
-
-
-
-
-
-
-
-
-KisPhongBumpmapConfigWidget::KisPhongBumpmapConfigWidget(const KisPaintDeviceSP dev, \
const KisImageWSP image, QWidget * parent, Qt::WFlags f)
- : KisConfigWidget(parent, f)
- , m_device(dev)
- , m_image(image)
-{
- Q_ASSERT(m_device);
- m_page = new PhongBumpmapWidget(this);
-
- connect(m_page->azimuthDial1, SIGNAL(valueChanged(int)), \
m_page->azimuthSpinBox1, SLOT(setValue(int)));
- connect(m_page->azimuthDial2, SIGNAL(valueChanged(int)), \
m_page->azimuthSpinBox2, SLOT(setValue(int)));
- connect(m_page->azimuthDial3, SIGNAL(valueChanged(int)), \
m_page->azimuthSpinBox3, SLOT(setValue(int)));
- connect(m_page->azimuthDial4, SIGNAL(valueChanged(int)), \
m_page->azimuthSpinBox4, SLOT(setValue(int)));
- connect(m_page->azimuthSpinBox1, SIGNAL(valueChanged(int)), \
m_page->azimuthDial1, SLOT(setValue(int)));
- connect(m_page->azimuthSpinBox2, SIGNAL(valueChanged(int)), \
m_page->azimuthDial2, SLOT(setValue(int)));
- connect(m_page->azimuthSpinBox3, SIGNAL(valueChanged(int)), \
m_page->azimuthDial3, SLOT(setValue(int)));
- connect(m_page->azimuthSpinBox4, SIGNAL(valueChanged(int)), \
m_page->azimuthDial4, SLOT(setValue(int)));
-
- connect(m_page->diffuseReflectivityCheckBox, SIGNAL(toggled(bool)),
- m_page->diffuseReflectivityKisDoubleSliderSpinBox, \
SLOT(setEnabled(bool)));
- connect(m_page->specularReflectivityCheckBox, SIGNAL(toggled(bool)),
- m_page->specularReflectivityKisDoubleSliderSpinBox, \
SLOT(setEnabled(bool)));
- connect(m_page->specularReflectivityCheckBox, SIGNAL(toggled(bool)),
- m_page->shinynessExponentKisSliderSpinBox, SLOT(setEnabled(bool)));
- connect(m_page->specularReflectivityCheckBox, SIGNAL(toggled(bool)),
- m_page->shinynessExponentLabel, SLOT(setEnabled(bool)));
-
- QVBoxLayout * l = new QVBoxLayout(this);
- Q_CHECK_PTR(l);
-
- l->addWidget(m_page);
-
- /* fill in the channel chooser */
- QList<KoChannelInfo *> channels = m_device->colorSpace()->channels();
- for (quint8 ch = 0; ch < m_device->colorSpace()->colorChannelCount(); ch++)
- m_page->heightChannelComboBox->addItem(channels.at(ch)->name());
-
-
-}
-
-void KisPhongBumpmapConfigWidget::setConfiguration(const KisPropertiesConfiguration \
* config)
-{
- QVariant tempcolor;
- m_page->ambientReflectivityKisDoubleSliderSpinBox->setValue( \
config->getDouble(PHONG_AMBIENT_REFLECTIVITY) );
- m_page->diffuseReflectivityKisDoubleSliderSpinBox->setValue( \
config->getDouble(PHONG_DIFFUSE_REFLECTIVITY) );
- m_page->specularReflectivityKisDoubleSliderSpinBox->setValue( \
config->getDouble(PHONG_SPECULAR_REFLECTIVITY) );
- m_page->shinynessExponentKisSliderSpinBox->setValue( \
config->getInt(PHONG_SHINYNESS_EXPONENT) );
- m_page->diffuseReflectivityCheckBox->setChecked( \
config->getBool(PHONG_DIFFUSE_REFLECTIVITY_IS_ENABLED) );
- m_page->specularReflectivityCheckBox->setChecked( \
config->getBool(PHONG_SPECULAR_REFLECTIVITY_IS_ENABLED) );
- // Indexes are off by 1 simply because arrays start at 0 and the GUI naming \
scheme started at 1
- m_page->lightSourceGroupBox1->setChecked( \
config->getBool(PHONG_ILLUMINANT_IS_ENABLED[0]) );
- m_page->lightSourceGroupBox2->setChecked( \
config->getBool(PHONG_ILLUMINANT_IS_ENABLED[1]) );
- m_page->lightSourceGroupBox3->setChecked( \
config->getBool(PHONG_ILLUMINANT_IS_ENABLED[2]) );
- m_page->lightSourceGroupBox4->setChecked( \
config->getBool(PHONG_ILLUMINANT_IS_ENABLED[3]) );
- config->getProperty(PHONG_ILLUMINANT_COLOR[0], tempcolor);
- m_page->lightKColorCombo1->setColor(tempcolor.value<QColor>());
- config->getProperty(PHONG_ILLUMINANT_COLOR[1], tempcolor);
- m_page->lightKColorCombo2->setColor(tempcolor.value<QColor>());
- config->getProperty(PHONG_ILLUMINANT_COLOR[2], tempcolor);
- m_page->lightKColorCombo3->setColor(tempcolor.value<QColor>());
- config->getProperty(PHONG_ILLUMINANT_COLOR[3], tempcolor);
- m_page->lightKColorCombo4->setColor(tempcolor.value<QColor>());
- m_page->azimuthSpinBox1->setValue( \
config->getDouble(PHONG_ILLUMINANT_AZIMUTH[0]) );
- m_page->azimuthSpinBox2->setValue( \
config->getDouble(PHONG_ILLUMINANT_AZIMUTH[1]) );
- m_page->azimuthSpinBox3->setValue( \
config->getDouble(PHONG_ILLUMINANT_AZIMUTH[2]) );
- m_page->azimuthSpinBox4->setValue( \
config->getDouble(PHONG_ILLUMINANT_AZIMUTH[3]) );
- m_page->inclinationSpinBox1->setValue( \
config->getDouble(PHONG_ILLUMINANT_INCLINATION[0]) );
- m_page->inclinationSpinBox2->setValue( \
config->getDouble(PHONG_ILLUMINANT_INCLINATION[1]) );
- m_page->inclinationSpinBox3->setValue( \
config->getDouble(PHONG_ILLUMINANT_INCLINATION[2]) );
- m_page->inclinationSpinBox4->setValue( \
config->getDouble(PHONG_ILLUMINANT_INCLINATION[3]) );
-
- if (!config) return;
-}
-
-KisPropertiesConfiguration* KisPhongBumpmapConfigWidget::configuration() const
-{
- KisFilterConfiguration * config = new KisFilterConfiguration("phongbumpmap", 2);
- config->setProperty(PHONG_HEIGHT_CHANNEL, \
m_page->heightChannelComboBox->currentText());
- config->setProperty(PHONG_AMBIENT_REFLECTIVITY, \
m_page->ambientReflectivityKisDoubleSliderSpinBox->value());
- config->setProperty(PHONG_DIFFUSE_REFLECTIVITY, \
m_page->diffuseReflectivityKisDoubleSliderSpinBox->value());
- config->setProperty(PHONG_SPECULAR_REFLECTIVITY, \
m_page->specularReflectivityKisDoubleSliderSpinBox->value());
- config->setProperty(PHONG_SHINYNESS_EXPONENT, \
m_page->shinynessExponentKisSliderSpinBox->value());
- config->setProperty(PHONG_DIFFUSE_REFLECTIVITY_IS_ENABLED, \
m_page->diffuseReflectivityCheckBox->isChecked());
- config->setProperty(PHONG_SPECULAR_REFLECTIVITY_IS_ENABLED, \
m_page->specularReflectivityCheckBox->isChecked());
- //config->setProperty(PHONG_SHINYNESS_EXPONENT_IS_ENABLED, \
m_page->specularReflectivityCheckBox->isChecked());
- // Indexes are off by 1 simply because arrays start at 0 and the GUI naming \
scheme started at 1
- config->setProperty(PHONG_ILLUMINANT_IS_ENABLED[0], \
m_page->lightSourceGroupBox1->isChecked());
- config->setProperty(PHONG_ILLUMINANT_IS_ENABLED[1], \
m_page->lightSourceGroupBox2->isChecked());
- config->setProperty(PHONG_ILLUMINANT_IS_ENABLED[2], \
m_page->lightSourceGroupBox3->isChecked());
- config->setProperty(PHONG_ILLUMINANT_IS_ENABLED[3], \
m_page->lightSourceGroupBox4->isChecked());
- config->setProperty(PHONG_ILLUMINANT_COLOR[0], \
m_page->lightKColorCombo1->color());
- config->setProperty(PHONG_ILLUMINANT_COLOR[1], \
m_page->lightKColorCombo2->color());
- config->setProperty(PHONG_ILLUMINANT_COLOR[2], \
m_page->lightKColorCombo3->color());
- config->setProperty(PHONG_ILLUMINANT_COLOR[3], \
m_page->lightKColorCombo4->color());
- config->setProperty(PHONG_ILLUMINANT_AZIMUTH[0], \
m_page->azimuthSpinBox1->value());
- config->setProperty(PHONG_ILLUMINANT_AZIMUTH[1], \
m_page->azimuthSpinBox2->value());
- config->setProperty(PHONG_ILLUMINANT_AZIMUTH[2], \
m_page->azimuthSpinBox3->value());
- config->setProperty(PHONG_ILLUMINANT_AZIMUTH[3], \
m_page->azimuthSpinBox4->value());
- config->setProperty(PHONG_ILLUMINANT_INCLINATION[0], \
m_page->inclinationSpinBox1->value());
- config->setProperty(PHONG_ILLUMINANT_INCLINATION[1], \
m_page->inclinationSpinBox2->value());
- config->setProperty(PHONG_ILLUMINANT_INCLINATION[2], \
m_page->inclinationSpinBox3->value());
- config->setProperty(PHONG_ILLUMINANT_INCLINATION[3], \
m_page->inclinationSpinBox4->value());
-
- // Read configuration
- QMap<QString, QVariant> rofl = QMap<QString, QVariant>(config->getProperties());
-
- QMap<QString, QVariant>::const_iterator i;
- for (i = rofl.constBegin(); i != rofl.constEnd(); ++i)
- qDebug() << i.key() << ":" << i.value();
-
- return config;
-}
-
-#include "phongbumpmap.moc"
diff --git a/krita/plugins/filters/phongbumpmap/phongbumpmap.h \
b/krita/plugins/filters/phongbumpmap/phongbumpmap.h deleted file mode 100644
index b1cf0cc..0000000
--- a/krita/plugins/filters/phongbumpmap/phongbumpmap.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2010 José Luis Vergara <pentalis@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef PHONGBUMPMAP_H
-#define PHONGBUMPMAP_H
-
-#include <QWidget>
-
-#include <QObject>
-#include <QVariant>
-
-#include <kis_types.h>
-#include <filter/kis_filter.h>
-#include "kis_config_widget.h"
-
-#include "ui_wdgphongbumpmap.h"
-
-#include "constants.h"
-
-#include "phong_pixel_processor.h"
-
-
-class KisNodeModel;
-
-class PhongBumpmapWidget : public QWidget, public Ui::WdgPhongBumpmap
-{
- Q_OBJECT
-
-public:
-
- PhongBumpmapWidget(QWidget *parent) : QWidget(parent)
- {
- setupUi(this);
-
- ambientReflectivityKisDoubleSliderSpinBox -> setRange(0, 1, 2);
- diffuseReflectivityKisDoubleSliderSpinBox -> setRange(0, 1, 2);
- specularReflectivityKisDoubleSliderSpinBox -> setRange(0, 1, 2);
- shinynessExponentKisSliderSpinBox -> setRange(1, 200);
-
- ambientReflectivityKisDoubleSliderSpinBox -> setValue(0.1);
- diffuseReflectivityKisDoubleSliderSpinBox -> setValue(0.5);
- specularReflectivityKisDoubleSliderSpinBox -> setValue(0.5);
- shinynessExponentKisSliderSpinBox -> setValue(40);
- }
-};
-
-class KritaPhongBumpmap : public QObject
-{
-public:
- KritaPhongBumpmap(QObject *parent, const QVariantList &);
- virtual ~KritaPhongBumpmap();
-};
-
-
-/**
- * Implementation of the phong illumination model on top of a
- * heightmap-based mesh to achieve a bumpmapping effect with
- * multiple illumination sources.
- *
- */
-class KisFilterPhongBumpmap : public KisFilter
-{
-public:
- KisFilterPhongBumpmap();
-
-public:
-
- using KisFilter::process;
-
- void process(KisPaintDeviceSP device,
- const QRect& applyRect,
- const KisFilterConfiguration* config,
- KoUpdater* progressUpdater
- ) const;
-
- qreal inline pixelProcess (quint8* heightmap, quint32 posup, quint32 posdown, \
quint32 posleft, quint32 posright);
-
- QRect neededRect(const QRect &rect, const KisFilterConfiguration* config) const;
- QRect changedRect(const QRect &rect, const KisFilterConfiguration* config) \
const;
-
- bool supportsAdjustmentLayers() const {
- return false;
- }
-
- virtual KisConfigWidget * createConfigurationWidget(QWidget* parent, const \
KisPaintDeviceSP dev, const KisImageWSP image = 0) const;
- virtual KisFilterConfiguration* factoryConfiguration(const KisPaintDeviceSP) \
const;
-
-};
-
-class KisPhongBumpmapConfigWidget : public KisConfigWidget
-{
-
- Q_OBJECT
-
-public:
- KisPhongBumpmapConfigWidget(const KisPaintDeviceSP dev, const KisImageWSP image, \
QWidget * parent, Qt::WFlags f = 0);
- virtual ~KisPhongBumpmapConfigWidget() {}
-
- void setConfiguration(const KisPropertiesConfiguration* config);
- KisPropertiesConfiguration* configuration() const;
-
- PhongBumpmapWidget * m_page;
-
-private:
-
- KisPaintDeviceSP m_device;
- KisImageWSP m_image;
-};
-
-#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic