minib3d not working with max2d?

BlitzMax Forums/MiniB3D Module/minib3d not working with max2d?

Pragun(Posted 2007) [#1]
hi guys..
i've been trying a bunch of stuff lately but i can't get max2d and minib3d to work together. i thought they were compatible but with max2d commands...the 3d scene disappears. ideas?

am i using a bad (old) module?


*(Posted 2007) [#2]
klepto's version allows Max2d in MiniB3d


Dreamora(Posted 2007) [#3]
BUT: 2D commands are under the same restriction as in B3D: Only after renderworld, otherwise 2D is cleared off again. (and you will most likely need to use alphablend, otherwise 3D stuff is "overwritten"


Chris C(Posted 2007) [#4]
no thats not correct, with rendermode you can do multiple renders on the same frame or mix and match 2d as you want...

CameraClsMode camera,cls_color,cls_zbuffer
Parameters:
camera - camera handle
cls_color - true to clear the color buffer, false not to
cls_zbuffer - true to clear the z-buffer, false not to

you may have to use a blend mode depending on the effect you want to achieve, but not unnecessarily


Pragun(Posted 2007) [#5]
hi guys
thanks for the responses.

i am using klepto's version and have been trying this code snippet...

Import sidesign.minib3d

Strict

Local width=640,height=480,depth=16,mode=0

Graphics3D width,height,depth,mode

Local cam:TCamera=CreateCamera()
CameraRange cam,.5,500
PositionEntity cam,0,10,-10

Local light:TLight=CreateLight(1)
RotateEntity light,90,0,0

Local mesh:TMesh=LoadMesh("test.b3d")
ScaleEntity mesh,10,10,10

' create mesh octree - makes collision detection faster (MiniB3D only)
CreateOctree(mesh,200,5)

' set camera entity type to 1
EntityType cam,1

' set camera radius as it's the source collision entity
EntityRadius cam,1

' set mesh entity type to 2
EntityType mesh,2

' use collisions command to enable colliisons between entity type 1 and 2, with reponse 4
Collisions 1,2,4,2

' used by camera code
Local mxs#=0
Local mys#=0
Local move#=0.5
MouseXSpeed() ' flush
MouseYSpeed() ' flush

' used by fps code
Local old_ms=MilliSecs()
Local renders
Local fps

While Not KeyDown(KEY_ESCAPE)		

	If KeyHit(KEY_ENTER) Then DebugStop

	'' control camera
	
	' mouse look
	
	mxs#=mxs#+(MouseXSpeed()/5.0)
	mys#=mys#+(MouseYSpeed()/5.0)

	RotateEntity cam,mys#,-mxs#,0

	MoveMouse width/2,height/2
	MouseXSpeed() ' flush
	MouseYSpeed() ' flush

	' move camera forwards/backwards/left/right with cursor keys
	
	If KeyDown(KEY_UP)=True Then MoveEntity cam,0,0,move# ' move camera forward
	If KeyDown(KEY_DOWN)=True Then MoveEntity cam,0,0,-move# ' move camera back

	If KeyDown(KEY_LEFT)=True Then MoveEntity cam,-move#,0,0 ' move camera left
	If KeyDown(KEY_RIGHT)=True Then MoveEntity cam,move#,0,0 ' move camera right

	''

	UpdateWorld
	RenderWorld

	renders=renders+1

	' calculate fps
	If MilliSecs()-old_ms>=1000
		old_ms=MilliSecs()
		fps=renders
		renders=0
	EndIf
	SetBlend AlphaBlend
	DrawText "FPS: "+String(fps),0,0
	
	SetAlpha 0.5
	
	If KeyDown(Key_Space)
	SetColor 255,0,0
	
	DrawRect 30,30,300,300
	EndIf
	
	SetColor 255,255,255

	Flip
	
Wend
End


but the whole object disappears unless i comment out between renderworld and flip


Chris C(Posted 2007) [#6]
Give this a try ;)



Pragun(Posted 2007) [#7]
cool, thanks chris...
but what's the main reason behind your modifications working and the initial code not working?


Pragun(Posted 2007) [#8]
whoops...my bad...thanks!