MtVector2 HlScreenSize::GetBorder() { if( ApConfig::IsAppleTV() ) { return MtVector2(90.0f, 60.0f); } return MtVector2(0, 0); }
void HlFont::RenderHeavy( const MtVector2 &v2Position, const BtChar *text, BtU32 sortOrder) { MtVector2 v2Scale( 1.0f, 1.0f ); m_pFont->Render(v2Position + MtVector2(-1, -1 ), v2Scale, RsColour::WhiteColour(), text, sortOrder); m_pFont->Render(v2Position + MtVector2( 0, 1 ), v2Scale, RsColour::WhiteColour(), text, sortOrder); m_pFont->Render(v2Position + MtVector2( 1, 0 ), v2Scale, RsColour::WhiteColour(), text, sortOrder); m_pFont->Render(v2Position + MtVector2( 1, 1 ), v2Scale, RsColour::WhiteColour(), text, sortOrder); m_pFont->Render(v2Position + MtVector2( 1, 1 ), v2Scale, RsColour::BlackColour(), text, sortOrder); }
// virtual MtVector2 RsFontWin32GL::Render( const MtVector2& v2StartPosition, const RsColour &colour, const BtChar* szText, BtU32 sortOrder ) { return Render( v2StartPosition, MtVector2( 1.0f, 1.0f ), colour, szText, sortOrder ); }
void HlView::Render() { if( BtStrCompare( m_lastArchiveName, m_archiveName ) == BtFalse ) { Unload(); Load(); } if( UiKeyboard::pInstance()->IsPressed( UiKeyCode_F2 ) ) { Unload(); Load(); } // Cache the screen dimension MtVector2 v2Dimension = RsRenderTarget::GetCurrent()->GetCamera().GetDimension(); if( m_isBackground ) { // Render from the top left corner 0, 0 downward RsColour colour( RsColour::WhiteColour() ); MtVector2 v2Position = MtVector2(0, 0); m_pBackgroundMaterial->Render( v2Position, v2Dimension, colour, 6 ); } // Render the menu RenderMenu(); }
void HlView::Render() { if( !m_isLoaded ) { return; } // if( BtStrCompare( m_lastArchiveName, m_archiveName ) == BtFalse ) // { // Unload(); // Load(); // } if( UiKeyboard::pInstance()->IsPressed( ReloadMenuKey ) ) { Unload(); Load(); } if( m_isBackground ) { BtAssert( m_pBackgroundMaterial ); // Render from the top left corner 0, 0 downward RsColour colour( RsColour::WhiteColour() ); MtVector2 v2Position = MtVector2(0, 0); m_pBackgroundMaterial->Render( v2Position, m_v2RenderDimension, colour, m_backgroundSortOrder ); } // Render the menu RenderMenu(); }
void SbPaint::Reset() { m_isClear = BtTrue; m_v2Last = MtVector2( 0, 0 ); m_isFirst = BtFalse; m_isPainting = BtFalse; m_hardness = 1.0f; }
MtVector2 HlScreenSize::Refactor( const MtVector2 &v2OriginalScreenSize, const MtVector2 &v2Coord, const MtVector2 &v2ScreenDimension ) { BtFloat x = (BtFloat)v2ScreenDimension.x / v2OriginalScreenSize.x; BtFloat y = (BtFloat)v2ScreenDimension.y / v2OriginalScreenSize.y; MtVector2 v2NewDimension = MtVector2( v2Coord.x * x, v2Coord.y * y); return v2NewDimension; }
void SbWidget::Reset() { m_firstTouchIndex = -1; m_secondTouchIndex = -1; m_initialLength = 0; m_v2LocalMouse = MtVector2( 0, 0 ); m_m4WorldTransform.SetIdentity(); m_m4Rotation.SetIdentity(); }
MtVector2 HlScreenSize::Refactor(const MtVector2 &v2OriginalScreenSize, const MtVector2 &v2Coord ) { BtFloat x = (BtFloat)RsUtil::GetWidth() / v2OriginalScreenSize.x; BtFloat y = (BtFloat)RsUtil::GetHeight() / v2OriginalScreenSize.y; MtVector2 v2NewDimension = MtVector2(v2Coord.x * x, v2Coord.y * y); return v2NewDimension; }
// virtual MtVector2 RsFontWin32GL::GetDimension( const BtChar* szText ) { MtVector2 v2LastPosition = MtVector2( 0, 0 ); // Set the start position MtVector2 v2Position = MtVector2( 0, 0 ); // Cache the string length BtU32 length = BtStrLength(szText); // Loop through the string for( BtU32 nCharacterIndex=0; nCharacterIndex<length; nCharacterIndex++ ) { // Cache each character BtUChar Character = szText[nCharacterIndex]; if( Character == '\n' ) { // Cache the font character LBaFontChar& fontChar = m_pFileData->m_characters['A']; v2Position.x = 0; v2Position.y += fontChar.m_fHeight * 1.50f; continue; } // Cache the font character LBaFontChar& fontChar = m_pFileData->m_characters[Character]; // Set the dimension from the width and height of the texture MtVector2 v2Dimension = MtVector2( fontChar.m_fWidth, fontChar.m_fHeight ); // Increment the last position v2LastPosition.x = MtMax( v2LastPosition.x, v2Position.x + v2Dimension.x ); v2LastPosition.y = MtMax( v2LastPosition.y, v2Position.y + v2Dimension.y ); // Increment the position v2Position.x += fontChar.m_nXAdvance; } MtVector2 v2Dimension = v2LastPosition; return v2Dimension; }
void SbMenu::Render() { MtVector2 v2Dimension = RsUtil::GetDimension(); if( ShHMD::IsHMD() ) { v2Dimension = ShHMD::GetDimension(); } if( SbMain::GetState() == GameState_Start ) { m_pStart->Render( MtVector2( 0, 0 ), v2Dimension, RsColour::WhiteColour(), MaxSortOrders - 1 ); } if(SbMain::GetState() == GameState_Win ) { m_pWin->Render(MtVector2(0, 0), v2Dimension, RsColour::WhiteColour(), MaxSortOrders - 1); } if(SbMain::GetState() == GameState_Lose ) { m_pLose->Render(MtVector2(0, 0), v2Dimension, RsColour::WhiteColour(), MaxSortOrders - 1); } }
MtVector2 MtVector2::GetNormalize() { BtFloat magnitude = Magnitude(); MtVector2 result; if( magnitude ) { BtFloat one_over_magnitude = 1.0f / magnitude; result = MtVector2( x * one_over_magnitude, y * one_over_magnitude ); } return result; }
void SbWidget::DropSecondTouch() { // Drop the second touch m_secondTouchIndex = -1; m_v2LocalMouse = MtVector2( 0, 0 ); Recentre(); // HACK // Make sure we have a proper offset if we've just dropped the second touch if( m_firstTouchIndex != -1 ) { MtVector2 v2MousePosition = ShTouch::GetPosition(m_firstTouchIndex); m_v2Offset = v2MousePosition - m_m4WorldTransform.GetTranslation(); } }
void HlView::LoadMenu() { BtChar *pMenu = BtNull; BtU32 length = 0; // Empty the items m_items.Empty(); m_pCurrentMenuItemSelected = BtNull; m_pCurrentMenuItem = BtNull; // Always load from the userdata BaUserData *userData = m_archive.GetUserData( m_screenName ); pMenu = (BtChar*)userData->GetData(); length = userData->GetSize(); if( ApConfig::IsDebug() ) { if( ApConfig::GetDevice() == ApDevice_WIN ) { // Set the filename BtChar filename[256]; sprintf(filename, "%s..\\gamedata\\%s.archive\\userdata\\%s.txt", ApConfig::GetResourcePath(), m_archiveName, m_screenName); // Open the file FsFile file; file.Open(filename, eFsMode_Read); if(file.IsOpen()) { BtU32 fileSize = file.GetSize(); // Read the file into memory BtChar contents[1024 * 32]; BtAssert(fileSize < 1024 * 32); length = file.GetSize(); file.Read((BtU8*)contents, length); file.Close(); *(contents + length) = '\0'; pMenu = contents; } } } // TEST XML PARSER HERE tinyxml2::XMLDocument doc; tinyxml2::XMLError errorCode = doc.Parse( pMenu, length ); // http://kokkachiprogramming.wordpress.com/2012/11/23/using-tinyxml2-for-xml-parsing-in-c/ // attribute= <person sex="female"> // element= <firstname>Anna</firstname> if( errorCode == tinyxml2::XML_NO_ERROR ) { tinyxml2::XMLNode *pNode = doc.FirstChildElement( "MENU" ); // Is there a child? while( pNode ) { tinyxml2::XMLNode *pItem = pNode->FirstChildElement( "ITEM" ); while( pItem ) { HlMenuItems item; item.m_alignment = 0; BtStrCopy( item.m_id, 64, "unset_id" ); // Set the default sort order item.m_sortOrder = MaxSortOrders-1; // Set the default fade item.m_fade = 1.0f; // We model menu items with a specific resolution in mind. Set this here. // Eventually we can pull this from the XML item.m_v2OriginalScreenSize = MtVector2( 800.0f, 600.0f ); // The default for each menu item is that it doesn't matter if it's a joystick or not item.m_joystick = HlMenuJoystick_Any; item.m_joystickButtonID = JoystickButton_MAX; // Find the fade tinyxml2::XMLElement *pFade = pItem->FirstChildElement( "FADE" ); if( pFade ) { const BtChar *pFadeString = pFade->GetText(); item.m_fade = atof( pFadeString ); } // Get the joystick tinyxml2::XMLElement *pJoystickButton = pItem->FirstChildElement( "JOYSTICKBUTTON" ); if( pJoystickButton ) { const BtChar *pJoystickButtonString = pJoystickButton->GetText(); if( BtStrCompareNoCase( pJoystickButtonString, "PAUSE" ) ) { item.m_joystickButtonID = JoystickButton_Pause; } if( BtStrCompareNoCase( pJoystickButtonString, "A" ) ) { item.m_joystickButtonID = JoystickButton_A; } else if( BtStrCompareNoCase( pJoystickButtonString, "B" ) ) { item.m_joystickButtonID = JoystickButton_B; } else if( BtStrCompareNoCase( pJoystickButtonString, "Y" ) ) { item.m_joystickButtonID = JoystickButton_Y; } else if( BtStrCompareNoCase( pJoystickButtonString, "X" ) ) { item.m_joystickButtonID = JoystickButton_X; } else if( BtStrCompareNoCase( pJoystickButtonString, "LEFTSHOULDER" ) ) { item.m_joystickButtonID = JoystickButton_LeftShoulder; } else if( BtStrCompareNoCase( pJoystickButtonString, "RIGHTSHOULDER" ) ) { item.m_joystickButtonID = JoystickButton_RightShoulder; } else if( BtStrCompareNoCase( pJoystickButtonString, "DPADLEFT" ) ) { item.m_joystickButtonID = JoystickButton_Left; } else if( BtStrCompareNoCase( pJoystickButtonString, "DPADRIGHT" ) ) { item.m_joystickButtonID = JoystickButton_Right; } } // Get the screen width tinyxml2::XMLElement *pScreenWidth = pItem->FirstChildElement( "SCREENWIDTH" ); if( pScreenWidth ) { const BtChar *pScreenWidthString = pScreenWidth->GetText(); item.m_v2OriginalScreenSize.x = atoi( pScreenWidthString ); } // Get the screen height tinyxml2::XMLElement *pScreenHeight = pItem->FirstChildElement( "SCREENHEIGHT" ); if( pScreenHeight ) { const BtChar *pScreenWidthString = pScreenHeight->GetText(); item.m_v2OriginalScreenSize.y = atoi( pScreenWidthString ); } // Get the sprite name const BtChar *pSpriteName = pItem->FirstChildElement( "SPRITE" )->GetText(); item.m_pSprite = m_archive.GetSprite( pSpriteName ); // Get the index tinyxml2::XMLElement *pElement = pItem->FirstChildElement( "SORTORDER" ); if( pElement ) { const BtChar *sortOrder = pElement->GetText(); if( sortOrder ) { item.m_sortOrder = atoi(sortOrder); } } // Get the index const BtChar *index = pItem->FirstChildElement( "INDEX" )->GetText(); item.m_index = atoi(index); // Find the sprite dimension item.m_v2OriginalDimension = item.m_pSprite->GetDimension( item.m_index ); // Get the width pElement = pItem->FirstChildElement( "WIDTH" ); if( pElement ) { const BtChar *widthstring = pElement->GetText(); if( widthstring ) { item.m_v2OriginalDimension.x = atoi( widthstring ); } } // Get the height pElement = pItem->FirstChildElement( "HEIGHT" ); if( pElement ) { const BtChar *heightstring = pItem->FirstChildElement( "HEIGHT" )->GetText(); if( heightstring ) { item.m_v2OriginalDimension.y = atoi( heightstring ); } } // Get the x const BtChar *xstring = pItem->FirstChildElement( "X" )->GetText(); // Get the y const BtChar *ystring = pItem->FirstChildElement( "Y" )->GetText(); BtFloat x, y; if( atof( xstring ) == 0 ) { if( BtStrCompareNoCase( xstring, "c" ) ) { item.m_alignment |= HlMenuItemAlignment_HorizontalCentre; x = (item.m_v2OriginalScreenSize.x * 0.5f) - (item.m_v2OriginalDimension.x * 0.5f); } else if( BtStrCompareNoCase( xstring, "l" ) ) { x = 0; item.m_alignment |= HlMenuItemAlignment_Left; } else if( BtStrCompareNoCase( xstring, "r" ) ) { item.m_alignment |= HlMenuItemAlignment_Right; x = item.m_v2OriginalScreenSize.x - item.m_v2OriginalDimension.x; } else { x = 0; } } else { x = atof(xstring); } if (atof(ystring) == 0) { if( BtStrCompareNoCase( ystring, "c" ) ) { item.m_alignment |= HlMenuItemAlignment_VerticalCentre; y = (item.m_v2OriginalScreenSize.y * 0.5f) - (item.m_v2OriginalDimension.y * 0.5f); } else if ( BtStrCompareNoCase( ystring, "t") ) { y = 0; item.m_alignment |= HlMenuItemAlignment_Top; } else if ( BtStrCompareNoCase( ystring, "b") ) { y = item.m_v2OriginalScreenSize.y - item.m_v2OriginalDimension.y; item.m_alignment |= HlMenuItemAlignment_Bottom; } else { y = 0; } } else { y = atof(ystring); } // Set the final position item.m_v2OriginalPosition = MtVector2( x, y ); // Refactor the position item.m_v2Position = HlScreenSize::Refactor( item.m_v2OriginalScreenSize, item.m_v2OriginalPosition ); // Refactor the size item.m_v2Dimension = HlScreenSize::Refactor( item.m_v2OriginalScreenSize, item.m_v2OriginalDimension ); // Get the ID const BtChar *pID = pItem->FirstChildElement( "ID" )->GetText(); BtStrCopy( item.m_id, 64, pID ); item.m_isVisible = BtTrue; tinyxml2::XMLElement *pIsVisible = pItem->FirstChildElement( "VISIBLE" ); if( pIsVisible ) { const BtChar *pIsVisibleText = pIsVisible->GetText(); if( BtStrCompareNoCase( pIsVisibleText, "TRUE" ) ) { item.m_isVisible = BtTrue; } else if( BtStrCompareNoCase( pIsVisibleText, "FALSE" ) ) { item.m_isVisible = BtFalse; } } // Get the fade when selected tinyxml2::XMLElement *pFadeWhenSelected = pItem->FirstChildElement( "FADEWHENSELECTED" ); if( pFadeWhenSelected ) { const BtChar *pFadeWhenSelectedString = pFadeWhenSelected->GetText(); item.m_fadeWhenSelected = atof( pFadeWhenSelectedString ); } else { item.m_fadeWhenSelected = 0.5f; } // Is this menu item selectable item.m_isSelectable = BtFalse; tinyxml2::XMLElement *pIsSlectable = pItem->FirstChildElement( "SELECTABLE" ); if( pIsSlectable ) { const BtChar *pIsSlectableText = pIsSlectable->GetText(); if( BtStrCompareNoCase( pIsSlectableText, "TRUE" ) ) { item.m_isSelectable = BtTrue; } } // Get whether this is joystick only tinyxml2::XMLElement *pJoystickOnly = pItem->FirstChildElement( "JOYSTICK" ); if( pJoystickOnly ) { const BtChar *pJoystickOnlyText = pJoystickOnly->GetText(); if( BtStrCompareNoCase( pJoystickOnlyText, "TRUE" ) ) { item.m_joystick = HlMenuJoystick_Yes; } else { item.m_joystick = HlMenuJoystick_No; } } // Add each item m_items.Add( item ); // Move to the next child pItem = pItem->NextSiblingElement(); } // Move to the next child pNode = pNode->NextSiblingElement(); } } int a=0; a++; }
void HlDebug::Render() { if( !ApConfig::IsDebug() ) { return; } BtU32 numItems = m_items.GetNumItems(); MtVector2 v2Position( 0, 0 ); MtVector2 v2Dimension( 0, 0 ); for( BtU32 i=0; i<numItems; i++ ) { HlItem &item = m_items[i]; if( !IsHidden(item) ) { RsColour textColour = RsColour::WhiteColour(); if( item.m_isReadOnly ) { textColour = RsColour( 0.7f, 0.7f, 0.7f, 1.0f ); } BtChar text[2048]; sprintf( text, "" ); for(BtU32 j = 0; j < GetNumParents(&item) * 4; j++) { sprintf( text + strlen(text), " "); } if(item.m_type == HlDebugEnum ) { BtU32 current = *item.m_pEnum; sprintf( text + strlen(text), "%s ", item.m_name ); BtU32 index = 0; BtChar *pStr = item.m_pEnumString; while( pStr ) { BtChar temp[32]; BtStrCopy( temp, 32, pStr, BtStrLength( pStr ) ); BtChar *eol = BtStrStr(temp, ";"); if( eol ) { *eol = 0; pStr = BtStrStr(pStr, ";") + 1; } else { pStr = 0; } if(current == index) { sprintf(text + strlen(text), "%s", temp); } ++index; } } else if(item.m_type == HlDebugSave ) { sprintf(text + strlen(text), "Save"); } else if( item.m_type == HlDebugNode ) { sprintf( text + strlen(text), "%s", item.m_name); if( item.m_isCollapsed ) { sprintf( text + strlen(text), "+" ); } else { sprintf(text + strlen(text), "-" ); } } else if( item.m_type == HlDebugFloat ) { BtFloat value = *item.m_pFloat; // Do the conversion if( item.m_unitsSystem == HLDebugKnots ) { value = MtMetersPerSecondToKnots( value ); sprintf(text + strlen(text), "%s %.2fKnts", item.m_name, value); } else { sprintf( text + strlen(text), "%s %.2f", item.m_name, value ); } } else if( item.m_type == HlDebugInteger ) { sprintf( text + strlen(text), "%s %d", item.m_name, *item.m_pInteger ); } else if(item.m_type == HlDebugBool ) { if( *item.m_pBool ) { sprintf(text + strlen(text), "%s True", item.m_name ); } else { sprintf(text + strlen(text), "%s False", item.m_name ); } } else if( item.m_type == HlDebugVector ) { sprintf(text + strlen(text), "%s %.2f %.2f %.2f", item.m_name, item.m_pVector->x, item.m_pVector->y, item.m_pVector->z ); } else if( item.m_type == HlDebugColour ) { sprintf(text + strlen(text), "%s %.2f %.2f %.2f", item.m_name, item.m_pColour->Red(), item.m_pColour->Green(), item.m_pColour->Blue() ); } else if( item.m_type == HlDebugFPS ) { sprintf( text + strlen(text), "FPS %.2f", RsUtil::GetFPS() ); } if( DebugIndex == i ) { sprintf( text + strlen(text), "*" ); } MtVector2 v2FontDimension = HlFont::GetDimension( text ); v2Dimension.x = MtMax( v2Dimension.x, v2Position.x + v2FontDimension.x + 15.0f ); v2Dimension.y = MtMax( v2Dimension.y, v2Position.y + v2FontDimension.y + 15.0f ); HlFont::Render(v2Position, text, textColour, MaxSortOrders - 1); v2Position.y += 15.0f; } } // Display the list of archives BtLinkedList<BaArchiveNode> archives = BaArchive::GetArchives(); BaArchiveNode *pCurrent = archives.pHead(); while( pCurrent ) { BtChar text[2048]; sprintf(text, pCurrent->m_pArchive->GetFilename()); MtVector2 v2FontDimension = HlFont::GetDimension(text); v2Dimension.x = MtMax(v2Dimension.x, v2Position.x + v2FontDimension.x + 30.0f); v2Dimension.y = MtMax(v2Dimension.y, v2Position.y + v2FontDimension.y + 30.0f); HlFont::Render(v2Position, text, RsColour(0.7f, 0.7f, 0.7f, 1.0f), MaxSortOrders - 1); v2Position.y += 15.0f; pCurrent = pCurrent->pNext(); } HlDraw::RenderQuad( MtVector2( 0, 0 ), v2Dimension, RsColour( 0.1f, 0.1f, 0.1f, 1.0f ), MaxSortOrders-1 ); }
void SbPaint::Render() { MtVector2 v2Dimension = RsUtil::GetDimension(); m_pRenderTarget->Render( MtVector2(0, 0), v2Dimension, RsColour::WhiteColour(), MaxSortOrders - 1); }
void SbPaint::Update() { if( ShTouch::IsShaken() ) { m_isClear = BtTrue; } if( UiKeyboard::pInstance()->IsPressed( UiKeyCode_R ) ) { Reset(); } if (UiKeyboard::pInstance()->IsPressed(UiKeyCode_S)) { m_hardness = 0.25f; } // Get the rotational angle MtMatrix4 m4Transform = ExWAX9::GetTransform(); MtVector3 v3XAxis = m4Transform.XAxis(); m_roll = v3XAxis.y; m_isRender = BtFalse; m_isBlob = BtFalse; // Calculate the thickness BtFloat edge = MtAbs(m_roll); BtFloat minWidth = RsUtil::GetHeight() * 0.001f; BtFloat maxWidth = RsUtil::GetHeight() * 0.010f; BtFloat width = MtLerp(edge, minWidth, maxWidth); m_thickness = width * MaxThickness * m_hardness; BtU32 colour = RsColour::BlueColour().asWord(); for(BtU32 i=0; i<MaxTouches; i++ ) { MtVector2 v2Position = ShTouch::GetPosition(i); if( ShTouch::IsPressed(i) ) { m_v2Last = v2Position; m_isFirst = BtTrue; } if( ShTouch::IsHeld(i) ) { m_isPainting = BtTrue; MtVector2 v2Delta = v2Position - m_v2Last; // m_hardness += BtTime::GetTick(); if (v2Delta.GetLength() > 0.01f) // 1% = 11 pixels of 1080p { // Increase the thickness m_hardness += 0.1f; if (m_hardness > 1.0f) { m_hardness = 1.0f; } m_thickness = width * MaxThickness * m_hardness; MtVector2 v2ScreenPosition = GetScreenPositionFromMouse( v2Position ); MtVector3 v3Delta( v2Delta.x, v2Delta.y, 0 ); v3Delta.Normalise(); MtVector3 v3Cross(v3Delta.y, v3Delta.x, 0); v3Cross *= m_thickness; if( m_isFirst == BtTrue ) { MtVector2 v2LastScreenPosition = GetScreenPositionFromMouse( m_v2Last ); m_v2LastL = v2LastScreenPosition + MtVector2(-v3Cross.x, -v3Cross.y); m_v2LastR = v2LastScreenPosition + MtVector2( v3Cross.x, v3Cross.y); m_isFirst = BtFalse; } else { m_strokeVertex[0].m_v2Position = m_v2LastR; m_strokeVertex[0].m_colour = colour; m_strokeVertex[0].m_v2UV = MtVector2(0.5, 0.5); m_strokeVertex[1].m_v2Position = m_v2LastL; m_strokeVertex[1].m_colour = colour; m_strokeVertex[1].m_v2UV = MtVector2(0.5, 0.5); m_strokeVertex[2].m_v2Position = v2ScreenPosition + MtVector2(v3Cross.x, v3Cross.y); m_strokeVertex[2].m_colour = colour; m_strokeVertex[2].m_v2UV = MtVector2(0.5, 0.5); m_strokeVertex[3].m_v2Position = v2ScreenPosition + MtVector2(-v3Cross.x, -v3Cross.y); m_strokeVertex[3].m_colour = colour; m_strokeVertex[3].m_v2UV = MtVector2(0.5, 0.5); m_v2LastR = m_strokeVertex[2].m_v2Position; m_v2LastL = m_strokeVertex[3].m_v2Position; m_isRender = BtTrue; } m_v2Last = v2Position; } if (1) { m_isBlob = BtTrue; MtVector2 v2ScreenPosition = GetScreenPositionFromMouse(v2Position); MtVector3 v3Cross(m_thickness, m_thickness, 0); m_blobVertex[0].m_v2Position = v2ScreenPosition + MtVector2(-v3Cross.x, -v3Cross.y); m_blobVertex[0].m_colour = colour; m_blobVertex[0].m_v2UV = MtVector2(0, 0); m_blobVertex[1].m_v2Position = v2ScreenPosition + MtVector2(-v3Cross.x, v3Cross.y); m_blobVertex[1].m_colour = colour; m_blobVertex[1].m_v2UV = MtVector2(0, 1); m_blobVertex[2].m_v2Position = v2ScreenPosition + MtVector2( v3Cross.x, -v3Cross.y); m_blobVertex[2].m_colour = colour; m_blobVertex[2].m_v2UV = MtVector2(1, 0); m_blobVertex[3].m_v2Position = v2ScreenPosition + MtVector2( v3Cross.x, v3Cross.y); m_blobVertex[3].m_colour = colour; m_blobVertex[3].m_v2UV = MtVector2(1, 1); } } else if(ShTouch::IsReleased(i)) { m_isFirst = BtTrue; m_v2Last = v2Position; } } }
void GameUpdate() { // Update the game mouse m_gameMouse.Update(); // Cache the number of mice BtU32 numMice = m_gameMouse.GetNumMice(); for( BtU32 device=0; device<numMice; device++ ) { // Cache the position of the mouse pointer MtVector2 v2Position = m_gameMouse.GetPosition( device ); BtFloat x = v2Position.x; BtFloat y = v2Position.y; BtU32 mouseIndex = device * 2; if( m_gameMouse.Pressed( 0, device ) == BtTrue ) { ShTouch::BeginTouch( mouseIndex, MtVector2( x, y ) ); } if( m_gameMouse.IsAlive( device ) == BtTrue ) { ShTouch::SetAlive( mouseIndex ); } ShTouch::MoveTouch( mouseIndex, MtVector2( x, y ) ); if( m_gameMouse.Released( 0, device ) == BtTrue ) { ShTouch::EndTouch( mouseIndex, MtVector2( x, y ) ); } BtU32 button2 = mouseIndex + 1; if( m_gameMouse.Pressed( 1, device ) == BtTrue ) { ShTouch::BeginTouch( button2, MtVector2( x, y ) ); } ShTouch::MoveTouch( button2, MtVector2( x, y ) ); if( m_gameMouse.Released( 1, device ) == BtTrue ) { ShTouch::EndTouch( button2, MtVector2( x, y ) ); } } ShTouch::Update(); if( UiKeyboard::pInstance()->IsPressed( UiKeyCode_F4 ) ) { windowCloseListener(); project->SetClosing(); } // Update if( project->IsClosed() == BtFalse ) { project->Update(); } }
void RsTextureWinGL::Render( const MtVector2& v2Position, const MtVector2& v2Dimension, RsColour colour, BtU32 sortOrder ) { // Cache the impl RsImplWinGL *pImpl = (RsImplWinGL*)RsImpl::pInstance(); // Cache the render target RsRenderTarget *pRenderTarget = RsRenderTarget::GetCurrent(); // Cache the camera RsCamera camera = pRenderTarget->GetCamera(); // Cache the display width and height BtFloat Width = (BtFloat)camera.GetViewport().m_width; BtFloat Height = (BtFloat)camera.GetViewport().m_height; // Cache the display width and height BtFloat fScaleWidth = 1.0f / Width; BtFloat fScaleHeight = 1.0f / Height; // Allocate vertex RsVertex3 *pStartVertex = pImpl->StartVertex(); // Set the start vertex RsVertex3 *pVertex = pStartVertex; // Cache the texture width and height BtFloat fTextureWidth = m_pMipmaps[0].m_nWidth; BtFloat fTextureHeight = m_pMipmaps[0].m_nHeight; // Calculate the texture scalars BtFloat fScalarX = 1.0f / fTextureWidth; BtFloat fScalarY = 1.0f / fTextureHeight; BtFloat minU = fScalarX / 2; BtFloat minV = fScalarY / 2; BtFloat maxU = ( m_pMipmaps[0].m_originalWidth * fScalarX ) - minU; BtFloat maxV = ( m_pMipmaps[0].m_originalHeight * fScalarY ) - minV; // Calculate the positions BtFloat xmin = v2Position.x; BtFloat xmax = v2Position.x + v2Dimension.x; BtFloat ymin = v2Position.y; BtFloat ymax = v2Position.y + v2Dimension.y; RsVertex3 *pQuad = pVertex; // Copy these into vertex pVertex->m_v3Position = MtVector3(xmin, ymin, 0.1f ); pVertex->m_v2UV = MtVector2( minU, minV ); ++pVertex; pVertex->m_v3Position = MtVector3(xmin, ymax, 0.1f ); pVertex->m_v2UV = MtVector2( minU, maxV ); ++pVertex; pVertex->m_v3Position = MtVector3(xmax, ymin, 0.1f ); pVertex->m_v2UV = MtVector2( maxU, minV ); ++pVertex; pVertex->m_v3Position = MtVector3(xmax, ymax, 0.1f ); pVertex->m_v2UV = MtVector2( maxU, maxV ); ++pVertex; // Scale the position to local screen space -1 to 1 for( BtU32 i=0; i<4; i++ ) { // Set the colour pQuad[ i ].m_colour = colour.asARGB(); // Flip the y pQuad[ i ].m_v3Position.y = Height - pQuad[ i ].m_v3Position.y; // Scale from 0..width to 0..1 pQuad[ i ].m_v3Position.x *= fScaleWidth; pQuad[ i ].m_v3Position.y *= fScaleHeight; // Scale from 0..1 to 0..2 pQuad[ i ].m_v3Position.x *= 2.0f; pQuad[ i ].m_v3Position.y *= 2.0f; // Translate from 0..2 to -1..1 pQuad[ i ].m_v3Position.x -= 1.0f; pQuad[ i ].m_v3Position.y -= 1.0f; } // Setup the primitive RsPrimitiveWinGL *pPrimitive = pImpl->AddPrimitive(); pPrimitive->m_primitiveType = GL_TRIANGLE_STRIP; pPrimitive->m_numVertex = 4; pPrimitive->m_nStartVertex = pImpl->GetCurrentVertex(); // End the current vertex pImpl->EndVertex( 4 ); // Make a new font renderable RsTextureRenderable *pTextureRenderable = pImpl->AddTexture(); pTextureRenderable->m_pTexture = this; pTextureRenderable->m_pVertex = pStartVertex; pTextureRenderable->m_primitive = pPrimitive; // Validate the shader BtAssert( pTextureRenderable->m_pShader != BtNull ); // Add the font to the renderable list RsRenderTargetWinGL *pCurrentRenderTarget = (RsRenderTargetWinGL*)RsRenderTarget::GetCurrent(); pCurrentRenderTarget->Add( sortOrder, pTextureRenderable ); }
void HlView::LoadMenu() { // Empty the items m_items.Empty(); m_pCurrentMenuItemSelected = BtNull; tinyxml2::XMLDocument doc; BtBool isParsed = HlUserData::GetXML(doc, &m_archive, m_screenName ); if(isParsed) { tinyxml2::XMLNode *pNode = doc.FirstChildElement( "MENU" ); // Is there a child? while( pNode ) { tinyxml2::XMLNode *pItem = pNode->FirstChildElement( "ITEM" ); while( pItem ) { HlMenuItems item; // Find the fade tinyxml2::XMLElement *pFade = pItem->FirstChildElement( "FADE" ); if( pFade ) { const BtChar *pFadeString = pFade->GetText(); item.m_fade = atof( pFadeString ); } // Get the joystick tinyxml2::XMLElement *pJoystickButton = pItem->FirstChildElement( "JOYSTICKBUTTON" ); if( pJoystickButton ) { const BtChar *pJoystickButtonString = pJoystickButton->GetText(); if( BtStrCompareNoCase( pJoystickButtonString, "PAUSE" ) ) { item.m_joystickButtonID = JoystickButton_Pause; } if( BtStrCompareNoCase( pJoystickButtonString, "A" ) ) { item.m_joystickButtonID = JoystickButton_A; } else if( BtStrCompareNoCase( pJoystickButtonString, "B" ) ) { item.m_joystickButtonID = JoystickButton_B; } else if( BtStrCompareNoCase( pJoystickButtonString, "Y" ) ) { item.m_joystickButtonID = JoystickButton_Y; } else if( BtStrCompareNoCase( pJoystickButtonString, "X" ) ) { item.m_joystickButtonID = JoystickButton_X; } else if( BtStrCompareNoCase( pJoystickButtonString, "LEFTSHOULDER" ) ) { item.m_joystickButtonID = JoystickButton_LeftShoulder; } else if( BtStrCompareNoCase( pJoystickButtonString, "RIGHTSHOULDER" ) ) { item.m_joystickButtonID = JoystickButton_RightShoulder; } else if( BtStrCompareNoCase( pJoystickButtonString, "DPADLEFT" ) ) { item.m_joystickButtonID = JoystickButton_Left; } else if( BtStrCompareNoCase( pJoystickButtonString, "DPADRIGHT" ) ) { item.m_joystickButtonID = JoystickButton_Right; } } // Get the screen width tinyxml2::XMLElement *pScreenWidth = pItem->FirstChildElement( "SCREENWIDTH" ); if( pScreenWidth ) { const BtChar *pScreenWidthString = pScreenWidth->GetText(); item.m_v2OriginalScreenSize.x = atoi( pScreenWidthString ); } // Get the screen height tinyxml2::XMLElement *pScreenHeight = pItem->FirstChildElement( "SCREENHEIGHT" ); if( pScreenHeight ) { const BtChar *pScreenWidthString = pScreenHeight->GetText(); item.m_v2OriginalScreenSize.y = atoi( pScreenWidthString ); } // Get the down GetFloatFromXML(pItem, "ANGLE", item.m_angle); // Navigation // Get the left GetIntFromXML(pItem, "LEFT", item.m_left ); // Get the right GetIntFromXML(pItem, "RIGHT", item.m_right ); // Get the up GetIntFromXML(pItem, "UP", item.m_up ); // Get the down GetIntFromXML(pItem, "DOWN", item.m_down ); // Get the width GetFloatFromXML(pItem, "WIDTH", item.m_v2OriginalDimension.x); // Get the height GetFloatFromXML(pItem, "HEIGHT", item.m_v2OriginalDimension.y); // Get the index GetIntFromXML(pItem, "INDEX", item.m_spriteIndex); // Get the sprite name tinyxml2::XMLElement *pSpriteItem = pItem->FirstChildElement("SPRITE"); if( pSpriteItem ) { const BtChar *pSpriteName = pSpriteItem->GetText(); item.m_pSprite = m_archive.GetSprite( pSpriteName ); // Get the index tinyxml2::XMLElement *pElement = pItem->FirstChildElement( "SORTORDER" ); if (pElement) { const BtChar *sortOrder = pElement->GetText(); if (sortOrder) { item.m_sortOrder = atoi(sortOrder); } } // Find the sprite dimension item.m_v2OriginalDimension = item.m_pSprite->GetDimension(item.m_spriteIndex); } // Get the selected index GetIntFromXML( pItem, "SELECTEDINDEX", item.m_selectedSpriteIndex ); // Get whether there is a background GetBoolFromXML(pItem, "BACKGROUND", m_isBackground ); // Get the background sort order GetUIntFromXML( pItem, "BACKGROUNDSORTORDER", m_backgroundSortOrder ); // Get the x const BtChar *xstring = pItem->FirstChildElement( "X" )->GetText(); // Get the y const BtChar *ystring = pItem->FirstChildElement( "Y" )->GetText(); BtFloat x, y; if( atof( xstring ) == 0 ) { if( BtStrCompareNoCase( xstring, "c" ) ) { item.m_alignment |= HlMenuItemAlignment_HorizontalCentre; x = (item.m_v2OriginalScreenSize.x * 0.5f) - (item.m_v2OriginalDimension.x * 0.5f); } else if( BtStrCompareNoCase( xstring, "l" ) ) { x = 0; item.m_alignment |= HlMenuItemAlignment_Left; } else if( BtStrCompareNoCase( xstring, "r" ) ) { item.m_alignment |= HlMenuItemAlignment_Right; x = item.m_v2OriginalScreenSize.x - item.m_v2OriginalDimension.x; } else { x = 0; } } else { x = atof(xstring); } if (atof(ystring) == 0) { if( BtStrCompareNoCase( ystring, "c" ) ) { item.m_alignment |= HlMenuItemAlignment_VerticalCentre; y = (item.m_v2OriginalScreenSize.y * 0.5f) - (item.m_v2OriginalDimension.y * 0.5f); } else if ( BtStrCompareNoCase( ystring, "t") ) { y = 0; item.m_alignment |= HlMenuItemAlignment_Top; } else if ( BtStrCompareNoCase( ystring, "b") ) { y = item.m_v2OriginalScreenSize.y - item.m_v2OriginalDimension.y; item.m_alignment |= HlMenuItemAlignment_Bottom; } else { y = 0; } } else { y = atof(ystring); } // Set the final position item.m_v2OriginalPosition = MtVector2( x, y ); // Refactor the position item.m_v2Position = HlScreenSize::Refactor( item.m_v2OriginalScreenSize, item.m_v2OriginalPosition ); // Refactor the size item.m_v2Dimension = HlScreenSize::Refactor( item.m_v2OriginalScreenSize, item.m_v2OriginalDimension ); // Get the ID const BtChar *pID = pItem->FirstChildElement( "ID" )->GetText(); BtStrCopy( item.m_id, 64, pID ); item.m_isVisible = BtTrue; tinyxml2::XMLElement *pIsVisible = pItem->FirstChildElement( "VISIBLE" ); if( pIsVisible ) { const BtChar *pIsVisibleText = pIsVisible->GetText(); if( BtStrCompareNoCase( pIsVisibleText, "TRUE" ) ) { item.m_isVisible = BtTrue; } else if( BtStrCompareNoCase( pIsVisibleText, "FALSE" ) ) { item.m_isVisible = BtFalse; } } // Get the fade when selected tinyxml2::XMLElement *pFadeWhenSelected = pItem->FirstChildElement( "FADEWHENSELECTED" ); if( pFadeWhenSelected ) { const BtChar *pFadeWhenSelectedString = pFadeWhenSelected->GetText(); item.m_fadeWhenSelected = atof( pFadeWhenSelectedString ); } else { item.m_fadeWhenSelected = 0.5f; } // Is this menu item selectable item.m_isSelectable = BtFalse; tinyxml2::XMLElement *pIsSlectable = pItem->FirstChildElement( "SELECTABLE" ); if( pIsSlectable ) { const BtChar *pIsSlectableText = pIsSlectable->GetText(); if( BtStrCompareNoCase( pIsSlectableText, "TRUE" ) ) { item.m_isSelectable = BtTrue; } } // Get whether this is apple TV only tinyxml2::XMLElement *pJoystickOnly = pItem->FirstChildElement("JOYSTICK"); if (pJoystickOnly) { const BtChar *pJoystickOnlyText = pJoystickOnly->GetText(); if (BtStrCompareNoCase(pJoystickOnlyText, "TRUE")) { item.m_joystick = HlMenuJoystick_Yes; } else { item.m_joystick = HlMenuJoystick_No; } } // Is this shown on Apple TV? GetBoolFromXML(pItem, "APPLETV", item.m_isAppleTV); // Add each item m_items.Add( item ); // Move to the next child pItem = pItem->NextSiblingElement(); } // Move to the next child pNode = pNode->NextSiblingElement(); } } int a=0; a++; }
// virtual void RsFlashWinGL::Render( const MtVector2& v2StartPosition, BtU32 sortOrder ) { MtVector2 v2Dimension( 0, 0 ); RsTexture *pTexture = BtNull; cJSON *pFames = cJSON_GetObjectItem( m_pJSON, "frames" ); cJSON *pCommands = cJSON_GetArrayItem( pFames, m_currentFrame ); if( pCommands == BtNull ) { m_currentFrameTime = 0; m_currentFrame = 0; pCommands = cJSON_GetArrayItem( pFames, m_currentFrame ); } RsColour colour( 1.0f, 1.0f, 1.0f, 1.0f ); BtU32 numCommands = cJSON_GetArraySize( pCommands ); for( BtU32 command=0; command<numCommands; command=command + 2 ) { // Cache the command cJSON *pCommand = cJSON_GetArrayItem( pCommands, command ); BtChar *pCommandString = pCommand->valuestring; // Cache the object cJSON *pObject = cJSON_GetArrayItem( pCommands, command + 1 ); if( BtStrCompare( pCommandString, "frameInfo" ) ) { cJSON *pFrameIndex = cJSON_GetObjectItem( pObject, "frameIndex" ); BtU32 frameIndex = pFrameIndex->valueint; (void)frameIndex; int a=0; a++; } else if( BtStrCompare( pCommandString, "texture" ) ) { cJSON *pTextureIndex = cJSON_GetObjectItem( pObject, "textureIndex" ); // Get the texture index BtU32 textureIndex = pTextureIndex->valueint - 1; pTexture = m_pFileData->m_pTextures[textureIndex]; colour = RsColour( 1.0f, 1.0f, 1.0f, 1.0f ); } else if( BtStrCompare( pCommandString, "colour" ) ) { // Get the colour object cJSON *pColour = cJSON_GetObjectItem( pObject, "colourArray" ); cJSON *pR = cJSON_GetArrayItem( pColour, 0 ); BtFloat r = (BtFloat)pR->valuedouble; cJSON *pG = cJSON_GetArrayItem( pColour, 1 ); BtFloat g = (BtFloat)pG->valuedouble; cJSON *pB = cJSON_GetArrayItem( pColour, 2 ); BtFloat b = (BtFloat) pB->valuedouble; colour = RsColour( r, g, b, 1.0f ); } else if( BtStrCompare( pCommandString, "vertex" ) ) { // Get the vertex object cJSON *pVertex = cJSON_GetObjectItem( pObject, "vertex" ); // Cache the number of vertex BtU32 numVertex = cJSON_GetArraySize( pVertex ); // Extract the vertex MtVector2 coords[4]; for( BtU32 vertexIndex=0; vertexIndex<numVertex; vertexIndex++ ) { // Cache each set of coordinates cJSON *pCoordinates = cJSON_GetArrayItem( pVertex, vertexIndex ); cJSON *pX = cJSON_GetObjectItem( pCoordinates, "positionx" ); cJSON *pY = cJSON_GetObjectItem( pCoordinates, "positiony" ); coords[vertexIndex].x = (BtFloat)pX->valueint / 20; coords[vertexIndex].y = (BtFloat)pY->valueint / 20; } { // Cache the impl RsImplWinGL *pImpl = (RsImplWinGL*)RsImpl::pInstance(); // Cache the render target RsRenderTarget *pRenderTarget = RsRenderTarget::GetCurrent(); // Cache the camera RsCamera camera = pRenderTarget->GetCamera(); // Cache the display width and height BtFloat Width = (BtFloat)camera.GetViewport().m_width; BtFloat Height = (BtFloat)camera.GetViewport().m_height; // Cache the display width and height BtFloat textureWidth = (BtFloat)pTexture->GetWidth(); BtFloat textureHeight = (BtFloat)pTexture->GetHeight(); // Cache the display width and height BtFloat fScaleWidth = 1.0f / Width; BtFloat fScaleHeight = 1.0f / Height; // Allocate vertex RsVertex3 *pStartVertex = pImpl->StartVertex(); // Set the start vertex RsVertex3 *pVertex = pStartVertex; RsVertex3 *pQuad = pVertex; BtFloat minU = 1.0f / textureWidth; BtFloat minV = 1.0f / textureHeight; BtFloat maxU = 1.0f - minU; BtFloat maxV = 1.0f - minV; /* coords[0].y = Height - coords[0].y; coords[1].y = Height - coords[1].y; coords[2].y = Height - coords[2].y; coords[3].y = Height - coords[3].y; */ // Copy these into vertex pVertex->m_v3Position = MtVector3(coords[0].x, coords[0].y, 0.1f ); pVertex->m_v2UV = MtVector2( minU, minV ); ++pVertex; pVertex->m_v3Position = MtVector3(coords[1].x, coords[1].y, 0.1f ); pVertex->m_v2UV = MtVector2( maxU, minV ); ++pVertex; pVertex->m_v3Position = MtVector3(coords[2].x, coords[2].y, 0.1f ); pVertex->m_v2UV = MtVector2( minU, maxV ); ++pVertex; pVertex->m_v3Position = MtVector3(coords[3].x, coords[3].y, 0.1f ); pVertex->m_v2UV = MtVector2( maxU, maxV ); ++pVertex; v2Dimension.x = MtMax( v2Dimension.x, coords[1].x - coords[0].x ); v2Dimension.y = MtMax( v2Dimension.y, coords[2].y - coords[0].y ); // Scale the position to local screen space -1 to 1 for( BtU32 i=0; i<4; i++ ) { // Set the colour pQuad[ i ].m_colour = colour.asARGB(); // Use the start position pQuad[ i ].m_v3Position.x += v2StartPosition.x; pQuad[ i ].m_v3Position.y += v2StartPosition.y; // Flip the y pQuad[ i ].m_v3Position.y = Height - pQuad[ i ].m_v3Position.y; pQuad[ i ].m_v3Position.x -= 0.5f; pQuad[ i ].m_v3Position.y -= 0.5f; // Scale from 0..width to 0..1 pQuad[ i ].m_v3Position.x *= fScaleWidth; pQuad[ i ].m_v3Position.y *= fScaleHeight; // Scale from 0..1 to 0..2 pQuad[ i ].m_v3Position.x *= 2.0f; pQuad[ i ].m_v3Position.y *= 2.0f; // Translate from 0..2 to -1..1 pQuad[ i ].m_v3Position.x -= 1.0f; pQuad[ i ].m_v3Position.y -= 1.0f; } // Setup the primitive RsPrimitiveWinGL *primitive = pImpl->AddPrimitive(); primitive->m_primitiveType = GL_TRIANGLE_STRIP; primitive->m_numVertex = 4; primitive->m_nStartVertex = pImpl->GetCurrentVertex(); // End the current vertex pImpl->EndVertex( 4 ); // Make a new font renderable RsTextureRenderable *pTextureRenderable = pImpl->AddTexture(); pTextureRenderable->m_pTexture = (RsTextureWinGL*)pTexture; pTextureRenderable->m_pVertex = pStartVertex; pTextureRenderable->m_primitive = primitive; // Validate the shader BtAssert( pTextureRenderable->m_pShader != BtNull ); // Add the font to the renderable list RsRenderTargetWinGL *pCurrentRenderTarget = (RsRenderTargetWinGL*)RsRenderTarget::GetCurrent(); pCurrentRenderTarget->Add( sortOrder, pTextureRenderable ); } } } (void)v2Dimension; int a=0; a++; }
// virtual MtVector2 RsFontWin32GL::Render( const MtVector2& v2StartPosition, const MtVector2& v2Scale, const RsColour &colour, const BtChar* szText, BtU32 sortOrder ) { const BtU32 MaxFontLength = 256; MtVector2 v2LastPosition = MtVector2( 0, 0 ); // Cache the impl RsImplWinGL *pImpl = (RsImplWinGL*)RsImpl::pInstance(); // Cache the render target RsRenderTarget *pRenderTarget = RsRenderTarget::GetCurrent(); // Cache the camera RsCamera camera = pRenderTarget->GetCamera(); // Cache the display width and height BtFloat Width = (BtFloat)camera.GetViewport().m_width; BtFloat Height = (BtFloat)camera.GetViewport().m_height; // Cache the display width and height BtFloat fScaleWidth = 1.0f / Width; BtFloat fScaleHeight = 1.0f / Height; // Allocate vertex RsVertex3 *pStartVertex = pImpl->StartVertex(); // Set the start vertex RsVertex3 *pVertex = pStartVertex; // Cache the texture RsTextureWinGL* pTexture = (RsTextureWinGL*) m_pTextures[ 0 ]; // Set the start position MtVector2 v2Position = v2StartPosition; // Cache the string length BtU32 length = strlen(szText); // Cache the texture width and height BtFloat TextureWidth = 1.0f / (BtFloat) pTexture->GetWidth(); BtFloat TextureHeight = 1.0f / (BtFloat) pTexture->GetHeight(); BtU32 currentVertex = 0; // Loop through the string for( BtU32 nCharacterIndex=0; nCharacterIndex<length; nCharacterIndex++ ) { // Cache each character BtUChar Character = szText[nCharacterIndex]; if( Character == '\n' ) { // Cache the font character LBaFontChar& fontChar = m_pFileData->m_characters['A']; v2Position.x = v2StartPosition.x; v2Position.y += fontChar.m_fHeight * 1.50f * v2Scale.y; continue; } // Cache the font character LBaFontChar& fontChar = m_pFileData->m_characters[Character]; // Set the dimension from the width and height of the texture MtVector2 v2Dimension = MtVector2( fontChar.m_fWidth, fontChar.m_fHeight ); // Calculate the positions BtFloat fX0 = v2Position.x; BtFloat fX1 = fX0 + ( v2Dimension.x * v2Scale.x ); BtFloat fY0 = v2Position.y + ( fontChar.m_nYOffset * v2Scale.y ); BtFloat fY1 = fY0 + ( v2Dimension.y * v2Scale.y ); RsVertex3 *pQuad = pVertex; // Copy these into vertex pVertex->m_v3Position = MtVector3(fX0, fY0, 0.1f ); pVertex->m_v2UV = MtVector2( fontChar.m_U0 , fontChar.m_V0 ); ++pVertex; pVertex->m_v3Position = MtVector3(fX0, fY1, 0.1f ); pVertex->m_v2UV = MtVector2( fontChar.m_U0, fontChar.m_V1 + 1 ); ++pVertex; pVertex->m_v3Position = MtVector3(fX1, fY0, 0.1f ); pVertex->m_v2UV = MtVector2( fontChar.m_U1 + 1, fontChar.m_V0 ); ++pVertex; pVertex->m_v3Position = MtVector3(fX0, fY1, 0.1f ); pVertex->m_v2UV = MtVector2( fontChar.m_U0 , fontChar.m_V1 + 1 ); ++pVertex; pVertex->m_v3Position = MtVector3(fX1, fY1, 0.1f ); pVertex->m_v2UV = MtVector2( fontChar.m_U1 + 1, fontChar.m_V1 + 1 ); ++pVertex; pVertex->m_v3Position = MtVector3(fX1, fY0, 0.1f ); pVertex->m_v2UV = MtVector2( fontChar.m_U1 + 1, fontChar.m_V0 ); ++pVertex; // Scale the position to local screen space -1 to 1 for( BtU32 i=0; i<6; i++ ) { // Set the colour pQuad[ i ].m_colour = colour.asWord(); // Scale the uvs pQuad[ i ].m_v2UV.x *= TextureWidth; pQuad[ i ].m_v2UV.y *= TextureHeight; // Flip the y pQuad[ i ].m_v3Position.y = Height - pQuad[ i ].m_v3Position.y; pQuad[ i ].m_v3Position.x -= 0.5f; pQuad[ i ].m_v3Position.y -= 0.5f; // Scale from 0..width to 0..1 pQuad[ i ].m_v3Position.x *= fScaleWidth; pQuad[ i ].m_v3Position.y *= fScaleHeight; // Scale from 0..1 to 0..2 pQuad[ i ].m_v3Position.x *= 2.0f; pQuad[ i ].m_v3Position.y *= 2.0f; // Translate from 0..2 to -1..1 pQuad[ i ].m_v3Position.x -= 1.0f; pQuad[ i ].m_v3Position.y -= 1.0f; } // Render the 6 new vertex // Increment the last position v2LastPosition.x = MtMax( v2LastPosition.x, v2Position.x + v2Dimension.x ); v2LastPosition.y = MtMax( v2LastPosition.y, v2Position.y + v2Dimension.y ); // Increment the position v2Position.x += ( fontChar.m_nXAdvance * v2Scale.x ); currentVertex += 6; } // Setup the primitive RsPrimitiveWinGL *pPrimitive = pImpl->AddPrimitive(); pPrimitive->m_primitiveType = GL_TRIANGLES; pPrimitive->m_numVertex = currentVertex; pPrimitive->m_nStartVertex = pImpl->GetCurrentVertex(); // End the current vertex pImpl->EndVertex( currentVertex ); // Make a new font renderable RsFontRenderable *pFontRenderable = pImpl->AddFont(); pFontRenderable->m_pFont = this; pFontRenderable->m_pVertex = pStartVertex; pFontRenderable->m_primitive = pPrimitive; // Validate the shader BtAssert( pFontRenderable->m_pShader != BtNull ); // Add the font to the renderable list RsRenderTargetWinGL *pCurrentRenderTarget = (RsRenderTargetWinGL*)RsRenderTarget::GetCurrent(); pCurrentRenderTarget->Add( sortOrder, pFontRenderable ); // Calculate the dimension MtVector2 v2Dimension = v2LastPosition - v2StartPosition; // Return the dimension return v2Dimension; }
MtVector2 RsTextureWinGL::GetDimension() const { return MtVector2( (BtFloat)GetWidth(), (BtFloat)GetHeight() ); }
void HlFont::Render( const MtVector2 &v2Position, const BtChar *text, const RsColour &colour, BtU32 sortOrder ) { m_pFont->Render( v2Position, MtVector2( 1, 1 ), colour, text, sortOrder ); }
MtVector2 RsTextureWinGL::GetOriginalDimension() const { return MtVector2( (BtFloat)GetOriginalWidth(), (BtFloat)GetOriginalHeight() ); }
void SbWaxGraph::RenderGraph() { //AddIMUData(); BtFloat width = RsUtil::GetWidth(); BtFloat height = RsUtil::GetHeight(); BtFloat halfHeight = height / 2.0f; BtFloat notches = (BtFloat)items; BtFloat notchWidth = width / notches; BtFloat notchHeight = height / 100.0f; MtVector2 v2Start( notchWidth, height / 2.0f ); HlDraw::RenderLine( MtVector2( 0, halfHeight ), MtVector2( width, halfHeight ), RsColour::WhiteColour() ); for( BtU32 i=0; i<items; i++ ) { MtVector2 v2A = v2Start - MtVector2( 0, notchHeight ); MtVector2 v2B = v2Start + MtVector2( 0, notchHeight ); HlDraw::RenderLine( v2A, v2B, RsColour::WhiteColour() ); } for( BtU32 i=0; i<items-1; i++ ) { MtVector3 v3Acc1 = v3Values[i]; v3Acc1 = v3Acc1 * height / 3.0f; MtVector3 v3Acc2 = v3Values[i+1]; v3Acc2 = v3Acc2 * height / 3.0f; MtVector2 v2A = v2Start + MtVector2( 0, v3Acc1.x ); MtVector2 v2B = v2Start + MtVector2( notchWidth, v3Acc2.x ); HlDraw::RenderLine( v2A, v2B, RsColour::RedColour() ); v2A = v2Start + MtVector2( 0, v3Acc1.y ); v2B = v2Start + MtVector2( notchWidth, v3Acc2.y ); HlDraw::RenderLine( v2A, v2B, RsColour::GreenColour() ); v2A = v2Start + MtVector2( 0, v3Acc1.z ); v2B = v2Start + MtVector2( notchWidth, v3Acc2.z ); HlDraw::RenderLine( v2A, v2B, RsColour::BlueColour() ); v2Start.x += (int)notchWidth; } MtVector3 v3Accel = ExWAX9::GetAccelerometer(); BtChar text[100]; sprintf( text, "%.2f\n%.2f\n%.2f", v3Accel.x, v3Accel.y, v3Accel.z ); HlFont::RenderHeavy( MtVector2( 0, 100 ), text, MaxSortOrders-1 ); }