mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-26 14:56:39 +00:00 
			
		
		
		
	Add extraRoll to the Lua camera package
This commit is contained in:
		
							parent
							
								
									4bd2f20979
								
							
						
					
					
						commit
						95ad67eb8b
					
				
					 6 changed files with 20 additions and 4 deletions
				
			
		|  | @ -67,8 +67,10 @@ namespace MWLua | |||
|         api["setRoll"] = [camera](float v) { camera->setRoll(-v); }; | ||||
|         api["setExtraPitch"] = [camera](float v) { camera->setExtraPitch(-v); }; | ||||
|         api["setExtraYaw"] = [camera](float v) { camera->setExtraYaw(-v); }; | ||||
|         api["setExtraRoll"] = [camera](float v) { camera->setExtraRoll(-v); }; | ||||
|         api["getExtraPitch"] = [camera]() { return -camera->getExtraPitch(); }; | ||||
|         api["getExtraYaw"] = [camera]() { return -camera->getExtraYaw(); }; | ||||
|         api["getExtraRoll"] = [camera]() { return -camera->getExtraRoll(); }; | ||||
| 
 | ||||
|         api["getThirdPersonDistance"] = [camera]() { return camera->getCameraDistance(); }; | ||||
|         api["setPreferredThirdPersonDistance"] = [camera](float v) { camera->setPreferredCameraDistance(v); }; | ||||
|  |  | |||
|  | @ -110,7 +110,7 @@ namespace MWRender | |||
| 
 | ||||
|     void Camera::updateCamera(osg::Camera *cam) | ||||
|     { | ||||
|         osg::Quat orient = osg::Quat(mRoll, osg::Vec3d(0, 1, 0)) * | ||||
|         osg::Quat orient = osg::Quat(mRoll + mExtraRoll, osg::Vec3d(0, 1, 0)) * | ||||
|                            osg::Quat(mPitch + mExtraPitch, osg::Vec3d(1, 0, 0)) * | ||||
|                            osg::Quat(mYaw + mExtraYaw, osg::Vec3d(0, 0, 1)); | ||||
|         osg::Vec3d forward = orient * osg::Vec3d(0,1,0); | ||||
|  |  | |||
|  | @ -60,8 +60,10 @@ namespace MWRender | |||
| 
 | ||||
|         float getExtraPitch() const { return mExtraPitch; } | ||||
|         float getExtraYaw() const { return mExtraYaw; } | ||||
|         float getExtraRoll() const { return mExtraRoll; } | ||||
|         void setExtraPitch(float angle) { mExtraPitch = angle; } | ||||
|         void setExtraYaw(float angle) { mExtraYaw = angle; } | ||||
|         void setExtraRoll(float angle) { mExtraRoll = angle; } | ||||
| 
 | ||||
|         /// @param Force view mode switch, even if currently not allowed by the animation.
 | ||||
|         void toggleViewMode(bool force=false); | ||||
|  | @ -125,7 +127,7 @@ namespace MWRender | |||
| 
 | ||||
|         float mHeight; | ||||
|         float mPitch, mYaw, mRoll; | ||||
|         float mExtraPitch = 0, mExtraYaw = 0; | ||||
|         float mExtraPitch = 0, mExtraYaw = 0, mExtraRoll = 0; | ||||
|         bool mLockPitch = false, mLockYaw = false; | ||||
|         osg::Vec3d mPosition; | ||||
|         osg::Matrixf mViewMatrix; | ||||
|  |  | |||
|  | @ -150,7 +150,7 @@ end | |||
| local function onUpdate(dt) | ||||
|     camera.setExtraPitch(0) | ||||
|     camera.setExtraYaw(0) | ||||
|     camera.setRoll(0) | ||||
|     camera.setExtraRoll(0) | ||||
|     camera.setFirstPersonOffset(util.vector3(0, 0, 0)) | ||||
|     updateSmoothedSpeed(dt) | ||||
| end | ||||
|  |  | |||
|  | @ -46,7 +46,7 @@ function M.update(dt, smoothedSpeed) | |||
|     local zOffset = (0.5 - effect) * coef * stepHeight  -- range from -stepHeight/2 to stepHeight/2 | ||||
|     local roll = ((stepState > 0 and 1) or -1) * effect * coef * maxRoll  -- range from -maxRoll to maxRoll | ||||
|     camera.setFirstPersonOffset(camera.getFirstPersonOffset() + util.vector3(0, 0, zOffset)) | ||||
|     camera.setRoll(camera.getRoll() + roll) | ||||
|     camera.setExtraRoll(camera.getExtraRoll() + roll) | ||||
| end | ||||
| 
 | ||||
| return M | ||||
|  |  | |||
|  | @ -111,6 +111,18 @@ | |||
| -- @function [parent=#camera] setExtraYaw | ||||
| -- @param #number value | ||||
| 
 | ||||
| --- | ||||
| -- Additional summand for the roll angle that is not affected by player input. | ||||
| -- Full yaw is `getRoll()+getExtraRoll()`. | ||||
| -- @function [parent=#camera] getExtraRoll | ||||
| -- @return #number | ||||
| 
 | ||||
| --- | ||||
| -- Additional summand for the roll angle; useful for camera shaking effects. | ||||
| -- Full yaw is `getRoll()+getExtraRoll()`. | ||||
| -- @function [parent=#camera] setExtraRoll | ||||
| -- @param #number value | ||||
| 
 | ||||
| --- | ||||
| -- Set camera position; can be used only if camera is in Static mode. | ||||
| -- @function [parent=#camera] setStaticPosition | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue