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