How to create a triangle using a SMeshBuffer?
Re: How to create a triangle using a SMeshBuffer?
Maybe check example 23.MeshHandling. The part where it fills the meshbuffer is in the addstrip function.
But in short: Meshbuffers have Vertices, Indices and a Material and you need to set those all.
Vertices are usually in the S3DVertex format and set the 3 corners of your triangle. Or 4 corners of a quad, etc.
Indices are, as the name says, indices into your Vertex array. So they the give the order in which those vertices are used. For a triangle it's probably the number 0,1,2. For a quad - where you have 4 vertices you will probably use 2 triangles. So you need 6 indices (each triangle always as 3) which can be like: 0,1,2, 2,3,0. Note that the order matters to decide which side of the polygon is front and back. Irrlicht has clockwise ordering I think (and a left-handed coordinate sytem).
As for the Material - it often helps by starting with Lighting set to off. Then you don't have to worry if something is invisible because it's not in your light or because you messed up otherwise ;-)
But in short: Meshbuffers have Vertices, Indices and a Material and you need to set those all.
Vertices are usually in the S3DVertex format and set the 3 corners of your triangle. Or 4 corners of a quad, etc.
Indices are, as the name says, indices into your Vertex array. So they the give the order in which those vertices are used. For a triangle it's probably the number 0,1,2. For a quad - where you have 4 vertices you will probably use 2 triangles. So you need 6 indices (each triangle always as 3) which can be like: 0,1,2, 2,3,0. Note that the order matters to decide which side of the polygon is front and back. Irrlicht has clockwise ordering I think (and a left-handed coordinate sytem).
As for the Material - it often helps by starting with Lighting set to off. Then you don't have to worry if something is invisible because it's not in your light or because you messed up otherwise ;-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm