Commit f000cfdd by Alisa Jung

tesselate with 2^t

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