Commit b0988a33 authored by cutealien's avatar cutealien

Add ISceneNodeAnimatorCameraMaya::setTargetMinDistance and...

Add ISceneNodeAnimatorCameraMaya::setTargetMinDistance and getTargetMinDistance which allow to keep a distance to the zoom target.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5106 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 89640518
-------------------------- --------------------------
Changes in 1.9 (not yet released) Changes in 1.9 (not yet released)
- Add ISceneNodeAnimatorCameraMaya::setTargetMinDistance and getTargetMinDistance.
- Add override font to IGUITreeView - Add override font to IGUITreeView
- CGUIComboBox now updates selection-list when font changes while it's open (thx @ rubixcuber for bugreport) - CGUIComboBox now updates selection-list when font changes while it's open (thx @ rubixcuber for bugreport)
- CAnimatedMeshSceneNode::setMesh does now set the animation speed again to that of the mesh (had been changed in 1.7, but not for obvious reasons) - CAnimatedMeshSceneNode::setMesh does now set the animation speed again to that of the mesh (had been changed in 1.7, but not for obvious reasons)
......
...@@ -49,6 +49,13 @@ namespace scene ...@@ -49,6 +49,13 @@ namespace scene
//! Set the distance //! Set the distance
virtual void setDistance(f32 distance) = 0; virtual void setDistance(f32 distance) = 0;
//! Set the minimal distance to the camera target for zoom
virtual void setTargetMinDistance(f32 minDistance) = 0;
//! Returns the minimal distance to the camera target for zoom
virtual f32 getTargetMinDistance() const = 0;
}; };
} // end namespace scene } // end namespace scene
......
...@@ -17,6 +17,7 @@ namespace scene ...@@ -17,6 +17,7 @@ namespace scene
CSceneNodeAnimatorCameraMaya::CSceneNodeAnimatorCameraMaya(gui::ICursorControl* cursor, CSceneNodeAnimatorCameraMaya::CSceneNodeAnimatorCameraMaya(gui::ICursorControl* cursor,
f32 rotateSpeed, f32 zoomSpeed, f32 translateSpeed, f32 distance) f32 rotateSpeed, f32 zoomSpeed, f32 translateSpeed, f32 distance)
: CursorControl(cursor), OldCamera(0), MousePos(0.5f, 0.5f), : CursorControl(cursor), OldCamera(0), MousePos(0.5f, 0.5f),
TargetMinDistance(0.f),
ZoomSpeed(zoomSpeed), RotateSpeed(rotateSpeed), TranslateSpeed(translateSpeed), ZoomSpeed(zoomSpeed), RotateSpeed(rotateSpeed), TranslateSpeed(translateSpeed),
CurrentZoom(distance), RotX(0.0f), RotY(0.0f), CurrentZoom(distance), RotX(0.0f), RotY(0.0f),
Zooming(false), Rotating(false), Moving(false), Translating(false) Zooming(false), Rotating(false), Moving(false), Translating(false)
...@@ -138,11 +139,10 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs) ...@@ -138,11 +139,10 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs)
} }
else else
{ {
const f32 targetMinDistance = 0.1f;
nZoom += (ZoomStart.X - MousePos.X) * ZoomSpeed; nZoom += (ZoomStart.X - MousePos.X) * ZoomSpeed;
if (nZoom < targetMinDistance) // jox: fixed bug: bounce back when zooming to close if (nZoom < TargetMinDistance+0.1f) // jox: fixed bug: bounce back when zooming too close
nZoom = targetMinDistance; nZoom = TargetMinDistance+0.1f;
} }
} }
else if (Zooming) else if (Zooming)
...@@ -151,7 +151,7 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs) ...@@ -151,7 +151,7 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs)
CurrentZoom = CurrentZoom + (ZoomStart.X - MousePos.X ) * ZoomSpeed; CurrentZoom = CurrentZoom + (ZoomStart.X - MousePos.X ) * ZoomSpeed;
nZoom = CurrentZoom; nZoom = CurrentZoom;
if (nZoom < 0) if (nZoom < TargetMinDistance)
nZoom = CurrentZoom = old; nZoom = CurrentZoom = old;
Zooming = false; Zooming = false;
} }
...@@ -309,6 +309,18 @@ f32 CSceneNodeAnimatorCameraMaya::getDistance() const ...@@ -309,6 +309,18 @@ f32 CSceneNodeAnimatorCameraMaya::getDistance() const
return CurrentZoom; return CurrentZoom;
} }
void CSceneNodeAnimatorCameraMaya::setTargetMinDistance(f32 minDistance)
{
TargetMinDistance = minDistance;
if ( CurrentZoom < TargetMinDistance )
CurrentZoom = TargetMinDistance;
}
f32 CSceneNodeAnimatorCameraMaya::getTargetMinDistance() const
{
return TargetMinDistance;
}
ISceneNodeAnimator* CSceneNodeAnimatorCameraMaya::createClone(ISceneNode* node, ISceneManager* newManager) ISceneNodeAnimator* CSceneNodeAnimatorCameraMaya::createClone(ISceneNode* node, ISceneManager* newManager)
{ {
......
...@@ -64,6 +64,12 @@ namespace scene ...@@ -64,6 +64,12 @@ namespace scene
//! Set the distance //! Set the distance
virtual void setDistance(f32 distance) _IRR_OVERRIDE_; virtual void setDistance(f32 distance) _IRR_OVERRIDE_;
//! Set the minimal distance to the camera target for zoom
virtual void setTargetMinDistance(f32 minDistance) _IRR_OVERRIDE_;
//! Returns the minimal distance to the camera target for zoom
virtual f32 getTargetMinDistance() const _IRR_OVERRIDE_;
//! This animator will receive events when attached to the active camera //! This animator will receive events when attached to the active camera
virtual bool isEventReceiverEnabled() const _IRR_OVERRIDE_ virtual bool isEventReceiverEnabled() const _IRR_OVERRIDE_
{ {
...@@ -98,6 +104,7 @@ namespace scene ...@@ -98,6 +104,7 @@ namespace scene
core::position2df ZoomStart; core::position2df ZoomStart;
core::position2df TranslateStart; core::position2df TranslateStart;
core::position2df MousePos; core::position2df MousePos;
f32 TargetMinDistance;
f32 ZoomSpeed; f32 ZoomSpeed;
f32 RotateSpeed; f32 RotateSpeed;
f32 TranslateSpeed; f32 TranslateSpeed;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment