CopyMesh and AddMesh problems

Blitz3D Forums/Blitz3D Beginners Area/CopyMesh and AddMesh problems

I have found that if you use CopyMesh or AddMesh on a source mesh that has a manually-added texture, the manually added texture doesn't get copied onto the new mesh.

However, if the source mesh was loaded using LoadMesh, and had a texture loaded as part of it, then that texture WILL get copied with CopyMesh and AddMesh.

This is causing problem with creating a dynamic texture for an entity that needs to be added to a mesh.

Graphics3D 1024,768

; Create the required camera and light
Global hCamera = CreateCamera()
Global hLight = CreateLight()
RotateEntity hLight,30,45,0

; Create a cube that will be used as the "master" cube for all other cubes to be copied from.
Global hPrototype = CreateCube()	;LoadMesh("yourtexturedmodel.x")
PositionEntity hPrototype,0,0,3	; put it in the back
hTex = CreateTexture(256,256)
SetBuffer TextureBuffer(hTex)
ClsColor 255,0,0
Cls
Text 0,0,"HERE IS TEXT"
SetBuffer BackBuffer()
EntityTexture hPrototype,hTex
FreeTexture hTex

; Create a mesh that will be assembled with parts.
Global hFullMesh = CreateMesh()
PositionEntity hFullMesh,2,0,0

; Create a new mesh from the prototype mesh.
Global hPart = CopyMesh(hPrototype)
PositionEntity hPart,-2,0,0

AddMesh hPart,hFullMesh


PositionEntity hCamera,0,3,-5
RotateEntity hCamera,30,0,0

Color 255,255,255

While Not KeyHit(1)
	TurnEntity hPrototype,0,.5,0
	TurnEntity hPart,0,.5,0
	TurnEntity hFullMesh,0,.5,0

	UpdateWorld
	RenderWorld

	Text 512,200,"Prototype",True
	Text 128,250,"CopyMesh() from Prototype",True
	Text 900,250,"AddMesh from copied mesh.",True

	Flip

	
Wend

FreeEntity hFullMesh
FreeEntity hPart


End