Code: Select all
String rutaTextura1 = @Principal.path + "Texturas/Suelos/baldosa.png";
String rutaTextura2 = @Principal.path + "Texturas/Paredes/paredSuper.jpg";
float cubeSize = 40.0f;
IrrlichtNETCP.Color cubeColour = new IrrlichtNETCP.Color(255, 255, 255, 255);
MeshBuffer buffer = new MeshBuffer(IrrlichtNETCP.VertexType.Standard);
MeshBuffer buffer2 = new MeshBuffer(IrrlichtNETCP.VertexType.Standard);
ushort[] u = { 0, 2, 1, 0, 3, 2 };
ushort[] u2 = { 0, 11, 10, 0, 10, 7 };
for (uint i = 0; i < 6; i++)
{
buffer.SetIndex(i, u[i]);
buffer2.SetIndex(i, u2[i]);
}
// set material per buffer, use this or the one at the end of this code
buffer.Material.Texture1 = this.device.VideoDriver.GetTexture(rutaTextura1);
buffer2.Material.Texture1 = this.device.VideoDriver.GetTexture(rutaTextura2);
buffer.SetVertex(0, new Vertex3D(new Vector3D(0, 0, 0), new Vector3D(-1, -1, -1), cubeColour, new Vector2D(0, 1)));
buffer.SetVertex(1, new Vertex3D(new Vector3D(1, 0, 0), new Vector3D(1, -1, -1), cubeColour, new Vector2D(1, 1)));
buffer.SetVertex(2, new Vertex3D(new Vector3D(1, 1, 0), new Vector3D(1, 1, -1), cubeColour, new Vector2D(1, 0)));
buffer.SetVertex(3, new Vertex3D(new Vector3D(0, 1, 0), new Vector3D(-1, 1, -1), cubeColour, new Vector2D(0, 0)));
buffer.SetVertex(4, new Vertex3D(new Vector3D(1, 0, 1), new Vector3D(1, -1, 1), cubeColour, new Vector2D(0, 1)));
buffer.SetVertex(5, new Vertex3D(new Vector3D(1, 1, 1), new Vector3D(1, 1, 1), cubeColour, new Vector2D(0, 0)));
buffer2.SetVertex(0, new Vertex3D(new Vector3D(0, 1, 1), new Vector3D(-1, 1, 1), cubeColour, new Vector2D(1, 0)));
buffer2.SetVertex(1, new Vertex3D(new Vector3D(0, 0, 1), new Vector3D(-1, -1, 1), cubeColour, new Vector2D(1, 1)));
buffer2.SetVertex(2, new Vertex3D(new Vector3D(0, 1, 1), new Vector3D(-1, 1, 1), cubeColour, new Vector2D(0, 1)));
buffer2.SetVertex(3, new Vertex3D(new Vector3D(0, 1, 0), new Vector3D(-1, 1, -1), cubeColour, new Vector2D(1, 1)));
buffer2.SetVertex(4, new Vertex3D(new Vector3D(1, 0, 1), new Vector3D(1, -1, 1), cubeColour, new Vector2D(1, 0)));
buffer2.SetVertex(5, new Vertex3D(new Vector3D(1, 0, 0), new Vector3D(1, -1, -1), cubeColour, new Vector2D(0, 0)));
Mesh cubeMesh = new Mesh();
cubeMesh.AddMeshBuffer(buffer);
cubeMesh.AddMeshBuffer(buffer2);
SceneNode cubeSceneNode = this.device.SceneManager.AddMeshSceneNode(cubeMesh, null, -1);
//Set material per scene node, material count should be the same as buffer count
cubeSceneNode.GetMaterial(0).Texture1 = this.device.VideoDriver.GetTexture(rutaTextura1);
cubeSceneNode.GetMaterial(1).Texture1 = this.device.VideoDriver.GetTexture(rutaTextura2);
cubeSceneNode.Scale = new Vector3D(cubeSize, cubeSize, cubeSize);
cubeSceneNode.SetMaterialFlag(MaterialFlag.Lighting, false);
In the scene the back face of the cube appears ok but the other face does not appear in a correct way, I suppose I have defined bad the vertex coordinates to render a cube. Someone can help me please??