Apply texture to single cube face
Blitz3D Forums/Blitz3D Programming/Apply texture to single cube face
| ||
Hi, After creating a cube using CreateCube(), I was wondering if anybody knows how to just texture a single face rather than have the texture be applied to all faces? Thanks |
| ||
The entire mesh is using the same surface when you use CreateCube, so without looping through its vertices/surfaces and breaking out the face you want onto its own surface - no, you can't. |
| ||
Write your own MyCreateCube() function that creates multiple surfaces. |
| ||
I did this function a while back. It could be helpful to you. It was designed to have the front surface change, but it would be easy to modify it so all the faces could be textured differently. Function createscreen(frntbrush,genbrush=0,parent=0) mesh=CreateMesh(parent) If genbrsh=0 Then genbrsh=frntbrsh fsurf=CreateSurface(mesh,frntbrush) AddVertex fsurf,-.5,-.5,.5,1,1;0 AddVertex fsurf,-.5,.5,.5,1,0;1 AddVertex fsurf,.5,.5,.5,0,0;2 AddVertex fsurf,.5,-.5,.5,0,1;3 AddTriangle (fsurf,2,1,0);front AddTriangle (fsurf,3,2,0) gsurf=CreateSurface(mesh,genbrush) AddVertex gsurf,-.5,-.5,.5,0,0;0 AddVertex gsurf,-.5,.5,.5,0,1;1 AddVertex gsurf,.5,.5,.5,1,1;2 AddVertex gsurf,.5,-.5,.5,1,0;3 AddVertex gsurf,-.5,-.5,-.5,0,0;4 AddVertex gsurf,-.5,.5,-.5,0,1;5 AddVertex gsurf,.5,.5,-.5,1,1;6 AddVertex gsurf,.5,-.5,-.5,1,0;7 AddTriangle (gsurf,4,5,7);back AddTriangle (gsurf,5,6,7) AddTriangle (gsurf,7,2,3);rside AddTriangle (gsurf,6,2,7) AddTriangle (gsurf,1,5,4);lside AddTriangle (gsurf,0,1,4) AddTriangle (gsurf,1,6,5);top AddTriangle (gsurf,1,2,6) AddTriangle (gsurf,4,7,0);bottom AddTriangle (gsurf,7,3,0) UpdateNormals mesh Return mesh End Function |
| ||
Thanks for the example Ziltch. Much appreciated. If I create a cube in say Truespace and export it as an .x object then load into into Blitz, does this change anything? I have a stretched cube object that I want to have a metallic texture on all sides but the front. On the front I want to use a different texture that will "scroll" using PositionTexture UV offsets. The effect I am after is that of one of those scrolling LED sign things. I can load my pre-textured cube object into B3D and it appears fine with the various textures on the correct faces but I have no idea how to access and offset the texture on my front face to get the desired "scrolling" effect. Does this make sense? |
| ||
You could pack textures. Check my 'leaf texture packer' archive. you could simply pack the two textures into 1 and then achieve what you want through u,v mapping. (It includes funcs to make it easy). |