couple of silly B3D questions...

Blitz3D Forums/Blitz3D Programming/couple of silly B3D questions...

My understanding is that every new object creates a new surface, regardless of whether they share the same texture and flags. In order to do a single surface, they need to be attatched into one object.


This code doesn't quite work, since it only uses the texture of cube 1 after using addmesh, but perhaps someone can fill in the blanks for us.


Graphics3D 640,480,0,2

; create a texture (blue checker)
tex = CreateTexture(128,128)
SetBuffer  TextureBuffer(tex)
Color 255,255,255
Rect 0,0,128,128,1
Color 0,0,255
Rect 0,0,64,64,1
Rect 64,64,128,128,1

; create a second texture (red checker)
tex2 = CreateTexture(128,128)
SetBuffer  TextureBuffer(tex2)
Color 255,255,255
Rect 0,0,128,128,1
Color 255,0,0
Rect 0,0,64,64,1
Rect 64,64,128,128,1

SetBuffer BackBuffer()

cube = CreateCube()
EntityTexture cube,Tex ;assign blue checker

cube2 = CreateCube()
PositionMesh cube2,3,0,0
EntityTexture cube2,Tex2 ;assign red checker

; combine to a single mesh. comment out these two lines to see what it should look like
AddMesh cube2,cube
FreeEntity cube2

surfcount  = CountSurfaces (cube)

cam = CreateCamera()
PositionEntity cam,0,0,-5

While Not KeyHit(1)
	RenderWorld()
	Text 10,10,"surface count of cube1: " + surfcount
	Flip
Wend 


This code shows up as a single surface, BUT,...
1. you cannot count surfaces across multiple objects. (does this mean multiple objects=multiple surfaces? I think so)
2. when I merge the two objects into one it shows 1 surface, but the second texture is lost in that example, so it is not a valid test. Can someone make that work?