Painting a Mesh/Surface

Blitz3D Forums/Blitz3D Programming/Painting a Mesh/Surface

GeordieB(Posted 2004) [#1]
Can anyone tell me why the below code wont actually show the texture or colour ive applied to this mesh/surface? all i get is my black shape....

--------------------------------
tstmesh=CreateMesh()
tstsur=CreateSurface(tstmesh)
v0=AddVertex(tstsur,0,10,0)
v1=AddVertex(tstsur,30,60,0)
v2=AddVertex(tstsur,60,15,0)

v3=AddVertex(tstsur,60,10,40)

v4=AddVertex(tstsur,0,10,40)

AddTriangle(tstsur,v0,v1,v2)
AddTriangle(tstsur,v2,v1,v3)
AddTriangle(tstsur,v1,v4,v3)
AddTriangle(tstsur,v1,v0,v4)

AddTriangle(tstsur,v0,v3,v4)
AddTriangle(tstsur,v3,v0,v2)

UpdateNormals(tstmesh)

PaintSurface(tstsur,wallbrush2)
PaintMesh(tstmesh,wallbrush2)
--------------------------------
tearing my hair out here :)

Cheers


jfk EO-11110(Posted 2004) [#2]
You need to define the U and V Coordinates with the AddVertex Commands. If you don't, all UVs are zero, so the texture will stretch across pixel 0,0 only.

UVs are the Coordinates on the texture, their values are from 0.0 to 1.0 (or higher if you want them to tile). So a Triangle needs 3 UV Coordinates to know how it should be texturemapped.