Today I was trying to use gg.irrBMax mod by gman with Newton mod by thierry-myke and I came to acomplish the first tutorial of newton(I hope so).
just copy paste the code and be sure to have properly installed gg.irrBMax and Newton.PUB
just copy paste the code and be sure to have properly installed gg.irrBMax and Newton.PUB
Strict Framework PUB.Newton Import GG.IrrBMax Local nWorld:Byte Ptr = NewtonCreate(Null , Null) Local collision:Byte Ptr = NewtonCreateBox(nWorld , 1.0 , 1.0 , 1.0 , Null) Local box:Byte Ptr = newtonCreateBody(nWorld , collision) NewtonBodySetMassMatrix(box , 1.0 , 1.0 , 1.0 , 1.0) Local device:T_irrIrrlichtDevice = T_irrIrrlichtDevice.create(EDT_OPENGL , T_irrDimension2d_s32.create(640 , 480) , 16 , False , False , False , 0) Local driver:T_irrIVideoDriver = device.getVideoDriver() Local smgr:T_IrrISceneManager = device.getSceneManager() Local node:T_irrISceneNode = smgr.addTestSceneNode(50) 'node.setPosition(T_irrVector3df.createFromVals(100 , 20 , 30)) 'node.setRotation(T_irrVector3df.createFromVals(10 , 20 ,30)) Local mat:Float[16] T_irrGetMatrix(node ,mat) newtonBodySetMatrix(box , Varptr Mat[0]) Local Omega:Float[] = [5.0 , 5.0 , 5.0] newtonBodySetOmega(box , Varptr Omega[0]) smgr.addLightSceneNode(0, T_irrVector3df.createFromVals(0 , 100 , 0)) Local camera:T_irrICameraSceneNode = smgr.addCameraSceneNodeFPS() camera.setPosition(T_irrVector3df.createFromVals(0,0,-150)) While (device.run()) NewtonUpdate(nWorld , MilliSecs()) NewtonBodyGetMatrix(box , Varptr Mat[0]) T_irrSetMatrix(node , Mat) driver.beginScene(True , True , T_irrSColor.createFromVals(0,200 , 200 , 200)) smgr.drawAll() driver.endScene() Wend device.drop() For Local i:Int = 0 To 15 Print Mat[i] Next Function T_irrGetMatrix(NSceneNode:T_irrISceneNode , NewtonMat:Float[]) Local Euler:Float[3] Euler[0] = NSceneNode.getRotation().getX() * (Pi / 180.0) Euler[1] = NSceneNode.getRotation().getY() * (Pi / 180.0) Euler[2] = NSceneNode.getRotation().getZ() * (Pi / 180.0) NewtonSetEulerAngle(Varptr Euler[0] , Varptr newtonMat[0]) NewtonMat[12] = NSceneNode.getPosition().getX() newtonMat[13] = NSceneNode.getPosition().getY() NewtonMat[14] = NSceneNode.getPosition().getZ() End Function Function T_irrSetMatrix(NSceneNode:T_irrISceneNode , NewtonMat:Float[]) Local Euler:Float[3] NewtonGetEulerAngle(Varptr NewtonMat[0] , Varptr Euler[0]) NSceneNode.setPosition(T_irrVector3df.createFromVals(NewtonMat[12] , NewtonMat[13] , NewtonMat[14])) NSceneNode.setRotation(T_irrVector3df.createfromVals(Euler[0] * (180 / Pi) , Euler[1]*(180/Pi) , Euler[2]*(180/Pi))) End Function