help with design[SOLVED]
Moderators: CEGUI MVP, CEGUI Team
help with design[SOLVED]
Hi Guys
i want to set up a joystick callibration inside my cegui application using dx9
but to be honest i'am not sure where to get started ie what widget / s to use etc ,etc
could someone point me in the ridght direction please
TIA
i want to set up a joystick callibration inside my cegui application using dx9
but to be honest i'am not sure where to get started ie what widget / s to use etc ,etc
could someone point me in the ridght direction please
TIA
Last edited by maori on Tue Sep 27, 2011 16:47, edited 1 time in total.
trying to upgrade to 0.8.2 from 0.7.9
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: help with design
Hi,
It largely depends on how you want it to look - you could do a calibration sequence using just plain text, or something with lots of UI. If you give some info (pictars, pls!) about the kind of general look you're after, it will be easier to make suggestions
CE.
It largely depends on how you want it to look - you could do a calibration sequence using just plain text, or something with lots of UI. If you give some info (pictars, pls!) about the kind of general look you're after, it will be easier to make suggestions
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: help with design
heya CE
what i have in mind is something simmiler to
http://img257.imageshack.us/my.php?image=97949185.jpg
and if you move the throttle or rudder
http://img26.imageshack.us/my.php?image=46036346.jpg
TIA
what i have in mind is something simmiler to
http://img257.imageshack.us/my.php?image=97949185.jpg
and if you move the throttle or rudder
http://img26.imageshack.us/my.php?image=46036346.jpg
TIA
trying to upgrade to 0.8.2 from 0.7.9
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: help with design
Ok, just a quickie as far as the UI aspects go - I want to go to bed!
For the throttle, a progress bar would do the job fine, and for the twist, two progress bars, side by side - the right one with regular operation, and the left one with reversed operation.
For the stick orientation indicator, I would suggest a StaticImage (no frame) that holds an image of a white background with the cross in the middle, this would be added as a child of some container window (maybe another StaticImage though this time with the frame). The window alignment on the 'embedded' static image should be centred in both axes, then use absolute offsets to move the child according to the stick positioning.
HTH
CE.
For the throttle, a progress bar would do the job fine, and for the twist, two progress bars, side by side - the right one with regular operation, and the left one with reversed operation.
For the stick orientation indicator, I would suggest a StaticImage (no frame) that holds an image of a white background with the cross in the middle, this would be added as a child of some container window (maybe another StaticImage though this time with the frame). The window alignment on the 'embedded' static image should be centred in both axes, then use absolute offsets to move the child according to the stick positioning.
HTH
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: help with design
hiya CE
thanks for the tip will try to get this going
thanks for the tip will try to get this going
trying to upgrade to 0.8.2 from 0.7.9
Re: help with design
Heya
Me Agian
okidoki is there a way i can use a float value for the uvector2 ?
i have a "StaticImage (no frame) that holds an image of a white background with the cross in the middle"
but the code uses floats for the value of movement and am unable to change this
cheers
Me Agian
okidoki is there a way i can use a float value for the uvector2 ?
i have a "StaticImage (no frame) that holds an image of a white background with the cross in the middle"
but the code uses floats for the value of movement and am unable to change this
cheers
trying to upgrade to 0.8.2 from 0.7.9
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: help with design
Hi,
To answer the easy bit first, using a float for a UVector2 value:
I'm not quite sure how you have things arranged, what you're doing, or how you're doing it (so, off to a good start then! ).
The main uncertainty is as regards to what the float represents? Is it the deflection of the stick? So, perhaps it has a range of -1.0f to 1.0f? Or perhaps it has a different range, or even does not represent the deflection, hehe.
Basically, your cross is centred when the stick is centred - the first bit of info to consider is the position of the image when it is centred, meaning is it zero or some other value (such as half the width of the container). If this is not how you have things set up (which you may not, since it's probably not the 'best' way to do it), you'll have to adjust what follows.
Basically if your float is the deflection value, you can use it to scale some other value to calculate the position of the image. The example here is using absolute pixels and standard alignments, though there are numerous other ways to do this.
Say your container window for the cross is 200 pixels square. When the cross image is at position 0 it is centred. This means that to get a full left position, the image has to be moved left by 100 pixels (half the width of the container), and to get a full right deflection, the image has to be moved right by 100 pixels. If the float value represents the deflection of the stick in the -1 to +1 range, to calculate the final pixel position, just multiply the deflection value by the amount of pixel deflection needed - in this example 100. This means that if your stick deflection float is at -1.0 (for full left), you multiply this by 100 and get -100.0 back out which is the value to use for the image position. If the stick was half-way right, at +0.5f then multiplying this by 100 gives 50.0f which would put the cross at the desired position. And obviously the same for the vertical axis.
Now what do you do if your deflection value is not in the range -1.0 to +1.0? Well, the best way to proceed is to normalise it to that range. If your values are instead -500.0f to +500.0 then divide the value by 500.0f. If the range is something like 0.0f to 1000.0f then subtract half and then divide - so if you had a value of 0 (representing full left), you subtract half of the full range of 1000, which is 500 which gives -500, then divide by 500 which gives you -1.0f.
Hope this is helpful and that I put it in a way that's not more confusing If it is confusing, please let us know what the float you have represents, it's range (if appropriate), and how you're positioning the cross (basically, where the cross is at position (0,0) and the size of the container holding the image).
CE.
To answer the easy bit first, using a float for a UVector2 value:
Code: Select all
// The UVector is built out of two UDim objects, each UDim object takes two
// float values; the first is a scale value, the second is an absolute pixel offset.
// either component can be set to zero if you just want one type of metric or
// the other.
// if you have a pixel float value, of say 100.0f...
float val = 100.0f;
// you can use this as input to a UVector2 like this...
UVector2 uvec2( UDim( 0.0f, val ), UDim( 0.0f, 0.0f ) );
// which sets the 'x' part of the vector to 100 and the 'y' part to zero.
I'm not quite sure how you have things arranged, what you're doing, or how you're doing it (so, off to a good start then! ).
The main uncertainty is as regards to what the float represents? Is it the deflection of the stick? So, perhaps it has a range of -1.0f to 1.0f? Or perhaps it has a different range, or even does not represent the deflection, hehe.
Basically, your cross is centred when the stick is centred - the first bit of info to consider is the position of the image when it is centred, meaning is it zero or some other value (such as half the width of the container). If this is not how you have things set up (which you may not, since it's probably not the 'best' way to do it), you'll have to adjust what follows.
Basically if your float is the deflection value, you can use it to scale some other value to calculate the position of the image. The example here is using absolute pixels and standard alignments, though there are numerous other ways to do this.
Say your container window for the cross is 200 pixels square. When the cross image is at position 0 it is centred. This means that to get a full left position, the image has to be moved left by 100 pixels (half the width of the container), and to get a full right deflection, the image has to be moved right by 100 pixels. If the float value represents the deflection of the stick in the -1 to +1 range, to calculate the final pixel position, just multiply the deflection value by the amount of pixel deflection needed - in this example 100. This means that if your stick deflection float is at -1.0 (for full left), you multiply this by 100 and get -100.0 back out which is the value to use for the image position. If the stick was half-way right, at +0.5f then multiplying this by 100 gives 50.0f which would put the cross at the desired position. And obviously the same for the vertical axis.
Now what do you do if your deflection value is not in the range -1.0 to +1.0? Well, the best way to proceed is to normalise it to that range. If your values are instead -500.0f to +500.0 then divide the value by 500.0f. If the range is something like 0.0f to 1000.0f then subtract half and then divide - so if you had a value of 0 (representing full left), you subtract half of the full range of 1000, which is 500 which gives -500, then divide by 500 which gives you -1.0f.
Hope this is helpful and that I put it in a way that's not more confusing If it is confusing, please let us know what the float you have represents, it's range (if appropriate), and how you're positioning the cross (basically, where the cross is at position (0,0) and the size of the container holding the image).
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: help with design
Thanks CE
That helped loads
just one quick Q
is there a way i can call my inject time pulse from within this window ?
from my render i have
and declared at top like so
so i tried in the window where my stick inputs are
to refresh the inputs but got a not declared error when compiling
what i'am trying to say is i need to call my function every 60 mseconds or so only when the joystick window is open
tia
That helped loads
just one quick Q
is there a way i can call my inject time pulse from within this window ?
from my render i have
Code: Select all
clock_t time_now = clock();
float elapsed = static_cast<float>( time_now - mLastTimeInjection ) / CLOCKS_PER_SEC;
mLastTimeInjection = time_now;
// inject time pulse into CEGUI
CEGUI::System::getSingleton().injectTimePulse( elapsed );
and declared at top like so
Code: Select all
clock_t mLastTimeInjection = clock();
clock_t time_now = clock();
bool injectTimePulse( float timeElapsed );
so i tried in the window where my stick inputs are
Code: Select all
clock_t time_now = clock();
to refresh the inputs but got a not declared error when compiling
what i'am trying to say is i need to call my
Code: Select all
void Refresh()
{
//Code to get the input values
}
tia
trying to upgrade to 0.8.2 from 0.7.9
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: help with design
I think what you want to do is subscribe to the window's EventWindowUpdated (which is passed a CEGUI::UpdateEventArgs as the args). In the handler you need to keep track of the elapsed time, and every 60ms do whatever you need. So your handler might look like this:
CE
Code: Select all
bool MyClass::updateHandler(const CEGUI::EventArgs& args)
{
// get the time elapsed since last frame from the event args
float elapsed = static_cast<const CEGUI::UpdateEventArgs&>(args).d_timeSinceLastFrame;
// add that elapsed time to the count that we weep in instances of MyClass (where d_totalElapsed is defined)
d_totalElapsed += elapsed;
// see if we need to do 'stuff'
if (d_totalElapsed >= 0.06f)
{
// TODO: Poll the joystick or what have you here.
// reset total elapsed
d_totalElapsed = 0.0f;
}
return true;
}
CE
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: help with design
HIya CE
Thanks for your help sir
just one more though and i know i miss something easy but cant work out what
one my mainUI screen i have a button that opens up a new window this one has its own joy.cpp and .h file
and has load function
then for test i have following
and i have bool d_totalElapsed; declared
this only works one time ie when i hit the joy button on mainUI kinda makes sense as RefreshJoystick(e); is only called on that so how can i make it be called continusly so that time function works as it should
hope i have'nt confussed you
TIA
Thanks for your help sir
just one more though and i know i miss something easy but cant work out what
one my mainUI screen i have a button that opens up a new window this one has its own joy.cpp and .h file
and has load function
Code: Select all
bool joy::LoadSetupWindow(const CEGUI::EventArgs& e)
{
try
{
using namespace CEGUI;
// load the layout
WindowManager& winMgr = WindowManager::getSingleton();
if (!winMgr.isWindowPresent("joywindow"))
Window* JoySetup = winMgr.loadWindowLayout("joysetup.layout");
RefreshJoystick(e);// this calls the function for refreshing joy inputs
if (winMgr.isWindowPresent("background_wnd"))
{
Window* background = (winMgr.getWindow("background_wnd"));
background->addChildWindow("joywindow");
}// catch any errors
catch (CEGUI::Exception)
{
MessageBox(NULL, "joywindow !", "Warning !",
MB_ICONEXCLAMATION | MB_OK);
return true;
}
return true;
}
}
then for test i have following
Code: Select all
bool Refresh(const CEGUI::EventArgs& e)
{
using namespace CEGUI;
WindowManager& winMgr = WindowManager::getSingleton();
// get the time elapsed since last frame from the event args
float elapsed = static_cast<const CEGUI::UpdateEventArgs&>(e).d_timeSinceLastFrame;
// add that elapsed time to the count that we weep in instances of MyClass (where d_totalElapsed is defined)
d_totalElapsed += elapsed;
// see if we need to do 'stuff'
if (d_totalElapsed >= 0.08f)
{
// TODO: Poll the joystick or what have you here.
MessageBox(NULL, "Timer Test", "Timer Function!",
MB_ICONEXCLAMATION | MB_OK);
// reset total elapsed
d_totalElapsed = 0.0f;
}
return true;
}
and i have bool d_totalElapsed; declared
this only works one time ie when i hit the joy button on mainUI kinda makes sense as RefreshJoystick(e); is only called on that so how can i make it be called continusly so that time function works as it should
hope i have'nt confussed you
TIA
trying to upgrade to 0.8.2 from 0.7.9
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: help with design
Ummm...
Three things:
I think you're missing subscribing to the event, in the joy::LoadSetupWindow function, after you load the layout, you need something like:
I wouldn't call the RefreshJoystick function directly in the LoadSetupWindow handler, since the event args are incompatible types (kind of demonstrates why static_cast is unsafe, I guess!), once the event subscription above is made it should get invoked properly anyway.
Not sure if it's a typo or not, but d_totalElapsed should be a float not a bool. Also, is that a global or a static or something? Since it's value needs to persist between calls to RefreshJoystick (which appears to be a stand alone function).
CE.
Three things:
I think you're missing subscribing to the event, in the joy::LoadSetupWindow function, after you load the layout, you need something like:
Code: Select all
JoySetup->subscribeEvent( Window::EventWindowUpdated, &RefreshJoystick);
I wouldn't call the RefreshJoystick function directly in the LoadSetupWindow handler, since the event args are incompatible types (kind of demonstrates why static_cast is unsafe, I guess!), once the event subscription above is made it should get invoked properly anyway.
and i have bool d_totalElapsed; declared
Not sure if it's a typo or not, but d_totalElapsed should be a float not a bool. Also, is that a global or a static or something? Since it's value needs to persist between calls to RefreshJoystick (which appears to be a stand alone function).
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: help with design
Hi guys
ok as you can i did get this to work but now i upgraded to 0.7.5 it stopped working
all i have done is changed the ->refresh() to the new ->invalidate() ways
the refresh does get called when i first open the window but when i open anew tab in that window it stops and never gets recalled i have tried adding the call
Code: Select all
JoySetup->subscribeEvent( Window::EventWindowUpdated, &RefreshJoystick);
to the open tab function in the usally places it goes though but never goes to the function ?
been trying various things for the few days and i'am at a loss to what could be wrong
there is no errors in the log
NM was being blonde again fixed
trying to upgrade to 0.8.2 from 0.7.9
Who is online
Users browsing this forum: No registered users and 11 guests