• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ VRMenuObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中VRMenuObject的典型用法代码示例。如果您正苦于以下问题:C++ VRMenuObject类的具体用法?C++ VRMenuObject怎么用?C++ VRMenuObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了VRMenuObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: GetMenuObject

void UILabel::SetText( const char *text )
{
	VRMenuObject * object = GetMenuObject();
	assert( object );
	object->SetText( text );
	CalculateTextOffset();
}
开发者ID:8BitRick,项目名称:GearVRNative,代码行数:7,代码来源:UILabel.cpp


示例2: DecomposeHandle

//==================================
// VRMenuMgrLocal::ToObject
// Return the object for a menu handle.
VRMenuObject * VRMenuMgrLocal::ToObject( menuHandle_t const handle ) const
{
	int index;
	UInt32 id;
	DecomposeHandle( handle, index, id );
	if ( id == INVALID_MENU_OBJECT_ID )
	{
		return NULL;
	}
	if ( !HandleComponentsAreValid( index, id ) )
	{
		LOG( "VRMenuMgrLocal::ToObject - invalid handle." );
		return NULL;
	}
	if ( index >= ObjectList.GetSizeI() )
	{
		LOG( "VRMenuMgrLocal::ToObject - index out of range." );
		return NULL;
	}
	VRMenuObject * object = ObjectList[index];
	if ( object == NULL )
	{
		LOG( "VRMenuMgrLocal::ToObject - slot empty." );
		return NULL;	// this can happen if someone is holding onto the handle of an object that's been freed
	}
	if ( object->GetHandle() != handle )
	{
		// if the handle of the object in the slot does not match, then the object the handle refers to was deleted
		// and a new object is in the slot
		LOG( "VRMenuMgrLocal::ToObject - slot mismatch." );
		return NULL;
	}
	return object;
}
开发者ID:beijingkaka,项目名称:shellspace,代码行数:37,代码来源:VRMenuMgr.cpp


示例3: DispatchToPath

//==============================
// VRMenuEventHandler::DispatchToPath
bool VRMenuEventHandler::DispatchToPath( OvrGuiSys & guiSys, VrFrame const & vrFrame, 
        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 = guiSys.GetVRMenuMgr().ToObject( path[i] );
		char const * const indent = "                                                                ";
		// set to 
		if ( obj != NULL && DispatchToComponents( guiSys, vrFrame, 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;
}
开发者ID:8BitRick,项目名称:GearVRNative,代码行数:28,代码来源:VRMenuEventHandler.cpp


示例4: OVR_UNUSED

//==============================
// 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 );
	}	
}
开发者ID:8BitRick,项目名称:GearVRNative,代码行数:28,代码来源:SliderComponent.cpp


示例5: UpdateText

//==============================
// 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;
}
开发者ID:1107979819,项目名称:OculusVRStudy,代码行数:37,代码来源:SliderComponent.cpp


示例6: 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 );
	}
}
开发者ID:8BitRick,项目名称:GearVRNative,代码行数:9,代码来源:ScrollBarComponent.cpp


示例7: 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 );
}
开发者ID:1107979819,项目名称:OculusVRStudy,代码行数:10,代码来源:ResumeMovieView.cpp


示例8: FindTargetPath

//==============================
// FindTargetPath
static void FindTargetPath( OvrGuiSys & guiSys, 
        menuHandle_t const curHandle, Array< menuHandle_t > & targetPath ) 
{
	VRMenuObject * obj = guiSys.GetVRMenuMgr().ToObject( curHandle );
	if ( obj != NULL )
	{
		FindTargetPath( guiSys, obj->GetParentHandle(), targetPath );
		targetPath.PushBack( curHandle );
	}
}
开发者ID:8BitRick,项目名称:GearVRNative,代码行数:12,代码来源:VRMenuEventHandler.cpp


示例9: 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 );
    }
}
开发者ID:colwalder,项目名称:unrealengine,代码行数:12,代码来源:VRMenuEventHandler.cpp


示例10: LOG

//==================================
// VRMenuMgrLocal::CreateObject
// creates a new menu object
menuHandle_t VRMenuMgrLocal::CreateObject( VRMenuObjectParms const & parms )
{
	if ( !Initialized )
	{
		LOG( "VRMenuMgrLocal::CreateObject - manager has not been initialized!" );
		return menuHandle_t();
	}

	// validate parameters
	if ( parms.Type >= VRMENU_MAX )
	{
		LOG( "VRMenuMgrLocal::CreateObject - Invalid menu object type: %i", parms.Type );
		return menuHandle_t();
	}

	// create the handle first so we can enforce setting it be requiring it to be passed to the constructor
	int index = -1;
	if ( FreeList.GetSizeI() > 0 )
	{
		index = FreeList.Back();
		FreeList.PopBack();
	}
	else
	{
		index = ObjectList.GetSizeI();
	}

	UInt32 id = ++CurrentId;
	menuHandle_t handle = ComposeHandle( index, id );
	//LOG( "VRMenuMgrLocal::CreateObject - handle is %llu", handle.Get() );

	VRMenuObject * obj = new VRMenuObjectLocal( parms, handle );
	if ( obj == NULL )
	{
		LOG( "VRMenuMgrLocal::CreateObject - failed to allocate menu object!" );
		OVR_ASSERT( obj != NULL );	// this would be bad -- but we're likely just going to explode elsewhere
		return menuHandle_t();
	}
	
	obj->Init( parms );

	if ( index == ObjectList.GetSizeI() )
	{
		// we have to grow the array
		ObjectList.PushBack( obj );
	}
	else
	{
		// insert in existing slot
		OVR_ASSERT( ObjectList[index] == NULL );
		ObjectList[index ] = obj;
	}

	return handle;
}
开发者ID:beijingkaka,项目名称:shellspace,代码行数:58,代码来源:VRMenuMgr.cpp


示例11: 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 );
	}
}
开发者ID:1107979819,项目名称:OculusVRStudy,代码行数:14,代码来源:SliderComponent.cpp


示例12: LOG

//==============================
// 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;
}
开发者ID:1107979819,项目名称:OculusVRStudy,代码行数:16,代码来源:SliderComponent.cpp


示例13: UIDiscreteSliderComponent

void UIDiscreteSlider::AddCells( unsigned int maxValue, unsigned int startValue, float cellSpacing )
{
	MaxValue = maxValue;
	StartValue = startValue;

	DiscreteSliderComponent = new UIDiscreteSliderComponent( *this, StartValue );
	OVR_ASSERT( DiscreteSliderComponent );
	AddComponent( DiscreteSliderComponent );

	float cellOffset = 0.0f;
	const float pixelCellSpacing = cellSpacing * VRMenuObject::DEFAULT_TEXEL_SCALE;

	VRMenuFontParms fontParms( HORIZONTAL_CENTER, VERTICAL_CENTER, false, false, false, 1.0f );
	Vector3f defaultScale( 1.0f );
	
	for ( unsigned int cellIndex = 0; cellIndex <= MaxValue; ++cellIndex )
	{
		const Posef pose( Quatf( Vector3f( 0.0f, 1.0f, 0.0f ), 0.0f ),
			Vector3f( cellOffset, 0.f, 0.0f ) );

		cellOffset += pixelCellSpacing;

		VRMenuObjectParms cellParms( VRMENU_BUTTON, Array< VRMenuComponent* >(), VRMenuSurfaceParms(),
			"", pose, defaultScale, fontParms, Menu->AllocId(),
			VRMenuObjectFlags_t(), VRMenuObjectInitFlags_t( VRMENUOBJECT_INIT_FORCE_POSITION ) );

		UICell * cellObject = new UICell( GuiSys );
		cellObject->AddToDiscreteSlider( Menu, this, cellParms );
		cellObject->SetImage( 0, SURFACE_TEXTURE_DIFFUSE, CellOffTexture );
		UICellComponent * cellComp = new UICellComponent( *DiscreteSliderComponent, cellIndex );

		VRMenuObject * object = cellObject->GetMenuObject();
		OVR_ASSERT( object );
		object->AddComponent( cellComp );

		DiscreteSliderComponent->AddCell( cellObject );
	}

	DiscreteSliderComponent->HighlightCells( StartValue );
}
开发者ID:8BitRick,项目名称:GearVRNative,代码行数:40,代码来源:UIDiscreteSlider.cpp


示例14: OVR_ASSERT

void OvrPanoMenu::UpdateButtonsState( const OvrMetaDatum * const ActivePano, bool showSwipeOverride /*= false*/ )
{
	// Reset button time
	ButtonCoolDown = BUTTON_COOL_DOWN_SECONDS;

	// Update favo
	bool isFavorite = false;

	for ( int i = 0; i < ActivePano->Tags.GetSizeI( ); ++i )
	{
		if ( ActivePano->Tags[ i ] == "Favorites" )
		{
			isFavorite = true;
			break;
		}
	}

	VRMenuObject * favoritesButtonObject = MenuMgr.ToObject( FavoritesButtonHandle );
	OVR_ASSERT( favoritesButtonObject != NULL );

	if ( OvrSurfaceToggleComponent * favToggleComp = favoritesButtonObject->GetComponentByName<OvrSurfaceToggleComponent>() )
	{
		const int fav = isFavorite ? 2 : 0;
		favToggleComp->SetGroupIndex( fav );
	}

	VRMenuObject * swipeRight = MenuMgr.ToObject( SwipeRightIndicatorHandle );
	OVR_ASSERT( swipeRight != NULL );

	VRMenuObject * swipeLeft = MenuMgr.ToObject( SwipeLeftIndicatorHandle );
	OVR_ASSERT( swipeLeft != NULL );

	const bool showSwipeIndicators = showSwipeOverride || ( Photos->GetNumPanosInActiveCategory( ) > 1 );

	VRMenuObjectFlags_t flagsLeft = swipeRight->GetFlags( );
	VRMenuObjectFlags_t flagsRight = swipeRight->GetFlags( );

	if ( showSwipeIndicators )
	{
		flagsLeft &= ~VRMenuObjectFlags_t( VRMENUOBJECT_DONT_RENDER );
		flagsRight &= ~VRMenuObjectFlags_t( VRMENUOBJECT_DONT_RENDER );
	}
	else
	{
		flagsLeft |= VRMenuObjectFlags_t( VRMENUOBJECT_DONT_RENDER );
		flagsRight |= VRMenuObjectFlags_t( VRMENUOBJECT_DONT_RENDER );
	}

	swipeLeft->SetFlags( flagsLeft );
	swipeRight->SetFlags( flagsRight );
}
开发者ID:rshi-google,项目名称:test,代码行数:51,代码来源:PanoMenu.cpp


示例15: Vector2f

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 );
	}
}
开发者ID:8BitRick,项目名称:GearVRNative,代码行数:39,代码来源:ScrollBarComponent.cpp


示例16: VRMenu

OvrVideoMenu::OvrVideoMenu( OvrGuiSys & guiSys, OvrMetaData & metaData, float radius )
	: VRMenu( MENU_NAME )
	, MetaData( metaData )
	, LoadingIconHandle( 0 )
	, AttributionHandle( 0 )
	, BrowserButtonHandle( 0 )
	, VideoControlButtonHandle( 0 )
	, Radius( radius )
	, ButtonCoolDown( 0.0f )
	, OpenTime( 0.0 )
{
	// Init with empty root
	Init( guiSys, 0.0f, VRMenuFlags_t() );

	// Create Attribution info view
	Array< VRMenuObjectParms const * > parms;
	Array< VRMenuComponent* > comps;
	VRMenuId_t attributionPanelId( ID_CENTER_ROOT.Get() + 10 );

	comps.PushBack( new OvrVideoMenuRootComponent( *this ) );

	Quatf rot( DOWN, 0.0f );
	Vector3f dir( -FWD );
	Posef panelPose( rot, dir * Radius );
	Vector3f panelScale( 1.0f );

	const VRMenuFontParms fontParms( true, true, false, false, true, 0.525f, 0.45f, 1.0f );

	VRMenuObjectParms attrParms( VRMENU_STATIC, comps,
		VRMenuSurfaceParms(), "Attribution Panel", panelPose, panelScale, Posef(), Vector3f( 1.0f ), fontParms, attributionPanelId,
		VRMenuObjectFlags_t(), VRMenuObjectInitFlags_t( VRMENUOBJECT_INIT_FORCE_POSITION ) );

	parms.PushBack( &attrParms );

	AddItems( guiSys, parms, GetRootHandle(), false );
	parms.Clear();
	comps.Clear();

	AttributionHandle = HandleForId( guiSys.GetVRMenuMgr(), attributionPanelId );
	VRMenuObject * attributionObject = guiSys.GetVRMenuMgr().ToObject( AttributionHandle );
	OVR_ASSERT( attributionObject != NULL );

	//Browser button
	float const ICON_HEIGHT = 80.0f * VRMenuObject::DEFAULT_TEXEL_SCALE;
	Array< VRMenuSurfaceParms > surfParms;

	Posef browserButtonPose( Quatf(), UP * ICON_HEIGHT * 2.0f );

	comps.PushBack( new OvrDefaultComponent( Vector3f( 0.0f, 0.0f, 0.05f ), 1.05f, 0.25f, 0.0f, Vector4f( 1.0f ), Vector4f( 1.0f ) ) );
	comps.PushBack( new OvrButton_OnUp( this, ID_BROWSER_BUTTON ) );
	comps.PushBack( new OvrSurfaceToggleComponent( ) );
	surfParms.PushBack( VRMenuSurfaceParms( "browser",
		"apk:///assets/nav_home_off.png", SURFACE_TEXTURE_DIFFUSE,
		NULL, SURFACE_TEXTURE_MAX, NULL, SURFACE_TEXTURE_MAX ) );
	surfParms.PushBack( VRMenuSurfaceParms( "browser",
		"apk:///assets/nav_home_on.png", SURFACE_TEXTURE_DIFFUSE,
		NULL, SURFACE_TEXTURE_MAX, NULL, SURFACE_TEXTURE_MAX ) );
	VRMenuObjectParms browserButtonParms( VRMENU_BUTTON, comps, surfParms, "",
		browserButtonPose, Vector3f( 1.0f ), Posef(), Vector3f( 1.0f ), fontParms,
		ID_BROWSER_BUTTON, VRMenuObjectFlags_t( VRMENUOBJECT_DONT_HIT_TEXT ),
		VRMenuObjectInitFlags_t( VRMENUOBJECT_INIT_FORCE_POSITION ) );
	parms.PushBack( &browserButtonParms );

	AddItems( guiSys, parms, AttributionHandle, false );
	parms.Clear();
	comps.Clear();
	surfParms.Clear();

	BrowserButtonHandle = attributionObject->ChildHandleForId( guiSys.GetVRMenuMgr(), ID_BROWSER_BUTTON );
	VRMenuObject * browserButtonObject = guiSys.GetVRMenuMgr().ToObject( BrowserButtonHandle );
	OVR_ASSERT( browserButtonObject != NULL );
	OVR_UNUSED( browserButtonObject );

	//Video control button 
	Posef videoButtonPose( Quatf(), DOWN * ICON_HEIGHT * 2.0f );

	comps.PushBack( new OvrDefaultComponent( Vector3f( 0.0f, 0.0f, 0.05f ), 1.05f, 0.25f, 0.0f, Vector4f( 1.0f ), Vector4f( 1.0f ) ) );
	comps.PushBack( new OvrButton_OnUp( this, ID_VIDEO_BUTTON ) );
	comps.PushBack( new OvrSurfaceToggleComponent( ) );
	surfParms.PushBack( VRMenuSurfaceParms( "browser",
		"apk:///assets/nav_restart_off.png", SURFACE_TEXTURE_DIFFUSE,
		NULL, SURFACE_TEXTURE_MAX, NULL, SURFACE_TEXTURE_MAX ) );
	surfParms.PushBack( VRMenuSurfaceParms( "browser",
		"apk:///assets/nav_restart_on.png", SURFACE_TEXTURE_DIFFUSE,
		NULL, SURFACE_TEXTURE_MAX, NULL, SURFACE_TEXTURE_MAX ) );
	VRMenuObjectParms controlButtonParms( VRMENU_BUTTON, comps, surfParms, "",
		videoButtonPose, Vector3f( 1.0f ), Posef(), Vector3f( 1.0f ), fontParms,
		ID_VIDEO_BUTTON, VRMenuObjectFlags_t( VRMENUOBJECT_DONT_HIT_TEXT ),
		VRMenuObjectInitFlags_t( VRMENUOBJECT_INIT_FORCE_POSITION ) );
	parms.PushBack( &controlButtonParms );

	AddItems( guiSys, parms, AttributionHandle, false );
	parms.Clear();
	comps.Clear();

	VideoControlButtonHandle = attributionObject->ChildHandleForId( guiSys.GetVRMenuMgr(), ID_VIDEO_BUTTON );
	VRMenuObject * controlButtonObject = guiSys.GetVRMenuMgr().ToObject( VideoControlButtonHandle );
	OVR_ASSERT( controlButtonObject != NULL );
	OVR_UNUSED( controlButtonObject );

//.........这里部分代码省略.........
开发者ID:yenchenlin,项目名称:gear-vr-360-player,代码行数:101,代码来源:VideoMenu.cpp


示例17: VRMenu

OvrPanoMenu::OvrPanoMenu( App * app, Oculus360Photos * photos, OvrVRMenuMgr & menuMgr, BitmapFont const & font,
		OvrMetaData & metaData, float fadeOutTime, float radius )
	: VRMenu( MENU_NAME )
	, AppPtr( app )
	, MenuMgr( menuMgr )
	, Font( font )
	, Photos( photos )
	, MetaData( metaData )
	, LoadingIconHandle( 0 )
	, AttributionHandle( 0 )
	, BrowserButtonHandle( 0 )
	, SwipeLeftIndicatorHandle( 0 )
	, SwipeRightIndicatorHandle( 0 )
	, Fader( 1.0f )
	, FadeOutTime( fadeOutTime )
	, currentFadeRate( 0.0f )
	, Radius( radius )
	, ButtonCoolDown( 0.0f )
{	
	currentFadeRate = 1.0f / FadeOutTime;

	// Init with empty root
	Init( menuMgr, font, 0.0f, VRMenuFlags_t() );
	
	// Create Attribution info view
	Array< VRMenuObjectParms const * > parms;
	Array< VRMenuComponent* > comps;
	VRMenuId_t attributionPanelId( ID_CENTER_ROOT.Get() + 10 );

	comps.PushBack( new OvrPanoMenuRootComponent( *this ) );

	Quatf rot( DOWN, 0.0f );
	Vector3f dir( -FWD );
	Posef panelPose( rot, dir * Radius );
	Vector3f panelScale( 1.0f );

	//const Posef textPose( Quatf(), Vector3f( 0.0f, 0.0f, 0.0f ) );

	const VRMenuFontParms fontParms( true, true, false, false, true, 0.525f, 0.45f, 1.0f );
	
	VRMenuObjectParms attrParms( VRMENU_STATIC, comps,
		VRMenuSurfaceParms(), "Attribution Panel", panelPose, panelScale, Posef(), Vector3f( 1.0f ), fontParms, attributionPanelId,
		VRMenuObjectFlags_t( VRMENUOBJECT_DONT_HIT_TEXT ), VRMenuObjectInitFlags_t( VRMENUOBJECT_INIT_FORCE_POSITION ) );

	parms.PushBack( &attrParms );

	AddItems( MenuMgr, Font, parms, GetRootHandle(), false );
	parms.Clear();
	comps.Clear();

	AttributionHandle = HandleForId( MenuMgr, attributionPanelId );
	VRMenuObject * attributionObject = MenuMgr.ToObject( AttributionHandle );
	OVR_ASSERT( attributionObject != NULL );

	//Browser button
	float const ICON_HEIGHT = 80.0f * VRMenuObject::DEFAULT_TEXEL_SCALE;
	Array< VRMenuSurfaceParms > surfParms;

	Posef browserButtonPose( Quatf( ), UP * ICON_HEIGHT * 2.0f );

	comps.PushBack( new OvrDefaultComponent( Vector3f( 0.0f, 0.0f, 0.05f ), 1.05f, 0.25f, 0.0f, Vector4f( 1.0f ), Vector4f( 1.0f ) ) );
	comps.PushBack( new OvrButton_OnUp( this, ID_BROWSER_BUTTON ) );
	comps.PushBack( new OvrSurfaceToggleComponent( ) );
	surfParms.PushBack( VRMenuSurfaceParms ( "browser",
		"assets/nav_home_off.png", SURFACE_TEXTURE_DIFFUSE,
		NULL, SURFACE_TEXTURE_MAX, NULL, SURFACE_TEXTURE_MAX ) );
	surfParms.PushBack( VRMenuSurfaceParms( "browser",
		"assets/nav_home_on.png", SURFACE_TEXTURE_DIFFUSE,
		NULL, SURFACE_TEXTURE_MAX, NULL, SURFACE_TEXTURE_MAX ) );
	VRMenuObjectParms browserButtonParms( VRMENU_BUTTON, comps, surfParms, "",
		browserButtonPose, Vector3f( 1.0f ), Posef( ), Vector3f( 1.0f ), fontParms,
		ID_BROWSER_BUTTON, VRMenuObjectFlags_t( VRMENUOBJECT_DONT_HIT_TEXT ),
		VRMenuObjectInitFlags_t( VRMENUOBJECT_INIT_FORCE_POSITION ) );
	parms.PushBack( &browserButtonParms );

	AddItems( MenuMgr, Font, parms, AttributionHandle, false );
	parms.Clear();
	comps.Clear();
	surfParms.Clear();

	BrowserButtonHandle = attributionObject->ChildHandleForId( MenuMgr, ID_BROWSER_BUTTON );
	VRMenuObject * browserButtonObject = MenuMgr.ToObject( BrowserButtonHandle );
	OVR_ASSERT( browserButtonObject != NULL );
	OVR_UNUSED( browserButtonObject );

	//Favorites button
	Posef favoritesButtonPose( Quatf( ), DOWN * ICON_HEIGHT * 2.0f );

	comps.PushBack( new OvrDefaultComponent( Vector3f( 0.0f, 0.0f, 0.05f ), 1.05f, 0.25f, 0.0f, Vector4f( 1.0f ), Vector4f( 1.0f ) ) );
	comps.PushBack( new OvrButton_OnUp( this, ID_FAVORITES_BUTTON ) );
	comps.PushBack( new OvrSurfaceToggleComponent() );
	
	surfParms.PushBack( VRMenuSurfaceParms( "favorites_off",
		"assets/nav_star_off.png", SURFACE_TEXTURE_DIFFUSE,
		NULL, SURFACE_TEXTURE_MAX, NULL, SURFACE_TEXTURE_MAX ) );

	surfParms.PushBack( VRMenuSurfaceParms( "favorites_on",
		"assets/nav_star_on.png", SURFACE_TEXTURE_DIFFUSE,
		NULL, SURFACE_TEXTURE_MAX, NULL, SURFACE_TEXTURE_MAX ) );

//.........这里部分代码省略.........
开发者ID:rshi-google,项目名称:test,代码行数:101,代码来源:PanoMenu.cpp


示例18: viewPos

//==============================
// VRMenuEventHandler::Frame
void VRMenuEventHandler::Frame( OvrGuiSys & guiSys, VrFrame const & vrFrame, 
        menuHandle_t const & rootHandle, Posef const & menuPose, Array< VRMenuEvent > & events )
{
	VRMenuObject * root = guiSys.GetVRMenuMgr().ToObject( rootHandle );
	if ( root == NULL )
	{
		return;
	}

	// find the object the gaze is touching and update gaze focus
	const Matrix4f viewMatrix = guiSys.GetApp()->GetLastViewMatrix();
	const Vector3f viewPos( GetViewMatrixPosition( viewMatrix ) );
	const Vector3f viewFwd( GetViewMatrixForward( viewMatrix ) );

	HitTestResult result;
	menuHandle_t hitHandle = root->HitTest( guiSys, menuPose, viewPos, viewFwd, ContentFlags_t( CONTENT_SOLID ), result );
	result.RayStart = viewPos;
	result.RayDir = viewFwd;

	VRMenuObject * hit = hitHandle.IsValid() ? guiSys.GetVRMenuMgr().ToObject( hitHandle ) : NULL;
/*
	if ( hit != NULL )
	{
		guiSys.GetApp()->ShowInfoText( 0.0f, "%s", hit->GetText().ToCStr() );
	}
*/
	bool focusChanged = ( hitHandle != FocusedHandle );
	if ( focusChanged )
	{
		// focus changed
		VRMenuObject * oldFocus = guiSys.GetVRMenuMgr().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;
	}

	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 );
	}

	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;

	// Need to update this for keyboard events as well
	for ( int i = 0; i < vrFrame.Input.NumKeyEvents; i++ )
	{
		if ( vrFrame.Input.KeyEvents[i].KeyCode == OVR_KEY_RETURN )
		{
			switch ( vrFrame.Input.KeyEvents[i].EventType )
			{
				case KEY_EVENT_DOWN:
					touchPressed = true;
					break;
				case KEY_EVENT_UP:
					touchReleased = true;
					break;
				default:
					break;
			}
		}
	}

 /*   
	// report swipe data
	char const * swipeNames[5] = { "none", "down", "up", "back", "forward" };
//.........这里部分代码省略.........
开发者ID:8BitRick,项目名称:GearVRNative,代码行数:101,代码来源:VRMenuEventHandler.cpp


示例19: LinearRangeMapFloat

void OvrScrollBarComponent::SetScrollFrac( OvrVRMenuMgr & menuMgr, VRMenuObject * self, const float pos )
{
	if ( NumOfItems <= 0 )
		return;

	// Updating thumb length when pulled beyond its bounds
	const float scrollEnd 			= (float)( NumOfItems - 1 );
	const float outOfBoundsOffset 	= 0.5f;
	const float minThumbLength		= ScrollBarCurrentThumbLength * THUMB_SHRINK_FACTOR;
	const float maxThumbLength		= ScrollBarCurrentThumbLength;
	const float minThumbOffset		= 0.0f;
	const float maxThumbOffset		= ( maxThumbLength - minThumbLength ) * 0.5f;
	float currentThumbLength 		= ScrollBarCurrentThumbLength;
	float thumbPosOffset 			= 0.0f;

	if ( pos < 0.0f )
	{
		currentThumbLength = LinearRangeMapFloat( pos, -outOfBoundsOffset, 0.0f, minThumbLength, maxThumbLength );
		thumbPosOffset = LinearRangeMapFloat( pos, -outOfBoundsOffset, 0.0f, -maxThumbOffset, minThumbOffset );
	}
	else if ( pos > scrollEnd )
	{
		currentThumbLength = LinearRangeMapFloat( pos, scrollEnd + outOfBoundsOffset, scrollEnd, minThumbLength, maxThumbLength );
		thumbPosOffset = LinearRangeMapFloat( pos, scrollEnd + outOfBoundsOffset, scrollEnd, maxThumbOffset, minThumbOffset );
	}

	float thumbWidth = ScrollBarThumbWidth;
	float thumbHeight = ScrollBarThumbHeight;

	if ( IsVertical )
	{
		thumbHeight = currentThumbLength;
	}
	else
	{
		thumbWidth = currentThumbLength;
	}

	VRMenuObject * thumb = menuMgr.ToObject( self->ChildHandleForId( menuMgr, ScrollBarThumbId ) );
	if ( thumb != NULL && NumOfItems > 0 )
	{
		thumb->SetSurfaceDims( 0, Vector2f( thumbWidth, thumbHeight ) );
		thumb->RegenerateSurfaceGeometry( 0, false );
	}

	// Updating thumb position
	float clampedPos = Alg::Clamp( pos, 0.0f, (float)(NumOfItems - 1) );
	float thumbPos = LinearRangeMapFloat( clampedPos, 0.0f, (float)(NumOfItems - 1), 0.0f, ( ScrollBarCurrentbaseLength - currentThumbLength ) );
	thumbPos -= ( ScrollBarCurrentbaseLength - currentThumbLength ) * 0.5f;
	thumbPos += thumbPosOffset;
	thumbPos *= VRMenuObject::DEFAULT_TEXEL_SCALE;

	if ( thumb != NULL  )
	{
		Vector3f direction = RIGHT;
		if ( IsVertical )
		{
			direction = DOWN;
		}
		thumb->SetLocalPosition( ( direction * thumbPos ) - ( FWD * THUMB_FROM_BASE_OFFSET ) );
	}
}
开发者ID:8BitRick,项目名称:GearVRNative,代码行数:62,代码来源:ScrollBarComponent.cpp


示例20: viewPos

//==============================
// 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 );
    }
//.........这里部分代码省略.........
开发者ID:colwalder,项目名称:unrealengine,代码行数:101,代码来源:VRMenuEventHandler.cpp



注:本文中的VRMenuObject类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ VRTDataset类代码示例发布时间:2022-05-31
下一篇:
C++ VRManager类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap