April 25, 2019, 04:18:06 AM

Author Topic: Physics in OpenB3DMax?  (Read 251 times)

Offline Cosmo

  • Jr. Member
  • **
  • Posts: 15
Physics in OpenB3DMax?
« on: February 27, 2019, 04:31:02 PM »
Do you have to do it yourself or is there some library I can use?

Online markcwm

  • Sr. Member
  • ****
  • Posts: 361
Re: Physics in OpenB3DMax?
« Reply #1 on: February 28, 2019, 01:24:46 AM »
Well, there were some physics wrappers written for Minib3d but the more complete ones were either restricted, like the demo for Itmbin's brightrealm wrapper or Windows only like JV-ODE physics. There are a few free Newton wrappers around but I haven't really looked into it, as physics is kind of last on my todo list. For a ready-to-use cross-platform physics solution I believe AGK2 is what many folks are using.

Offline angros47

  • Jr. Member
  • **
  • Posts: 14
Re: Physics in OpenB3DMax?
« Reply #2 on: April 06, 2019, 08:57:52 PM »
OpenB3D features also some physics features itself, since it allows to use constraints, and to bind an entity to some constrained pivots, to simulate a rigid body

Online markcwm

  • Sr. Member
  • ****
  • Posts: 361
Re: Physics in OpenB3DMax?
« Reply #3 on: April 06, 2019, 09:45:55 PM »
Hi Angelo,

nice to see you back at SyntaxBomb. Did you ever write a demo of how to correctly set up constraints? I couldn't figure out how to use them.

Offline angros47

  • Jr. Member
  • **
  • Posts: 14
Re: Physics in OpenB3DMax?
« Reply #4 on: April 10, 2019, 08:51:35 PM »
Here is an old quick and dirty example:

Code: [Select]
#include "openb3d.bi"




screen 18,  32, , &h10002


Graphics3d 640,480,32,1,1

var camera=createcamera(0)
var cube=createcube()


dim piv(8) as any ptr
for i as integer=1 to 8
piv(i)=createpivot()
entitytype piv(i),1
entityradius piv(i),.01
next

positionentity piv(1),-1,-1,-1
positionentity piv(2), 1,-1,-1
positionentity piv(3),-1, 1,-1
positionentity piv(4), 1, 1,-1
positionentity piv(5),-1,-1, 1
positionentity piv(6), 1,-1, 1
positionentity piv(7),-1, 1, 1
positionentity piv(8), 1, 1, 1



for i as integer=1 to 8
actvector piv(i),0,-.01,0
actnewtonian piv(i),.9
for i2 as integer=i+1 to 8
createconstraint piv(i),piv(i2), entitydistance(piv(i),piv(i2))
next
next

createrigidbody cube,piv(1),piv(2),piv(3),piv(5)
fitmesh cube,0,0,0,1,1,1





var cube2=createcube()


dim piv2(8) as any ptr
for i as integer=1 to 8
piv2(i)=createpivot()
entitytype piv2(i),1
entityradius piv2(i),.01
next

positionentity piv2(1), 2,-1,-1
positionentity piv2(2), 4,-1,-1
positionentity piv2(3), 2, 1,-1
positionentity piv2(4), 4, 1,-1
positionentity piv2(5), 2,-1, 1
positionentity piv2(6), 4,-1, 1
positionentity piv2(7), 2, 1, 1
positionentity piv2(8), 4, 1, 1



for i as integer=1 to 8
actvector piv2(i),0,-.01,0
actnewtonian piv2(i),.9
for i2 as integer=i+1 to 8
createconstraint piv2(i),piv2(i2), entitydistance(piv2(i),piv2(i2))
next
next






createrigidbody cube2,piv2(1),piv2(2),piv2(3),piv2(5)
fitmesh cube2,0,0,0,1,1,1
updateworld
renderworld

entitytype cube,-2
entitytype cube2,-2

var plane=createplane()':scaleentity plane, 100,.1,100
entitytype plane,-2

moveentity plane,0,-4,15
entitycolor plane,255,0,0

collisions 1,2,1,3


var light=createlight()
positionentity light,5,5,5
pointentity light,cube
moveentity camera,0,2,-15
pointentity camera,cube

var s=createcube
positionentity s,3,-3,0
scaleentity s,2,1,2
entitytype s,-2
'turnentity plane,0,0,10

dim key as string
do




key=inkey
        if key=chr(255)+"H" then moveentity s,0,0,.1
        if key=chr(255)+"P" then moveentity s,0,0,-.1
        if key=chr(255)+"M" then moveentity s,.1,0,0
        if key=chr(255)+"K" then moveentity s,-.1,0,0
updateworld 1


renderworld
sleep 1
flip
flip
loop until key=chr(27)