Gorilla - minimal hud and overlay replacement for OGRE

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
Post Reply
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: gorilla - minimal hud and overlay replacement. UPDATED!

Post by betajaen »

CABAListic wrote:Sounds great :)
I'm currently writing a small little game engine for Python for which I hope to get to the GUI part in the next few weeks. Once I do, I will take a very close look at gorilla, and then perhaps we could discuss a few concrete ideas what and how could go into the Ogre core.
Absolutely.
User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
x 3
Contact:

Re: gorilla - minimal hud and overlay replacement. UPDATED!

Post by Praetor »

CABAListic wrote:Sounds great :)
I'm currently writing a small little game engine for Python for which I hope to get to the GUI part in the next few weeks. Once I do, I will take a very close look at gorilla, and then perhaps we could discuss a few concrete ideas what and how could go into the Ogre core.
Of course you meant the components, right? Like where the terrain and paging features currently reside? That has to be what you meant...
Game Development, Engine Development, Porting
http://www.darkwindmedia.com
mrmclovin
Gnome
Posts: 324
Joined: Sun May 11, 2008 9:27 pm
x 20

Re: gorilla - minimal hud and overlay replacement. UPDATED!

Post by mrmclovin »

Hey Betajaen!

Great work you're doing here. I'm currently playing around with Gorilla in my engine and so far it seems _exactly_ what I need. Im trying to implement a basic mouse cursor appearance. I'm using a Rectangle with background set to "mousecursor" and when I set top() and left() accordingly as the mouse moves, it seem to only move left and top corners. Right/bottom corners are stuck at their original positon. Am I misinterpreting left() top() as canvas/rectangle position ..?
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

Re: gorilla - minimal hud and overlay replacement. UPDATED!

Post by CABAListic »

Praetor wrote:
CABAListic wrote:Sounds great :)
I'm currently writing a small little game engine for Python for which I hope to get to the GUI part in the next few weeks. Once I do, I will take a very close look at gorilla, and then perhaps we could discuss a few concrete ideas what and how could go into the Ogre core.
Of course you meant the components, right? Like where the terrain and paging features currently reside? That has to be what you meant...
Hm nope, didn't think of that. :oops: But sure, that's a sensible safe approach.
(Although, for lower-level components like a TextureAtlas and a 'ManualObject' for 2D stuff, I could see benefits of placing them in the core. But nevermind, I really just didn't think of a component.)
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: gorilla - minimal hud and overlay replacement. UPDATED!

Post by betajaen »

mrmclovin wrote:Right/bottom corners are stuck at their original positon. Am I misinterpreting left() top() as canvas/rectangle position ..?
It was a bug I found yesterday, redownload from Github, there is a fixed version.
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: gorilla - minimal hud and overlay replacement. UPDATED!

Post by betajaen »

Image

Code: Select all

Changes:

- Added multiple font support for a single Texture Atlas
- Added Dejavu-9 and Dejavu-24 fonts to dejavu.gorilla and dejavu.png, known as "9", "24". Existing font is known as "14".
- Improved Glyph rendering
- Fixed memory leak with TextureAtlases not freeing Glyphs or Sprites
http://github.com/betajaen/gorilla
User avatar
_tommo_
Gnoll
Posts: 677
Joined: Tue Sep 19, 2006 6:09 pm
x 5
Contact:

Re: gorilla - minimal hud and overlay replacement. UPDATED!

Post by _tommo_ »

betajaen wrote:Image
Most awesome screenshot ever.

:lol:
OverMindGames Blog
IndieVault.it: Il nuovo portale italiano su Game Dev & Indie Games
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Re: gorilla - hud/overlay replacement - Updated on 07-Sep-20

Post by syedhs »

Although I have not used it (yet), I would say this fits what we call 'less for more' :D
I think I am going to replace all my overlays with gorilla.
Thank you.
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: gorilla - hud/overlay replacement - Updated on 07-Sep-20

Post by AshMcConnell »

I've just been walking with gorillas. Looks great :).

Is there any way to show part of a sprite? I was thinking of showing a percentage of my RPM metre would work nicely. I could show each RPM element separately, but it would be more efficient just to show a percentage. Can anyone think of a way to do that?

Thanks for your help!
Ash
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: gorilla - hud/overlay replacement - Updated on 07-Sep-20

Post by betajaen »

Perhaps, yes. I'd have to put some code in though.
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: gorilla - hud/overlay replacement - Updated on 07-Sep-20

Post by betajaen »

Updated

Code: Select all

Changes

- (Requested by AshMcConnell) Sprites used with Rectangles can be partially shown from the left/top position. See: Rectangle::background_image
http://github.com/betajaen/gorilla

@AshMcConnell

Something like this is what you want. (Remember to keep a cache of the sprite pointer for speed!)

Code: Select all

rect = mLayer->createRectangle(400,400,50,100);
Gorilla::Sprite* coco = mLayer->_getSprite("coco");
rect->background_image(coco, 0.5f, 1.0f);
When you want to update, just adjust the width and background image:

Code: Select all

rect->background_image(coco, 0.75f, 1.0f); // 0.75 = 75% = 75% power!
rect->width(75); // 75px (Sprite is 100px in size)
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: gorilla - hud/overlay replacement - Updated on 08-Sep-20

Post by AshMcConnell »

Damn, that was quick! I was fiddling with the same lines of code and came up with the same solution :)

Thanks a lot! I'll try and get my RPM Meter working and let you know how I get on.

Thanks again,
Ash
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: gorilla - hud/overlay replacement - Updated on 08-Sep-20

Post by betajaen »

No probs. ;)
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: gorilla - hud/overlay replacement - Updated on 08-Sep-20

Post by AshMcConnell »



Pretty basic textures, but it works in principle :)

Are you still intending to allow render to texture as an option?

All the best,
Ash
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: gorilla - hud/overlay replacement - Updated on 08-Sep-20

Post by betajaen »

Nice. :D

Working on it now. Trying to decided on a name for a "RenderTarget" type class for Screen and RTTScreen to inherit from.
mrmclovin
Gnome
Posts: 324
Joined: Sun May 11, 2008 9:27 pm
x 20

Re: gorilla - hud/overlay replacement - Updated on 08-Sep-20

Post by mrmclovin »

Yoo! Any opacity support implemented / planned ?

Love this framework.
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: gorilla - hud/overlay replacement - Updated on 08-Sep-20

Post by betajaen »

Already in.
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: gorilla - hud/overlay replacement - Updated on 08-Sep-20

Post by AshMcConnell »

Hi Betajean,

I'm having a bit of a problem with the widthClip / resize stuff (sorry I've been a pain already!). The co-ordinates seem to be a little off.

Here is a video showing the problem. You may need to go fullscreen in youtube to see it properly. If you look at the RPM bar you can see where the polys join as the co-ords are slightly off. Is there any way I can limit this problem?



Thanks for your help
All the best,
Ash
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: gorilla - hud/overlay replacement - Updated on 08-Sep-20

Post by betajaen »

Silly question, but what does it look like in OpenGL?
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: gorilla - hud/overlay replacement - Updated on 08-Sep-20

Post by AshMcConnell »

betajaen wrote:Silly question, but what does it look like in OpenGL?
Oddly it's absolutely perfect.
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: gorilla - hud/overlay replacement - Updated on 08-Sep-20

Post by betajaen »

It's Microsoft everything is half and half with them.

I think the rectangles width/height need to have added texelWidth/texelHeight and left/top need to be subtracted texelWidth/texelHeight. Maybe the UV's too.

I can't try it out at the moment because my Gorilla has a missing Screen class, but if you want to try it out for me, the caption code is a good place to show you what to do.

[Edit]

Basically, in the Rectangle::_redraw function. You need to expand the rectangle size by twice the texel size.

Something like that.

Code: Select all

Ogre::Real texelOffsetX = mLayer->_getTexelX(), texelOffsetY = mLayer->_getTexelY()
  Ogre::Vector2 a, b, c, d;
  a.x = mLeft - texelOffsetX;  a.y = mTop - texelOffsetY;
  b.x = mRight + texelOffsetX; b.y = mTop - texelOffsetY;
  c.x = mLeft - texelOffsetX;  c.y = mBottom + texelOffsetY;
  d.x = mRight + texelOffsetX; d.y = mBottom + texelOffsetY;
You may need to do the same thing for the UV too, but that would be in the background_image function.
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: gorilla - hud/overlay replacement - Updated on 08-Sep-20

Post by AshMcConnell »

Thanks BetaJaen



It has made the textures link up correctly, but the lights are still creeping when the width is changed.

I tried adding the texelOffset to the uv, but it didn't seem to make a difference.

Code: Select all

Vertex temp;
Ogre::Vector2 uv = mLayer->_getSolidUV();
uv.x += texelOffsetX;
uv.y += texelOffsetY;
Thanks again,
Ash

PS. lol, you got a bit of F1 practice in the video too :)
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: gorilla - hud/overlay replacement - Updated on 08-Sep-20

Post by betajaen »

Wrong UV. ;)

Code: Select all

    /*! function. background_image
        desc.
            Set the background to a sprite from the texture atlas.
        note.
            To remove the image pass on a null pointer.
    */
    void  background_image(Sprite* sprite)
    {
     if (sprite == 0)
     {
      mUV[0] = mUV[1] = mUV[2] = mUV[3] = mLayer->_getSolidUV();
     }
     else
     {
      Ogre::Real texelOffsetX = mLayer->_getTexelX(), texelOffsetY = mLayer->_getTexelY();
      mUV[0].x = mUV[3].x = sprite->uvLeft - texelOffsetX;
      mUV[0].y = mUV[1].y = sprite->uvTop - texelOffsetY;
      mUV[1].x = mUV[2].x = sprite->uvRight + texelOffsetX;
      mUV[2].y = mUV[3].y = sprite->uvBottom + texelOffsetY;
     }
     mDirty = true;
     mLayer->_markDirty();
    }
[Edit]

Forgot your using this one:

Code: Select all

    /*! function. background_image
        desc.
            Set the background to a sprite from the texture atlas, with clipping.
            Clipping is used for example with RPM meters on HUDs, where a portion
            of the sprite needs to be shown to indicate the RPM on the car.
            
            widthClip  is a decimal percentage of the width of the sprite (0.0 none, 1.0 full)
            heightClip is a decimal percentage of the height of the sprite (0.0 none, 1.0 full)
            
            You should use this with the width() and height() functions for a full effect.
        note.
            To remove the image pass on a null pointer.
    */
    void  background_image(Sprite* sprite, Ogre::Real widthClip, Ogre::Real heightClip)
    {
     if (sprite == 0)
     {
      mUV[0] = mUV[1] = mUV[2] = mUV[3] = mLayer->_getSolidUV();
     }
     else
     {
      Ogre::Real texelOffsetX = mLayer->_getTexelX(), texelOffsetY = mLayer->_getTexelY();
      mUV[0].x = mUV[3].x = sprite->uvLeft - texelOffsetX;
      mUV[0].y = mUV[1].y = sprite->uvTop - texelOffsetY;
      mUV[1].x = mUV[2].x = sprite->uvLeft + ( (sprite->uvRight - sprite->uvLeft) * widthClip ) + texelOffsetX ;
      mUV[2].y = mUV[3].y = sprite->uvTop + ( (sprite->uvBottom - sprite->uvTop) * heightClip ) + texelOffsetY;
     }
     mDirty = true;
     mLayer->_markDirty();
    }
The other background functions of Rectangle need to be similar like that too.
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: gorilla - hud/overlay replacement - Updated on 08-Sep-20

Post by AshMcConnell »

Hmm that doesn't seem to work properly. It makes the RPM lights disappear entirely.

From some tracing I get

sprite->uvLeft = 0.0
sprite->uvRight = 0.29297
texelOffsetX = -0.5

mUV[1].x and mUV[2].x become (0.29297 - 0.5) => -0.207 when we are showing the full width

Which doesn't seem right?

Thanks!
Ash
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: gorilla - hud/overlay replacement - Updated on 08-Sep-20

Post by betajaen »

Do'h yes.

I'm mixing up the units, they needs to be converted.

Code: Select all

Ogre::Real texelOffsetX = mLayer->_getTexelX(), texelOffsetY = mLayer->_getTexelY();
      texelOffsetX /= mLayer->_getTextureSize().x;
      texelOffsetY /= mLayer->_getTextureSize().y;
Post Reply