CreateTree() Problems

Blitz3D Forums/Blitz3D Programming/CreateTree() Problems

Maybe try this:

Function CreateTree(file$,width#,Height)

tree = CreateMesh()

surf1 = CreateSurface(tree)

v0 = AddVertex(surf1,-1.0,-1.0,0,0,0)
v1 = AddVertex(surf1,1.0,-1.0,0,1,0)
v2 = AddVertex(surf1,1.0,1.0,0,1,0)
v3 = AddVertex(surf1,-1.0,1.0,0,0,1)

tri0 = AddTriangle(surf1,v0,v1,v2)
tri1 = AddTriangle(surf1,v0,v2,v3)

v4 = AddVertex(surf1,-1.0,0,-1.0,0,0)
v5 = AddVertex(surf1,1.0,0,-1.0,1,0)
v6 = AddVertex(surf1,1.0,0,1.0,1,1)
v7 = AddVertex(surf1,-1.0,0,1.0,0,1)

tri2 = AddTriangle(surf1,v4,v5,v6)
tri3 = AddTriangle(surf1,v4,v6,v7)

updatenormals tree
tex = Loadbrush(file$,4) ; using masked flag (4)
paintmesh tree,tex
entityfx tree,16 ; make visible from both sides
Return tree

End Function



This should create 2 crossed Quads that are visible from both sides. The texture uses the mask flag, this means all black pixels are transparent. So you'd need to use a texture that contains a tree image with black background.

No need for seperate surfaces as long as they use the same brush or texture. Added UV Coods to the AddVertex Commands.

I didn't test it, but it probably works. :)