HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] Scale a GUI-Texture with HSL  (Read 2499 times)

Cromm_Cruach

  • General Accounts
  • *
  • Posts: 2
    • View Profile
[Resolved] Scale a GUI-Texture with HSL
« on: Sep 26, 11, 08:13:20 AM »

Hi,

i'm scripting a SplashScreen at the moment.

This ist the code:

Code: [Select]
  screen as Vector3 = GetViewPortSize()
bg as NodeRef of Class GUIControl = CreateNodeFromPrototype("StartScreen")
 
  bg.name = "LoadingAreaBg"
  bg.size.x = screen.x
  bg.size.y = screen.y
  bg.visible = true
 
  logo as NodeRef of Class GUIPanel = CreateNodeFromPrototype("EN_Panel")
  logo.build = true
  logo.name = "LoadingAreaLogo"
  logo.visible = true
  logo.texture = "GUI\login_hintergrund2.dds"
  logo.defaultStatePresentation.color.r = 1.0
  logo.defaultStatePresentation.color.g = 1.0
  logo.defaultStatePresentation.color.b = 1.0
  logo.defaultStatePresentation.color.a = 1.0
  logo.defaultStatePresentation.position.x = 0
  logo.defaultStatePresentation.position.y = 0
  logo.defaultStatePresentation.size.x = 800
  logo.defaultStatePresentation.size.y = 600
  logo.size.x = 800
  logo.size.y = 600
  logo.autoCenter.horizontal = true
  logo.autoCenter.vertical = true
 
  add back logo to bg.children
  bg.build = true

My problem is that the texture is not scaled to the size of the panel. It is truncated and shows only a part. In the wiki I've read that tilling should be set to false so that the texture is scaled to the size of the panel. But that don't work.

I hope you have a solution for me.

Greetz
Cromm
« Last Edit: Nov 03, 12, 07:57:16 PM by HE-Cooper »
Logged

HE-JAY

  • HeroEngine
  • *****
  • Posts: 122
    • View Profile
Re: Scale a GUI-Texture with HSL
« Reply #1 on: Sep 26, 11, 10:11:53 AM »

Is your logo actually 800x600 pixels in size? The following lines will select an 800x600 pixel texture for the default state presentation:

Code: [Select]
logo.defaultStatePresentation.size.x = 800
logo.defaultStatePresentation.size.y = 600

If your logo is smaller than this, your texture will be comprised of (for example) 128x128 worth of actual texture with an added 672x472 of blank space. As a result, your 800x600 control will have your logo + empty-space scaled appropriately at a factor of 1.0.

If your logo is larger than this, you'll see only part of the image.

My hunch is that the texture size you're defining is not the true size of your logo. Possible correct definitions might be:
Code: [Select]
logo.defaultStatePresentation.size.x = 1024
logo.defaultStatePresentation.size.y = 768
logo.size.x = 800
logo.size.y = 600

or

Code: [Select]
logo.defaultStatePresentation.size.x = 256
logo.defaultStatePresentation.size.y = 256
logo.size.x = 800
logo.size.y = 600

Let me know if this helps.
Logged

Cromm_Cruach

  • General Accounts
  • *
  • Posts: 2
    • View Profile
Re: Scale a GUI-Texture with HSL
« Reply #2 on: Sep 26, 11, 12:54:27 PM »

You where Right. My Texturesize was wrong.

Code: [Select]
logo.defaultStatePresentation.size.x = 1024
logo.defaultStatePresentation.size.y = 1024

I do not know why it works with these settings but it works.
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Scale a GUI-Texture with HSL
« Reply #3 on: Sep 26, 11, 05:32:33 PM »

From what I have seen, when an image is used for a gui texture, the dimensions used for specifying position and size in the presentation settings get rounded up to the next power of 2.  So, like you found to be the case, a dimension of an image that is > 512 but <= 1024 will be considered 1024 wide/tall in the settings, regardless of the original dimensions.   The easiest way is to set the settings via the texture setting dialog you get from clicking the ... button on the Texture line in Properties, then clicking the Select All button.

Furthermore, for you, using 512 for settings will correspond to 400 in width and 300 in height.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.