CSG talk

Blitz3D Forums/Blitz3D Programming/CSG talk

Coyote...wouldn't it be cool to make a simple csg modeler but only using the built in blitz3d primitives.

Check this code out. You can change the CreateCube() to any blitz3d primitive and it works well. If the csg function from the archives worked better, this could come together really fast with a ui by winblit3d.

Choose your primitive, choose the csg mode, a la maplet style. This would be a cool community project...but I don't have the time to coordinate it. =( I could definitely contribute to it tho.

Graphics3D 800,600,32,2
SetBuffer BackBuffer()

camera = CreateCamera()
PositionEntity camera,0,100,0
RotateEntity camera,60,0,0
light = CreateLight()

plane = CreatePlane()
EntityOrder plane,1
EntityColor plane,100,150,250
EntityPickMode plane,2



While Not KeyHit(1)
Cls

LMB = MouseHit(1)
LMH = MouseDown(1)

test = CameraPick( camera, MouseX(), MouseY() )

If test 

	If LMB=True And grab = 0
		xpos# = PickedX#()
		zpos# = PickedZ#()
		grab = 1
		mesh = CreateCube()
		PositionEntity mesh,xpos,0,zpos
	EndIf

	If LMH=True And grab = 1
		cx# = PickedX#()
		cz# = PickedZ#()
		
		PositionEntity mesh,(xpos+cx)/2,0,(zpos+cz)/2
		ScaleEntity mesh,(cx-xpos)/2,.001,(zpos-cz)/2
		EndIf
	EndIf

	If LMH=False And grab = 1
		;FlipMesh mesh
		grab = 2
	EndIf

	If grab = 2
		PositionEntity mesh,EntityX(mesh),(PickedZ()-cz)/2,EntityZ(mesh)
		ScaleEntity mesh,(cx-xpos)/2,(PickedZ()-cz)/2,(zpos-cz)/2
	EndIf
	
	If LMB=True And grab = 2 
		grab = 0
	EndIf


UpdateWorld
RenderWorld

Flip
Wend
End