1 (edited by porcus 2007-06-15 15:19:16)

Topic: Newton

I took the Newton example out of this page and I excanged some things (Irrlicht 1.3). And displaying the
scene without newton works normally, but with newton I get always an error in:

newtonUpdate(nWorld , 0.001)

(I used the Newton-Wrapper by Klepto, because I didn't found the original used mod. (klepto.newton
instead of pub.Newton))

Has anybody an idea how to fix this ?

'Strict

'Framework PUB.Newton
'Import GG.IrrBMax
'Import BRL.PNGLoader

Framework BRL.Blitz
Import Irrlicht.Core
Import BRL.StandardIO
Import klepto.newton
Import BRL.PNGLoader

Local device:IrrlichtDevice = IrrlichtDevice.create(EDT_OPENGL , _Dimension2di(640 , 480) , 16 , False , False , False , Null)
Global driver:IVideoDriver = device.getVideoDriver()
Global smgr:ISceneManager = device.getSceneManager() 
'Local Tex:ITexture = driver.getTexture("brlLogo.png")
Local camera:ICameraSceneNode = smgr.addCameraSceneNodeFPS()
camera.setPosition(Vector3df.createFromVals(-19,-49,-30))
camera.setRotation(Vector3df.createFromVals(0 , 0 , 0))
Local light:ILightSceneNode = smgr.addLightSceneNode( Null , Vector3df.createfromVals(-20 , -40 , -30), Null)


Global nWorld:Byte Ptr = newtonCreate(PhysicsAlloc , PhysicsFree)

initScene()
Local Timer:Int = MilliSecs()
While (device.run())
    Timer:+MilliSecs()
    newtonUpdate(nWorld , 0.001)
    Timer = MilliSecs()
    ''NewtonBodyGetMatrix(box , Varptr Mat[0])
    ''SetMatrix(node , Mat)
    driver.beginScene(True , True , SColor.createFromVals(0,200 , 200 , 200))
    smgr.drawAll()
    
     driver.endScene()
Wend

Rem '''''''''''''''''''''''''''''''''''/////////////////////////////////////   The Convertion Matrix Functions
        GetMatrix is the function to get the matrix from the Irrlecht SceneNode And pass it
    to an array to be used by Newton.
        SetMatrix is the function to pass the Matrix from Newton to the Irrlicht SceneNode
EndRem
Function GetMatrix(NSceneNode:ISceneNode , NewtonMat:Float Ptr)
    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 SetMatrix(NSceneNode:ISceneNode , NewtonMat:Float Ptr)
    Local Euler:Float[3]
    NewtonGetEulerAngle(Varptr NewtonMat[0] , Varptr Euler[0])
    NSceneNode.setPosition(Vector3df.createFromVals(NewtonMat[12] , NewtonMat[13] , NewtonMat[14]))
    NSceneNode.setRotation(Vector3df.createfromVals(Euler[0] * (180 / Pi) , Euler[1] * (180 / Pi) , Euler[2] * (180 / Pi)))
End Function
Rem 
                    THE FUNCTIONS FROM TUTORIAL 2
End Rem
Function    PhysicsAlloc:Byte Ptr(sizeInBytes:Int)
    Return MemAlloc(sizeInBytes)
End Function
Function    PhysicsFree( memptr:Byte Ptr, sizeInBytes:Int)
    MemFree (memptr)
End Function
' set the tranformation of a rigid body
Function  PhysicsApplyForceAndTorque (Body:Byte Ptr)
    Local mass:Float
    Local Ixx:Float
    Local Iyy:Float
    Local Izz:Float
    NewtonBodyGetMassMatrix (body,Varptr mass, Varptr Ixx, Varptr Iyy, Varptr Izz);
    'Local force:Float[] =  [0.0, -mass * 9.8 , 0.0]
    ' GG: messed with the mass multiplier to make it look like the tutorial.  have no idea why this is different.
    Local force:Float[] =  [0.0, -mass * 410 , 0.0]
    NewtonBodySetForce (body, Varptr force[0])
End Function
Function  PhysicsSetTransform (body:Byte Ptr, NewtonMat:Float Ptr)
    Local primitive:ISceneNode
    '// get the graphic Object form the rigid body
    ' GG: changed to recreate the scenenode based on the C++ object handle
    primitive = ISceneNode.CreateFromHandle(Int(newtonBodyGetUserData(body)),False)
    
    '// set the transformation matrix For this rigid body
    newtonBodyGetMatrix(body , Varptr NewtonMat[0])
    SetMatrix(Primitive , Varptr NewtonMat[0])
    
End Function
Function PhysicsBodyDestructor(body:Byte Ptr)
    Local primitive:ISceneNode
    '// get the graphic Object form the rigid body
    ' GG: changed to recreate the scenenode based on the C++ object handle
    primitive = ISceneNode.CreateFromHandle(Int(newtonBodyGetUserData(body)),False)
    '// destroy the graphic Object
    primitive.remove()
    
End Function
Function CleanUp ()
    '// destroy the Newton world
    NewtonDestroy (nWorld);
    
End Function
Function InitScene()
    Global Texture:ITexture = Driver.getTexture("test/tswood18.jpg") 
    Global box:ISceneNode
    Global IFloor:ISceneNode
    Global boxBody:Byte Ptr
    Global floorBody:Byte Ptr
    Global collision:Byte Ptr
    Global Mat:Float[16]
    '// create the newton world
    
    '// set the linear solver model For faster speed 
    NewtonSetSolverModel(nWorld, 8)
    '// set the adpative friction model For faster speed 
    NewtonSetFrictionModel(nWorld, 1)
    
    '// Set the termination Function
    'atexit(CleanUp);   '//// I Haven't Found The Apropriaty Function for Irrlicht
    
    '// create the the Floor graphic objects
'    IFloor = smgr.addTestSceneNode(100 )
IFloor = smgr.addcubescenenode(100)
    'IFloor.setMaterialFlag(EMF_LIGHTING,True)
    IFloor.setMaterialTexture(0 , texture)
    IFloor.setPosition(Vector3df.createFromVals(0,-100 , 0))
    collision = newtonCreateBox(nWorld , 100.0 , 100.0 , 100.0 , Null)
    FloorBody = newtonCreateBody(nWorld , collision)
    
    '// set the transformation For this rigid body
    GetMatrix(IFloor ,Varptr Mat[0])
    NewtonBodySetMatrix(floorBody,Varptr Mat[0])
    
    '// save the pointer To the graphic Object with the body.
    ' GG: changed to store the scenenode C++ object handle instead of a reference to the BMAX object with falls out of scope
    NewtonBodySetUserData(floorBody,Byte Ptr(IFloor.handle))
    
    '// set a destrutor For this rigid body
    NewtonBodySetDestructorCallback(floorBody, PhysicsBodyDestructor);
    
    '// set the initial size
    'size = dVector(0.5f, 0.5f, 0.5f);    Not really nesesery(I think so)
    '// create the collision 
    newtonReleaseCollision(nWorld , collision)
    collision = NewtonCreateBox(nWorld, 0.5 , 0.5, 0.5 , Null) 
    Local location:Float[] = [0.0 , 0.0 , 0.0]
    location[0] = -10.0   'FOR  X
    For Local k:Int = 0 To 9
        location[2] = 0.0    'For Z
        For Local J:Int = 0 To 9
            location[1] = 2.0    'For Y
            For Local i:Int = 0  To 9
                box = smgr.addcubescenenode(0.5)
                box.setMaterialFlag(EMF_LIGHTING,True)
                box.SetMaterialTexture(0 , Texture)
                box.setPosition(Vector3df.createFromVals(location[0] ,location[1] , location[2]))
                boxBody = newtonCreateBody(nWorld , collision)                
                ' GG: changed to store the scenenode C++ object handle instead of a reference to the BMAX object with falls out of scope
                newtonBodySetUserData(boxBody ,Byte Ptr(box.handle))        
                '// set a destrutor For this rigid body
                NewtonBodySetDestructorCallback(boxBody, PhysicsBodyDestructor)
                '// set the tranform call back Function
                NewtonBodySetTransformCallback(boxBody, PhysicsSetTransform)
                '// set the force And torque call back funtion
                NewtonBodySetForceAndTorqueCallback(boxBody, PhysicsApplyForceAndTorque)
                '// set the mass matrix
                '//NewtonBodySetMassMatrix (boxBody, 1.0f, 1.0f / 6.0f, 1.0f / 6.0f, 1.0f  / 6.0f);
                NewtonBodySetMassMatrix(boxBody, 1.0, 1.0, 1.0, 1.0)                
                '// set the matrix For tboth the rigid nody And the graphic body
                GetMatrix(box , Varptr Mat[0])
                NewtonBodySetMatrix(boxBody,Varptr Mat[0])
                PhysicsSetTransform(boxBody, Varptr Mat[0])
                Location[1] :+ 0.5 * 2.0
            Next
            Location[2] :- 0.5 * 4.0     
        Next
        location[0] :- 0.5 * 4.0 
    Next
    '// Release the collsion geometry when Not need it
    NewtonReleaseCollision(nWorld, collision)

EndFunction

Re: Newton

greetings porcus smile  whats the error you are receiving?

Re: Newton

Unhandled Memory Exception

Re: Newton

usually that means an invalid handle was passed into a function.  i would guess that either newtoncreate failed or that one of the bodies added are not valid.

make sure your running in debug mode and add the following line right after the newtoncreate call:

DebugLog("nworld: "+Int(nWorld))

also, comment out initscene and see if it runs.  if nworld is >0 and it runs, a body is not being created right in initscene.  if nworld is 0 there is something deeper wrong in using the library.  potentially a mismatched newton library and mod?  what version of newton are you using?

Re: Newton

nworld is bigger then 0, but even if I don't call initscene() the error message is always the same.
I had no experience with newton before, so it can be, that I made something wrong.
Do you know a possible reason for this ?

Re: Newton

Has anyone succesfully run this source ?

Re: Newton

SuperStrict

Framework BRL.Blitz
Import Irrlicht.Core
Import BRL.StandardIO
Import BRL.PNGLoader
Import "Newton.lib"

Local device:IrrlichtDevice = IrrlichtDevice.create(EDT_OPENGL , _Dimension2di(640 , 480) , 16 , False , False , False , Null)
Global driver:IVideoDriver = device.getVideoDriver()
Global smgr:ISceneManager = device.getSceneManager() 

Local camera:ICameraSceneNode = smgr.addCameraSceneNodeFPS()
camera.setPosition(Vector3df.createFromVals(-19,-49,-30))
camera.setRotation(Vector3df.createFromVals(0 , 0 , 0))
Local light:ILightSceneNode = smgr.addLightSceneNode( Null , Vector3df.createfromVals(-20 , -40 , -30), Null)


Global nWorld:Byte Ptr = NewtonCreate(PhysicsAlloc , PhysicsFree)

initScene()
Local Timer:Int = MilliSecs()
While (device.run())
    Timer:+MilliSecs()
    NewtonUpdate(nWorld , 0.001)
    Timer = MilliSecs()
    ''NewtonBodyGetMatrix(box , Varptr Mat[0])
    ''SetMatrix(node , Mat)
    driver.beginScene(True , True , SColor.createFromVals(0,200 , 200 , 200))
    smgr.drawAll()
    
     driver.endScene()
Wend

Rem '''''''''''''''''''''''''''''''''''/////////////////////////////////////   The Convertion Matrix Functions
        GetMatrix is the function to get the matrix from the Irrlecht SceneNode And pass it
    to an array to be used by Newton.
        SetMatrix is the function to pass the Matrix from Newton to the Irrlicht SceneNode
EndRem
Function GetMatrix(NSceneNode:ISceneNode , NewtonMat:Float Ptr)
    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 SetMatrix(NSceneNode:ISceneNode , NewtonMat:Float Ptr)
    Local Euler:Float[3]
    NewtonGetEulerAngle(Varptr NewtonMat[0] , Varptr Euler[0])
    NSceneNode.setPosition(Vector3df.createFromVals(NewtonMat[12] , NewtonMat[13] , NewtonMat[14]))
    NSceneNode.setRotation(Vector3df.createfromVals(Euler[0] * (180 / Pi) , Euler[1] * (180 / Pi) , Euler[2] * (180 / Pi)))
End Function
Rem 
                    THE FUNCTIONS FROM TUTORIAL 2
End Rem
Function    PhysicsAlloc:Byte Ptr(sizeInBytes:Int)
    Return MemAlloc(sizeInBytes)
End Function
Function    PhysicsFree( memptr:Byte Ptr, sizeInBytes:Int)
    MemFree (memptr)
End Function
' set the tranformation of a rigid body
Function  PhysicsApplyForceAndTorque (Body:Byte Ptr)
    Local mass:Float
    Local Ixx:Float
    Local Iyy:Float
    Local Izz:Float
    NewtonBodyGetMassMatrix (body,Varptr mass, Varptr Ixx, Varptr Iyy, Varptr Izz);
    'Local force:Float[] =  [0.0, -mass * 9.8 , 0.0]
    ' GG: messed with the mass multiplier to make it look like the tutorial.  have no idea why this is different.
    Local force:Float[] =  [0.0, -mass * 410 , 0.0]
    NewtonBodySetForce (body, Varptr force[0])
End Function
Function  PhysicsSetTransform (body:Byte Ptr, NewtonMat:Float Ptr)
    Local primitive:ISceneNode
    '// get the graphic Object form the rigid body
    ' GG: changed to recreate the scenenode based on the C++ object handle
    primitive = ISceneNode.CreateFromHandle(Int(newtonBodyGetUserData(body)),False)
    
    '// set the transformation matrix For this rigid body
    newtonBodyGetMatrix(body , Varptr NewtonMat[0])
    SetMatrix(Primitive , Varptr NewtonMat[0])
    
End Function
Function PhysicsBodyDestructor(body:Byte Ptr)
    Local primitive:ISceneNode
    '// get the graphic Object form the rigid body
    ' GG: changed to recreate the scenenode based on the C++ object handle
    primitive = ISceneNode.CreateFromHandle(Int(newtonBodyGetUserData(body)),False)
    '// destroy the graphic Object
    primitive.remove()
    
End Function
Function CleanUp ()
    '// destroy the Newton world
    NewtonDestroy (nWorld);
    
End Function
Function InitScene()
    ' 2007/6/20 GG
    'Global Texture:ITexture = Driver.getTexture("test/tswood18.jpg") 
    Global box:ISceneNode
    Global IFloor:ISceneNode
    Global boxBody:Byte Ptr
    Global floorBody:Byte Ptr
    Global collision:Byte Ptr
    Global Mat:Float[16]
    '// create the newton world
    
    '// set the linear solver model For faster speed 
    NewtonSetSolverModel(nWorld, 8)
    '// set the adpative friction model For faster speed 
    NewtonSetFrictionModel(nWorld, 1)
    
    '// Set the termination Function
    'atexit(CleanUp);   '//// I Haven't Found The Apropriaty Function for Irrlicht
    
    '// create the the Floor graphic objects
'    IFloor = smgr.addTestSceneNode(100 )
IFloor = smgr.addcubescenenode(100)
    'IFloor.setMaterialFlag(EMF_LIGHTING,True)

    ' 2007/6/20 GG
    'IFloor.setMaterialTexture(0 , texture)
    IFloor.setPosition(Vector3df.createFromVals(0,-100 , 0))
    collision = newtonCreateBox(nWorld , 100.0 , 100.0 , 100.0 , Null)
    FloorBody = newtonCreateBody(nWorld , collision)
    
    '// set the transformation For this rigid body
    GetMatrix(IFloor ,Varptr Mat[0])
    NewtonBodySetMatrix(floorBody,Varptr Mat[0])
    
    '// save the pointer To the graphic Object with the body.
    ' GG: changed to store the scenenode C++ object handle instead of a reference to the BMAX object with falls out of scope
    NewtonBodySetUserData(floorBody,Byte Ptr(IFloor.handle))
    
    '// set a destrutor For this rigid body
    NewtonBodySetDestructorCallback(floorBody, PhysicsBodyDestructor);
    
    '// set the initial size
    'size = dVector(0.5f, 0.5f, 0.5f);    Not really nesesery(I think so)
    '// create the collision 
    newtonReleaseCollision(nWorld , collision)
    collision = NewtonCreateBox(nWorld, 0.5 , 0.5, 0.5 , Null) 
    Local location:Float[] = [0.0 , 0.0 , 0.0]
    location[0] = -10.0   'FOR  X
    For Local k:Int = 0 To 9
        location[2] = 0.0    'For Z
        For Local J:Int = 0 To 9
            location[1] = 2.0    'For Y
            For Local i:Int = 0  To 9
                box = smgr.addcubescenenode(0.5)
                box.setMaterialFlag(EMF_LIGHTING,True)
                ' 2007/6/20 GG
                'box.SetMaterialTexture(0 , Texture)
                box.setPosition(Vector3df.createFromVals(location[0] ,location[1] , location[2]))
                boxBody = newtonCreateBody(nWorld , collision)                
                ' GG: changed to store the scenenode C++ object handle instead of a reference to the BMAX object with falls out of scope
                newtonBodySetUserData(boxBody ,Byte Ptr(box.handle))        
                '// set a destrutor For this rigid body
                NewtonBodySetDestructorCallback(boxBody, PhysicsBodyDestructor)
                '// set the tranform call back Function
                NewtonBodySetTransformCallback(boxBody, PhysicsSetTransform)
                '// set the force And torque call back funtion
                NewtonBodySetForceAndTorqueCallback(boxBody, PhysicsApplyForceAndTorque)
                '// set the mass matrix
                '//NewtonBodySetMassMatrix (boxBody, 1.0f, 1.0f / 6.0f, 1.0f / 6.0f, 1.0f  / 6.0f);
                NewtonBodySetMassMatrix(boxBody, 1.0, 1.0, 1.0, 1.0)                
                '// set the matrix For tboth the rigid nody And the graphic body
                GetMatrix(box , Varptr Mat[0])
                NewtonBodySetMatrix(boxBody,Varptr Mat[0])
                PhysicsSetTransform(boxBody, Varptr Mat[0])
                Location[1] :+ 0.5 * 2.0
            Next
            Location[2] :- 0.5 * 4.0     
        Next
        location[0] :- 0.5 * 4.0 
    Next
    '// Release the collsion geometry when Not need it
    NewtonReleaseCollision(nWorld, collision)

EndFunction

Extern
'================================================
' World Functions
'================================================
Function NewtonCreate:Byte Ptr( mallocFnt: Byte Ptr, mfreeFnt:Byte Ptr)
Function NewtonDestroy(nWorld: Byte Ptr)
Function NewtonUpdate(NewtonWorld: Byte Ptr, time:Float)
Function NewtonDestroyAllBodies(NewtonWorld: Byte Ptr)
Function NewtonSetSolverModel(NewtonWorld:Byte Ptr, model:Int)
Function NewtonSetFrictionModel(NewtonWorld:Byte Ptr, model:Int)
Function NewtonGetTimeStep:Float(NewtonWorld:Byte Ptr)
Function NewtonSetMinimumFrameRate(NewtonWorld:Byte Ptr, frameRate:Float)
Function NewtonSetBodyLeaveWorldEvent(NewtonWorld:Byte Ptr, BodyLeaveWorld_callback:Byte Ptr)
Function NewtonSetWorldSize(NewtonWorld:Byte Ptr, minPoint: Byte Ptr, maxPoint:Byte Ptr)
Function NewtonWorldFreezeBody(NewtonWorld:Byte Ptr, body:Byte Ptr)
Function NewtonWorldUnFreezeBody(NewtonWorld:Byte Ptr, body:Byte Ptr)
Function NewtonWorldForEachBodyDo(NewtonWorld:Byte Ptr, BodyIterator_callback:Byte Ptr)
Function NewtonWorldSetUserData(NewtonWorld:Byte Ptr, userData:Byte Ptr)
Function NewtonWorldGetUserData:Byte Ptr(NewtonWorld:Byte Ptr)
Function NewtonWorldGetVersion:Int(NewtonWorld:Byte Ptr)
Function NewtonWorldRayCast(NewtonWorld:Byte Ptr, p0:Byte Ptr, p1:Byte Ptr, WorldRayFilterCallback:Byte Ptr, userData:Byte Ptr)
Function NewtonWorldCollide:Int(NewtonWorld:Byte Ptr, maxSize:Int,collsionA:Byte Ptr, matrixA:Byte Ptr, collsionB:Byte Ptr, matrixB:Byte Ptr, contacts:Byte Ptr, normals:Byte Ptr, penetration:Byte Ptr)
Function NewtonMaterialGetDefaultGroupID:Int(NewtonWorld:Byte Ptr)
Function NewtonMaterialCreateGroupID:Int(NewtonWorld:Byte Ptr)
Function NewtonMaterialDestroyAllGroupID(NewtonWorld:Byte Ptr)
Function NewtonMaterialSetDefaultSoftness(NewtonWorld:Byte Ptr, id0:Int, id1:Int, value:Float)
Function NewtonMaterialSetDefaultElasticity(NewtonWorld:Byte Ptr, id0:Int, id1:Int, elasticCoef:Float)
Function NewtonMaterialSetDefaultCollidable(NewtonWorld:Byte Ptr, id0:Int, id1:Int, state:Int)
Function NewtonMaterialSetDefaultFriction(NewtonWorld:Byte Ptr, id0:Int, id1:Int, staticFriction:Float, kineticFriction:Float)
Function NewtonMaterialSetCollisionCallback(NewtonWorld:Byte Ptr, id0:Int, id1:Int, userData:Byte Ptr, begin:Byte Ptr, process:Byte Ptr, NEnd:Byte Ptr)
Function NewtonMaterialGetUserData:Byte Ptr(NewtonWorld:Byte Ptr, id0:Int, id1:Int)
Function NewtonMaterialDisableContact (material:Byte Ptr)
Function NewtonMaterialGetCurrentTimestep:Float(material:Byte Ptr)
Function NewtonMaterialGetMaterialPairUserData:Byte Ptr(material:Byte Ptr)
Function NewtonMaterialGetContactFaceAttribute:Int(material: Byte Ptr)
Function NewtonMaterialGetBodyCollisionID:Int(material: Byte Ptr, body:Byte Ptr)
Function NewtonMaterialGetContactNormalSpeed:Float(material:Byte Ptr, contactlHandle:Byte Ptr)
Function NewtonMaterialGetContactForce(material: Byte Ptr, force:Byte Ptr)
Function NewtonMaterialGetContactPositionAndNormal(material:Byte Ptr, posit:Byte Ptr, normal:Byte Ptr)
Function NewtonMaterialGetContactTangentDirections(material:Byte Ptr, dir0:Byte Ptr, dir:Byte Ptr)
Function NewtonMaterialGetContactTangentSpeed:Float(material:Byte Ptr, NewtonContact:Byte Ptr, index:Int)

Function NewtonSetPlatformArchitecture(world:Byte Ptr,mode:Int)

Function NewtonMaterialSetContactSoftness(NewtonMaterial:Byte Ptr, softness:Float)
Function NewtonMaterialSetContactElasticity(NewtonMaterial:Byte Ptr, restitution:Float)
Function NewtonMaterialSetContactFrictionState(NewtonMaterial:Byte Ptr, state:Int, index:Int)
Function NewtonMaterialSetContactStaticFrictionCoef(NewtonMaterial:Byte Ptr, coef:Float, index:Int)
Function NewtonMaterialSetContactKineticFrictionCoef(NewtonMaterial:Byte Ptr, coef:Float, index:Int)
Function NewtonMaterialSetContactTangentAcceleration(NewtonMaterial:Byte Ptr , accel:Float , index:Int)
Function NewtonMaterialSetContactNormalAcceleration(NewtonMaterial:Byte Ptr, accel:Float)
Function NewtonMaterialSetContactNormalDirection(NewtonMaterial:Byte Ptr, dir:Byte Ptr)




Function NewtonMaterialContactRotateTangentDirections(NewtonMaterial:Byte Ptr, directionVector:Byte Ptr)

'================================================
' convex collision primitives creation functions
'================================================
Function NewtonCreateNull:Byte Ptr(NewtonWorld:Byte Ptr)    'NewtonCollision
Function NewtonCreateSphere:Byte Ptr(NewtonWorld:Byte Ptr, radiusX:Float, radiusY:Float, radiusZ:Float, offsetMatrix:Byte Ptr)
Function NewtonCreateBox:Byte Ptr(NewtonWorld:Byte Ptr, dx:Float, dy:Float, dz:Float, offsetMatrix:Byte Ptr)
Function NewtonCreateCone:Byte Ptr(NewtonWorld:Byte Ptr, radius:Float, height:Float, offsetMatrix:Byte Ptr)
Function NewtonCreateCapsule:Byte Ptr(NewtonWorld:Byte Ptr, radius:Float, height:Float, offsetMatrix:Byte Ptr)
Function NewtonCreateCylinder:Byte Ptr(NewtonWorld:Byte Ptr, radius:Float, height:Float, offsetMatrix:Byte Ptr)
Function NewtonCreateChamferCylinder:Byte Ptr(NewtonWorld:Byte Ptr, radius:Float, height:Float, offsetMatrix:Byte Ptr)
Function NewtonCreateConvexHull:Byte Ptr(NewtonWorld:Byte Ptr, count:Int, vertexCloud:Byte Ptr, strideInBytes:Int, offsetMatrix:Byte Ptr)
Function NewtonCreateConvexHullModifier:Byte Ptr(NewtonWorld:Byte Ptr, convexHullCollision:Byte Ptr)
Function NewtonConvexHullModifierGetMatrix(convexHullCollision:Byte Ptr, matrix:Byte Ptr)
Function NewtonConvexHullModifierSetMatrix(convexHullCollision:Byte Ptr, matrix:Byte Ptr)
    
Function NewtonConvexCollisionSetUserID(convexCollision:Byte Ptr, id:Int)
Function NewtonConvexCollisionGetUserID:Int(convexCollision:Byte Ptr)

'================================================
'complex collision primitives creation functions
'================================================
Function NewtonCreateCompoundCollision:Byte Ptr(NewtonWorld:Byte Ptr, count:Int, collisionPrimitiveArray:Byte Ptr[])
Function NewtonCreateUserMeshCollision:Byte Ptr(NewtonWorld:Byte Ptr, minBox:Byte Ptr, maxBox:Byte Ptr, userData:Byte Ptr, collideCallback:Byte Ptr, rayHitCallback:Byte Ptr, destroyCallback:Byte Ptr)

'================================================
' CollisionTree Utility functions
'================================================
Function NewtonCreateTreeCollision:Byte Ptr(NewtonWorld:Byte Ptr, userCallback:Byte Ptr)
Function NewtonTreeCollisionBeginBuild(NewtonCollision: Byte Ptr)
Function NewtonTreeCollisionAddFace(NewtonCollision: Byte Ptr, vertexCount:Int, vertexPtr: Byte Ptr, strideInBytes:Int, faceAttribute:Int)
Function NewtonTreeCollisionEndBuild(NewtonCollision: Byte Ptr, optimize:Int)
'    NEWTON_API void NewtonTreeCollisionSerialize (Const NewtonCollision* treeCollision, NewtonSerialize serializeFunction, 
'        void* serializeHandle);
Function NewtonCreateTreeCollisionFromSerialization:Byte Ptr(NewtonWorld:Byte Ptr, userCallback:Byte Ptr,deserializeFunction:Byte Ptr, serializeHandle:Byte Ptr)
Function NewtonTreeCollisionGetFaceAtribute:Int(NewtonCollision:Byte Ptr, faceIndexArray:Byte Ptr) 
Function NewtonTreeCollisionSetFaceAtribute(NewtonCollision: Byte Ptr, faceIndexArray: Byte Ptr, attribute:Int) 

'================================================
' Collision Miscelaneos Function
'================================================
Function NewtonReleaseCollision(NewtonWorld:Byte Ptr, NewtonCollision:Byte Ptr)
Function NewtonCollisionCalculateAABB(NewtonCollision:Byte Ptr, matrix:Byte Ptr, p0:Byte Ptr, p1:Byte Ptr)
Function NewtonCollisionRayCast:Float(NewtonCollision:Byte Ptr, p0:Byte Ptr, p1:Byte Ptr, normals:Byte Ptr, attribute:Byte Ptr)

'================================================
' transforms utility functions
'================================================
Function NewtonGetEulerAngle(matrix:Byte Ptr, eulersAngles:Byte Ptr)
Function NewtonSetEulerAngle(eulersAngles:Byte Ptr, matrix:Byte Ptr)

'================================================
' body manipulation functions
'================================================
Function NewtonCreateBody:Byte Ptr(NewtonWorld:Byte Ptr, NewtonCollision:Byte Ptr)
Function NewtonDestroyBody(NewtonWorld:Byte Ptr, body:Byte Ptr)

Function NewtonBodyAddForce(body:Byte Ptr, force:Byte Ptr)
Function NewtonBodyAddTorque(body:Byte Ptr, torque:Byte Ptr)

Function NewtonBodySetMatrix(body:Byte Ptr, matrix:Byte Ptr)
Function NewtonBodySetMatrixRecursive(body:Byte Ptr, matrix:Byte Ptr)
Function NewtonBodySetMassMatrix(body:Byte Ptr, mass:Float, Ixx:Float, Iyy:Float, Izz:Float)
Function NewtonBodySetMaterialGroupID(body:Byte Ptr, id:Int)
Function NewtonBodySetContinuousCollisionMode(body:Byte Ptr, state:Int)
Function NewtonBodySetJointRecursiveCollision(body:Byte Ptr, state:Int)
Function NewtonBodySetOmega(body:Byte Ptr, omega:Byte Ptr)
Function NewtonBodySetVelocity(body:Byte Ptr, velocity:Byte Ptr)
Function NewtonBodySetForce (body:Byte Ptr, force:Byte Ptr)
Function NewtonBodySetTorque(body:Byte Ptr, torque:Byte Ptr)
Function NewtonBodySetLinearDamping(body:Byte Ptr, linearDamp:Float)
Function NewtonBodySetAngularDamping(body:Byte Ptr, angularDamp:Byte Ptr)
Function NewtonBodySetUserData(body:Byte Ptr, userData:Byte Ptr)
Function NewtonBodyCoriolisForcesMode(body:Byte Ptr, mode:Int)
Function NewtonBodySetCollision(body:Byte Ptr, collision:Byte Ptr)
Function NewtonBodySetAutoFreeze(body:Byte Ptr, state:Int)
Function NewtonBodySetFreezeTreshold(body:Byte Ptr, freezeSpeed2:Float, freezeOmega2:Float, framesCount:Int)
    
Function NewtonBodySetTransformCallback(body:Byte Ptr, SetTransform_callback:Byte Ptr)
Function NewtonBodySetDestructorCallback(body:Byte Ptr, BodyDest_callback:Byte Ptr)
Function NewtonBodySetAutoactiveCallback(body:Byte Ptr, BodyActState_callback:Byte Ptr)
Function NewtonBodySetForceAndTorqueCallback(body:Byte Ptr, ApplyForceTorque_callback:Byte Ptr)

Function NewtonBodyGetWorld:Byte Ptr(body:Byte Ptr)
Function NewtonBodyGetUserData:Byte Ptr(body:Byte Ptr)
Function NewtonBodyGetCollision:Byte Ptr(body:Byte Ptr)
Function NewtonBodyGetMaterialGroupID:Int(body:Byte Ptr)
Function NewtonBodyGetContinuousCollisionMode:Int(body:Byte Ptr)
Function NewtonBodyGetJointRecursiveCollision:Int(body:Byte Ptr)
Function NewtonBodyGetMatrix(body:Byte Ptr, matrix:Byte Ptr)
Function NewtonBodyGetMassMatrix(body:Byte Ptr, mass:Byte Ptr, Ixx:Byte Ptr, Iyy:Byte Ptr, Izz:Byte Ptr)
Function NewtonBodyGetInvMass(body:Byte Ptr, invMass:Byte Ptr, invIxx:Byte Ptr, invIyy:Byte Ptr, invIzz:Byte Ptr)
Function NewtonBodyGetOmega(body:Byte Ptr, vector:Byte Ptr)
Function NewtonBodyGetVelocity(body:Byte Ptr, vector:Byte Ptr)
Function NewtonBodyGetForce(body:Byte Ptr, vector:Byte Ptr)
Function NewtonBodyGetTorque(body:Byte Ptr, vector:Byte Ptr)
    
Function NewtonBodyGetSleepingState:Int(body:Byte Ptr)
Function NewtonBodyGetAutoFreeze:Int(body:Byte Ptr)
Function NewtonBodyGetLinearDamping:Float(body:Byte Ptr)
Function NewtonBodyGetAngularDamping (body:Byte Ptr, vector:Byte Ptr)
Function NewtonBodyGetAABB (body:Byte Ptr, p0:Byte Ptr, p1:Byte Ptr)    
Function NewtonBodyGetFreezeTreshold(body:Byte Ptr, freezeSpeed2:Byte Ptr, freezeOmega2:Byte Ptr)
Function NewtonBodyGetTotalVolume:Float(body:Byte Ptr)
Function NewtonBodyAddBuoyancyForce(body:Byte Ptr, fluidDensity:Float, fluidLinearViscosity:Float, fluidAngularViscosity:Float,gravityVector:Byte Ptr, buoyancyPlane:Byte Ptr, context:Byte Ptr)

Function NewtonBodyForEachPolygonDo (body:Byte Ptr, CollisionIterator_callback:Byte Ptr)
Function NewtonAddBodyImpulse(body:Byte Ptr, pointDeltaVeloc:Byte Ptr, pointPosit:Byte Ptr)

'================================================
' Common joint funtions
'================================================
Function NewtonJointGetUserData:Byte Ptr(joint:Byte Ptr)
Function NewtonJointSetUserData(joint:Byte Ptr, userData:Byte Ptr)

Function NewtonJointGetCollisionState:Int(joint:Byte Ptr)
Function NewtonJointSetCollisionState(joint:Byte Ptr, state:Int)

Function NewtonJointGetStiffness:Float(joint:Byte Ptr)
Function NewtonJointSetStiffness(joint:Byte Ptr, state:Float)

Function NewtonDestroyJoint(NewtonWorld:Byte Ptr, joint:Byte Ptr)
Function NewtonJointSetDestructor(joint:Byte Ptr, destructor:Byte Ptr)

'================================================
' Ball And Socket joint functions
'================================================
Function NewtonConstraintCreateBall:Byte Ptr(NewtonWorld:Byte Ptr, pivotPoint:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)
Function NewtonBallSetUserCallback(ball:Byte Ptr, BallCallBack_callback:Byte Ptr)
Function NewtonBallGetJointAngle (ball:Byte Ptr, angle:Byte Ptr)
Function NewtonBallGetJointOmega (ball:Byte Ptr, omega:Byte Ptr)
Function NewtonBallGetJointForce (ball:Byte Ptr, force:Byte Ptr)
Function NewtonBallSetConeLimits (ball:Byte Ptr, pin:Byte Ptr, maxConeAngle:Float, maxTwistAngle:Float)

'================================================
' Hinge joint functions
'================================================
Function NewtonConstraintCreateHinge:Byte Ptr(NewtonWorld:Byte Ptr, pivotPoint:Byte Ptr, pinDir:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)

Function NewtonHingeSetUserCallback(hinge:Byte Ptr, HingeCallBack_callback:Byte Ptr)
Function NewtonHingeGetJointAngle:Float(hinge:Byte Ptr)
Function NewtonHingeGetJointOmega:Float(hinge:Byte Ptr)
Function NewtonHingeGetJointForce(hinge:Byte Ptr,  force:Byte Ptr)
Function NewtonHingeCalculateStopAlpha:Float(hinge:Byte Ptr, desc:Byte Ptr, angle:Float)


'================================================
' Slider joint functions
'================================================
Function NewtonConstraintCreateSlider:Byte Ptr(NewtonWorld:Byte Ptr,pivotPoint:Byte Ptr, pinDir:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)
Function NewtonSliderSetUserCallback(slider:Byte Ptr, SliderCallBack_callback:Byte Ptr)
Function NewtonSliderGetJointPosit:Float(slider:Byte Ptr)
Function NewtonSliderGetJointVeloc:Float(slider:Byte Ptr)
Function NewtonSliderGetJointForce (slider:Byte Ptr,  force:Byte Ptr)
Function NewtonSliderCalculateStopAccel:Float(slider:Byte Ptr, desc:Byte Ptr, position:Float)


'================================================
' Corkscrew joint functions
'================================================
Function NewtonConstraintCreateCorkscrew:Byte Ptr(NewtonWorld:Byte Ptr,pivotPoint:Byte Ptr, pinDir:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)
Function NewtonCorkscrewSetUserCallback(corkscrew:Byte Ptr, CorkscrewCallBack_callback:Byte Ptr)
Function NewtonCorkscrewGetJointPosit:Float (corkscrew:Byte Ptr)
Function NewtonCorkscrewGetJointAngle:Float( corkscrew:Byte Ptr)
Function NewtonCorkscrewGetJointVeloc:Float(corkscrew:Byte Ptr)
Function NewtonCorkscrewGetJointOmega:Float( corkscrew:Byte Ptr)
Function NewtonCorkscrewGetJointForce(corkscrew:Byte Ptr, force:Byte Ptr)
Function NewtonCorkscrewCalculateStopAlpha:Float(corkscrew:Byte Ptr, desc:Byte Ptr, angle:Float)
Function NewtonCorkscrewCalculateStopAccel:Float(corkscrew:Byte Ptr, desc:Byte Ptr, position:Float)


'================================================
' Universal joint functions
'================================================
Function NewtonConstraintCreateUniversal:Byte Ptr(NewtonWorld:Byte Ptr, pivotPoint:Byte Ptr, pinDir0:Byte Ptr, pinDir1:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr)
Function NewtonUniversalSetUserCallback(universal:Byte Ptr, UniversalCallBack_callback:Byte Ptr)
Function NewtonUniversalGetJointAngle0:Float( universal:Byte Ptr)
Function NewtonUniversalGetJointAngle1:Float(universal:Byte Ptr)
Function NewtonUniversalGetJointOmega0:Float( universal:Byte Ptr)
Function NewtonUniversalGetJointOmega1:Float (universal:Byte Ptr)
Function NewtonUniversalGetJointForce(universal:Byte Ptr, force:Byte Ptr)
Function NewtonUniversalCalculateStopAlpha0:Float(universal:Byte Ptr, desc:Byte Ptr, angle:Float)
Function NewtonUniversalCalculateStopAlpha1:Float(universal:Byte Ptr, desc:Byte Ptr, angle:Float)


'================================================
'Up vector joint functions
'================================================
Function NewtonConstraintCreateUpVector:Byte Ptr(NewtonWorld:Byte Ptr, pinDir:Byte Ptr, body:Byte Ptr) 
Function NewtonUpVectorGetPin(upVector:Byte Ptr, pin:Byte Ptr)
Function NewtonUpVectorSetPin(upVector:Byte Ptr, pin:Byte Ptr)


'================================================
' User defined bilateral Joint
'================================================
Function NewtonConstraintCreateUserJoint:Byte Ptr(NewtonWorld:Byte Ptr, maxDOF:Int, UserBilateralCallBack_callback:Byte Ptr, childBody:Byte Ptr, parentBody:Byte Ptr) 
Function NewtonUserJointAddLinearRow(joint:Byte Ptr, pivot0:Byte Ptr, pivot1:Byte Ptr, dir:Byte Ptr)
Function NewtonUserJointAddAngularRow(joint:Byte Ptr, relativeAngle:Float, dir:Byte Ptr)
Function NewtonUserJointSetRowMinimunFriction(joint:Byte Ptr,  friction:Float)
Function NewtonUserJointSetRowMaximunFriction( joint:Float, friction:Float)
Function NewtonUserJointSetRowAcceleration(joint:Byte Ptr,  acceleration:Float)
Function NewtonUserJointSetRowStiffness( joint:Float,stiffness:Float)
Function NewtonUserJointGetRowForce:Float(joint:Byte Ptr, row:Int)


'================================================
' Ragdoll joint contatiner funtion
'================================================
Function NewtonCreateRagDoll:Byte Ptr(NewtonWorld:Byte Ptr)
Function NewtonDestroyRagDoll(NewtonWorld:Byte Ptr, ragDoll:Byte Ptr)

Function NewtonRagDollBegin( ragDoll:Byte Ptr)
Function NewtonRagDollEnd( ragDoll:Byte Ptr)


Function NewtonRagDollFindBone:Byte Ptr( ragDoll:Byte Ptr, id:Int)
Function NewtonRagDollGetRootBone:Byte Ptr( ragDoll:Byte Ptr)

Function NewtonRagDollSetForceAndTorqueCallback( ragDoll:Byte Ptr, ApplyForceAndTorque_callback:Byte Ptr)
Function NewtonRagDollSetTransformCallback(ragDoll:Byte Ptr, SetRagDollTransform_callback:Byte Ptr)
Function NewtonRagDollAddBone:Byte Ptr(ragDoll:Byte Ptr, parent:Byte Ptr, userData:Byte Ptr, mass:Float, matrix:Byte Ptr, boneCollision:Byte Ptr, size:Byte Ptr)

Function NewtonRagDollBoneGetUserData:Byte Ptr( bone:Byte Ptr)
Function NewtonRagDollBoneGetBody:Byte Ptr( bone:Byte Ptr)
Function NewtonRagDollBoneSetID(bone:Byte Ptr, id:Int)


Function NewtonRagDollBoneSetLimits(bone:Byte Ptr, coneDir:Byte Ptr, minConeAngle:Float, maxConeAngle:Float, maxTwistAngle:Float, bilateralConeDir:Byte Ptr, negativeBilateralConeAngle:Float, positiveBilateralConeAngle:Float)
    

Function NewtonRagDollBoneGetLocalMatrix(bone:Byte Ptr,  matrix:Byte Ptr)
Function NewtonRagDollBoneGetFunctionMatrix( bone:Byte Ptr,  matrix:Byte Ptr)


'================================================
' Vehicle joint functions
'================================================
Function NewtonConstraintCreateVehicle:Byte Ptr(NewtonWorld:Byte Ptr, upDir:Byte Ptr, body:Byte Ptr) 
Function NewtonVehicleReset(vehicle:Byte Ptr) 
Function NewtonVehicleSetTireCallback(vehicle:Byte Ptr, update:Byte Ptr)
Function NewtonVehicleAddTire:Int(vehicle:Byte Ptr, localMatrix:Byte Ptr, pin:Byte Ptr, mass:Float, width:Float, radius:Float, suspesionShock:Float, suspesionSpring:Float, suspesionLength:Float, userData:Byte Ptr, collisionID:Int)
Function NewtonVehicleRemoveTire(vehicle:Byte Ptr, tireIndex:Int)
Function NewtonVehicleBalanceTires(vehicle:Byte Ptr, gravityMag:Float)

Function NewtonVehicleGetFirstTireID:Int(vehicle:Byte Ptr)
Function NewtonVehicleGetNextTireID:Int(vehicle:Byte Ptr, tireId:Int)

Function NewtonVehicleTireIsAirBorne:Int (vehicle:Byte Ptr, tireId:Int)
Function NewtonVehicleTireLostSideGrip:Int(vehicle:Byte Ptr, tireId:Int)
Function NewtonVehicleTireLostTraction:Int(vehicle:Byte Ptr, tireId:Int)

Function NewtonVehicleGetTireUserData:Byte Ptr(vehicle:Byte Ptr, tireId:Int)
Function NewtonVehicleGetTireOmega:Float(vehicle:Byte Ptr, tireId:Int)
Function NewtonVehicleGetTireNormalLoad:Float(vehicle:Byte Ptr, tireId:Int)
Function NewtonVehicleGetTireSteerAngle:Float (vehicle:Byte Ptr, tireId:Int)
Function NewtonVehicleGetTireLateralSpeed:Float(vehicle:Byte Ptr, tireId:Int)
Function NewtonVehicleGetTireLongitudinalSpeed:Float(vehicle:Byte Ptr, tireId:Int)
Function hicleGetTireMatrix(vehicle:Byte Ptr, tireId:Int , matrix:Byte Ptr)


Function NewtonVehicleSetTireTorque(vehicle:Byte Ptr, tireId:Int, torque:Float)
Function NewtonVehicleSetTireSteerAngle(vehicle:Byte Ptr, tireId:Int,  angle:Float)
    
Function NewtonVehicleSetTireMaxSideSleepSpeed(vehicle:Byte Ptr, tireId:Int, speed:Float)
Function NewtonVehicleSetTireSideSleepCoeficient(vehicle:Byte Ptr, tireId:Int,  coeficient:Float)
Function NewtonVehicleSetTireMaxLongitudinalSlideSpeed(vehicle:Byte Ptr, tireId:Int, speed:Float)
Function NewtonVehicleSetTireLongitudinalSlideCoeficient(vehicle:Byte Ptr, tireId:Int, coeficient:Float)

Function NewtonVehicleTireCalculateMaxBrakeAcceleration:Float(vehicle:Byte Ptr, tireId:Int)
Function NewtonVehicleTireSetBrakeAcceleration(vehicle:Byte Ptr, tireId:Int,  accelaration:Float, torqueLimit:Float)

Function NewtonConvexCollisionCalculateInertialMatrix(body:Byte Ptr,inertia:Byte Ptr,mass:Byte Ptr)
Function NewtonBodySetCentreOfMass(Node:Byte Ptr,Massp:Byte Ptr)
Function NewtonConvexCollisionCalculateVolume:Float(body:Byte Ptr)
'Function NewtonMaterialContactRotateTangentDirections(NewtonMaterial:Byte Ptr, directionVector:Byte Ptr)
Function NewtonMaterialSetContinuousCollisionMode(NewtonWorld:Byte Ptr, id0:Int,id1:Int,state:Int)


End Extern

Re: Newton

Thank you very much.

Re: Newton

Re: Newton

Re: Newton

Re: Newton

my apologies on the delay in looking at this.  we've been down 2 developers over the last 2 weeks due to vacations and things are pretty hectic for me.  mid next week my workload should start to lighten.

Re: Newton

Has nobody used Newton and Irrlicht with Linux successful?
Has nobody an idea how to fix this ?

Re: Newton

greetings porcus.  i spent several hours last night trying to resolve the issue.  i dont think its an Irrlicht/Newton issue but a BMAX/Newton issue.  no matter what i tried i still got the error on the newtonupdate() call.  even with nothing at all in the world.  the definitions for the functions involved are straight-forward enough.  i tried downloding klepto's mod and i also used my own partially complete mod.  they all had the same error.  i also tried the samples that come with the newton SDK and they worked fine, eliminating my thoughts that maybe my linux install was missing something with my install...  im at a loss.

Re: Newton

Re: Newton

thanks for the update porcus.  so those 3 lines were all that was needed?

Re: Newton

Yes!