Newton Module (2-22-7)

BlitzMax Forums/BlitzMax Programming/Newton Module (2-22-7)

JoshK(Posted 2007) [#1]
Here is my Newton module for BlitzMax, as of February 22, 2007:



Chroma(Posted 2007) [#2]
hicleGetTireMatrix=GetProcAddress(HLIB_NEWTON,"hicleGetTireMatrix")


Just wanted to point out the typo above in case anyone missed it. I'm assuming it should start with NewtonVe.


JoshK(Posted 2007) [#3]
Anyone know how you would statically link to Newton?


klepto2(Posted 2007) [#4]
yes.
the needed mingw lib is offically available here:
http://www.newtondynamics.com/downloads/NewtonMinGW-1.53.zip



The only restriction with this is, that you have to set the:
NewtonSetPlatformArchitecture(world:Byte Ptr,mode:Int)
to the mode 0. This is due the lack of current mmx,sse etc problems with the current build. (Hopefully this is solved in the next version)


Chroma(Posted 2007) [#5]
Anyone have a small demo that uses Halo's newton wrapper?

This is as far as I've gotten:
Strict

Import Pub.Newton

Graphics 800,600,0,0

Local NewtonStatus:Int = StartNewton()
If NewtonStatus = False Then Notify("Newton Failure.")

While Not KeyHit(KEY_ESCAPE)
Cls

Flip
Wend
StopNewton()
EndGraphics
End



Filax(Posted 2007) [#6]
Any chance to see some examples ?? :)


JoshK(Posted 2007) [#7]
Read the manual and the Newton forum, it's easy to set up.


verfum(Posted 2007) [#8]
I've been using the Newton SDK docs to get your module working and it's a bit complex, I'm no c++ programmer so bare with me, it has transform matrix code which I can't convert
dMatrix matrix (box.getMatrix())
matrix.m_poit_x = 0.0f;
matrix.m_poit_y = 1.0f;
matrix.m_poit_z = 0.0f;

NewtonBodySetMatrix(rigidBodyBox, &matrix[0][0]);


How can this be converted in BlitzMax? Thanks.


JoshK(Posted 2007) [#9]
In my engine I do this:
NewtonBodySetMatrix(rigidBodyBox,mat.grid)

However, I rewrote MiniB3D's matrix routines to work with a left-handed coordinate system. MiniB3D stores the z-axis backwards and renders it in a right-handed coord system, so I am not sure if you will have to make changes to the matrix you give Newton.


JoshK(Posted 2007) [#10]
This adds syntax highlighting and a couple of extra functions.

I am not going to document this, but if someone else wants to, I will use whatever they give me. Newton comes with a chm file you could cut and paste from.



verfum(Posted 2007) [#11]
Because I'm quite new here with Bmax, there is no need to re-program the functions which come with the Newton examples? eg. I started converting the functions that come with the tutorials for Newton, like this:
Function PhysicsApplyGravityForce(Body:Byte Ptr)
	Local mass:Float
	Local Ixx:Float
	Local Iyy:Float
	Local Izz:Float
	
'	NewtonBodyGetMassMatrix (body, &mass, &Ixx, &Iyy, &Izz);
	NewtonBodyGetMassMatrix(body, Varptr mass, Varptr Ixx, Varptr Iyy, Varptr Izz)

'	dVector force (0.0f, -mass * 9.8f, 0.0f);
	Local force:Float[] = [0.0, Varptr mass * GRAVITY, 0.0]
	NewtonBodySetForce (body, Varptr force[0])
	
End Function


But infact all I need to do is what you've done, type Global NewtonApplyGravityForce(Body:Byte Ptr), that's it? Or am I missing something here?


JoshK(Posted 2007) [#12]
You do not need to write a wrapper.


verfum(Posted 2007) [#13]
Okay no problem, so where is the best place to go to get my code checked, I've tried posting on the programming section but noone has helped me, I'm trying to convert these c++ functions blind :( Gman started to convert the functions from Tutorial 2 and I'm carrying on from where he left off.