I want simply to apply a texture to one face of a CubeSceneNode, I followed the tutorial about custom scene nodes but I dont know how to apply the texture only to one face of the cube. help please!
Thanks in advance!
How to apply a texture in a specific face of cube
You could either UV map your own cube in a modeling program, or make a custom scene node with mesh buffers for each side of a face.
Here's two links where it's explained it better [in C++ though]:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24533
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=3680
Here's two links where it's explained it better [in C++ though]:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24533
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=3680
thank you for answering.
I think the solution for my problem is the second option you talk about , because the texture to apply in the front face of the cube is choosed dynamically by user so generate UV coordenates from an external tool I think is not possible (maybe I am wrong...)
Now I will try to understand the example in the first thread you quoted...
I think the solution for my problem is the second option you talk about , because the texture to apply in the front face of the cube is choosed dynamically by user so generate UV coordenates from an external tool I think is not possible (maybe I am wrong...)
Now I will try to understand the example in the first thread you quoted...
I have tried the second option but It doesn't work and I don't know why...:
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??
Thanks
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);
Thanks