Game Development Community

dev|Pro Game Development Curriculum

Add Lock Zoom & Rotate Option for GuiObjectViewCtrl

by Mquaker · 02/22/2011 (5:29 pm) · 0 comments

[GuiObjectView.h]
declare variable for Lock Zoom & Vertical Rotation into 'class GuiObjectView : public GuiTSCtrl' protected section.
bool mLockZRot;
bool mLockZoom;

[GuiObjectView.cpp]
init declared variable into 'GuiObjectView::GuiObjectView()'.
mLockZRot( false ),
mLockZoom( false ),

lock option into Gui Editor
add 'addfield' into 'void GuiObjectView::initPersistFields()' 'addGroup( "Camera" );' section.
addField( "LockVertexRot", TypeBool, Offset( mLockZRot, GuiObjectView ),
		 "Lock Model Rotation Vertical." );

	  addField( "LockZoom", TypeBool, Offset( mLockZoom, GuiObjectView ),
		  "Lock Model Zoom." );

add lock left mouse drag event(rotate) into 'void GuiObjectView::onMouseDragged( const GuiEvent &event )'.
add code
if( !mLockZRot )
before
mCameraRot.x += ( delta.y * mCameraSpeed );

add lock right mouse drag event(zoom) into 'void GuiObjectView::onRightMouseDragged( const GuiEvent &event )'.
change code
if( mMouseState != Zooming )
to
if( mMouseState != Zooming || mLockZoom )

recompile.

now, you can see 'LockVertexRot' and 'LockZoom' option in Gui Editor.
mquaker.files.wordpress.com/2011/02/020711_0824_guiobjectvi14.jpg