Commit c4814ea9 by Kai Westerkamp

move fix multiple groups

parent 49ce7bd6
......@@ -158,7 +158,6 @@ MainWindow::MainWindow(QWidget *parent)
torusAdd->setIcon(QIcon(":/img/torus.png"));
connect(torusAdd, SIGNAL(triggered()), scene, SLOT(addTorus()));
qDebug()<<"Test";
groupAdd = new QAction("Group",this);
groupAdd->setIcon(QIcon(":/img/wireframe.png"));
connect(groupAdd, SIGNAL(triggered()), scene, SLOT(addNode()));
......
......@@ -120,11 +120,15 @@ void Scene::deletActive()
QModelIndex parentIndex = activeIndex.parent();
SceneNode *parent = static_cast<SceneNode*>(active->getParent());
active->childNumber();
int number = active->childNumber();
beginRemoveColumns(parentIndex, number, number);
parent->remove(number);
endRemoveColumns();
active = parent;
activeIndex = parentIndex;
emit activChanged();
}
......
......@@ -24,6 +24,7 @@ public:
void draw();
void add(SceneObject *child);
void remove(int number);
};
#endif // SCENENODE_H
......@@ -7,6 +7,7 @@ SceneObject::SceneObject()
name = QString("Scene Object "+id);
rotation = QQuaternion();
translation = QVector3D();
parent = NULL;
}
......@@ -65,11 +66,22 @@ int SceneObject::getID(){return id;}
QString SceneObject::getName(){return name;}
QQuaternion SceneObject::getGlobalRotation(){
qDebug()<<this->getName()<<" "<<parent;
if(parent == NULL)
return QQuaternion();
else
return parent->getGlobalRotation() *rotation;
}
void SceneObject::move(QVector3D dir)
{
translation+=dir;
QQuaternion rot = parent->getGlobalRotation();
qDebug()<<rot;
translation+=rot.conjugate().rotatedVector(dir);
}
void SceneObject::rotate(QQuaternion rot)
{
......
......@@ -45,6 +45,8 @@ public:
void move(QVector3D dir);
void rotate(QQuaternion rot);
QQuaternion getGlobalRotation();
};
#endif // SCENEOBJECT_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment