Texturing with CreateMesh

Blitz3D Forums/Blitz3D Beginners Area/Texturing with CreateMesh

I'm really confused about to how to do this. I understand how the 00 10 01 11 system works - top left, top right, bottom left, bottom right - corners of the texture corrosponding to the corners of the mesh, but short of having 6 separate surfaces for a cube, how on Earth are you supposed to get the same image on each face? And if it can be done, and with only one surface and one texture, how are you supposed to figure out how to wrap it, when that - ow - really makes my brain hurt :D

If someone could download, modify, and repost this please, that would really help me a lot:
http://files.filefront.com/Texturing+with+CreateMeshzip/;12799767;/fileinfo.html

ScaleTexture probably

Edit: Oh I see you problem now, I've made a thing that creates 5 sided cubes with the same texture on each side, didn't know it could give anyone that big of a problem though lol.

Here's is code I'm using in my Gorilla game, the back of the cube has no face on it because it's a side scrolling game so I didn't need it. I also had to scale the texture by .5 on the Y axis to fit because of the way I set up the cube creation. The textures I'm using in my game are 512,1024 so I had to set the cubes so the fit a certain of the texture. Feel free to change it.



Graphics3D 800,600,0,2
SetBuffer BackBuffer()

Global Light = CreateLight()

Global elementtexture=LoadTexture("elementtexture.png",8)
	ScaleTexture elementtexture,1,.5
	
Global Camera = CreateCamera()
	PositionEntity Camera,0,0,-5

Global Ground = CreatePlane()
	PositionEntity Ground,0,-2,0

Local Piece.TYPE_Ground = FUNC_Create_Ground(0,0,0)

While Not KeyDown(1)
	
	TurnEntity Piece\E_Point,.25,.5,0
	
	UpdateWorld
	RenderWorld
	
	Flip
	
Wend
End



Type TYPE_Ground
	Field E_Point%,E_Texture%
	
	Field F_X#,F_Y#,F_Z#
	
	Field I_AngledMdl%
	Field I_Turn
	
	Field E_Left[3];Left Vertices
	Field E_Right[3];Right Vertices
	Field E_Top[3];Top Vertices
	Field E_Bottom[3];Bottom Vertices
	Field E_Front[3];Front Vertices
	Field E_Triangle[9];Triangles/Faces
	Field surfleft,surfright,surftop,surfbottom,surffront
End Type

Function FUNC_Create_Ground.TYPE_Ground(x#,y#,z#,mdl$=1,turn%=0)
	Local a.TYPE_Ground = New TYPE_Ground
	
	a\F_X = x
	a\F_Y = y
	a\F_Z = z
	
	a\I_Turn = turn
	
		;Complex Piece Creation
			a\E_Point = CreateMesh()
			PositionEntity a\E_Point,x,y,0,1
			
	Select mdl
			
			Case 1
			
			a\surfleft = CreateSurface(a\E_Point)
			a\surfright = CreateSurface(a\E_Point)
			a\surftop = CreateSurface(a\E_Point)
			a\surfbottom = CreateSurface(a\E_Point)
			a\surffront = CreateSurface(a\E_Point)
				
				;Left Vertices
				a\E_Left[0] = AddVertex(a\surfleft,-1,-1,1,1,.5);Bottom Back Vertex ; Front being closer to the camera
				a\E_Left[1] = AddVertex(a\surfleft,-1,-1,-1,0,.5);Bottom Front Vertex
				a\E_Left[2] = AddVertex(a\surfleft,-1,1,1,1,0);Top Front Vertex
				a\E_Left[3] = AddVertex(a\surfleft,-1,1,-1,0,0);Top Back Vertex
					
				;Left Triangles
					a\E_Triangle[0] = AddTriangle(a\surfleft,a\E_Left[0],a\E_Left[3],a\E_Left[1])
					a\E_Triangle[1] = AddTriangle(a\surfleft,a\E_Left[0],a\E_Left[2],a\E_Left[3])
					
				;Right Vertices
					a\E_Right[0] = AddVertex(a\surfright,1,-1,1,1,.5);Bottom Back Vertex
					a\E_Right[1] = AddVertex(a\surfright,1,-1,-1,0,.5);Bottom Front Vertex
					a\E_Right[2] = AddVertex(a\surfright,1,1,1,1,0);Top Front Vertex
					a\E_Right[3] = AddVertex(a\surfright,1,1,-1,0,0);Top Back Vertex
					
				;Right Triangles
					a\E_Triangle[2] = AddTriangle(a\surfright,a\E_Right[1],a\E_Right[2],a\E_Right[0])
					a\E_Triangle[3] = AddTriangle(a\surfright,a\E_Right[1],a\E_Right[3],a\E_Right[2])
					
				;Top Vertices
					a\E_Top[0] = AddVertex(a\surftop,-1,1,1,1,.5);Left Back Vertex
					a\E_Top[1] = AddVertex(a\surftop,-1,1,-1,0,.5);Left Front Vertex
					a\E_Top[2] = AddVertex(a\surftop,1,1,1,1,1);Right Front Vertex
					a\E_Top[3] = AddVertex(a\surftop,1,1,-1,0,1);Right Back Vertex
					
				;Top Triangles
					a\E_Triangle[4] = AddTriangle(a\surftop,a\E_Top[1],a\E_Top[2],a\E_Top[3])
					a\E_Triangle[5] = AddTriangle(a\surftop,a\E_Top[1],a\E_Top[0],a\E_Top[2])
					
				;Bottom Vertices
					a\E_Bottom[0] = AddVertex(a\surfbottom,-1,-1,1,1,.5);Left Back Vertex
					a\E_Bottom[1] = AddVertex(a\surfbottom,-1,-1,-1,0,.5);Left Front Vertex
					a\E_Bottom[2] = AddVertex(a\surfbottom,1,-1,1,1,1);Right Front Vertex
					a\E_Bottom[3] = AddVertex(a\surfbottom,1,-1,-1,0,1);Right Back Vertex
					
				;Bottom Triangles
					a\E_Triangle[6] = AddTriangle(a\surfbottom,a\E_Bottom[0],a\E_Bottom[1],a\E_Bottom[3])
					a\E_Triangle[7] = AddTriangle(a\surfbottom,a\E_Bottom[0],a\E_Bottom[3],a\E_Bottom[2])
					
				;Front Vertices
					a\E_Front[0] = AddVertex(a\surffront,-1,-1,-1,1,.5);Bottom Left Vertex
					a\E_Front[1] = AddVertex(a\surffront,1,-1,-1,0,.5);Bottom Right Vertex
					a\E_Front[2] = AddVertex(a\surffront,-1,1,-1,1,0);Top Left Vertex

					a\E_Front[3] = AddVertex(a\surffront,1,1,-1,0,0);Top Right Vertex
					
				;Front Triangles
					a\E_Triangle[8] = AddTriangle(a\surffront,a\E_Front[0],a\E_Front[3],a\E_Front[1])
					a\E_Triangle[9] = AddTriangle(a\surffront,a\E_Front[0],a\E_Front[2],a\E_Front[3])
					
			Case 2
				
				a\surfleft = CreateSurface(a\E_Point)
				a\surfright = CreateSurface(a\E_Point)
				a\surfbottom = CreateSurface(a\E_Point)
				a\surffront = CreateSurface(a\E_Point)
				
			If a\I_Turn = 0; /|
				;Left Vertices
					a\E_Left[0] = AddVertex(a\surfleft,-1,-1,1,1,.5);Left Bottom Back
					a\E_Left[1] = AddVertex(a\surfleft,-1,-1,-1,0,.5);Left Bottom Front 
					a\E_Left[2] = AddVertex(a\surfleft,1,1,1,1,1);Right Top Back 
					a\E_Left[3] = AddVertex(a\surfleft,1,1,-1,0,1);Right Top Front 
					
				;Left Triangles
					a\E_Triangle[0] = AddTriangle(a\surfleft,a\E_Left[0],a\E_Left[3],a\E_Left[1])
					a\E_Triangle[1] = AddTriangle(a\surfleft,a\E_Left[0],a\E_Left[2],a\E_Left[3])
					
				;Right Vertices
					a\E_Right[0] = AddVertex(a\surfright,1,-1,1,1,.5);Right Bottom Back 
					a\E_Right[1] = AddVertex(a\surfright,1,-1,-1,0,.5);Right Bottom Front
					a\E_Right[2] = AddVertex(a\surfright,1,1,1,1,1);Right Top Back 
					a\E_Right[3] = AddVertex(a\surfright,1,1,-1,0,1);Right Top Front 
					
				;Right Triangles
					a\E_Triangle[2] = AddTriangle(a\surfright,a\E_Right[1],a\E_Right[2],a\E_Right[0])
					a\E_Triangle[3] = AddTriangle(a\surfright,a\E_Right[1],a\E_Right[3],a\E_Right[2])
					
				;Bottom Vertices
					a\E_Bottom[0] = AddVertex(a\surfbottom,-1,-1,1,1,.5);Left Bottom Back 
					a\E_Bottom[1] = AddVertex(a\surfbottom,-1,-1,-1,0,.5);Left Bottom Front 
					a\E_Bottom[2] = AddVertex(a\surfbottom,1,-1,1,1,1);Right Bottom Back
					a\E_Bottom[3] = AddVertex(a\surfbottom,1,-1,-1,0,1);Right Bottom Front
					
				;Bottom Triangles
					a\E_Triangle[6] = AddTriangle(a\surfbottom,a\E_Bottom[0],a\E_Bottom[1],a\E_Bottom[3])
					a\E_Triangle[7] = AddTriangle(a\surfbottom,a\E_Bottom[0],a\E_Bottom[3],a\E_Bottom[2])
					
				;Front Vertices
					a\E_Front[0] = AddVertex(a\surffront,-1,-1,-1,1,.5);Left Bottom Front
					a\E_Front[1] = AddVertex(a\surffront,1,-1,-1,0,.5);Right Bottom Front
					a\E_Front[3] = AddVertex(a\surffront,1,1,-1,0,0);Right Top Front
					
				;Front Triangles
					a\E_Triangle[8] = AddTriangle(a\surffront,a\E_Front[0],a\E_Front[3],a\E_Front[1])
					
			ElseIf a\I_Turn = 1 ; |\
				;Left Vertices
					a\E_Left[0] = AddVertex(a\surfleft,-1,-1,1,1,.5);Left Bottom Back 
					a\E_Left[1] = AddVertex(a\surfleft,-1,-1,-1,0,.5);Left Bottom Front 
					a\E_Left[2] = AddVertex(a\surfleft,-1,1,1,1,1);Left Top Back 
					a\E_Left[3] = AddVertex(a\surfleft,-1,1,-1,0,1);Left Top Front
					
				;Left Triangles
					a\E_Triangle[0] = AddTriangle(a\surfleft,a\E_Left[0],a\E_Left[3],a\E_Left[1])
					a\E_Triangle[1] = AddTriangle(a\surfleft,a\E_Left[0],a\E_Left[2],a\E_Left[3])
					
				;Right Vertices
					a\E_Right[0] = AddVertex(a\surfright,1,-1,1,1,.5);Right Bottom Back 
					a\E_Right[1] = AddVertex(a\surfright,1,-1,-1,0,.5);Right Bottom Front
					a\E_Right[2] = AddVertex(a\surfright,-1,1,1,1,1);Left Top Back
					a\E_Right[3] = AddVertex(a\surfright,-1,1,-1,0,1);Left Top Front
					
				;Right Triangles
					a\E_Triangle[2] = AddTriangle(a\surfright,a\E_Right[1],a\E_Right[2],a\E_Right[0])
					a\E_Triangle[3] = AddTriangle(a\surfright,a\E_Right[1],a\E_Right[3],a\E_Right[2])
					
				;Bottom Vertices
					a\E_Bottom[0] = AddVertex(a\surfbottom,-1,-1,1,1,.5);Left Bottom Back 
					a\E_Bottom[1] = AddVertex(a\surfbottom,-1,-1,-1,0,.5);Left Bottom Front 
					a\E_Bottom[2] = AddVertex(a\surfbottom,1,-1,1,1,1);Right Bottom Back
					a\E_Bottom[3] = AddVertex(a\surfbottom,1,-1,-1,0,1);Right Bottom Front
					
				;Bottom Triangles
					a\E_Triangle[6] = AddTriangle(a\surfbottom,a\E_Bottom[0],a\E_Bottom[1],a\E_Bottom[3])
					a\E_Triangle[7] = AddTriangle(a\surfbottom,a\E_Bottom[0],a\E_Bottom[3],a\E_Bottom[2])
					
				;Front Vertices
					a\E_Front[0] = AddVertex(a\surffront,-1,-1,-1,1,.5);Left Bottom Front
					a\E_Front[1] = AddVertex(a\surffront,1,-1,-1,0,.5);Right Bottom Front
					a\E_Front[3] = AddVertex(a\surffront,-1,1,-1,0,0);Left Top Front
					
				;Front Triangles
					a\E_Triangle[8] = AddTriangle(a\surffront,a\E_Front[0],a\E_Front[3],a\E_Front[1])
					
			ElseIf a\I_Turn = 2; |/
				;Left Vertices
					a\E_Left[0] = AddVertex(a\surfleft,-1,-1,1,1,.5);Left Bottom Back 
					a\E_Left[1] = AddVertex(a\surfleft,-1,-1,-1,0,.5);Left Bottom Front 
					a\E_Left[2] = AddVertex(a\surfleft,-1,1,1,1,1);Left Top Back 
					a\E_Left[3] = AddVertex(a\surfleft,-1,1,-1,0,1);Left Top Front
					
				;Left Triangles
					a\E_Triangle[0] = AddTriangle(a\surfleft,a\E_Left[0],a\E_Left[3],a\E_Left[1])
					a\E_Triangle[1] = AddTriangle(a\surfleft,a\E_Left[0],a\E_Left[2],a\E_Left[3])
					
				;Top Vertices
					a\E_Right[0] = AddVertex(a\surfright,1,1,1,1,.5);Right Top Back
					a\E_Right[1] = AddVertex(a\surfright,1,1,-1,0,.5);Right Top Front
					a\E_Right[2] = AddVertex(a\surfright,-1,1,1,1,1);Left Top Back 
					a\E_Right[3] = AddVertex(a\surfright,-1,1,-1,0,1);Left Top Front
					
				;Top Triangles
					a\E_Triangle[2] = AddTriangle(a\surfright,a\E_Right[1],a\E_Right[2],a\E_Right[0])
					a\E_Triangle[3] = AddTriangle(a\surfright,a\E_Right[1],a\E_Right[3],a\E_Right[2])
					
				;Bottom Vertices
					a\E_Bottom[0] = AddVertex(a\surfbottom,-1,-1,1,1,.5);Left Bottom Back 
					a\E_Bottom[1] = AddVertex(a\surfbottom,-1,-1,-1,0,.5);Left Bottom Front 
					a\E_Bottom[2] = AddVertex(a\surfbottom,1,1,1,1,1);Right Top Back 
					a\E_Bottom[3] = AddVertex(a\surfbottom,1,1,-1,0,1);Right Top Front 
					
				;Bottom Triangles
					a\E_Triangle[6] = AddTriangle(a\surfbottom,a\E_Bottom[0],a\E_Bottom[1],a\E_Bottom[3])
					a\E_Triangle[7] = AddTriangle(a\surfbottom,a\E_Bottom[0],a\E_Bottom[3],a\E_Bottom[2])
					
				;Front Vertices
					a\E_Front[0] = AddVertex(a\surffront,-1,-1,-1,0,.5);Left Bottom Front 
					a\E_Front[1] = AddVertex(a\surffront,1,1,-1,1,0);Right Top Front
					a\E_Front[3] = AddVertex(a\surffront,-1,1,-1,0,0);Left Top Front
					
				;Front Triangles
					a\E_Triangle[8] = AddTriangle(a\surffront,a\E_Front[0],a\E_Front[3],a\E_Front[1])
					
			ElseIf a\I_Turn = 3; \|
				;Left Vertices
					a\E_Left[0] = AddVertex(a\surfleft,1,-1,1,1,.5);Right Bottom Back 
					a\E_Left[1] = AddVertex(a\surfleft,1,-1,-1,0,.5);Right Bottom Front
					a\E_Left[2] = AddVertex(a\surfleft,-1,1,1,1,1);Left Top Back 
					a\E_Left[3] = AddVertex(a\surfleft,-1,1,-1,0,1);Left Top Front
					
				;Left Triangles
					a\E_Triangle[0] = AddTriangle(a\surfleft,a\E_Left[0],a\E_Left[3],a\E_Left[1])
					a\E_Triangle[1] = AddTriangle(a\surfleft,a\E_Left[0],a\E_Left[2],a\E_Left[3])
					
				;Right Vertices
					a\E_Right[0] = AddVertex(a\surfright,1,1,1,1,.5);Right Top Back
					a\E_Right[1] = AddVertex(a\surfright,1,1,-1,0,.5);Right Top Front
					a\E_Right[2] = AddVertex(a\surfright,-1,1,1,1,1);Left Top Back
					a\E_Right[3] = AddVertex(a\surfright,-1,1,-1,0,1);Left Top Front
					
				;Right Triangles
					a\E_Triangle[2] = AddTriangle(a\surfright,a\E_Right[1],a\E_Right[2],a\E_Right[0])
					a\E_Triangle[3] = AddTriangle(a\surfright,a\E_Right[1],a\E_Right[3],a\E_Right[2])
					
				;Bottom Vertices
					a\E_Bottom[0] = AddVertex(a\surfbottom,1,1,1,1,.5);Right Top Back
					a\E_Bottom[1] = AddVertex(a\surfbottom,1,1,-1,0,.5);Right Top Front
					a\E_Bottom[2] = AddVertex(a\surfbottom,1,-1,1,1,1);Right Bottom Back
					a\E_Bottom[3] = AddVertex(a\surfbottom,1,-1,-1,0,1);Right Bottom Front
					
				;Bottom Triangles
					a\E_Triangle[6] = AddTriangle(a\surfbottom,a\E_Bottom[2],a\E_Bottom[3],a\E_Bottom[0])
					a\E_Triangle[7] = AddTriangle(a\surfbottom,a\E_Bottom[1],a\E_Bottom[0],a\E_Bottom[3])
					
				;Front Vertices
					a\E_Front[0] = AddVertex(a\surffront,1,-1,-1,0,.5);Right Bottom Front
					a\E_Front[1] = AddVertex(a\surffront,1,1,-1,1,0);Right Top Front
					a\E_Front[3] = AddVertex(a\surffront,-1,1,-1,0,0);Left Top Front
					
				;Front Triangles
					a\E_Triangle[8] = AddTriangle(a\surffront,a\E_Front[0],a\E_Front[3],a\E_Front[1])
					
			EndIf

				
				a\I_AngledMdl = 1
				
	End Select
			EntityFX a\E_Point,2
			
			UpdateComplexPieces()
			
			UpdateNormals a\E_Point
			
		;End of Complex Piece Creation
		
	EntityTexture a\E_Point,elementtexture
	PositionEntity a\E_Point,a\F_X,a\F_Y,a\F_Z
	
	Return a
End Function

Function UpdateComplexPieces()
	Local a.TYPE_Ground,b.TYPE_Ground
	
	For a.TYPE_Ground = Each TYPE_Ground
		For b.TYPE_Ground = Each TYPE_Ground
		If a\I_AngledMdl = 0 And b\I_AngledMdl = 0
			If EntityX(b\E_Point) = EntityX(a\E_Point) + 2;If second entity is to the right of first entity
				If (EntityY(b\E_Point) = EntityY(a\E_Point))
					ClearSurface b\surfleft
					ClearSurface a\surfright
				EndIf
			EndIf
			
			If EntityX(b\E_Point) = EntityX(a\E_Point) - 2;If second entity is to the left of first entity
				If (EntityY(b\E_Point) = EntityY(a\E_Point))
					ClearSurface b\surfright
					ClearSurface a\surfleft
				EndIf
			EndIf
			
			If EntityY(b\E_Point) = EntityY(a\E_Point) + 2;If second entity is above the first entity
				If (EntityX(b\E_Point) = EntityX(a\E_Point))
					ClearSurface b\surfbottom
					ClearSurface a\surftop
				EndIf					
			EndIf
			
			If EntityY(b\E_Point) = EntityY(a\E_Point) - 2;If second entity is under the first entity
				If (EntityX(b\E_Point) = EntityX(a\E_Point))
					ClearSurface b\surftop
					ClearSurface a\surfbottom
				EndIf
			EndIf
		EndIf
		
		
		
		
		If a\I_AngledMdl = 1 And b\I_AngledMdl = 0
			Select a\I_Turn 
				
				Case 0; /|
					
					If EntityX(b\E_Point) = EntityX(a\E_Point) + 2;If second entity is to the right of first entity
						If (EntityY(b\E_Point) = EntityY(a\E_Point))
							ClearSurface b\surfleft
							ClearSurface a\surfright
						EndIf
					EndIf
					
					If EntityY(b\E_Point) = EntityY(a\E_Point) - 2;If second entity is under the first entity
						If (EntityX(b\E_Point) = EntityX(a\E_Point))
							ClearSurface b\surftop
							ClearSurface a\surfbottom
						EndIf
					EndIf
					
				Case 1; |\
					
					If EntityX(b\E_Point) = EntityX(a\E_Point) - 2;If second entity is to the left of first entity
						If (EntityY(b\E_Point) = EntityY(a\E_Point))
							ClearSurface b\surfright
							ClearSurface a\surfleft
						EndIf
					EndIf
					
					If EntityY(b\E_Point) = EntityY(a\E_Point) - 2;If second entity is under the first entity
						If (EntityX(b\E_Point) = EntityX(a\E_Point))
							ClearSurface b\surftop
							ClearSurface a\surfbottom
						EndIf
					EndIf
					
				Case 2; |/
					
					If EntityX(b\E_Point) = EntityX(a\E_Point) - 2;If second entity is to the left of first entity
						If (EntityY(b\E_Point) = EntityY(a\E_Point))
							ClearSurface b\surfright
							ClearSurface a\surfleft
						EndIf
					EndIf
					
					If EntityY(b\E_Point) = EntityY(a\E_Point) + 2;If second entity is above the first entity
						If (EntityX(b\E_Point) = EntityX(a\E_Point))
							ClearSurface b\surfbottom
							ClearSurface a\surfright
						EndIf
					EndIf
					
				Case 3; \|
					
					If EntityX(b\E_Point) = EntityX(a\E_Point) + 2;If second entity is to the right of first entity
						If (EntityY(b\E_Point) = EntityY(a\E_Point))
							ClearSurface b\surfleft
							ClearSurface a\surfbottom
						EndIf
					EndIf
					
					If EntityY(b\E_Point) = EntityY(a\E_Point) + 2;If second entity is above the first entity
						If (EntityX(b\E_Point) = EntityX(a\E_Point))
							ClearSurface b\surfbottom
							ClearSurface a\surfright
						EndIf
					EndIf
					
			End Select
		EndIf
			
		Next
	Next
End Function


mesh=createmesh()
entityfx mesh,1+16 ;because I can't remember if blitz renders triangle vertices clockwise or anticlockwise
surf=createsurface(mesh)

;Side Back
v0=addvertex(surf,-1,-1,-1,0,0)
v1=addvertex(surf,-1,1,-1,0,1)
v2=addvertex(surf,1,1,-1,1,1)
v3=addvertex(surf,1,-1,-1,1,0)
addtriangle surf,v0,v1,v2
addtriangle surf,v2,v3,v0

;Side Front

v0=addvertex(surf,-1,-1,1,0,0)
v1=addvertex(surf,-1,1,1,0,1)
v2=addvertex(surf,1,1,1,1,1)
v3=addvertex(surf,1,-1,1,1,0)
addtriangle surf,v0,v1,v2
addtriangle surf,v2,v3,v0

;Side Top

v0=addvertex(surf,-1,1,-1,0,0)
v1=addvertex(surf,-1,1,1,0,1)
v2=addvertex(surf,1,1,1,1,1)
v3=addvertex(surf,1,1,-1,1,0)
addtriangle surf,v0,v1,v2
addtriangle surf,v2,v3,v0


;Side Bottom

v0=addvertex(surf,-1,-1,-1,0,0)
v1=addvertex(surf,-1,-1,1,0,1)
v2=addvertex(surf,1,-1,1,1,1)
v3=addvertex(surf,1,-1,-1,1,0)
addtriangle surf,v0,v1,v2
addtriangle surf,v2,v3,v0

;Side Left

v0=addvertex(surf,-1,-1,-1,0,0)
v1=addvertex(surf,-1,-1,1,0,1)
v2=addvertex(surf,-1,1,1,1,1)
v3=addvertex(surf,-1,1,-1,1,0)
addtriangle surf,v0,v1,v2
addtriangle surf,v2,v3,v0


;Side Right

v0=addvertex(surf,1,-1,-1,0,0)
v1=addvertex(surf,1,-1,1,0,1)
v2=addvertex(surf,1,1,1,1,1)
v3=addvertex(surf,1,1,-1,1,0)
addtriangle surf,v0,v1,v2
addtriangle surf,v2,v3,v0

entitytexture mesh,"yourtexturehandlehere" ;replace the "yourtexturehandlehere" with your texture handle.
'1 mesh, 6 sides, all 1 surface.




Can't test as I'm doing this from memory, don't have blitz in front of me but play around with it..

Blitz's native createcube already allows you to have the SAME texture on each cube face. It contains no shared vertices across each face ( i.e. 24 vertices , 12 triangles ) so should work just fine as is. Is there something I'm missing?

Yeah um, about that...my game engine sorta has some...Maya type features. Heh. So though it may appear to start as a cube, I'll be expecting more from it than just that. Currenly I have it working so each vertex can be manipulated with the mouse (yes, that was a mountain of code!) What isn't working is getting each side textured right. I realize I could do that with CreateCube, but of course that strips away the ability to manipulate each vertex.

Well I'm looking forward to trying all your suggestions so far, thanks!


I realize I could do that with CreateCube, but of course that strips away the ability to manipulate each vertex.



Not really, just find all the vertices which are under your cursor and move all 3 together.

You need unwelded vertices to texture each correctly I'm afraid so you have no option other than this.

Stevie

Sorry Gia, that was way over my head! Well, I still use that camera fixer you made for me. Thanks for trying to help anyway :)

Matty, I understand yours, but doesn't the method you're using make it impossible to use VertexCoords on anything but the most recently finished side? I mean, what you're doing is essentially like using a cement form. You reuse it on each newly created side, but you can't go back and "edit" already finished sides, right? Only the last one that was last created. I need to keep track of all vertexes, but also have the vertex and surface count be as small as possible, because my engine's already pretty huge with 32 elements to manage.

You can use any wallish texture for this example, just make sure it's named elementtexture and has the right extension. I think if I could get this to work pretty much like it does now, but so it affects three corners instead of just one, I could probably figure out the rest from there. Sorry for turning your v0s 1s 2s and 3s into vertex1s 2s 3s and 4s, but that's just more understandable for me!

Graphics3D 640,480,32,1
SetBuffer BackBuffer()

ArialBold=LoadFont("arial",14,1,0,0)
SetFont ArialBold
Color 127,127,127

camera=CreateCamera()
light=CreateLight()

mesh=CreateMesh()
elementtexture=LoadTexture("elementtexture.png")
MoveEntity mesh,0,0,5
EntityFX mesh,1+16
EntityAlpha mesh,.5
TurnEntity mesh,0,-30,0

vertex1height#=-1

surface=CreateSurface(mesh)

; Back
vertex1=AddVertex(surface,-1,-1,-1, 0,0)
vertex2=AddVertex(surface,-1, 1,-1, 0,1)
vertex3=AddVertex(surface, 1, 1,-1, 1,1)
vertex4=AddVertex(surface, 1,-1,-1, 1,0)
AddTriangle surface,vertex1,vertex2,vertex3
AddTriangle surface,vertex3,vertex4,vertex1

; Front
vertex1=AddVertex(surface,-1,-1, 1, 0,0)
vertex2=AddVertex(surface,-1, 1, 1, 0,1)
vertex3=AddVertex(surface, 1, 1, 1, 1,1)
vertex4=AddVertex(surface, 1,-1, 1, 1,0)
AddTriangle surface,vertex1,vertex2,vertex3
AddTriangle surface,vertex3,vertex4,vertex1

; Top
vertex1=AddVertex(surface,-1, 1,-1, 0,0)
vertex2=AddVertex(surface,-1, 1, 1, 0,1)
vertex3=AddVertex(surface, 1, 1, 1, 1,1)
vertex4=AddVertex(surface, 1, 1,-1, 1,0)
AddTriangle surface,vertex1,vertex2,vertex3
AddTriangle surface,vertex3,vertex4,vertex1

; Bottom
vertex1=AddVertex(surface,-1,-1,-1, 0,0)
vertex2=AddVertex(surface,-1,-1, 1, 0,1)
vertex3=AddVertex(surface, 1,-1, 1, 1,1)
vertex4=AddVertex(surface, 1,-1,-1, 1,0)
AddTriangle surface,vertex1,vertex2,vertex3
AddTriangle surface,vertex3,vertex4,vertex1

; Left
vertex1=AddVertex(surface,-1,-1,-1, 0,0)
vertex2=AddVertex(surface,-1,-1, 1, 0,1)
vertex3=AddVertex(surface,-1, 1, 1, 1,1)
vertex4=AddVertex(surface,-1, 1,-1, 1,0)
AddTriangle surface,vertex1,vertex2,vertex3
AddTriangle surface,vertex3,vertex4,vertex1

; Right
vertex1=AddVertex(surface, 1,vertex1height,-1, 0,0)
vertex2=AddVertex(surface, 1,-1, 1, 0,1)
vertex3=AddVertex(surface, 1, 1, 1, 1,1)
vertex4=AddVertex(surface, 1, 1,-1, 1,0)
AddTriangle surface,vertex1,vertex2,vertex3
AddTriangle surface,vertex3,vertex4,vertex1

; 1 mesh, 6 sides, all 1 surface.
EntityTexture mesh,elementtexture

While Not KeyHit(1)

If KeyDown(200) TurnEntity mesh, 1, 0, 0
If KeyDown(208) TurnEntity mesh,-1, 0, 0
If KeyDown(203) TurnEntity mesh, 0,-1, 0
If KeyDown(205) TurnEntity mesh, 0, 1, 0

If KeyDown(30) vertex1height=vertex1height+.05
If KeyDown(44) vertex1height=vertex1height-.05
VertexCoords surface,vertex1,1,vertex1height,-1

UpdateWorld
RenderWorld

Text 0,0,"'Matty's CreateCube style texturing for CreateMesh!' (still working on the name)"
Text 0,15,"Controls: directionals, a, and z.
Text 0,30,"vertex1height " +vertex1height

Flip
Wend
End


No, you can still access the vertices using the countvertices() command and iterating through each of the vertices attached to the surface.

Got it. Well, not what you just said, but I'll try that tonight. But I wrote this last night. You just need a wall texture to run it, like the last one.

Graphics3D 640,480,32,1
SetBuffer BackBuffer()

ArialBold=LoadFont("arial",14,1,0,0)
SetFont ArialBold
Color 127,127,127

camera=CreateCamera()
light=CreateLight()

mesh=CreateMesh()
elementtexture=LoadTexture("elementtexture.png")
MoveEntity mesh,0,0,5
EntityFX mesh,1+16
EntityAlpha mesh,.5
TurnEntity mesh,0,-30,0

; Top
topsurfacevertex1position#=-1
topsurfacevertex1height#=   1
topsurfacevertex1distance#= 1
topsurfacevertex2position#= 1
topsurfacevertex2height#=   1
topsurfacevertex2distance#= 1
topsurfacevertex3position#=-1
topsurfacevertex3height#=   1
topsurfacevertex3distance#=-1
topsurfacevertex4position#= 1
topsurfacevertex4height#=   1
topsurfacevertex4distance#=-1
topsurface=CreateSurface(mesh)
topsurfacevertex1=AddVertex(topsurface,topsurfacevertex1position,topsurfacevertex1height,topsurfacevertex1distance,0,0)
topsurfacevertex2=AddVertex(topsurface,topsurfacevertex2position,topsurfacevertex2height,topsurfacevertex2distance,1,0)
topsurfacevertex3=AddVertex(topsurface,topsurfacevertex3position,topsurfacevertex3height,topsurfacevertex3distance,0,1)
topsurfacevertex4=AddVertex(topsurface,topsurfacevertex4position,topsurfacevertex4height,topsurfacevertex4distance,1,1)
AddTriangle topsurface,topsurfacevertex1,topsurfacevertex2,topsurfacevertex3
AddTriangle topsurface,topsurfacevertex2,topsurfacevertex4,topsurfacevertex3

; Back
backsurfacevertex1position#=-1
backsurfacevertex1height#=   1
backsurfacevertex1distance#= 1
backsurfacevertex2position#= 1
backsurfacevertex2height#=   1
backsurfacevertex2distance#= 1
backsurfacevertex3position#=-1
backsurfacevertex3height#=  -1
backsurfacevertex3distance#= 1
backsurfacevertex4position#= 1
backsurfacevertex4height#=  -1
backsurfacevertex4distance#= 1
backsurface=CreateSurface(mesh)
backsurfacevertex1=AddVertex(backsurface,backsurfacevertex1position,backsurfacevertex1height,backsurfacevertex1distance,0,0)
backsurfacevertex2=AddVertex(backsurface,backsurfacevertex2position,backsurfacevertex2height,backsurfacevertex2distance,1,0)
backsurfacevertex3=AddVertex(backsurface,backsurfacevertex3position,backsurfacevertex3height,backsurfacevertex3distance,0,1)
backsurfacevertex4=AddVertex(backsurface,backsurfacevertex4position,backsurfacevertex4height,backsurfacevertex4distance,1,1)
AddTriangle backsurface,backsurfacevertex1,backsurfacevertex2,backsurfacevertex3
AddTriangle backsurface,backsurfacevertex2,backsurfacevertex4,backsurfacevertex3

; Left
leftsurfacevertex1position#=-1
leftsurfacevertex1height#=   1
leftsurfacevertex1distance#=-1
leftsurfacevertex2position#=-1
leftsurfacevertex2height#=   1
leftsurfacevertex2distance#= 1
leftsurfacevertex3position#=-1
leftsurfacevertex3height#=  -1
leftsurfacevertex3distance#=-1
leftsurfacevertex4position#=-1
leftsurfacevertex4height#=  -1
leftsurfacevertex4distance#= 1
leftsurface=CreateSurface(mesh)
leftsurfacevertex1=AddVertex(leftsurface,leftsurfacevertex1position,leftsurfacevertex1height,leftsurfacevertex1distance,0,0)
leftsurfacevertex2=AddVertex(leftsurface,leftsurfacevertex2position,leftsurfacevertex2height,leftsurfacevertex2distance,1,0)
leftsurfacevertex3=AddVertex(leftsurface,leftsurfacevertex3position,leftsurfacevertex3height,leftsurfacevertex3distance,0,1)
leftsurfacevertex4=AddVertex(leftsurface,leftsurfacevertex4position,leftsurfacevertex4height,leftsurfacevertex4distance,1,1)
AddTriangle leftsurface,leftsurfacevertex1,leftsurfacevertex2,leftsurfacevertex3
AddTriangle leftsurface,leftsurfacevertex2,leftsurfacevertex4,leftsurfacevertex3

; Right
rightsurfacevertex1position#= 1
rightsurfacevertex1height#=   1
rightsurfacevertex1distance#= 1
rightsurfacevertex2position#= 1
rightsurfacevertex2height#=   1
rightsurfacevertex2distance#=-1
rightsurfacevertex3position#= 1
rightsurfacevertex3height#=  -1
rightsurfacevertex3distance#= 1
rightsurfacevertex4position#= 1
rightsurfacevertex4height#=  -1
rightsurfacevertex4distance#=-1
rightsurface=CreateSurface(mesh)
rightsurfacevertex1=AddVertex(rightsurface,rightsurfacevertex1position,rightsurfacevertex1height,rightsurfacevertex1distance,0,0)
rightsurfacevertex2=AddVertex(rightsurface,rightsurfacevertex2position,rightsurfacevertex2height,rightsurfacevertex2distance,1,0)
rightsurfacevertex3=AddVertex(rightsurface,rightsurfacevertex3position,rightsurfacevertex3height,rightsurfacevertex3distance,0,1)
rightsurfacevertex4=AddVertex(rightsurface,rightsurfacevertex4position,rightsurfacevertex4height,rightsurfacevertex4distance,1,1)
AddTriangle rightsurface,rightsurfacevertex1,rightsurfacevertex2,rightsurfacevertex3
AddTriangle rightsurface,rightsurfacevertex2,rightsurfacevertex4,rightsurfacevertex3

; Front
frontsurfacevertex1position#=-1
frontsurfacevertex1height#=   1
frontsurfacevertex1distance#=-1
frontsurfacevertex2position#= 1
frontsurfacevertex2height#=   1
frontsurfacevertex2distance#=-1
frontsurfacevertex3position#=-1
frontsurfacevertex3height#=  -1
frontsurfacevertex3distance#=-1
frontsurfacevertex4position#= 1
frontsurfacevertex4height#=  -1
frontsurfacevertex4distance#=-1
frontsurface=CreateSurface(mesh)
frontsurfacevertex1=AddVertex(frontsurface,frontsurfacevertex1position,frontsurfacevertex1height,frontsurfacevertex1distance,0,0)
frontsurfacevertex2=AddVertex(frontsurface,frontsurfacevertex2position,frontsurfacevertex2height,frontsurfacevertex2distance,1,0)
frontsurfacevertex3=AddVertex(frontsurface,frontsurfacevertex3position,frontsurfacevertex3height,frontsurfacevertex3distance,0,1)
frontsurfacevertex4=AddVertex(frontsurface,frontsurfacevertex4position,frontsurfacevertex4height,frontsurfacevertex4distance,1,1)
AddTriangle frontsurface,frontsurfacevertex1,frontsurfacevertex2,frontsurfacevertex3
AddTriangle frontsurface,frontsurfacevertex2,frontsurfacevertex4,frontsurfacevertex3

; Bottom
bottomsurfacevertex1position#=-1
bottomsurfacevertex1height#=  -1
bottomsurfacevertex1distance#= 1
bottomsurfacevertex2position#= 1
bottomsurfacevertex2height#=  -1
bottomsurfacevertex2distance#= 1
bottomsurfacevertex3position#=-1
bottomsurfacevertex3height#=  -1
bottomsurfacevertex3distance#=-1
bottomsurfacevertex4position#= 1
bottomsurfacevertex4height#=  -1
bottomsurfacevertex4distance#=-1
bottomsurface=CreateSurface(mesh)
bottomsurfacevertex1=AddVertex(bottomsurface,bottomsurfacevertex1position,bottomsurfacevertex1height,bottomsurfacevertex1distance,0,0)
bottomsurfacevertex2=AddVertex(bottomsurface,bottomsurfacevertex2position,bottomsurfacevertex2height,bottomsurfacevertex2distance,1,0)
bottomsurfacevertex3=AddVertex(bottomsurface,bottomsurfacevertex3position,bottomsurfacevertex3height,bottomsurfacevertex3distance,0,1)
bottomsurfacevertex4=AddVertex(bottomsurface,bottomsurfacevertex4position,bottomsurfacevertex4height,bottomsurfacevertex4distance,1,1)
AddTriangle bottomsurface,bottomsurfacevertex1,bottomsurfacevertex2,bottomsurfacevertex3
AddTriangle bottomsurface,bottomsurfacevertex2,bottomsurfacevertex4,bottomsurfacevertex3

; 1 mesh, 6 sides, all 1 surface.
EntityTexture mesh,elementtexture

While Not KeyHit(1)

If KeyDown(200) TurnEntity mesh, 1, 0, 0
If KeyDown(208) TurnEntity mesh,-1, 0, 0
If KeyDown(203) TurnEntity mesh, 0,-1, 0
If KeyDown(205) TurnEntity mesh, 0, 1, 0

If KeyDown(44)
topsurfacevertex2height=topsurfacevertex2height+.05
topsurfacevertex4height=topsurfacevertex4height+.05
frontsurfacevertex2height=frontsurfacevertex2height+.05
backsurfacevertex2height=frontsurfacevertex2height+.05
rightsurfacevertex1height=rightsurfacevertex1height+.05
rightsurfacevertex2height=rightsurfacevertex2height+.05
EndIf

If KeyDown(45)
topsurfacevertex2height=topsurfacevertex2height-.05
topsurfacevertex4height=topsurfacevertex4height-.05
frontsurfacevertex2height=frontsurfacevertex2height-.05
backsurfacevertex2height=frontsurfacevertex2height-.05
rightsurfacevertex1height=rightsurfacevertex1height-.05
rightsurfacevertex2height=rightsurfacevertex2height-.05
EndIf

VertexCoords topsurface,topsurfacevertex2,topsurfacevertex2position,topsurfacevertex2height,topsurfacevertex2distance
VertexCoords topsurface,topsurfacevertex4,topsurfacevertex4position,topsurfacevertex4height,topsurfacevertex4distance
VertexCoords frontsurface,frontsurfacevertex2,frontsurfacevertex2position,frontsurfacevertex2height,frontsurfacevertex2distance
VertexCoords backsurface,backsurfacevertex2,backsurfacevertex2position,backsurfacevertex2height,backsurfacevertex2distance
VertexCoords rightsurface,rightsurfacevertex1,rightsurfacevertex1position,rightsurfacevertex1height,rightsurfacevertex1distance
VertexCoords rightsurface,rightsurfacevertex2,rightsurfacevertex2position,rightsurfacevertex2height,rightsurfacevertex2distance

UpdateWorld
RenderWorld

Text 0,0,"'Matty's CreateCube style texturing for CreateMesh!' (still working on the name)"
Text 0,15,"Controls: directionals, and z and x.

Flip
Wend
End


Okay, here's the thing. I don't actually mind writing tedious code like this believe it or not. I like getting a good coffee buzz on and basically just duplicating everything over and over til it's done. The only thing I'm worried about is, the above code is for just one level element, and my engine will have 32, plus a few more to be used as area change triggers, door openers, etc., all told about 50 elements. Like I said, I don't mind coding all that, but wouldn't all that create some lag? Or is 1200 vertexes 1200 vertexes either way? What I mean is, is there a difference in speed between a level made up of normal meshes totaling 1200, and one made up of highly editable ones like mine totaling 1200? The reason I'm wondering that is not so much because I'm worried about slowdown while editing, but because when an area's done and being played, the vertexes and surfaces would all still have the same long names. I like them to be descriptive since there's so much to keep track of, but would all those names piled up cause problems, or is that nothing to a processor?

Okay, this concludes my embarrassing post for today! :)

The PC cares not for your lengthy variable names - it does not matter what you name your variables the PC doesn't notice any difference whether I call something "x" or "thisisthexvariable" and so on.

Great. Always wondered about that.