How to run Irrlicht in a panel

Irrlicht.Net is no longer developed or supported, Irrlicht.Net Cross Platform is a much more complete wrapper. Please ask your C# related questions on their forums first.
Locked
mihich
Posts: 4
Joined: Sun Mar 04, 2007 9:27 pm

How to run Irrlicht in a panel

Post by mihich »

I am using WPF, is there any possibility of running 3D in a container (such as a grid, viewport3d) ?

Thnx
Mobeen
Posts: 37
Joined: Sat Mar 25, 2006 9:31 am
Location: Karachi, PAKISTAN

re:Running Irrlicht in Panel

Post 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
Proud to be a PAKISTANI
Darkness
Posts: 3
Joined: Sat Apr 07, 2007 8:39 am

Post 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.
Mobeen
Posts: 37
Joined: Sat Mar 25, 2006 9:31 am
Location: Karachi, PAKISTAN

Re:

Post 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?
Proud to be a PAKISTANI
Darkness
Posts: 3
Joined: Sat Apr 07, 2007 8:39 am

Post by Darkness »

I am using C#. I have set the KeyPreview property to true but I am still unable to move around the map.
mihich
Posts: 4
Joined: Sun Mar 04, 2007 9:27 pm

Post by mihich »

Make sure that your control (PictureBox, Panel, etc) has focus.
Mobeen
Posts: 37
Joined: Sat Mar 25, 2006 9:31 am
Location: Karachi, PAKISTAN

RE:

Post 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.
Proud to be a PAKISTANI
Locked