..CSG operations..

BlitzMax Forums/MiniB3D Module/..CSG operations..

Naughty Alien(Posted 2013) [#1]
Hi guys..im curious, does minib3d have csg operations in its feature list?


simonh(Posted 2013) [#2]
Nope, 'fraid not.


angros47(Posted 2013) [#3]
OpenB3d (a fork of iMiniB3d) has CSG operations (union, subtraction, intersection), you can use it.


Zethrax(Posted 2013) [#4]
The link for OpenB3d seems to be: http://minib3d.sourceforge.net/

If you google 'OpenB3d' there seems to be a lot of language wrappers available for it too.


Naughty Alien(Posted 2013) [#5]
Thank you guys very much. I cant see any tutorial, how to setup OpenB3D with FB. Also, is there any full list of commands supported for CSG operations, with some example maybe?


Kryzon(Posted 2013) [#6]
If you're going to ask FreeBasic questions, there's an external forum for that software.
Note I don't mean to be rude, it's just that there's really a specialized forum on it, with a thread on people figuring out how to build with this library etc. and you'll get better help.


angros47(Posted 2013) [#7]
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.


Naughty Alien(Posted 2013) [#8]
..thank you very much angros..that worked well