picked to type

Blitz3D Forums/Blitz3D Beginners Area/picked to type

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

perhaps some more info would be more helpful...

Here is a test function that I am using to create the "walls" (there are many types, this is the basic block, without any special things)

Function add_wall(x,y,z,mesh)
	Local mesh1 = CreateMesh()
	Local surf1 = CreateSurface(mesh1)
	Local vbtr = AddVertex(surf1,x+5,y-7.5,z+5)
	Local vbtl = AddVertex(surf1,x-5,y-7.5,z+5)
	Local vbbr = AddVertex(surf1,x+5,y-7.5,z-5)
	Local vbbl = AddVertex(surf1,x-5,y-7.5,z-5)
	Local vttl = AddVertex(surf1,x-5,y+7.5,z+5)
	Local vttr = AddVertex(surf1,x+5,y+7.5,z+5)
	Local vtbl = AddVertex(surf1,x-5,y+7.5,z-5)
	Local vtbr = AddVertex(surf1,x+5,y+7.5,z-5)
	
	AddTriangle(surf1,vbbl,vbtr,vbtl)	;bottom
	AddTriangle(surf1,vbtr,vbbl,vbbr)	;bottom
	AddTriangle(surf1,vbtl,vttl,vbbl)	;left
	AddTriangle(surf1,vtbl,vbbl,vttl)	;left
	AddTriangle(surf1,vtbl,vtbr,vbbr)	;front
	AddTriangle(surf1,vbbr,vbbl,vtbl)	;front
	AddTriangle(surf1,vbbr,vtbr,vttr)	;right
	AddTriangle(surf1,vttr,vbtr,vbbr)	;right
	AddTriangle(surf1,vttr,vttl,vbtl)	;back
	AddTriangle(surf1,vbtl,vbtr,vttr)	;back
	AddTriangle(surf1,vttl,vttr,vtbr)	;top
	AddTriangle(surf1,vtbr,vtbl,vttl)	;top
	
	AddMesh mesh1,mesh
End Function


Not shown, but I will assign from a mesh two of the triangles to be "clickable", and store their address in an array of types representing their position. I have two ways of implementing finding which triangle was clicked: One would be two create everything in order, following the array, and then take whatever the index returned from a pick and divide by two (round down), then convert the one dimensional array info into my two dimensional array, to find the type that it is in. Whenever a block is created or destroyed I would have to delete everything and re-create the mesh all over again. The other method would be to loop through the array and check every triangle against the picked one and find a match.

I hope some of this made sense...