Controlling the camera angle in GuiObjectView
by Kyrah Abattoir · 04/07/2013 (9:32 pm) · 3 comments
This is a very simple mofification of the GuiObjectView class that will add methods and controls to set the camera rotation through the gui editor.
This is useful if you have non interactive GuiObjectView and want to set them to a specific view angle.
(My code will be enclosed in tags with the original code around it.)
In guiObjectView.h:
@ line 90
In guiObjectView.cpp:
@ line 181
This should add a handy new field "cameraRotation" (which take values in radiant i believe) in the camera subsection.
This is useful if you have non interactive GuiObjectView and want to set them to a specific view angle.
(My code will be enclosed in tags with the original code around it.)
In guiObjectView.h:
@ line 90
F32 mMaxOrbitDist;
F32 mMinOrbitDist;
// Kyrah :: added a way to set the camera GuiObjectView rotation >>>
EulerF mCameraRotation;
// Kyrah :: added a way to set the camera GuiObjectView rotation <<<
///
F32 mOrbitDist;
/// Multiplier for camera mouse operations (rotation and zooming).@line 248/// @param distance The distance to set the orbit to (will be clamped).
void setOrbitDistance( F32 distance );
// Kyrah :: added a way to set the camera GuiObjectView rotation >>>
void setCameraRotation( const EulerF& rotation );
// Kyrah :: added a way to set the camera GuiObjectView rotation <<<
/// @}
/// @name LightingIn guiObjectView.cpp:
@ line 181
addField( "maxOrbitDiststance", TypeF32, Offset( mMaxOrbitDist, GuiObjectView ),
"Minimum distance below which the camera will not zoom in further." );
addField( "cameraSpeed", TypeF32, Offset( mCameraSpeed, GuiObjectView ),
"Multiplier for mouse camera operations." );
// Kyrah :: added a way to set the camera GuiObjectView rotation >>>
addField( "cameraRotation", TypePoint3F, Offset( mCameraRotation, GuiObjectView ),
"Set the camera rotation." );
// Kyrah :: added a way to set the camera GuiObjectView rotation <<<
endGroup( "Camera" );
Parent::initPersistFields();@ line 209static StringTableEntry sMaxOrbitDistance = StringTable->insert( "maxOrbitDistance" );
static StringTableEntry sAnimSequence = StringTable->insert( "animSequence" );
// Kyrah :: added a way to set the camera GuiObjectView rotation >>>
static StringTableEntry sCameraRotation = StringTable->insert( "cameraRotation" );
// Kyrah :: added a way to set the camera GuiObjectView rotation <<<
if( slotName == sShapeFile )
setObjectModel( String( mModelName ) );@ line 236else if( slotName == sAnimSequence )
setObjectAnimation( String( mAnimationSeqName ) );
// Kyrah :: added a way to set the camera GuiObjectView rotation >>>
else if( slotName == sCameraRotation )
setCameraRotation( mCameraRotation );
// Kyrah :: added a way to set the camera GuiObjectView rotation <<<
}
//------------------------------------------------------------------------------
// Kyrah :: added a way to set the camera GuiObjectView rotation >>>
void GuiObjectView::setCameraRotation( const EulerF& rotation )
{
mCameraRot.set(rotation);
}
// Kyrah :: added a way to set the camera GuiObjectView rotation <<<
bool GuiObjectView::onWake()
{
if( !Parent::onWake() )This should add a handy new field "cameraRotation" (which take values in radiant i believe) in the camera subsection.
About the author
3D artist, programmer, game designer, jack of all trades, master of none.

Richard Marrevee
R.G.S - Richards Game Studio