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-e03cc46cb475master
parent
89640518bf
commit
b0988a33a6
|
@ -1,6 +1,7 @@
|
|||
--------------------------
|
||||
Changes in 1.9 (not yet released)
|
||||
|
||||
- Add ISceneNodeAnimatorCameraMaya::setTargetMinDistance and getTargetMinDistance.
|
||||
- Add override font to IGUITreeView
|
||||
- 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)
|
||||
|
|
|
@ -49,6 +49,13 @@ namespace scene
|
|||
|
||||
//! Set the distance
|
||||
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
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace scene
|
|||
CSceneNodeAnimatorCameraMaya::CSceneNodeAnimatorCameraMaya(gui::ICursorControl* cursor,
|
||||
f32 rotateSpeed, f32 zoomSpeed, f32 translateSpeed, f32 distance)
|
||||
: CursorControl(cursor), OldCamera(0), MousePos(0.5f, 0.5f),
|
||||
TargetMinDistance(0.f),
|
||||
ZoomSpeed(zoomSpeed), RotateSpeed(rotateSpeed), TranslateSpeed(translateSpeed),
|
||||
CurrentZoom(distance), RotX(0.0f), RotY(0.0f),
|
||||
Zooming(false), Rotating(false), Moving(false), Translating(false)
|
||||
|
@ -138,11 +139,10 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs)
|
|||
}
|
||||
else
|
||||
{
|
||||
const f32 targetMinDistance = 0.1f;
|
||||
nZoom += (ZoomStart.X - MousePos.X) * ZoomSpeed;
|
||||
|
||||
if (nZoom < targetMinDistance) // jox: fixed bug: bounce back when zooming to close
|
||||
nZoom = targetMinDistance;
|
||||
if (nZoom < TargetMinDistance+0.1f) // jox: fixed bug: bounce back when zooming too close
|
||||
nZoom = TargetMinDistance+0.1f;
|
||||
}
|
||||
}
|
||||
else if (Zooming)
|
||||
|
@ -151,7 +151,7 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs)
|
|||
CurrentZoom = CurrentZoom + (ZoomStart.X - MousePos.X ) * ZoomSpeed;
|
||||
nZoom = CurrentZoom;
|
||||
|
||||
if (nZoom < 0)
|
||||
if (nZoom < TargetMinDistance)
|
||||
nZoom = CurrentZoom = old;
|
||||
Zooming = false;
|
||||
}
|
||||
|
@ -309,6 +309,18 @@ f32 CSceneNodeAnimatorCameraMaya::getDistance() const
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -64,6 +64,12 @@ namespace scene
|
|||
//! Set the distance
|
||||
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
|
||||
virtual bool isEventReceiverEnabled() const _IRR_OVERRIDE_
|
||||
{
|
||||
|
@ -98,6 +104,7 @@ namespace scene
|
|||
core::position2df ZoomStart;
|
||||
core::position2df TranslateStart;
|
||||
core::position2df MousePos;
|
||||
f32 TargetMinDistance;
|
||||
f32 ZoomSpeed;
|
||||
f32 RotateSpeed;
|
||||
f32 TranslateSpeed;
|
||||
|
|
Loading…
Reference in New Issue