add textureTransform to ObjectBase
before textures load refactoring
This commit is contained in:
@@ -63,27 +63,28 @@ ObjectBase::~ObjectBase() {
|
||||
|
||||
|
||||
ObjectBase * ObjectBase::clone(bool withChildren) {
|
||||
ObjectBase * o = new ObjectBase();
|
||||
o->prev_pass = prev_pass;
|
||||
o->is_init = false;
|
||||
o->accept_light = accept_light;
|
||||
o->accept_fog = accept_fog;
|
||||
o->visible_ = visible_;
|
||||
o->color_ = color_;
|
||||
o->type_ = type_;
|
||||
o->raw_matrix = raw_matrix;
|
||||
o->mat_ = mat_;
|
||||
o->trans = trans;
|
||||
o->itransform_ = itransform_;
|
||||
o->bound = bound;
|
||||
o->name_ = name_; // + "_copy";
|
||||
o->blend_src = blend_src;
|
||||
o->blend_dest = blend_dest;
|
||||
o->pos_h = pos_h;
|
||||
o->material_ = material_;
|
||||
o->mesh_ = mesh_;
|
||||
o->meta = meta;
|
||||
o->scene_ = nullptr;
|
||||
ObjectBase * o = new ObjectBase();
|
||||
o->prev_pass = prev_pass;
|
||||
o->is_init = false;
|
||||
o->accept_light = accept_light;
|
||||
o->accept_fog = accept_fog;
|
||||
o->visible_ = visible_;
|
||||
o->color_ = color_;
|
||||
o->type_ = type_;
|
||||
o->raw_matrix = raw_matrix;
|
||||
o->mat_ = mat_;
|
||||
o->trans = trans;
|
||||
o->trans_texture = trans_texture;
|
||||
o->itransform_ = itransform_;
|
||||
o->bound = bound;
|
||||
o->name_ = name_; // + "_copy";
|
||||
o->blend_src = blend_src;
|
||||
o->blend_dest = blend_dest;
|
||||
o->pos_h = pos_h;
|
||||
o->material_ = material_;
|
||||
o->mesh_ = mesh_;
|
||||
o->meta = meta;
|
||||
o->scene_ = nullptr;
|
||||
if (withChildren) {
|
||||
for (int i = 0; i < children_.size(); ++i)
|
||||
o->addChild(children_[i]->clone(withChildren));
|
||||
@@ -345,6 +346,31 @@ void ObjectBase::cleanTree() {
|
||||
}
|
||||
|
||||
|
||||
void ObjectBase::setTextureTransform(const Transform & t) {
|
||||
trans_texture = t;
|
||||
setObjectsChanged();
|
||||
}
|
||||
|
||||
|
||||
void ObjectBase::setTextureMatrix(const QMatrix4x4 & t) {
|
||||
trans_texture.setMatrix(t);
|
||||
setObjectsChanged();
|
||||
}
|
||||
|
||||
|
||||
QMatrix4x4 ObjectBase::textureMatrix() const {
|
||||
return trans_texture.matrix();
|
||||
}
|
||||
|
||||
|
||||
QGenericMatrix<3, 2, float> ObjectBase::textureGLMatrix() const {
|
||||
QGenericMatrix<3, 2, float> ret = textureMatrix().toGenericMatrix<3, 2>();
|
||||
ret(0, 2) = -trans_texture.translation().x();
|
||||
ret(1, 2) = -trans_texture.translation().y();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool ObjectBase::isSelected(bool check_parents) const {
|
||||
if (!check_parents) return selected_;
|
||||
if (selected_) return true;
|
||||
@@ -600,6 +626,7 @@ ObjectBase * Light::clone(bool withChildren) {
|
||||
o->color_ = color_;
|
||||
o->light_type = light_type;
|
||||
o->trans = trans;
|
||||
o->trans_texture = trans_texture;
|
||||
o->aim_dist = aim_dist;
|
||||
o->angle_start = angle_start;
|
||||
o->angle_end = angle_end;
|
||||
@@ -634,7 +661,8 @@ QDataStream & operator<<(QDataStream & s, const ObjectBase * p) {
|
||||
.add(17, p->name_)
|
||||
.add(18, p->meta)
|
||||
.add(19, p->color_)
|
||||
.add(20, p->trans);
|
||||
.add(20, p->trans)
|
||||
.add(21, p->trans_texture);
|
||||
// qDebug() << "place self done";
|
||||
if (p->type_ == ObjectBase::glLight) {
|
||||
// qDebug() << "place light ...";
|
||||
@@ -734,6 +762,9 @@ QDataStream & operator>>(QDataStream & s, ObjectBase *& p) {
|
||||
case 20:
|
||||
if (p) p->trans = cs.getData<Transform>();
|
||||
break;
|
||||
case 21:
|
||||
if (p) p->trans_texture = cs.getData<Transform>();
|
||||
break;
|
||||
case 100:
|
||||
if (l) l->setAim(cs.getData<QVector3D>());
|
||||
break;
|
||||
|
||||
@@ -267,11 +267,18 @@ public:
|
||||
void setTransform(const Transform & t);
|
||||
void setMatrix(const QMatrix4x4 & t);
|
||||
QMatrix4x4 matrix() const;
|
||||
|
||||
bool isRawMatrix() { return raw_matrix; }
|
||||
QVector3D inParentSpace(const QVector3D & v) const;
|
||||
void transferTransformToChildren(bool only_scale = false);
|
||||
void cleanTree();
|
||||
|
||||
Transform textureTransform() { return trans_texture; }
|
||||
void setTextureTransform(const Transform & t);
|
||||
void setTextureMatrix(const QMatrix4x4 & t);
|
||||
QMatrix4x4 textureMatrix() const;
|
||||
QGenericMatrix<3, 2, float> textureGLMatrix() const;
|
||||
|
||||
bool isAcceptLight() const { return accept_light; }
|
||||
void setAcceptLight(bool yes) { accept_light = yes; }
|
||||
|
||||
@@ -333,7 +340,7 @@ protected:
|
||||
Type type_;
|
||||
RenderMode render_mode;
|
||||
Box3D bound;
|
||||
Transform trans;
|
||||
Transform trans, trans_texture;
|
||||
ObjectBaseList children_;
|
||||
QMatrix4x4 itransform_, mat_;
|
||||
QString name_;
|
||||
|
||||
Reference in New Issue
Block a user