OpenB3d does not require any setup (assuming you already have FB installed). Just copy OpenB3D.dll (windows) or libOpenB3D.so (linux) in the same directory of your project, with the file openb3d.bi. The file 2d.bi is optional: normally, in FreeBasic, 2d commands doesn't work on opengl (so, when you use OpenB3d, you can't use commands like LINE, CIRCLE and so on; the file 2d.bi allows you to use them).
There is only one CSG command: MeshCSG (mesh1, mesh2, operator)
The operator can be 0 (subtract), 1 (add --- default), 2 (intersect)
Here is a demo:
#include "openb3d.bi"
screen 18, 32, , &h02
Graphics3d 640,480,32,1,1
var camera=createcamera(0)
var tube=Createcylinder(16)
scaleentity tube,10,50,10
var tube2=Createcylinder(16)
scaleentity tube2,10,50,10
rotateentity tube2,0,0,90
var cs=meshcsg(tube, tube2)
scaleentity tube,8,50,8
scaleentity tube2,8,50,8
var cs2=meshcsg(tube, tube2)
cs=meshcsg(cs, cs2,0)
'moveentity cs,0,0,15
fitmesh cs,-1,-1,-1,2,2,2,1
scaleentity cs,5,5,5,0
moveentity cs,0,0,15
dim a as single
dim key as string
var light=createlight()
positionentity light,5,5,5
pointentity light, tube
freeentity tube
freeentity tube2
do
'EntityTexture cube,tex',a
a=a+.01':if a>30 then a=0
'setfloat shader, "sTime",a
key=inkey
if key=" " then moveentity camera,0,0,0.1
if key=chr(255)+"H" then turnentity cs,1,0,0
if key=chr(255)+"P" then turnentity cs,-1,0,0,0
if key=chr(255)+"M" then turnentity cs,0,-1,0,0
if key=chr(255)+"K" then turnentity cs,0,1,0,0
updateworld 1
renderworld
sleep 1
flip
loop until key=chr(27)
You should get two crossing pipes: a simple mesh, but very hard to draw without CSG operations.
|