本文整理汇总了C++中OvrVRMenuMgr::ToObject方法的典型用法代码示例。如果您正苦于以下问题:C++ OvrVRMenuMgr::ToObject方法的具体用法?C++ OvrVRMenuMgr::ToObject怎么用?C++ OvrVRMenuMgr::ToObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OvrVRMenuMgr
的用法示例。
在下文中一共展示了OvrVRMenuMgr::ToObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleEvents
//==============================
// VRMenuEventHandler::HandleEvents
void VRMenuEventHandler::HandleEvents( App * app, VrFrame const & vrFrame, OvrVRMenuMgr & menuMgr,
menuHandle_t const rootHandle, Array< VRMenuEvent > const & events ) const
{
VRMenuObject * root = menuMgr.ToObject( rootHandle );
if ( root == NULL )
{
return;
}
// find the list of all objects that are in the focused path
Array< menuHandle_t > focusPath;
FindTargetPath( menuMgr, rootHandle, FocusedHandle, focusPath );
Array< menuHandle_t > targetPath;
for ( int i = 0; i < events.GetSizeI(); ++i )
{
VRMenuEvent const & event = events[i];
switch ( event.DispatchType )
{
case EVENT_DISPATCH_BROADCAST:
{
// broadcast to everything
BroadcastEvent( app, vrFrame, menuMgr, event, root );
}
break;
case EVENT_DISPATCH_FOCUS:
// send to the focus path only -- this list should be parent -> child order
DispatchToPath( app, vrFrame, menuMgr, event, focusPath, false );
break;
case EVENT_DISPATCH_TARGET:
if ( targetPath.GetSizeI() == 0 || event.TargetHandle != targetPath.Back() )
{
targetPath.Clear();
FindTargetPath( menuMgr, rootHandle, event.TargetHandle, targetPath );
}
DispatchToPath( app, vrFrame, menuMgr, event, targetPath, false );
break;
default:
OVR_ASSERT( !"unknown dispatch type" );
break;
}
}
}
示例2: SetCaretPoseFromFrac
//==============================
// OvrSliderComponent::SetCaretPoseFromFrac
void OvrSliderComponent::SetCaretPoseFromFrac( OvrVRMenuMgr & menuMgr, VRMenuObject * self, float const frac )
{
OVR_UNUSED( frac );
VRMenuObject * caret = menuMgr.ToObject( self->ChildHandleForId( menuMgr, ScrubberId ) );
if ( caret != NULL )
{
Posef curPose = CaretBasePose;
float range = MaxValue - MinValue;
float frac = floor( SliderFrac * range ) / range;
curPose.Position += ( LocalSlideDelta * -0.5f ) + LocalSlideDelta * frac;
caret->SetLocalPose( curPose );
}
// find the fill object and scale it
menuHandle_t fillHandle = Menu.HandleForId( menuMgr, FillId );
VRMenuObject * fillObj = menuMgr.ToObject( fillHandle );
if ( fillObj != NULL )
{
Vector4f clipUVs( 0.0f, 1.0f - SliderFrac, 1.0f, 1.0f );
VRMenuSurface & surf = fillObj->GetSurface( 0 );
surf.SetClipUVs( clipUVs );
//LOG( "SliderFrac = %.2f", SliderFrac );
//LOG( "Setting clip UVs to ( %.2f, %.2f, %.2f, %.2f )", clipUVs.x, clipUVs.y, clipUVs.z, clipUVs.w );
}
}
示例3: OnFrameUpdate
//==============================
// OvrSliderComponent::OnFrameUpdate
eMsgStatus OvrSliderComponent::OnFrameUpdate( App * app, VrFrame const & vrFrame, OvrVRMenuMgr & menuMgr,
VRMenuObject * self, VRMenuEvent const & event )
{
if ( TouchDown )
{
UpdateText( menuMgr, self, BubbleId );
UpdateText( menuMgr, self, TextId );
}
if ( BubbleFadeOutTime > 0.0 )
{
if ( ovr_GetTimeInSeconds() >= BubbleFadeOutTime )
{
BubbleFadeOutTime = -1.0;
BubbleFader.StartFadeOut();
}
}
VRMenuObject * bubble = menuMgr.ToObject( self->ChildHandleForId( menuMgr, BubbleId ) );
if ( bubble != NULL )
{
float const fadeTime = 0.5f;
float const fadeRate = 1.0 / fadeTime;
BubbleFader.Update( fadeRate, vrFrame.DeltaSeconds );
Vector4f color = bubble->GetColor();
color.w = BubbleFader.GetFinalAlpha();
bubble->SetColor( color );
Vector4f textColor = bubble->GetTextColor();
textColor.w = color.w;
bubble->SetTextColor( textColor );
}
return MSG_STATUS_ALIVE;
}
示例4: DispatchToPath
//==============================
// VRMenuEventHandler::DispatchToPath
bool VRMenuEventHandler::DispatchToPath( App * app, VrFrame const & vrFrame, OvrVRMenuMgr & menuMgr,
VRMenuEvent const & event, Array< menuHandle_t > const & path, bool const log ) const
{
// send to the focus path only -- this list should be parent -> child order
for ( int i = 0; i < path.GetSizeI(); ++i )
{
VRMenuObject * obj = menuMgr.ToObject( path[i] );
char const * const indent = " ";
// set to
if ( obj != NULL && DispatchToComponents( app, vrFrame, menuMgr, event, obj ) )
{
if ( log )
{
LOG( "%sDispatchToPath: %s, object '%s' consumed event.", &indent[64 - i * 2],
VRMenuEvent::EventTypeNames[event.EventType], ( obj != NULL ? obj->GetText().ToCStr() : "<null>" ) );
}
return true; // consumed by a component
}
if ( log )
{
LOG( "%sDispatchToPath: %s, object '%s' passed event.", &indent[64 - i * 2],
VRMenuEvent::EventTypeNames[event.EventType], obj != NULL ? obj->GetText().ToCStr() : "<null>" );
}
}
return false;
}
示例5: SetBaseColor
void OvrScrollBarComponent::SetBaseColor( OvrVRMenuMgr & menuMgr, VRMenuObject * self, const Vector4f & color )
{
// Set alpha on the base - move this to somewhere more explicit if needed
VRMenuObject * base = menuMgr.ToObject( self->ChildHandleForId( menuMgr, ScrollBarBaseId ) );
if ( base != NULL )
{
base->SetSurfaceColor( 0, color );
}
}
示例6: SetPosition
void ResumeMovieView::SetPosition( OvrVRMenuMgr & menuMgr, const Vector3f &pos )
{
menuHandle_t centerRootHandle = Menu->HandleForId( menuMgr, ID_CENTER_ROOT );
VRMenuObject * centerRoot = menuMgr.ToObject( centerRootHandle );
OVR_ASSERT( centerRoot != NULL );
Posef pose = centerRoot->GetLocalPose();
pose.Position = pos;
centerRoot->SetLocalPose( pose );
}
示例7: FindTargetPath
//==============================
// FindTargetPath
static void FindTargetPath( OvrVRMenuMgr const & menuMgr,
menuHandle_t const curHandle, Array< menuHandle_t > & targetPath )
{
VRMenuObject * obj = menuMgr.ToObject( curHandle );
if ( obj != NULL )
{
FindTargetPath( menuMgr, obj->GetParentHandle(), targetPath );
targetPath.PushBack( curHandle );
}
}
示例8: SetCaretPoseFromFrac
//==============================
// OvrSliderComponent::SetCaretPoseFromFrac
void OvrSliderComponent::SetCaretPoseFromFrac( OvrVRMenuMgr & menuMgr, VRMenuObject * self, float const frac )
{
VRMenuObject * caret = menuMgr.ToObject( self->ChildHandleForId( menuMgr, ScrubberId ) );
if ( caret != NULL )
{
Posef curPose = CaretBasePose;
float range = MaxValue - MinValue;
float frac = floor( SliderFrac * range ) / range;
curPose.Position += ( LocalSlideDelta * -0.5f ) + LocalSlideDelta * frac;
caret->SetLocalPose( curPose );
}
}
示例9: UpdateScrollBar
void OvrScrollBarComponent::UpdateScrollBar( OvrVRMenuMgr & menuMgr, VRMenuObject * self, const int numElements )
{
NumOfItems = numElements;
if ( IsVertical )
{
ScrollBarCurrentbaseLength = ScrollBarBaseHeight;
}
else
{
ScrollBarCurrentbaseLength = ScrollBarBaseWidth;
}
ScrollBarCurrentThumbLength = ScrollBarCurrentbaseLength / NumOfItems;
ScrollBarCurrentThumbLength = ( ScrollBarCurrentThumbLength < BASE_THUMB_WIDTH ) ? BASE_THUMB_WIDTH : ScrollBarCurrentThumbLength;
if ( IsVertical )
{
ScrollBarThumbHeight = ScrollBarCurrentThumbLength;
}
else
{
ScrollBarThumbWidth = ScrollBarCurrentThumbLength;
}
VRMenuObject * thumb = menuMgr.ToObject( self->ChildHandleForId( menuMgr, ScrollBarThumbId ) );
if ( thumb != NULL && NumOfItems > 0 )
{
thumb->SetSurfaceDims( 0, Vector2f( ScrollBarThumbWidth, ScrollBarThumbHeight ) );
thumb->RegenerateSurfaceGeometry( 0, false );
}
VRMenuObject * base = menuMgr.ToObject( self->ChildHandleForId( menuMgr, ScrollBarBaseId ) );
if ( thumb != NULL )
{
base->SetSurfaceDims( 0, Vector2f( ScrollBarBaseWidth, ScrollBarBaseHeight ) );
base->RegenerateSurfaceGeometry( 0, false );
}
}
示例10: OnInit
//==============================
// OvrSliderComponent::OnInit
eMsgStatus OvrSliderComponent::OnInit( App * app, VrFrame const & vrFrame, OvrVRMenuMgr & menuMgr,
VRMenuObject * self, VRMenuEvent const & event )
{
// find the starting offset of the caret
LOG( "OvrSliderComponent - VRMENU_EVENT_INIT" );
VRMenuObject * caret = menuMgr.ToObject( self->ChildHandleForId( menuMgr, ScrubberId ) );
if ( caret != NULL )
{
CaretBasePose = caret->GetLocalPose();
}
SetCaretPoseFromFrac( menuMgr, self, SliderFrac );
UpdateText( menuMgr, self, BubbleId );
return MSG_STATUS_ALIVE;
}
示例11: SetFrameVisibilities
void OvrTrailsAnimComponent::SetFrameVisibilities( App * app, VrFrame const & vrFrame, OvrVRMenuMgr & menuMgr, VRMenuObject * self ) const
{
// LOG( "FracFrame: %f", GetFractionalFrame() );
for ( int i = 0; i < self->NumChildren(); ++i )
{
menuHandle_t childHandle = self->GetChildHandleForIndex( i );
if ( VRMenuObject * childObject = menuMgr.ToObject( childHandle ) )
{
Vector4f color = childObject->GetColor();
color.w = GetAlphaForFrame( i );
childObject->SetColor( color );
}
}
}
示例12: UpdateText
//==============================
// OvrSliderComponent::UpdateText
void OvrSliderComponent::UpdateText( OvrVRMenuMgr & menuMgr, VRMenuObject * self, VRMenuId_t const id )
{
if ( !id.IsValid() )
{
return;
}
VRMenuObject * obj = menuMgr.ToObject( self->ChildHandleForId( menuMgr, id ) );
if ( obj != NULL )
{
char valueStr[127];
GetStringValue( valueStr, sizeof( valueStr ) );
obj->SetText( valueStr );
}
}
示例13: CreateMenu
void MoviePlayerView::CreateMenu( App * app, OvrVRMenuMgr & menuMgr, BitmapFont const & font )
{
Menu = VRMenu::Create( "MoviePlayerMenu" );
Array< VRMenuObjectParms const * > parms;
Posef moveScreenPose( Quatf( Vector3f( 0.0f, 1.0f, 0.0f ), 0.0f ),
Vector3f( 0.0f, 0.0f, -1.8f ) );
VRMenuFontParms moveScreenFontParms( true, true, false, false, false, 0.5f );
VRMenuSurfaceParms moveScreenSurfParms( "",
NULL, SURFACE_TEXTURE_MAX,
NULL, SURFACE_TEXTURE_MAX,
NULL, SURFACE_TEXTURE_MAX );
VRMenuObjectParms moveScreenParms( VRMENU_BUTTON, Array< VRMenuComponent* >(), moveScreenSurfParms,
Strings::MoviePlayer_Reorient, moveScreenPose, Vector3f( 1.0f ), moveScreenFontParms, ID_MOVE_SCREEN,
VRMenuObjectFlags_t(), VRMenuObjectInitFlags_t( VRMENUOBJECT_INIT_FORCE_POSITION ) );
parms.PushBack( &moveScreenParms );
Menu->InitWithItems(menuMgr, font, 0.0f, VRMenuFlags_t( VRMENU_FLAG_TRACK_GAZE ) | VRMENU_FLAG_BACK_KEY_DOESNT_EXIT, parms);
parms.Clear();
MoveScreenHandle = Menu->HandleForId( menuMgr, ID_MOVE_SCREEN );
MoveScreenObj = menuMgr.ToObject( MoveScreenHandle );
MoveScreenObj->AddFlags( VRMENUOBJECT_DONT_RENDER );
Vector3f moveScreenTextPosition = Vector3f( 0.0f, -24 * VRMenuObject::DEFAULT_TEXEL_SCALE, 0.0f );
MoveScreenObj->SetTextLocalPosition( moveScreenTextPosition );
// ==============================================================================
//
// finalize
//
Cinema.app->GetGuiSys().AddMenu( Menu );
}
示例14: BroadcastEvent
//==============================
// VRMenuEventHandler::BroadcastEvent
bool VRMenuEventHandler::BroadcastEvent( App * app, VrFrame const & vrFrame, OvrVRMenuMgr & menuMgr,
VRMenuEvent const & event, VRMenuObject * receiver ) const
{
DROID_ASSERT( receiver != NULL, "VrMenu" );
// allow parent components to handle first
if ( DispatchToComponents( app, vrFrame, menuMgr, event, receiver ) )
{
return true;
}
// if the parent did not consume, dispatch to children
int numChildren = receiver->NumChildren();
for ( int i = 0; i < numChildren; ++i )
{
menuHandle_t childHandle = receiver->GetChildHandleForIndex( i );
VRMenuObject * child = menuMgr.ToObject( childHandle );
if ( child != NULL && BroadcastEvent( app, vrFrame, menuMgr, event, child ) )
{
return true; // consumed by child
}
}
return false;
}
示例15: Frame
//==============================
// VRMenuEventHandler::Frame
void VRMenuEventHandler::Frame( App * app, VrFrame const & vrFrame, OvrVRMenuMgr & menuMgr, BitmapFont const & font,
menuHandle_t const & rootHandle,Posef const & menuPose, gazeCursorUserId_t const & gazeUserId,
Array< VRMenuEvent > & events )
{
VRMenuObject * root = menuMgr.ToObject( rootHandle );
if ( root == NULL )
{
return;
}
// find the object the gaze is touching and update gaze focus
const Matrix4f viewMatrix = app->GetLastViewMatrix();
const Vector3f viewPos( GetViewMatrixPosition( viewMatrix ) );
const Vector3f viewFwd( GetViewMatrixForward( viewMatrix ) );
HitTestResult result;
menuHandle_t hitHandle = root->HitTest( app, menuMgr, font, menuPose, viewPos, viewFwd, ContentFlags_t( CONTENT_SOLID ), result );
result.RayStart = viewPos;
result.RayDir = viewFwd;
VRMenuObject * hit = hitHandle.IsValid() ? menuMgr.ToObject( hitHandle ) : NULL;
app->GetGazeCursor().UpdateForUser( gazeUserId, result.t, ( hit != NULL && !( hit->GetFlags() & VRMenuObjectFlags_t( VRMENUOBJECT_NO_GAZE_HILIGHT ) ) ) ? CURSOR_STATE_HILIGHT : CURSOR_STATE_NORMAL );
/*
if ( hit != NULL )
{
app->ShowInfoText( 0.0f, "%s", hit->GetText().ToCStr() );
}
*/
bool focusChanged = ( hitHandle != FocusedHandle );
if ( focusChanged )
{
// focus changed
VRMenuObject * oldFocus = menuMgr.ToObject( FocusedHandle );
if ( oldFocus != NULL )
{
// setup event for item losing the focus
VRMenuEvent event( VRMENU_EVENT_FOCUS_LOST, EVENT_DISPATCH_TARGET, FocusedHandle, Vector3f( 0.0f ), result );
events.PushBack( event );
}
if ( hit != NULL )
{
if ( ( hit->GetFlags() & VRMENUOBJECT_FLAG_NO_FOCUS_GAINED ) == 0 )
{
// set up event for item gaining the focus
VRMenuEvent event( VRMENU_EVENT_FOCUS_GAINED, EVENT_DISPATCH_FOCUS, hitHandle, Vector3f( 0.0f ), result );
events.PushBack( event );
}
}
FocusedHandle = hitHandle;
}
bool touchPressed = ( vrFrame.Input.buttonPressed & ( BUTTON_TOUCH | BUTTON_A ) ) != 0;
bool touchReleased = !touchPressed && ( vrFrame.Input.buttonReleased & ( BUTTON_TOUCH | BUTTON_A ) ) != 0;
bool touchDown = ( vrFrame.Input.buttonState & BUTTON_TOUCH ) != 0;
if ( ( vrFrame.Input.buttonPressed & BUTTON_SWIPE_UP ) != 0 )
{
VRMenuEvent event( VRMENU_EVENT_SWIPE_UP, EVENT_DISPATCH_FOCUS, FocusedHandle, Vector3f( 0.0f ), result );
events.PushBack( event );
}
if ( ( vrFrame.Input.buttonPressed & BUTTON_SWIPE_DOWN ) != 0 )
{
VRMenuEvent event( VRMENU_EVENT_SWIPE_DOWN, EVENT_DISPATCH_FOCUS, FocusedHandle, Vector3f( 0.0f ), result );
events.PushBack( event );
}
if ( ( vrFrame.Input.buttonPressed & BUTTON_SWIPE_FORWARD ) != 0 )
{
VRMenuEvent event( VRMENU_EVENT_SWIPE_FORWARD, EVENT_DISPATCH_FOCUS, FocusedHandle, Vector3f( 0.0f ), result );
events.PushBack( event );
}
if ( ( vrFrame.Input.buttonPressed & BUTTON_SWIPE_BACK ) != 0 )
{
VRMenuEvent event( VRMENU_EVENT_SWIPE_BACK, EVENT_DISPATCH_FOCUS, FocusedHandle, Vector3f( 0.0f ), result );
events.PushBack( event );
}
/*
// report swipe data
char const * swipeNames[5] = { "none", "down", "up", "back", "forward" };
int swipeUpDown = ( vrFrame.Input.buttonPressed & BUTTON_SWIPE_UP ) ? 2 : 0;
swipeUpDown = ( vrFrame.Input.buttonPressed & BUTTON_SWIPE_DOWN ) ? 1 : swipeUpDown;
int swipeForwardBack = ( vrFrame.Input.buttonPressed & BUTTON_SWIPE_FORWARD ) ? 4 : 0;
swipeForwardBack = ( vrFrame.Input.buttonPressed & BUTTON_SWIPE_BACK ) ? 3 : swipeForwardBack;
app->ShowInfoText( 1.0f, "touch %s\n( %s, %s )\n( %.2f, %.2f )\n( %.2f, %.2f )",
touchDown ? swipeNames[1] : swipeNames[2],
swipeNames[swipeUpDown], swipeNames[swipeForwardBack],
vrFrame.Input.touch[0], vrFrame.Input.touch[1],
vrFrame.Input.touchRelative[0], vrFrame.Input.touchRelative[1] );
*/
// if nothing is focused, send events to the root
if ( touchPressed )
{
VRMenuEvent event( VRMENU_EVENT_TOUCH_DOWN, EVENT_DISPATCH_FOCUS, FocusedHandle, Vector3f( 0.0f ), result );
events.PushBack( event );
}
//.........这里部分代码省略.........