Looks good, but there's one major problem: NO LICENSE INFO!
That's right ! I fixed it

It's the same Licence as all the project files. You can download the new example zip that contains the licence.
Moving on from that, I like it. However, what I really want is a 2D gui... which I know is not your objective, but your gui is so simple and nice I'd really like to use it anywa. Would it be possible to add an option to use it as a normal 2D gui rendering at screen depth? I don't know if that would be complicated to change or simple, I'm hoping simple. If you don't want to do this yourself, could you point me to what I might need to change to have this modification myself?
Thanks for the feedback !
Unfortunately, as you said, it's not my aim ; some other GUI library such as CEGUI can do that easily.
Anyway, if you want to, you can take a look at the way Gorilla system works (
http://www.ogre3d.org/tikiwiki/Gorilla)
and adapt it the way you want. Gui3D use the Gorilla::ScreenRenderable object to create a 2D Panel in 3D environment. Then
to create a widget, Gui3D only use the position of a Gorilla element depending on others ;
for example, a Gui3D::Scrollbar is just three Gorilla::Rectangle setup together.
To display Rectangle or anything like that on the screen (such as the mouse cursor on the demo which is a Gorilla::Rectangle
with a background image), you can have a look at the Gorilla::Screen object. It uses the same Gorilla objects than
a Gorilla::ScreenRenderable (Gorilla::Caption, Gorilla::Rectangle...), making all Gui3D widgets reusable for Gorilla::Screen.
For Gui3D::Panel, you should create a Gui3D::ScreenPanel that use a Gorilla::Screen instead of a Gorilla::ScreenRenderable.
I recommend you to take a look at the Gorilla examples, made by betajean, that show you how to use the Gorilla::Screen object :
https://github.com/betajaen/gorilla.
There's also a mini-tutorial series by Tom Koole who made some 2D widgets on Gorilla::Screen using Gorilla :
http://tomkoole.com/blog.php?id=31.
Keep me update if you have any question about Gui3D, or if you want to release the Gui3D::ScreenPanel addon.
One other thing, it would be nice if buttons reacted when you press them. At the moment the button doesn't do anything, though I can see the press counter go up.
That's right, I haven't add this functionnality ; I keep that in my mind for a futur release
Noticed what seems to be a bug, don't know if it's just in my version or not. You can zoom up to be over the counter button, it glows because you are over it. Now you can pull back and look around, no longer over the button, but it stays glowing, and if you press the mouse button it counts as a press even though you aren't pointing at, or anywhere near, the button.
Yep, I saw it before. Until I don't release anything (a visual editor to place widget on Panels and minor fixes), you can change the injectMouseMoved method in Gui3DPanel.cpp to (I haven't try this that much, but that should do the job (unOverAllElements when the mouse isn't on the Panel)):
Code: Select all
void Panel::injectMouseMoved(const Ogre::Ray& ray)
{
Ogre::Matrix4 transform;
transform.makeTransform(mNode->getPosition(), mNode->getScale(), mNode->getOrientation());
Ogre::AxisAlignedBox aabb = mScreenRenderable->getBoundingBox();
aabb.transform(transform);
pair<bool, Ogre::Real> result = Ogre::Math::intersects(ray, aabb);
if (result.first == false)
{
unOverAllElements();
return;
}
Ogre::Vector3 a,b,c,d;
Ogre::Vector2 halfSize = mSize * 0.5f;
a = transform * Ogre::Vector3(-halfSize.x,-halfSize.y,0);
b = transform * Ogre::Vector3( halfSize.x,-halfSize.y,0);
c = transform * Ogre::Vector3(-halfSize.x, halfSize.y,0);
d = transform * Ogre::Vector3( halfSize.x, halfSize.y,0);
result = Ogre::Math::intersects(ray, c, b, a);
if (result.first == false)
result = Ogre::Math::intersects(ray, c, d, b);
if (result.first == false)
{
unOverAllElements();
return;
}
if (result.second > 10.0f)
{
unOverAllElements();
return;
}
Ogre::Vector3 hitPos = ( ray.getOrigin() + (ray.getDirection() * result.second) );
Ogre::Vector3 localPos = transform.inverse() * hitPos;
localPos.x += halfSize.x;
localPos.y -= halfSize.y;
localPos.x *= 100;
localPos.y *= 100;
// Cursor clip
localPos.x = Ogre::Math::Clamp<Ogre::Real>(localPos.x, 0, (mSize.x * 100) - 10);
localPos.y = Ogre::Math::Clamp<Ogre::Real>(-localPos.y, 0, (mSize.y * 100) - 18);
mInternalMousePos = Ogre::Vector2(localPos.x, localPos.y);
// Let's actualize the "over" for each elements
for (size_t i=0; i < mPanelElements.size(); i++)
mPanelElements[i]->isOver(mInternalMousePos);
}