Textures on a mesh/surface/triangle?

Blitz3D Forums/Blitz3D Beginners Area/Textures on a mesh/surface/triangle?

Gauge(Posted 2003) [#1]
Okay so far i can creat ea "cube" ,etc mesh and texture it, but using Addvertex, addsurface, add mesh whenever i try to paintmesh, entitytexture, paintsurface, it all appears as 1 color. The texture i'm using is black/red checkerboard? Im guessing its only painted one pixel of it?
heres my code...
Graphics3D 800,600,16,3
SetBuffer BackBuffer()
light=CreateLight()
RotateEntity light,90,0,0
world=CreateMesh()
surf=CreateSurface(world)

v1=AddVertex(surf,0,10,0)
v2=AddVertex(surf,10,10,0)
v3=AddVertex(surf,10,0,0)
tri=AddTriangle(surf,v1,v2,v3)
surf2=CreateSurface(world)
v4=AddVertex(surf2,0,0,0)
v5=AddVertex(surf2,0,10,0)
v6=AddVertex(surf2,10,0,0)
tri2=AddTriangle(surf2,v5,v6,v4)
cam = CreateCamera()
UpdateNormals world
PositionEntity cam,0,2,-15
brush=LoadTexture("c:\blitz\checker.bmp")
EntityTexture world,brush
RenderWorld
Flip

WaitKey()
End



Sunteam Software(Posted 2003) [#2]
The most useful thing to remember (or learn about) is UV texturing. If you have a look at the AddVertex command you'll see optional u,v,w components. The U and V is the most important for texturing as they determine the positioning of textures on surfaces. So for example a surface on a cube, let's say one side of the cube, has four vertices. Therefore to be textured correctly the U and V coords should be 0,0 for top left and 1,1 for bottom right ala:

0,0-------1,0
|
|
|
|
0,1-------1,1

Hope that helps.

PS - I never used the w component, I'm sure it has some use but it isn't required to get the texturing working.


Gabriel(Posted 2003) [#3]
The manual says the W component is there for future compatibiity. Maybe Mark used it for something, but I've never used it either.