freezereagle Posted March 11, 2014 Share Posted March 11, 2014 I am trying to apply a different texture to each face of a cube.I have been able to do this using MultiMaterial and subMeshes, but my images are not oriented on the faces of the box the way I need them to be. I tried using vAng, wAng, and uAng, but they do not seem to give me the results I need. I just get black faces. I only need to rotate the images by increments of 90 degrees (PI/2)I cannot pre-rotate the images, because they are used in other areas and the orientation is correct for those purposes. Here is a sample of the code I have so far. var box = BABYLON.Mesh.CreateBox("Box", 1.0, scene); var FrontMaterial = new BABYLON.StandardMaterial("cubeFront", scene); FrontMaterial.emissiveTexture = new BABYLON.Texture("images/front.png", scene); var BackMaterial = new BABYLON.StandardMaterial("cubeBack", scene); BackMaterial.emissiveTexture = new BABYLON.Texture("images/back.png", scene, false, true); var LeftMaterial = new BABYLON.StandardMaterial("cubeLeft", scene); LeftMaterial.emissiveTexture = new BABYLON.Texture("images/left.png", scene); var RightMaterial = new BABYLON.StandardMaterial("cubeRight", scene); RightMaterial.emissiveTexture = new BABYLON.Texture("imagesright.png", scene); var TopMaterial = new BABYLON.StandardMaterial("cubeTop", scene); TopMaterial.emissiveTexture = new BABYLON.Texture("images/top.png", scene); var BottomMaterial = new BABYLON.StandardMaterial("cubeBottom", scene); BottomMaterial.emissiveTexture = new BABYLON.Texture("images/bottom.png", scene); var cubeMultiMat = new BABYLON.MultiMaterial("cubeMulti", scene); cubeMultiMat.subMaterials.push(BackMaterial); cubeMultiMat.subMaterials.push(FrontMaterial); cubeMultiMat.subMaterials.push(RightMaterial); cubeMultiMat.subMaterials.push(LeftMaterial); cubeMultiMat.subMaterials.push(TopMaterial); cubeMultiMat.subMaterials.push(BottomMaterial); box.subMeshes = []; box.subMeshes.push(new BABYLON.SubMesh(0, 0, 4, 0, 6, box)); box.subMeshes.push(new BABYLON.SubMesh(1, 4, 4, 6, 6, box)); box.subMeshes.push(new BABYLON.SubMesh(2, 8, 4, 12, 6, box)); box.subMeshes.push(new BABYLON.SubMesh(3, 12, 4, 18, 6, box)); box.subMeshes.push(new BABYLON.SubMesh(4, 16, 4, 24, 6, box)); box.subMeshes.push(new BABYLON.SubMesh(5, 20, 4, 30, 6, box)); box.material = cubeMultiMat; Thanks, Xanmia 1 Quote Link to comment Share on other sites More sharing options...
freezereagle Posted March 13, 2014 Author Share Posted March 13, 2014 I solved my issue.It was related to a typo. I used Math.Pi instead of Math.PI. Just for anyone reference the Texture member to use is wAng. GameMonetize, Xanmia and gwenael 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.