Advertisement
kneefer

GK - animacja ósemki

Mar 28th, 2015
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. void updateTeapot()
  2. {
  3.     static int currentAngle = 0;
  4.     static bool animationState = true;
  5.  
  6.     int angleRotateStep = 1;
  7.     auto cubePos = cubeMatrix.getTrans();
  8.     auto point1 = osg::Vec3d(cubePos.x() - 1, cubePos.y(), cubePos.z());
  9.     auto point2 = osg::Vec3d(cubePos.x() + 1, cubePos.y(), cubePos.z());
  10.  
  11.     if(currentAngle++ == 360) {
  12.         throw 1;
  13.         animationState = !animationState;
  14.         currentAngle = 0;
  15.     }
  16.  
  17.     if(animationState){
  18.         teapotMatrix *= osg::Matrix::translate(-point1);
  19.         teapotMatrix *= osg::Matrix::rotate(osg::DegreesToRadians((float)angleRotateStep), 0,0,1);
  20.         teapotMatrix *= osg::Matrix::translate(point1);
  21.     } else {
  22.         teapotMatrix *= osg::Matrix::translate(-point2);
  23.         teapotMatrix *= osg::Matrix::rotate(osg::DegreesToRadians(-(float)angleRotateStep), 0,0,1);
  24.         teapotMatrix *= osg::Matrix::translate(point2);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement