Changeset 13041 for OpenSceneGraph/trunk/src/osgGA/DriveManipulator.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgGA/DriveManipulator.cpp
r11475 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 74 74 //_height = sqrtf(_modelScale)*0.03; 75 75 //_buffer = sqrtf(_modelScale)*0.05; 76 76 77 77 _height = getHeightOfDriver(); 78 78 _buffer = _height*2.5; 79 79 } 80 if (getAutoComputeHomePosition()) computeHomePosition(); 80 if (getAutoComputeHomePosition()) computeHomePosition(); 81 81 } 82 82 … … 99 99 osgUtil::IntersectionVisitor iv(lsi.get()); 100 100 iv.setTraversalMask(_intersectTraversalMask); 101 101 102 102 _node->accept(iv); 103 103 104 104 if (lsi->containsIntersections()) 105 105 { … … 185 185 186 186 computePosition(_homeEye, _homeCenter, _homeUp); 187 187 188 188 _velocity = 0.0; 189 189 190 190 _pitch = 0.0; 191 191 … … 430 430 osg::Vec3d u(s^f); 431 431 u.normalize(); 432 432 433 433 osg::Matrixd rotation_matrix(s[0], u[0], -f[0], 0.0, 434 434 s[1], u[1], -f[1], 0.0, 435 435 s[2], u[2], -f[2], 0.0, 436 436 0.0, 0.0, 0.0, 1.0); 437 437 438 438 _eye = eye; 439 439 _rotation = rotation_matrix.getRotate().inverse(); … … 453 453 dt = 0.0; 454 454 } 455 455 456 456 double accelerationFactor = _height*10.0; 457 457 … … 495 495 osg::Matrixd rotation_matrix; 496 496 rotation_matrix.makeRotate(_rotation); 497 497 498 498 osg::Vec3d up = osg::Vec3d(0.0,1.0,0.0) * rotation_matrix; 499 499 osg::Vec3d lv = osg::Vec3d(0.0,0.0,-1.0) * rotation_matrix; … … 505 505 double yaw = -inDegrees(dx*50.0*dt); 506 506 507 507 508 508 #ifdef KEYBOARD_PITCH 509 509 double pitch_delta = 0.5; … … 521 521 _pitch += dy*dt; 522 522 #endif 523 523 524 524 osg::Quat yaw_rotation; 525 525 yaw_rotation.makeRotate(yaw,up); 526 526 527 527 _rotation *= yaw_rotation; 528 528 529 529 rotation_matrix.makeRotate(_rotation); 530 530 … … 539 539 if (distanceToMove>=0.0) signedBuffer=_buffer; 540 540 else signedBuffer=-_buffer; 541 541 542 542 // check to see if any obstruction in front. 543 543 osg::Vec3d ip, np; … … 575 575 576 576 } 577 577 578 578 // no hit on the terrain found therefore resort to a fall under 579 579 // under the influence of gravity. … … 599 599 600 600 lv *= (_velocity*dt); 601 601 602 602 _eye += lv; 603 603 }
