I have a problem to draw a mesh buffer.The problem is that my mesh buffer does not appear when I use the drawMeshBuffer() method, only with drawAll().
First, I already have searched about this problem and I have tried a lot of thing but none of that work for me. Second, I am using the .NET wrapper for Irrlicht and I need to know if my code is right before start to think that the problem could be with the wrapper.
As I said before, I have tried a lot of code and below is the last version of my code.
Code: Select all
static void Main(string[] args)
{
IrrlichtDevice device =
new IrrlichtDevice(DriverType.Software, new Dimension2D(512, 384), 32, false, true, true, true);
device.WindowCaption = "Hello World! - Irrlicht Engine Demo";
VideoDriver driver = device.VideoDriver;
SceneManager smgr = device.SceneManager;
MeshBuffer mb = new MeshBuffer(VertexType.Standard);
mb.BoundingBox = new Box3D();
float fSide = 25f;
Vector3D vec3D = new Vector3D(-fSide, 0, -fSide), vecN = new Vector3D(0f, 1f, 0f);
Vector2D vec2D = new Vector2D(0f, 0f);
mb.SetVertex(0, new Vertex3D(vec3D, vecN, Color.White, vec2D));
vec3D = new Vector3D(-fSide, 0, fSide);
vec2D = new Vector2D(1f, 0f);
mb.SetVertex(1, new Vertex3D(vec3D, vecN, Color.White, vec2D));
vec3D = new Vector3D(fSide, 0, -fSide);
vec2D = new Vector2D(0f, 1f);
mb.SetVertex(2, new Vertex3D(vec3D, vecN, Color.White, vec2D));
vec3D = new Vector3D(fSide, 0, fSide);
vec2D = new Vector2D(1f, 1f);
mb.SetVertex(3, new Vertex3D(vec3D, vecN, Color.White, vec2D));
mb.SetIndex(0, 2);
mb.SetIndex(1, 0);
mb.SetIndex(2, 1);
mb.SetIndex(3, 2);
mb.SetIndex(4, 1);
mb.SetIndex(5, 3);
Mesh m = new Mesh();
m.AddMeshBuffer(mb);
SceneNode node = smgr.AddMeshSceneNode(m, smgr.RootSceneNode, -1);
node.SetMaterialTexture(0, driver.GetTexture("num.png"));
node.SetMaterialFlag(MaterialFlag.Lighting, false);
mb.Material = node.GetMaterial(0);
CameraSceneNode cam = smgr.AddCameraSceneNode(smgr.RootSceneNode);
cam.Position = new Vector3D(50, 100, 0);
cam.Target = new Vector3D(0, 0, 0);
while (device.Run())
{
driver.BeginScene(true, true, new Color(255, 0, 0, 0));
driver.SetMaterial(mb.Material);
driver.SetTransform(TransformationState.World, node.AbsoluteTransformation);
driver.DrawMeshBuffer(mb);
//smgr.DrawAll();
driver.EndScene();
}
//In the end, delete the Irrlicht device.
device.Dispose();
Thanks in advance.