ObjectBase materials for custom preset
This commit is contained in:
@@ -521,6 +521,14 @@ void ObjectBase::setPreset(int preset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVector<int> ObjectBase::availablePresets() const {
|
||||||
|
QVector<int> ret;
|
||||||
|
for (int i = 0; i < presets.size(); ++i)
|
||||||
|
ret << i;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ObjectBase::setMatrix(const QMatrix4x4 & t) {
|
void ObjectBase::setMatrix(const QMatrix4x4 & t) {
|
||||||
// raw_matrix = true;
|
// raw_matrix = true;
|
||||||
// mat_ = t;
|
// mat_ = t;
|
||||||
@@ -636,13 +644,30 @@ ObjectBase * ObjectBase::selectedParent() const {
|
|||||||
void ObjectBase::setMaterial(Material * m, bool with_children) {
|
void ObjectBase::setMaterial(Material * m, bool with_children) {
|
||||||
currentPreset().material = m;
|
currentPreset().material = m;
|
||||||
if (with_children)
|
if (with_children)
|
||||||
foreach(ObjectBase * i, children_)
|
for (auto * i: children_)
|
||||||
i->setMaterial(m, true);
|
i->setMaterial(m, true);
|
||||||
setObjectsChanged();
|
setObjectsChanged();
|
||||||
if (scene_) scene_->mat_changed = scene_->tree_changed = true;
|
if (scene_) scene_->mat_changed = scene_->tree_changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ObjectBase::setMaterialForPreset(Material * m, int p, bool with_children) {
|
||||||
|
if (p < 0 || p >= presets.size()) return;
|
||||||
|
presets[p].material = m;
|
||||||
|
if (with_children)
|
||||||
|
for (auto * i: children_)
|
||||||
|
i->setMaterialForPreset(m, p, true);
|
||||||
|
setObjectsChanged();
|
||||||
|
if (scene_) scene_->mat_changed = scene_->tree_changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Material * ObjectBase::materialForPreset(int p) {
|
||||||
|
if (p < 0 || p >= presets.size()) return nullptr;
|
||||||
|
return presets[p].material;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ObjectBase::setColor(QColor c, bool with_children) {
|
void ObjectBase::setColor(QColor c, bool with_children) {
|
||||||
color_ = c;
|
color_ = c;
|
||||||
if (with_children)
|
if (with_children)
|
||||||
|
|||||||
@@ -179,7 +179,9 @@ public:
|
|||||||
void setDestAlpha(GLenum mode) { blend_dest = mode; }
|
void setDestAlpha(GLenum mode) { blend_dest = mode; }
|
||||||
|
|
||||||
void setMaterial(Material * m, bool with_children = false);
|
void setMaterial(Material * m, bool with_children = false);
|
||||||
|
void setMaterialForPreset(Material * m, int p, bool with_children = false);
|
||||||
Material * material() { return currentPreset().material; }
|
Material * material() { return currentPreset().material; }
|
||||||
|
Material * materialForPreset(int p);
|
||||||
|
|
||||||
void setColor(QColor c, bool with_children = false);
|
void setColor(QColor c, bool with_children = false);
|
||||||
QColor color() { return color_; }
|
QColor color() { return color_; }
|
||||||
@@ -198,6 +200,8 @@ public:
|
|||||||
|
|
||||||
void setPreset(int preset);
|
void setPreset(int preset);
|
||||||
|
|
||||||
|
QVector<int> availablePresets() const;
|
||||||
|
|
||||||
QVector3D pos_h;
|
QVector3D pos_h;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Reference in New Issue
Block a user