PDA

View Full Version : Detect scrolling/swipes for irrlicht?



darkchazz
11-26-2013, 10:02 AM
I've been trying to use the scrollcomponent to detect horizontal scrolling/swipes and move a scene node in irrlicht.
But so far I'm lost. It doesn't seem to be the way to go.

Will the scroll component work correctly even if it has no entities to scroll (like text) ?
Is there a way to obtain the displacement or scrolling speed from the scroll component?

Seth
11-26-2013, 10:34 AM
Hmm, probably the best way is to use TouchStripComponent instead

darkchazz
11-26-2013, 12:14 PM
Thanks. I had no idea about that component.
How do I get the vector from it though?

osgoz
11-26-2013, 12:15 PM
Hi.

In Proton & Irrlicht sample have you the way to go with TouchStripComponent, like Seth said.
It is the easy way.
In my application, I have create an Irrlicht view, and link the "OnInput" signal to a function of my own.
I use something like this on the create function of Irrlicht view:


pParent->GetFunction("OnInput")->sig_function.connect(&MyOnInput);

After that, the MyOnInput function looks like this:


void MyOnInput(VariantList *pVList)
{
//0 = message type, 1 = parent coordinate offset
CL_Vec2f pt = pVList->Get(1).GetVector2();

uint32 fingerID = 0;
if (pVList->Get(2).GetType() == Variant::TYPE_UINT32)
{
fingerID = pVList->Get(2).GetUINT32();
}

switch (eMessageType( int(pVList->Get(0).GetFloat())))
{
case MESSAGE_TYPE_GUI_CLICK_START:/// like Mouse Left Button Down
OnLButtonDown(pt,fingerID);
break;
case MESSAGE_TYPE_GUI_CLICK_END:/// like Mouse Left Button Up
OnLButtonUp(pt,fingerID);
break;
case MESSAGE_TYPE_GUI_CLICK_MOVE:/// like Mouse Left Button Down && Mouse Move
OnMove(pt, fingerID);
break;
};
}


In each of that cases I call the especific function for my needs.
That is my way of doing it, I know that it is not the best, but it is mine :)

For your needs, the function OnMove must move ( change the position and/or target) of the active camera in Irrlicht.

Regards.

darkchazz
11-26-2013, 06:09 PM
Hi.

In Proton & Irrlicht sample have you the way to go with TouchStripComponent, like Seth said.
It is the easy way.
In my application, I have create an Irrlicht view, and link the "OnInput" signal to a function of my own.
I use something like this on the create function of Irrlicht view:


pParent->GetFunction("OnInput")->sig_function.connect(&MyOnInput);

After that, the MyOnInput function looks like this:


void MyOnInput(VariantList *pVList)
{
//0 = message type, 1 = parent coordinate offset
CL_Vec2f pt = pVList->Get(1).GetVector2();

uint32 fingerID = 0;
if (pVList->Get(2).GetType() == Variant::TYPE_UINT32)
{
fingerID = pVList->Get(2).GetUINT32();
}

switch (eMessageType( int(pVList->Get(0).GetFloat())))
{
case MESSAGE_TYPE_GUI_CLICK_START:/// like Mouse Left Button Down
OnLButtonDown(pt,fingerID);
break;
case MESSAGE_TYPE_GUI_CLICK_END:/// like Mouse Left Button Up
OnLButtonUp(pt,fingerID);
break;
case MESSAGE_TYPE_GUI_CLICK_MOVE:/// like Mouse Left Button Down && Mouse Move
OnMove(pt, fingerID);
break;
};
}


In each of that cases I call the especific function for my needs.
That is my way of doing it, I know that it is not the best, but it is mine :)

For your needs, the function OnMove must move ( change the position and/or target) of the active camera in Irrlicht.

Regards.

That's very helpful thank you :)

What is the correct usage of TouchStripComponent though?

osgoz
11-27-2013, 07:55 AM
Hi.

I think the best usage for TouchStripComponent is shown by Seth in the RT3DApp sample project.
It is used to show two virtual joysticks, one for direction and the other for orientation, to move across the Irrlicht scene.
Use it for your start point. You will learn very much diving in that sample project :)

Regards

darkchazz
11-27-2013, 04:20 PM
I already figured it out but thanks anyway ;)
I did check out the rt3dapp example long time ago but I forgot about it.

The reason I was lost is because I did not pay any attention to proton's variant/signal systems.
Anyhow the component does work pretty well.