One surface

Blitz3D Forums/Blitz3D Programming/One surface

Jeroen(Posted 2004) [#1]
Hi!

Is it possible to convert a multiple surface mesh to a single sutface mesh? (I don't care how it looks texture wise, as long as the shape is the same)


big10p(Posted 2004) [#2]
Yes, as long as the mesh doesn't contain too many verts/tris to fit in a single surface. Just build the new mesh from scratch by iterating through all the verts/tris and copying them into the new mesh.


Rottbott(Posted 2004) [#3]
You could even save the texturing by combining the textures and adjusting the UVs accordingly, but you could potentially end up with some very large textures.


Jeroen(Posted 2004) [#4]
thanks guys. I'm not very good at manually building a mesh, I'm gonna take a shot at it!


Jeroen(Posted 2004) [#5]
based on some code by Sswift, I am trying to achieve this, but all meshes change in some sort of abstract cubism :(




Ross C(Posted 2004) [#6]
Does the addmesh commands not combine and create one surface? I'm sure it does, but you lose the texture info i think for all but one surface.


Stevie G(Posted 2004) [#7]
Yeah, addmesh will work as long as the surfaces share the same brush properties.


Rottbott(Posted 2004) [#8]
I would do it like this (untested):

Function CollapseMesh(Mesh)

	BaseSurface = GetSurface(Mesh, 1)
	For i = 2 To CountSurfaces(Mesh)
		S = GetSurface(Mesh, i)
		For j = 0 To CountTriangles(S) - 1

			V0 = TriangleVertex(S, j, 0)
			V1 = TriangleVertex(S, j, 1)
			V2 = TriangleVertex(S, j, 2)

			NV0 = AddVertex(BaseSurface, VertexX#(S, V0), VertexY#(S, V0), VertexZ#(S, V0), VertexU#(S, V0), VertexV#(S, V0))
			VertexNormal BaseSurface, NV0, VertexNX#(S, V0), VertexNY#(S, V0), VertexNZ#(S, V0)
			VertexColor BaseSurface, NV0, VertexRed#(S, V0), VertexGreen#(S, V0), VertexBlue#(S, V0), VertexAlpha#(S, V0)

			NV1 = AddVertex(BaseSurface, VertexX#(S, V1), VertexY#(S, V1), VertexZ#(S, V1), VertexU#(S, V1), VertexV#(S, V1))
			VertexNormal BaseSurface, NV1, VertexNX#(S, V1), VertexNY#(S, V1), VertexNZ#(S, V1)
			VertexColor BaseSurface, NV1, VertexRed#(S, V1), VertexGreen#(S, V1), VertexBlue#(S, V1), VertexAlpha#(S, V1)

			NV2 = AddVertex(BaseSurface, VertexX#(S, V2), VertexY#(S, V2), VertexZ#(S, V2), VertexU#(S, V2), VertexV#(S, V2))
			VertexNormal BaseSurface, NV2, VertexNX#(S, V2), VertexNY#(S, V2), VertexNZ#(S, V2)
			VertexColor BaseSurface, NV2, VertexRed#(S, V2), VertexGreen#(S, V2), VertexBlue#(S, V2), VertexAlpha#(S, V2)

			AddTriangle BaseSurface, NV0, NV1, NV2
		Next
	Next

End Function



Jeroen(Posted 2004) [#9]
w00t. Nice guys. Rottbott, looks good, but the mesh has still 23 surfaces. However, one texture is smeared all over the mesh.