Problem converting from Blitz3D...

BlitzMax Forums/MiniB3D Module/Problem converting from Blitz3D...

SLotman(Posted 2009) [#1]
This is the original B3D code:


Here's the BlitzMax code:


I don't know why, but on BlitzMax/miniB3D the trail keeps disappearing with no apparent reason. Can anyone please help me and pinpoint what I'm doing wrong?


xlsior(Posted 2009) [#2]
No idea why it disappears, but I did notice that it comes back if you change directions: Go forward until the trail disappears. Then go backwards, until THAT trail disappears. Now going forward again the trail re-appears.


SLotman(Posted 2009) [#3]
Yeah, keeping it "turning" non stop, also makes the trail appears for a little while... O_o


SLotman(Posted 2009) [#4]
It's a bug on miniB3D!

Adding meshcullradius(t.id,10000) before the "next" on UpdateTrails fixes it, forcing an enormous cull radius on the updated mesh.

miniB3D is culling the mesh out, even the brush having BrushFX 16 (no culling). Still have to dig deeper into the code to fix this though...

EntityFX 16 has no effect either... are those not implemented?


SLotman(Posted 2009) [#5]
I found a partial solution. Open TGlobal.bmx, go to RenderCamera and change:

			Local inview%=cam.EntityInFrustum(mesh)


to

			' Perform frustum cull			
			Local inview%

			If ((mesh.brush.fx And 16) = 16) Then 
			   inview=True
			Else
			   inview=cam.EntityInFrustum(mesh)
			End If


Now setting EntityFX 16 works, but BrushFX won't... and I don't have a clue why.


SLotman(Posted 2009) [#6]
Now it get even more confusing!

this works:
	t.id = CreateMesh()
	t.brush = CreateBrush()

	BrushFX t.id.brush,2+16	
	BrushBlend t.brush,3

	t.surface = CreateSurface(t.id,t.brush)


but this won't (only on bmax, on b3d it does!):
	t.id = CreateMesh()
	t.brush = CreateBrush()

	BrushFX t.brush,2+16	
	BrushBlend t.brush,3

	t.surface = CreateSurface(t.id,t.brush)


Apparently, CreateSurface does not relate t.brush with t.id, and it's creating a new brush, while on B3D it just sets the brush from id (or overwrites it with the new one)

Edit: Yes, it is some relational thing going on. doing like this:

	
       ';Create mesh And set properties
	t.id = CreateMesh()
	t.brush = CreateBrush()

	BrushFX t.brush,2+16	
	BrushBlend t.brush,3
	
	t.surface = CreateSurface(t.id,t.brush)
	
	PaintEntity t.id,t.brush

Also works! Maybe this PaintEntity line should be added to CreateSurface?

Even a simple "t.id.brush = t.brush" (instead of PaintEntity) solves this issue...


SLotman(Posted 2009) [#7]
Finally!

Besides the fix on TGlobal.bmx and RenderCamera, this is also needed:

on TMesh.bmx, on CreateSurface change:

		If bru<>Null
			surf.brush=bru.Copy()
		EndIf


to:

		If bru<>Null
		   surf.brush=bru.Copy()
	           brush = bru.Copy()
		EndIf


And the code from Blitz3D will behave as expected. Phew!