test_cylinder.cpp

Christof Elbrechter, 2012-10-10 17:30

Download (1.37 KB)

 
1

    
2
#include <ICLQuick/Common.h>
3
#include <ICLGeom/Geom.h>
4
#include <ICLQt/DrawWidget3D.h>
5
#include <ICLUtils/FPSLimiter.h>
6
#include <ICLUtils/FPSEstimator.h>
7

    
8
#include <Cylinder.h>
9

    
10
GUI gui("hsplit");
11
Scene scene;
12
CylinderObject* cylinder1;
13

    
14
void init() {
15

    
16
  Size size = pa("-size");
17

    
18
  printf("%dx%d\n", size.width, size.height);
19

    
20
  gui << "draw3D[@handle=draw3D@minsize=32x24]"
21
      << "!show";
22

    
23
  Camera view_cam = Camera();
24
  FixedMatrix<float,4,4> m = Mat::id();
25
  m = m * create_rot_4x4<float>(0, 0, 1, M_PI/2);
26
  m = m * create_rot_4x4<float>(0, 1, 0, M_PI/4);
27
  view_cam.setTransformation(m);
28
  view_cam.translate(Vec(400,0,-400));
29
  view_cam.setResolution(size);
30
  scene.addCamera(view_cam);
31

    
32
  scene.setDrawCoordinateFrameEnabled(true);
33

    
34
  cylinder1 = new CylinderObject();
35
  cylinder1->setupGeometry(16);
36
  scene.addObject(cylinder1);
37

    
38
  gui["draw3D"].install(scene.getMouseHandler(0));
39
  gui["draw3D"].link(scene.getGLCallback(0));
40
}
41

    
42

    
43
void run() {
44
  cylinder1->updateGeometry(100.0, 40.0, GeomColor(200,100,0,255));
45
  cylinder1->setTransformation(Mat::id());
46
  //cylinder1->rotate(0.0, M_PI/2, 0.0);
47
  //cylinder1->translate(-50.0, 0.0, 0.0);
48
  
49
  gui["draw3D"].render();
50

    
51
  static FPSEstimator estimator;
52
  estimator.showFPS();
53
}
54

    
55
void quit() {
56
}
57

    
58
int main(int n, char **ppc){
59
  ICLApp app = ICLApp(n,ppc,"-size|-s(Size=QVGA)",init,run);
60
  app.addFinalization(quit);
61
  return app.exec();
62
}