本文整理汇总了C++中VRMenuObject::RegenerateSurfaceGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ VRMenuObject::RegenerateSurfaceGeometry方法的具体用法?C++ VRMenuObject::RegenerateSurfaceGeometry怎么用?C++ VRMenuObject::RegenerateSurfaceGeometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VRMenuObject
的用法示例。
在下文中一共展示了VRMenuObject::RegenerateSurfaceGeometry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
}
示例2: SetScrollFrac
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 ) );
}
}