Page 1 of 1

How to run Irrlicht in a panel

Posted: Sat Mar 24, 2007 2:18 pm
by mihich
I am using WPF, is there any possibility of running 3D in a container (such as a grid, viewport3d) ?

Thnx

re:Running Irrlicht in Panel

Posted: Sun Apr 01, 2007 9:18 am
by Mobeen
Hi there,
You can run irrlicht inside a Panel. You have to do two things
1) Pass the Handle of your panel to createDevice (see the last overload which accepts the Intptr handle)
2) Alter the while main loop slightly. Currently in all the samples, its like this

Code: Select all

while(device.run())
{
   if(device.windowActive)
   {
      //beginscene
      //render ...
      //end scene
   }
}
When you have a panel control the windowactive flag is false because it is not the active window. To rectify this do this (assuming that your panel is named panel1)

Code: Select all

while(device.run())
{
   if(panel1.Parent == Form.ActiveForm)
   {
      //beginscene
      //render ...
      //end scene
   }
}
And there you have it irrlicht working inside a panel.
Let me know if there is anything which needs explanation.
Regards,
Mobeen

Posted: Sat Apr 07, 2007 9:01 am
by Darkness
I would like to run a FPS scene inside a pictureBox. I have been able to get the map to display in the pictureBox and I can use the mouse to change the point of view but I can't move around the map with the arrow keys. Is it possible to use FPS scene in a pictureBox? If so how?

Also I would like the user to be able to use the mouse to click on buttons on the form so I have used the CursorControl.Visible property but the cursor does not move. Can this be done?

Any help is greatly appreciated.

Re:

Posted: Sat Apr 21, 2007 2:55 pm
by Mobeen
What language are you using c++ or c#.
If you are using c#, then make sure that the KeyPreview property of your form is set to true otherwise the key input will be set to the control having focus and the form key handler will not be called.
If you are using c++ then what windowing apui are u using MFC, wxWidgets or custom?

Posted: Sun Apr 22, 2007 4:43 am
by Darkness
I am using C#. I have set the KeyPreview property to true but I am still unable to move around the map.

Posted: Sun Apr 22, 2007 6:08 pm
by mihich
Make sure that your control (PictureBox, Panel, etc) has focus.

RE:

Posted: Mon Apr 23, 2007 4:28 pm
by Mobeen
Darkness wrote:I am using C#. I have set the KeyPreview property to true but I am still unable to move around the map.
Yeah I tried that too and it doesnot work even if u attach a custom eventreceiver. Only mouse movement is working ok. I feel that the .Net forms do not allow keyboard events to be passed to irrlicht. I will try to see this and let u know if i come up with anything.