multiple openGL irrlichtDevice

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

it works now. i'm using Qt Creator instead of C::B
Escen
Competition winner
Posts: 167
Joined: Sun Jul 19, 2009 11:27 am
Location: the Netherlands
Contact:

Post by Escen »

I prefer using C::B when an application get more complicated.

To get it working I just followed the Wiki:

http://code.google.com/p/qtworkbench/wi ... chProjects
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

another question... the left, middle and right clicks are working fine in my qt-irrlicht app but how come I can't drag anything?

for example I opened a file dialogue (irrlicht's gui), it appears in my irrlicht widget, I can press the buttons or select a file but I can't drag-moving the file selector window as well as the scrollbar... any idea?
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

bump
hmm no one know the reason why?
Escen
Competition winner
Posts: 167
Joined: Sun Jul 19, 2009 11:27 am
Location: the Netherlands
Contact:

Post by Escen »

You are using QT already, can you not use an QFileDialog instead?
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

i'm not sure whether i'm doing the right thing or not, i created an event receiver for mouse clicking (for mesh selection) but when i click on the irrlicht widget the whole program crashes. hmm anyone know how to do it in a correct way?
xirtamatrix
Posts: 219
Joined: Fri Feb 19, 2010 4:03 pm
Location: Estonia

Post by xirtamatrix »

Hi all,

Did anyone manage to get the event-handler working??

I'm stuck with this like a week now and ready to jump off my balcony!
ANY working code examples would be much MUCH appreciated!

Thanks in advance!
Escen
Competition winner
Posts: 167
Joined: Sun Jul 19, 2009 11:27 am
Location: the Netherlands
Contact:

Post by Escen »

Don't jump, Virion saved your life.

You have to grab the keyboard input when initialize the widget class.

this->grabKeyboard();

http://irrlicht.sourceforge.net/phpBB2/ ... highlight=
xirtamatrix
Posts: 219
Joined: Fri Feb 19, 2010 4:03 pm
Location: Estonia

Post by xirtamatrix »

Thanks Escence,

but I figure I must be missing something.
And that something is: where is the message loop?

So app.exec() in main captures Qt events, and we have mapped selctively some keys of Qt to Irrlicht, but where should the Irrlicht message loop be? Now we cant have it in main.cpp obviously... so... humn... (scratching head)

I'm probably missing something very fundamental here that everyone else seems to know... well, since I'm quite a beginner in Irrlicht, please forgive me.

Any help would be much appreciated! :)

/regards
xirtamatrix
Posts: 219
Joined: Fri Feb 19, 2010 4:03 pm
Location: Estonia

Post by xirtamatrix »

xirtamatrix wrote:Thanks Escence,

but I figure I must be missing something.
And that something is: where is the message loop?

So app.exec() in main captures Qt events, and we have mapped selctively some keys of Qt to Irrlicht, but where should the Irrlicht message loop be? Now we cant have it in main.cpp obviously... so... humn... (scratching head)

I'm probably missing something very fundamental here that everyone else seems to know... well, since I'm quite a beginner in Irrlicht, please forgive me.

Any help would be much appreciated! :)

/regards

Or is it that, since we have the Qt message loop running, we dot need a seperate Irrlicht message loop... well.. that would be logical. But then, why the hell camera dont move! Not even with this->grabkeyboard() thingy, it still dont move. darn!
Escen
Competition winner
Posts: 167
Joined: Sun Jul 19, 2009 11:27 am
Location: the Netherlands
Contact:

Post by Escen »

Maybe try this to get it working.

First you have to make sure you are using a FPS camera.

Code: Select all

scene::ICameraSceneNode* cam = manager->addCameraSceneNodeFPS(0,100,0.5f,-1,0,false,0,false,true );
Tell QT to enable mousetracking when initialize the widget class, and grab keyboard.

Code: Select all

setMouseTracking(true);//enable constant mouse movement
this->grabKeyboard(); 

Declare mouseMoveEvent in your header file:

Code: Select all

virtual void mouseMoveEvent(  QMouseEvent* event );
Paste Method to your class:

Code: Select all

void QIrrlichtWidget::mouseMoveEvent(  QMouseEvent* event )
{
    irr::SEvent irrEvent;

    irrEvent.EventType = irr::EET_MOUSE_INPUT_EVENT;

     if ( device != 0 )
    {
    irrEvent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;

    irrEvent.MouseInput.X = event->x();
    irrEvent.MouseInput.Y = event->y();
    irrEvent.MouseInput.Wheel = 0.0f; // Zero is better than undefined


    device->postEventFromUser( irrEvent );
    }


   event->ignore();
};
... so... humn... (scratching head)
Don't do that to much, or you getting bald early.

Cheers,
Escen
xirtamatrix
Posts: 219
Joined: Fri Feb 19, 2010 4:03 pm
Location: Estonia

Post by xirtamatrix »

Thanks a bundle Escen! God bless you... I mean.... umn.. whatever you believe in bless you... ah heck, well let em all just bless you. Yeps that better... people of the world, go all bless Escen!

how stupid of me, once again I had not properly looked into Irrlicht cause I was too busy digging into Qt... so.. yes... I had a standard camera which obviously did not provide any key/mouse movement and I had no method of my own to handle that either! blast!

So far so good! I truely appreciate the time you took to write and explain the code, many many thanks again!

One little thing though, this FPS camera is probably the worst invention of mankind and I'd been trying to change it to something more civilized, tried the Maya camera but thats not what I want either, so I figure will have to write my own camera. I've been searching the forums for some reliable 3rd person camera method... do you happen to know any? Or, if you have some decent working camera, could you kindly share the code? :)
Escen wrote: Don't do that to much, or you getting bald early.

Cheers,
Escen
LOL, and I been wondering where do my hair keep disappearing.

Cheers mate!
XirtamatriX
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

I'm using FPS camera with Qt too and it's cool. I'm using Qt's input for almost everything except when moving around with FPS camera, which I transfer the input from Qt to Irrlicht. When I don't have to move around I can switch back to normal, static camera using right click.

conclusion: FPSCamera rocks.
xirtamatrix
Posts: 219
Joined: Fri Feb 19, 2010 4:03 pm
Location: Estonia

Post by xirtamatrix »

Virion wrote:I'm using FPS camera with Qt too and it's cool. I'm using Qt's input for almost everything except when moving around with FPS camera, which I transfer the input from Qt to Irrlicht. When I don't have to move around I can switch back to normal, static camera using right click.

conclusion: FPSCamera rocks.
So you like the FPS camera and I dont, guess we can live with it :)

Depends on the needs of your application though.

What annoys me most is the mouse grabbing behaviour of it for rotation, I dont want it, instead, I want to rotate when user clicks-holds-drags the mouse to a certain direction, as in the maya camera. But the problem with Maya camera is when you drag it up or down it rotates, insted I would want it to move in the Z direction. The keys behaviour of FPS is ok, left and right moves to left and right and up/down moves in Z direction.

I read somewhere its not a good idea to modify existing cameras, hence looking forward to write my own camera.

EDIT: ideally though, I'd like to provide a choice of at least 2 cameras, one FPS style but without mouse-locking, and another 3rd-person-follow style which follows the avatar.

cheers!
bonsalty
Posts: 120
Joined: Thu Dec 10, 2009 1:30 pm
Location: Budapest,Hungary

Post by bonsalty »

Im creating two different windows and when the second is attached to irrlicht with CreateDeviceEx, the first seems to get corrupted. Can you explain how to solve this problem? You said its because OpenGL is not supporting rendering from the same threads. I dont understand this. How should it work?

In Direct3D its fine, but I need to use OpenGL!
Tomi
Post Reply