I have been experimenting with the .NET version for a few weeks in my off time. I have version 0.12.0.
I basically want to draw 3 sides of an open box, then rotate that structure in front of a camera using my own buttons (not FPS). I don't know anything about meshes etc., so I am using flat TestSceneNodes scaled to the sizes I need. I can draw 2 sides of the box, but as soon as I parent one to the other, the child one disappears.
Any ideas what I am doing wrong?
Here is some sample code, just create a new .NET Windows Form and throw this after (outside) the Main() method:
Code: Select all
IrrlichtDevice device = null;
ICameraSceneNode camera = null;
ISceneNode container = null;
bool OKtoDraw = false;
private void Form1_Load(object sender, System.EventArgs e)
{
// start up the engine
this.device = new IrrlichtDevice(DriverType.OPENGL,
new Dimension2D(640, 480),
8,
false,
false,
false,
false,
this.Handle
);
this.device.ResizeAble = true;
// load some textures
ITexture texWall = this.device.VideoDriver.GetTexture(@"C:\irrlicht-0.12.0\media\wall.bmp");
ITexture texStones = this.device.VideoDriver.GetTexture(@"C:\irrlicht-0.12.0\media\stones.jpg");
this.camera = this.device.SceneManager.AddCameraSceneNode(
null, new Vector3D(30, 5, 5), new Vector3D(0, 0, 0), -1);
// Floor of the container:
ISceneNode containerFloor = this.device.SceneManager.AddTestSceneNode(1,
null, 1,
new Vector3D(10, 0, 4),
new Vector3D(0, 0, 0),
// Length, Height, Width
new Vector3D(20, 0, 8)
);
containerFloor.SetMaterialTexture(0, texWall);
// Closed end of the container:
ISceneNode containerClosedEnd = this.device.SceneManager.AddTestSceneNode(1,
null, 2,
new Vector3D(0, 5, 4),
new Vector3D(0, 0, 0),
new Vector3D(0, 10, 8)
);
containerClosedEnd.SetMaterialTexture(0, texStones);
// Attach the Closed End to the Floor:
// As soon as I do this, the containerClosedEnd disappears!
containerFloor.AddChild(containerClosedEnd);
this.container = containerFloor;
// Fire up the engine
this.device.Run();
// View Form
this.Show();
this.OKtoDraw = true;
}
void RefreshWindow()
{
if (this.OKtoDraw)
{
this.device.VideoDriver.BeginScene(true, true, new Irrlicht.Video.Color(0, 100, 100, 100));
this.device.SceneManager.DrawAll();
this.device.VideoDriver.EndScene();
}
}
private void Form1_Resize(object sender, System.EventArgs e)
{
RefreshWindow();
}
private void Form1_Closed(object sender, System.EventArgs e)
{
Application.Exit();
}
private void Form1_Activated(object sender, System.EventArgs e)
{
RefreshWindow();
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
RefreshWindow();
}