Commit c4814ea9 by Kai Westerkamp

move fix multiple groups

parent 49ce7bd6
...@@ -112,7 +112,7 @@ void Controler::move(QPointF * newPos){ ...@@ -112,7 +112,7 @@ void Controler::move(QPointF * newPos){
activeView->getCamera()->move(QVector3D(dx,dy,0.0)); activeView->getCamera()->move(QVector3D(dx,dy,0.0));
} else if((viewMode == EDIT) ^ ctrlPressed){ } else if((viewMode == EDIT) ^ ctrlPressed){
QVector3D vec = activeView->getCamera()->rotation->conjugate().rotatedVector(QVector3D(dx,dy,0.0)); QVector3D vec = activeView->getCamera()->rotation->conjugate().rotatedVector(QVector3D(dx,dy,0.0));
scene->moveActive(vec); scene->moveActive(vec);
} else{ } else{
qDebug()<<"möp"<<viewMode<<" "<<CAMERA<<" "<<EDIT; qDebug()<<"möp"<<viewMode<<" "<<CAMERA<<" "<<EDIT;
} }
......
...@@ -158,7 +158,6 @@ MainWindow::MainWindow(QWidget *parent) ...@@ -158,7 +158,6 @@ MainWindow::MainWindow(QWidget *parent)
torusAdd->setIcon(QIcon(":/img/torus.png")); torusAdd->setIcon(QIcon(":/img/torus.png"));
connect(torusAdd, SIGNAL(triggered()), scene, SLOT(addTorus())); connect(torusAdd, SIGNAL(triggered()), scene, SLOT(addTorus()));
qDebug()<<"Test";
groupAdd = new QAction("Group",this); groupAdd = new QAction("Group",this);
groupAdd->setIcon(QIcon(":/img/wireframe.png")); groupAdd->setIcon(QIcon(":/img/wireframe.png"));
connect(groupAdd, SIGNAL(triggered()), scene, SLOT(addNode())); connect(groupAdd, SIGNAL(triggered()), scene, SLOT(addNode()));
......
...@@ -120,11 +120,15 @@ void Scene::deletActive() ...@@ -120,11 +120,15 @@ void Scene::deletActive()
QModelIndex parentIndex = activeIndex.parent(); QModelIndex parentIndex = activeIndex.parent();
SceneNode *parent = static_cast<SceneNode*>(active->getParent()); SceneNode *parent = static_cast<SceneNode*>(active->getParent());
active->childNumber();
int number = active->childNumber(); int number = active->childNumber();
beginRemoveColumns(parentIndex, number, number); beginRemoveColumns(parentIndex, number, number);
parent->remove(number); parent->remove(number);
endRemoveColumns(); endRemoveColumns();
active = parent;
activeIndex = parentIndex;
emit activChanged();
} }
......
...@@ -24,6 +24,7 @@ public: ...@@ -24,6 +24,7 @@ public:
void draw(); void draw();
void add(SceneObject *child); void add(SceneObject *child);
void remove(int number); void remove(int number);
}; };
#endif // SCENENODE_H #endif // SCENENODE_H
...@@ -7,6 +7,7 @@ SceneObject::SceneObject() ...@@ -7,6 +7,7 @@ SceneObject::SceneObject()
name = QString("Scene Object "+id); name = QString("Scene Object "+id);
rotation = QQuaternion(); rotation = QQuaternion();
translation = QVector3D(); translation = QVector3D();
parent = NULL;
} }
...@@ -65,11 +66,22 @@ int SceneObject::getID(){return id;} ...@@ -65,11 +66,22 @@ int SceneObject::getID(){return id;}
QString SceneObject::getName(){return name;} 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) void SceneObject::move(QVector3D dir)
{ {
translation+=dir; QQuaternion rot = parent->getGlobalRotation();
qDebug()<<rot;
translation+=rot.conjugate().rotatedVector(dir);
} }
void SceneObject::rotate(QQuaternion rot) void SceneObject::rotate(QQuaternion rot)
{ {
......
...@@ -45,6 +45,8 @@ public: ...@@ -45,6 +45,8 @@ public:
void move(QVector3D dir); void move(QVector3D dir);
void rotate(QQuaternion rot); void rotate(QQuaternion rot);
QQuaternion getGlobalRotation();
}; };
#endif // SCENEOBJECT_H #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