Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void updateTeapot()
- {
- static int currentAngle = 0;
- static bool animationState = true;
- int angleRotateStep = 1;
- auto cubePos = cubeMatrix.getTrans();
- auto point1 = osg::Vec3d(cubePos.x() - 1, cubePos.y(), cubePos.z());
- auto point2 = osg::Vec3d(cubePos.x() + 1, cubePos.y(), cubePos.z());
- if(currentAngle++ == 360) {
- throw 1;
- animationState = !animationState;
- currentAngle = 0;
- }
- if(animationState){
- teapotMatrix *= osg::Matrix::translate(-point1);
- teapotMatrix *= osg::Matrix::rotate(osg::DegreesToRadians((float)angleRotateStep), 0,0,1);
- teapotMatrix *= osg::Matrix::translate(point1);
- } else {
- teapotMatrix *= osg::Matrix::translate(-point2);
- teapotMatrix *= osg::Matrix::rotate(osg::DegreesToRadians(-(float)angleRotateStep), 0,0,1);
- teapotMatrix *= osg::Matrix::translate(point2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement