[SOLVED] OIS Problem

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
User avatar
fixtone
Gnoblar
Posts: 19
Joined: Tue Jan 24, 2012 1:32 pm
Location: Barcelona
x 2

[SOLVED] OIS Problem

Post by fixtone »

Hello,

I have a problem with OIS mouse moved.
The mouse moved works backwards, I use LandScape Right in info.plist file.

This is the video.

[youtube]HEqDyF8hl2M[/youtube]

In the function touchMoved call:

Code: Select all

m_pTrayMgr-> injectMouseMove (evt)
I am using Xcode 4.3, IOS 5.1 and ogre 1.8

P.D: If I use SetOrientation method of viewport produce an Exception es not suported.

Thanks
Last edited by fixtone on Tue Jul 24, 2012 8:22 am, edited 1 time in total.
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: OIS Problem

Post by masterfalcon »

SetOrientation was only supported for OGRE 1.7. You'll see that we transform the touch coordinates somewhere in the sample code(not sure where it is right now). You may need to do the same.
User avatar
fixtone
Gnoblar
Posts: 19
Joined: Tue Jan 24, 2012 1:32 pm
Location: Barcelona
x 2

Re: OIS Problem

Post by fixtone »

Thank you very much masterfalcon.

Just one question: how to transform the touch coordinates?

Can you show me an example?
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: OIS Problem

Post by masterfalcon »

Yeah, see the implementation of transformInputState in SampleContext.h
User avatar
fixtone
Gnoblar
Posts: 19
Joined: Tue Jan 24, 2012 1:32 pm
Location: Barcelona
x 2

Re: OIS Problem

Post by fixtone »

Thanks masterfalcon,

But I have a question, I can't modify the evt.state because is read only read-only.
I let my code to know how to fix it.

Code: Select all

bool MenuState::touchMoved(const OIS::MultiTouchEvent &evt)
{

    OIS::MultiTouchState state = evt.state;
    AdvancedOgreFramework::getSingletonPtr()->transformInputState(state);
    if(AdvancedOgreFramework::getSingletonPtr()->m_pTrayMgr->injectMouseMove(evt)) return true;
	return true;

}
AdvancedOgreFramework.cpp (Only LandScape Right)

Code: Select all

// Variation based upon device orientation for use with a view controller
void AdvancedOgreFramework::transformInputState(OIS::MultiTouchState &state)
{
    int w = m_pRenderWnd->getViewport(0)->getActualWidth();
    int h = m_pRenderWnd->getViewport(0)->getActualHeight();
    int absX = state.X.abs;
    int absY = state.Y.abs;
    int relX = state.X.rel;
    int relY = state.Y.rel;
    
    state.X.abs = w - absY;
    state.Y.abs = absX;
    state.X.rel = -relY;
    state.Y.rel = relX;
}
I hope your answer. Thank you very much;
User avatar
fixtone
Gnoblar
Posts: 19
Joined: Tue Jan 24, 2012 1:32 pm
Location: Barcelona
x 2

Re: OIS Problem

Post by fixtone »

Please Help! :D :D

I'm doing a study to determine the feasibility of using OGRE at work. :D
User avatar
fixtone
Gnoblar
Posts: 19
Joined: Tue Jan 24, 2012 1:32 pm
Location: Barcelona
x 2

Re: OIS Problem

Post by fixtone »

I've solved the problem, then show the solution to someone helps.

Code: Select all

bool MenuState::touchMoved(const OIS::MultiTouchEvent &evt)
{

    OIS::MultiTouchState state = evt.state;    

    AdvancedOgreFramework::getSingletonPtr()->transformInputState(state);    

    Ogre::OverlayContainer* o = AdvancedOgreFramework::getSingletonPtr()->m_pTrayMgr->getCursorContainer();

    o->setPosition(state.X.abs,state.Y.abs);

    return true;
}
Only for Right Landscape

Code: Select all

void AdvancedOgreFramework::transformInputState(OIS::MultiTouchState &state)
{
    int w = m_pRenderWnd->getViewport(0)->getActualWidth();
    int h = m_pRenderWnd->getViewport(0)->getActualHeight();

    int absX = state.X.abs;
    int absY = state.Y.abs;
    int relX = state.X.rel;
    int relY = state.Y.rel;

    state.X.abs = absY;
    state.Y.abs = h - absX;
    state.X.rel = relY;
    state.Y.rel = -relX;
}
Thank you very much for the help masterfalcon. :D