RenderWorld gives MAV

Blitz3D Forums/Blitz3D Programming/RenderWorld gives MAV

_PJ_(Posted 2010) [#1]
Here's the guts of a function which is supposed to 'snaphshot' the renders as frames for a texture.

Unfortunately, at RenderWorld, it breaks with an MAV error. Could it be just that my PC is lacking the VRam?

	CameraProjMode Camera,False
	Local TempCamera=CreateCamera()
	CameraViewport TempCamera,0,0,128,128
	Local TempAlien=CopyEntity(Master_Invaders[1])
	Local R=232,G=192,B=32
	Local X,Y,Z
	PositionEntity TempCamera,0,0,0,True
	PositionEntity TempAlien,0,0,2,True
	Local Frames
	Local Quad=CreateQuad()
	If (MasterExplosionTexture)
		FreeTexture MasterExplosionTexture
		MasterExplosionTexture=False
	End If
	MasterExplosionTexture=CreateTexture(128,128,777,15)
	Local PixelsX
	Local PixelsY
	Local Child
	Local MaxChildren=CountChildren(TempAlien)
	Local IterChildren
	Local FBuff=FrontBuffer()
	Local TBuff
	For Frames=0 To 14
		R=R+8-Frames
		G=G-4
		B=B-1
		If R<1 Then R=0
		If G<1 Then G=0
		If B<1 Then B=0
		If R>255 Then R=255
		If G>255 Then G=255
		If B>255 Then B=255
		TBuff=TextureBuffer(MasterExplosionTexture,Frames)
		For IterChildren=1 To MaxChildren
			Child=GetChild(TempAlien,IterChildren)
			X=EntityX(Child,True)
			Y=EntityY(Child,True)
			Z=EntityZ(Child,True)
			EntityColor Child,R,G,B
			MoveEntity Child,Sgn(X)*0.1,Sgn(Y)*0.1,Sgn(Z)*0.1
			ScaleMesh  Child,0.75,0.75,0.75
		Next
		UpdateWorld
		CaptureWorld
		RenderWorld
		Color R,G,B
		Oval 64-Frames,64-Frames,Frames Shl True,False
		Flip
		LockBuffer FBuff
		LockBuffer TextureBuffer(TBuff)
		For PixelsX=0 To 127
			For PixelsY=0 To 127
				CopyPixelFast (PixelsX,PixelsY,FBuff,PixelsX,PixelsY,TBuff)
			Next
		Next
		UnlockBuffer(TBuff)
		UnlockBuffer(FBuff)
	Next
	SetBuffer BackBuffer()
	CameraProjMode Camera,True
	FreeEntity TempAlien
	FreeEntity TempCamera
	Return Quad



Warner(Posted 2010) [#2]
Not sure. I've experienced a MAV on RenderWorld in 2 situations: 1) when using Sprites, on some machines. 2) when adding too much vertices/triangles to a surface. The above doesn't look like either one of them.
Maybe you could post a working sample. (Or in this case: a not-working example offcourse) That would make it easier to debug.


_PJ_(Posted 2010) [#3]
Well the entire thing is pretty big,

I'll try and cut it down as much as possible removing external resources etc. and post something more 'runnable' (though non-compiling) in a little while.

The above is the complete function, however. Al;l variables/handles NOT declared with Local are globals that are declared.

The Children of "Invader" are actually just primitive cubes, of which there are approximately 50.

"Camera" is the main camera but is disabled in this function. the snapshots are rendered to "TempCamera" which is only a temporary camera entity solely for grabbing the snapshot.

-----

One thing you do mention, Warner, that may be interesting, is the too many verts on screen. Wihlst it's not obvious here, there is a possibility other entities might be visible (at least to the renderer), so I will try repositioning the TempInvader, its children AND the TempCamera to somewhere WAY out of the general 'play area'. 0,0,0 is probably too cluttered with things :)


Warner(Posted 2010) [#4]
It should be simply the number of active (as in used by tris) vertices on a surface that gives a RenderWorld MAV. The following MAVs on my computer:
Graphics3D 800, 600, 0, 2
SetBuffer BackBuffer()

cam = CreateCamera()
MoveEntity cam, 0, 0, -15

mesh = CreateMesh()
surf = CreateSurface(mesh)

For i = 0 To 65536
	If p = 100 DebugLog i:p=0 Else p=p+1
	v0=AddVertex (surf, 0, 0, 0)
	v1=AddVertex (surf, 1, 0, 0)
	v2=AddVertex (surf, 1, 1, 0)
	AddTriangle surf, v0,v1,v2
Next

Repeat

	RenderWorld
	Text 0, 0, "Ok"
	Flip
	
Until KeyHit(1)

End



Jiffy(Posted 2010) [#5]
change the for... next to

v0=AddVertex (surf, 0, 0, 0)
For i = 1 To 32767;0 is a number
	If p = 100 DebugLog i:p=0 Else p=p+1
	v1=AddVertex (surf, 1, 0, 0)
	v2=AddVertex (surf, 1, 1, 0)
	AddTriangle surf, v0,v1,v2
	v0=v1
Next

tri limit might be 32768
vertex limit= 65536
I use 32767 because of the v0 vertex outside the loop