Fixed: #1301 Now works correctly with translucent tiles.
--HG-- branch : gsoc2011-worldeditorqt
This commit is contained in:
parent
7ab6c38496
commit
51a8add985
4 changed files with 43 additions and 11 deletions
|
@ -1,5 +1,4 @@
|
|||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
@ -100,14 +99,15 @@ QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePo
|
|||
// Enable bilinear filtering
|
||||
item->setTransformationMode(Qt::SmoothTransformation);
|
||||
|
||||
NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilder->getZoneBank().getElementByZoneName(data.zoneName);
|
||||
sint32 sizeX = 1, sizeY = 1;
|
||||
sizeX = float(pixmap->width()) / m_zoneBuilder->pixmapDatabase()->textureSize();
|
||||
sizeY = float(pixmap->width()) / m_zoneBuilder->pixmapDatabase()->textureSize();
|
||||
|
||||
sint32 deltaX = 0, deltaY = 0;
|
||||
|
||||
// Calculate offset for graphics item (for items with size that are larger than 1)
|
||||
if ((zoneBankItem->getSizeX() > 1) || (zoneBankItem->getSizeY() > 1))
|
||||
if ((sizeX > 1) || (sizeY > 1))
|
||||
{
|
||||
sint32 sizeX = zoneBankItem->getSizeX(), sizeY = zoneBankItem->getSizeY();
|
||||
if (data.flip == 0)
|
||||
{
|
||||
switch (data.rot)
|
||||
|
@ -165,6 +165,8 @@ QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePo
|
|||
// for not full item zone
|
||||
item->setZValue(LAYER_ZONES);
|
||||
|
||||
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@ -178,6 +180,7 @@ QGraphicsItem *LandscapeScene::createItemEmptyZone(const ZonePosition &zonePos)
|
|||
|
||||
// Get image from pixmap database
|
||||
QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(STRING_UNUSED));
|
||||
|
||||
if (pixmap == 0)
|
||||
return 0;
|
||||
|
||||
|
@ -195,6 +198,8 @@ QGraphicsItem *LandscapeScene::createItemEmptyZone(const ZonePosition &zonePos)
|
|||
// for not full item zone
|
||||
item->setZValue(LAYER_EMPTY_ZONES);
|
||||
|
||||
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,14 +97,15 @@ QGraphicsItem *LandscapeSceneBase::createItemZone(const LigoData &data, const Zo
|
|||
// Enable bilinear filtering
|
||||
item->setTransformationMode(Qt::SmoothTransformation);
|
||||
|
||||
NLLIGO::CZoneBankElement *zoneBankItem = m_zoneBuilderBase->getZoneBank().getElementByZoneName(data.zoneName);
|
||||
sint32 sizeX = 1, sizeY = 1;
|
||||
sizeX = float(pixmap->width()) / m_zoneBuilderBase->pixmapDatabase()->textureSize();
|
||||
sizeY = float(pixmap->width()) / m_zoneBuilderBase->pixmapDatabase()->textureSize();
|
||||
|
||||
sint32 deltaX = 0, deltaY = 0;
|
||||
|
||||
// Calculate offset for graphics item (for items with size that are larger than 1)
|
||||
if ((zoneBankItem->getSizeX() > 1) || (zoneBankItem->getSizeY() > 1))
|
||||
if ((sizeX > 1) || (sizeY > 1))
|
||||
{
|
||||
sint32 sizeX = zoneBankItem->getSizeX(), sizeY = zoneBankItem->getSizeY();
|
||||
if (data.flip == 0)
|
||||
{
|
||||
switch (data.rot)
|
||||
|
@ -162,6 +163,8 @@ QGraphicsItem *LandscapeSceneBase::createItemZone(const LigoData &data, const Zo
|
|||
// for not full item zone
|
||||
item->setZValue(LAYER_ZONES);
|
||||
|
||||
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@ -192,6 +195,8 @@ QGraphicsItem *LandscapeSceneBase::createItemEmptyZone(const ZonePosition &zoneP
|
|||
// for not full item zone
|
||||
item->setZValue(LAYER_EMPTY_ZONES);
|
||||
|
||||
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
// Qt includes
|
||||
#include <QtCore/QDir>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QProgressDialog>
|
||||
|
@ -35,12 +36,23 @@ namespace LandscapeEditor
|
|||
{
|
||||
|
||||
PixmapDatabase::PixmapDatabase(int textureSize)
|
||||
: m_textureSize(textureSize)
|
||||
: m_textureSize(textureSize),
|
||||
m_errorPixmap(0)
|
||||
{
|
||||
m_errorPixmap = new QPixmap(QSize(m_textureSize, m_textureSize));
|
||||
QPainter painter(m_errorPixmap);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
painter.fillRect(m_errorPixmap->rect(), QBrush(QColor(Qt::black)));
|
||||
painter.setFont(QFont("Helvetica [Cronyx]", 14));
|
||||
painter.setPen(QPen(Qt::red, 2, Qt::SolidLine));
|
||||
painter.drawText(m_errorPixmap->rect(), Qt::AlignCenter | Qt::TextWordWrap,
|
||||
QObject::tr("Pixmap and LIGO files not found. Set the correct data path and reload landscape."));
|
||||
painter.end();
|
||||
}
|
||||
|
||||
PixmapDatabase::~PixmapDatabase()
|
||||
{
|
||||
delete m_errorPixmap;
|
||||
reset();
|
||||
}
|
||||
|
||||
|
@ -73,9 +85,19 @@ bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zon
|
|||
if (pixmap->isNull())
|
||||
{
|
||||
// Generate filled pixmap
|
||||
QPixmap *emptyPixmap = new QPixmap(QSize(sizeX * m_textureSize, sizeY * m_textureSize));
|
||||
QPainter painter(emptyPixmap);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
painter.fillRect(emptyPixmap->rect(), QBrush(QColor(Qt::black)));
|
||||
painter.setFont(QFont("Helvetica [Cronyx]", 18));
|
||||
painter.setPen(QPen(Qt::red, 2, Qt::SolidLine));
|
||||
painter.drawText(emptyPixmap->rect(), Qt::AlignCenter, QObject::tr("Pixmap not found"));
|
||||
painter.end();
|
||||
delete pixmap;
|
||||
m_pixmapMap.insert(zonePixmapName, emptyPixmap);
|
||||
}
|
||||
// All pixmaps must be have same size
|
||||
if (pixmap->width() != sizeX * m_textureSize)
|
||||
else if (pixmap->width() != sizeX * m_textureSize)
|
||||
{
|
||||
QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(sizeX * m_textureSize, sizeY * m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||
delete pixmap;
|
||||
|
@ -114,7 +136,7 @@ QStringList PixmapDatabase::listPixmaps() const
|
|||
|
||||
QPixmap *PixmapDatabase::pixmap(const QString &zoneName) const
|
||||
{
|
||||
QPixmap *result = 0;
|
||||
QPixmap *result = m_errorPixmap;
|
||||
if (!m_pixmapMap.contains(zoneName))
|
||||
nlwarning("QPixmap %s not found", zoneName.toStdString().c_str());
|
||||
else
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
@ -61,6 +60,7 @@ public:
|
|||
private:
|
||||
|
||||
int m_textureSize;
|
||||
QPixmap *m_errorPixmap;
|
||||
QMap<QString, QPixmap *> m_pixmapMap;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue