Commit f000cfdd by Alisa Jung

tesselate with 2^t

parent 767b1f89
...@@ -80,8 +80,8 @@ void Controller::showQuadView(){ ...@@ -80,8 +80,8 @@ void Controller::showQuadView(){
void Controller::setTessellation(int t){ void Controller::setTessellation(int t){
qDebug() << "Tesselation: " << t; tesselation = pow(2,t);
tesselation = t; qDebug() << "Tesselation: " << t << ", tess: " << tesselation;
} }
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include <QGridLayout> #include <QGridLayout>
#include <rigidbodytransformation.h> #include <rigidbodytransformation.h>
#include <math.h>
class MyGLWidget; class MyGLWidget;
class SceneGraph; class SceneGraph;
......
...@@ -113,8 +113,8 @@ MainWindow::MainWindow(QWidget *parent) ...@@ -113,8 +113,8 @@ MainWindow::MainWindow(QWidget *parent)
tesselationSlider->setTickPosition(QSlider::TicksBelow); tesselationSlider->setTickPosition(QSlider::TicksBelow);
tesselationSlider->setTickInterval(2); tesselationSlider->setTickInterval(2);
tesselationSlider->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); tesselationSlider->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
tesselationSlider->setMinimum(1); tesselationSlider->setMinimum(0);
tesselationSlider->setMaximum(16); tesselationSlider->setMaximum(10);
tesselationSlider->setValue(1); tesselationSlider->setValue(1);
toolBar->addWidget(tesselationSlider); toolBar->addWidget(tesselationSlider);
connect(tesselationSlider,SIGNAL(valueChanged(int)),controller,SLOT(setTessellation(int))); connect(tesselationSlider,SIGNAL(valueChanged(int)),controller,SLOT(setTessellation(int)));
......
...@@ -22,8 +22,10 @@ void SceneGraph::registerView(MyGLWidget* view){ ...@@ -22,8 +22,10 @@ void SceneGraph::registerView(MyGLWidget* view){
//add primitives to sceneGraph //add primitives to sceneGraph
RigidBodyTransformation* SceneGraph::addSphere(int tesselation){ RigidBodyTransformation* SceneGraph::addSphere(int tesselation){
nextSphereName = "Sphere " + sphereIndex; nextSphereName = "Sphere " + sphereIndex;
//tesselation < 3 makes no sense. //tesselation < 3 makes no sense (except for box)
Primitive* p = new Primitive(idCounter, nextSphereName, tesselation+2, Primitive::Type::SPHERE); int t = tesselation;
if (t < 3) t = 3;
Primitive* p = new Primitive(idCounter, nextSphereName, t, Primitive::Type::SPHERE);
idCounter++; idCounter++;
sphereIndex++; sphereIndex++;
...@@ -46,7 +48,9 @@ RigidBodyTransformation* SceneGraph::addBox(int tesselation){ ...@@ -46,7 +48,9 @@ RigidBodyTransformation* SceneGraph::addBox(int tesselation){
RigidBodyTransformation* SceneGraph::addCylinder(int tesselation){ RigidBodyTransformation* SceneGraph::addCylinder(int tesselation){
nextCylName = "Cylinder " + cylIndex; nextCylName = "Cylinder " + cylIndex;
Primitive* p = new Primitive(idCounter,nextCylName, tesselation+2, Primitive::Type::CYLINDER); int t = tesselation;
if (t < 3) t = 3;
Primitive* p = new Primitive(idCounter,nextCylName, t, Primitive::Type::CYLINDER);
idCounter++; idCounter++;
cylIndex++; cylIndex++;
qDebug("added Cylinder to scenegraph"); qDebug("added Cylinder to scenegraph");
...@@ -56,7 +60,9 @@ RigidBodyTransformation* SceneGraph::addCylinder(int tesselation){ ...@@ -56,7 +60,9 @@ RigidBodyTransformation* SceneGraph::addCylinder(int tesselation){
RigidBodyTransformation* SceneGraph::addCone(int tesselation){ RigidBodyTransformation* SceneGraph::addCone(int tesselation){
nextConeName = "Cone " + coneIndex; nextConeName = "Cone " + coneIndex;
Primitive* p = new Primitive(idCounter,nextConeName, tesselation+2, Primitive::Type::CONE); int t = tesselation;
if (t < 3) t = 3;
Primitive* p = new Primitive(idCounter,nextConeName, t, Primitive::Type::CONE);
idCounter++; idCounter++;
coneIndex++; coneIndex++;
return addPrimitive(p); return addPrimitive(p);
...@@ -65,7 +71,9 @@ RigidBodyTransformation* SceneGraph::addCone(int tesselation){ ...@@ -65,7 +71,9 @@ RigidBodyTransformation* SceneGraph::addCone(int tesselation){
RigidBodyTransformation* SceneGraph::addTorus(int tesselation){ RigidBodyTransformation* SceneGraph::addTorus(int tesselation){
nextTorusName = "Torus " + torusIndex; nextTorusName = "Torus " + torusIndex;
Primitive* p = new Primitive(idCounter,nextTorusName, tesselation+2, Primitive::Type::TORUS); int t = tesselation;
if (t < 3) t = 3;
Primitive* p = new Primitive(idCounter,nextTorusName, t, Primitive::Type::TORUS);
idCounter++; idCounter++;
torusIndex++; torusIndex++;
return addPrimitive(p); return addPrimitive(p);
......
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