Newton goes mad
BlitzMax Forums/BlitzMax Programming/Newton goes mad
| ||
Hey guys First of all, a piece of Code thats works: 'Extern 'include Newton took from here: 'http://www.blitzbasic.com/Community/posts.php?topic=69650#779390 'End Extern Local nWorld:Byte Ptr=NewtonCreate(Null,Null) Local collision:Byte Ptr= NewtonCreateSphere (nWorld, 2,2,2,Null); Local ribidBodyBox:Byte Ptr = NewtonCreateBody (nWorld, collision); NewtonReleaseCollision (nWorld, collision); Local gravitation:Float[]=[0.0,2.0,0.0] Local pos:Float[16] pos[0]=1 pos[5]=1 pos[10]=1 pos[15]=1 Local posi:Byte Ptr=Varptr pos[0] NewtonBodySetMassMatrix (ribidBodyBox, 1.0, 5.0, 1.0, 5.0); NewtonBodySetMatrix(ribidBodyBox,Varptr pos[0]) NewtonBodySetOmega (ribidBodyBox, Varptr gravitation[0]); Local rendertime:Float=1 Repeat Local lasttime:Float=MilliSecs() NewtonUpdate(nWorld, 5.0); Local matrix:Float[4,4] NewtonBodyGetMatrix(ribidBodyBox, Varptr matrix[0,0]) DebugLog matrix[0,0] rendertime=MilliSecs()-lasttime Until KeyHit(KEY_ESCAPE) NewtonDestroy (nWorld) End But it behaves very Strange: 1. After removing this senseless line "Local posi:Byte Ptr=Varptr pos[0]", the programm crashes (MAV) 2. For Setting the PositionMatrix, i need an 1d Array, but for reading it a 2d-Array is nessesary 3. DebugLog matrix[0,0]+" "+ matrix[1,0] 'doesnt work DebugLog matrix[0,0] 'works DebugLog matrix[1,0] 'works I hope you can help me and i hope you understand my english as i'm from Germany Mfg Lukas |
| ||
Your code looks correct to me and I use Newton extensively. |