Create a room with bottom texture different?
Blitz3D Forums/Blitz3D Beginners Area/Create a room with bottom texture different?
| ||
Hi, I'm trying to make a room out of just a cube, I use the flipMesh code to make it my room. How do I Make the walls and ceiling a stone texture, and then have the ground a wood texture. Here is the code I use to make the room... room=CreateCube() FitMesh room,-250,0,-250,500,500,500 FlipMesh room tex=LoadTexture("wall.jpg") ScaleTexture tex, 0.5, 0.5 EntityTexture room,tex EntityFX room,1 In the code, I've loaded the texture for the walla but not for the ground. How would I use both Textures? Thanks for the help! |
| ||
You'll need to either: - Build your own cube making the bottom a separate surface so that you can texture it with a separate texture. or - Combine your ground and wall textures into a single texture and then alter the UV coords so that the walls map to the wall portion of the texture, and the ground maps to the ground portion. |
| ||
How would I combine the Textures then alter the UV coords? |
| ||
Combine the textures in a painting program. For an example on how to alter the UV coords, look up the "createskybox" function in the "castle" sample in Blitz. It uses that technique. |
| ||
You sure can work with UV Coords and a single texture and you also will learn a lot in this area. As a simple solution you could also use more primitives for the room. Example given one additional cube as the floor.room=CreateCube() FitMesh room,-250,0,-250,500,500,500 FlipMesh room tex=LoadTexture("wall.jpg") ScaleTexture tex, 0.5, 0.5 EntityTexture room,tex floor=CreateCube() FitMesh floor,-250,-1,-250,500,2,500 tex2=LoadTexture("ground.jpg") ScaleTexture tex2, 0.5, 0.5 EntityTexture floor,tex2 If you really want to use more than one texture on a single mesh, then you need more than one surface with this mesh. Triangles are assigned to surfaces. Meshes are built this way: -Create a mesh (still empty, only a handle) -create and assign a surface to the mesh -assign texture (in fact: brush) to this surface -assign Vertices and Triangles to this surface -Create and apply more surfaces, each with it's own triangles ... So adding a new texture to the floor of a flipped box means: rebuild the box, but this time use two surfaces. A bit complicated for what you want. Personally I would build this in a modeler and load it in Blitz, as an extended primitive so to say. BTW: using too much surfaces can slow down the machine, so big10p has a good point with the single surface suggestion. Understanding the mesh structure may however be useful. |
| ||
This should work for you ..Graphics3D 1024,768,32,1 Global light = CreateLight() Global camera = CreateCamera() Global room = CreateRoom() ;use this to test without media ;brush1 = CreateBrush( 255,0,0 ) ;brush2 = CreateBrush( 0,0,255 ) brush1 = CreateBrush() brush2 = CreateBrush() tex1 = LoadTexture("floor.jpg") tex2 = LoadTexture("wall.jpg") ScaleTexture tex2, .5, .5 BrushTexture brush1, tex1 BrushTexture brush2, tex2 PaintSurface GetSurface( room, 1 ) , brush1 PaintSurface GetSurface( room, 2 ) , brush2 EntityFX room,4 PositionEntity camera, 0,750,-250 PointEntity camera, room While Not KeyHit(1) TurnEntity room, 0, 1, 0 RenderWorld() Color 255,255,255 Text 0,0,"Surfaces: "+CountSurfaces( room ) Flip Wend ;================================================================== ;================================================================== ;================================================================== Function CreateRoom( Width# = 500 , Height# = 500 , Depth# = 500 ) ;create temporary cube mesh tmp = CreateCube() FitMesh tmp,-Width*.5 , 0 , -Depth*.5 , Width , Height , Depth FlipMesh tmp s = GetSurface( tmp, 1 ) ;create room mesh + 2 surfaces mesh = CreateMesh() ns1 = CreateSurface( mesh ) ns2 = CreateSurface( mesh ) For t = 0 To CountTriangles( s )-1 v0 = TriangleVertex( s , t , 0 ) v1 = TriangleVertex( s , t , 1 ) v2 = TriangleVertex( s , t , 2 ) ;if the normal is > 0 it's the floor If VertexNY( s , v0 ) > 0 ns = ns1 Else ns = ns2 EndIf ;add vertices Nv0 = AddVertex( ns , VertexX( s , v0 ) , VertexY( s, v0 ) , VertexZ( s, v0 ) , VertexU( s , v0 ) , VertexV( s, v0 ) ) Nv1 = AddVertex( ns , VertexX( s , v1 ) , VertexY( s, v1 ) , VertexZ( s, v1 ) , VertexU( s , v1 ) , VertexV( s, v1 ) ) Nv2 = AddVertex( ns , VertexX( s , v2 ) , VertexY( s, v2 ) , VertexZ( s, v2 ) , VertexU( s , v2 ) , VertexV( s, v2 ) ) ;copy normals VertexNormal ns , Nv0 , VertexNX( s, v0 ) , VertexNY( s, v0 ) , VertexNZ( s, v0 ) VertexNormal ns , Nv1 , VertexNX( s, v1 ) , VertexNY( s, v1 ) , VertexNZ( s, v1 ) VertexNormal ns , Nv2 , VertexNX( s, v2 ) , VertexNY( s, v2 ) , VertexNZ( s, v2 ) ;add triangle AddTriangle ns, Nv0, Nv1, Nv2 Next ;free tmp mesh as we don't need it FreeEntity tmp ;return new 2 surface mesh Return mesh End Function |