Newton on the iPhone

Share with us how are you using the powerrrr of the force

Moderator: Alain

Newton on the iPhone

Postby Caleb Cannon » Tue Sep 30, 2008 5:53 pm

Here's a video of the first iPhone app I made using Newton.

:D

http://ca.youtube.com/watch?v=_6mQEfK88GM
Caleb Cannon
 
Posts: 3
Joined: Sat Sep 27, 2008 4:28 pm

Re: Newton on the iPhone

Postby Julio Jerez » Tue Sep 30, 2008 6:27 pm

ho jo jo jo joww,

the powaaaa of teh force srate to shine in the. :shock: :shock:

you are that very first show and actual app in teh iphione device, an dI di dn no even test it te hliob :mrgreen: :mrgreen: ,
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton on the iPhone

Postby Dave Gravel » Tue Sep 30, 2008 8:22 pm

Nice and good first app idea.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Newton on the iPhone

Postby Yezide » Wed Oct 01, 2008 3:21 am

Cool! Now I wanna buy an iphone and make some demos for it :)
User avatar
Yezide
 
Posts: 173
Joined: Tue Oct 18, 2005 4:31 am

Re: Newton on the iPhone

Postby brianhammond » Wed Oct 01, 2008 2:24 pm

Cool, I originally got Julio to make the iPhone build but my app idea is fairly saturated in the app store market (billiards) at the moment. Sure, they all * but I moved on to a different idea that does not use Newton (yet).

Anything you'd like to add regarding problems getting Newton up on the iPhone from the original thread?

Looks great. So you just do a low pass filter on the accelerometer to get the gravity vector relative to the device and then use that in your callback in Newton. Nice and simple I like it.
User avatar
brianhammond
 
Posts: 14
Joined: Thu Sep 06, 2007 7:59 pm

Re: Newton on the iPhone

Postby JernejL » Wed Oct 01, 2008 3:06 pm

Some collision responses in the video there look as if your inertial values or body masses are not set properly.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Newton on the iPhone

Postby Dave Gravel » Wed Oct 01, 2008 3:13 pm

by Delfi on Wed Oct 01, 2008 2:06 pm
Some collision responses in the video there look as if your inertial values or body masses are not set properly.


I'm not 100% sure but I think it happening because the dice's is all times under a force controled.
Maybe the setup is not 100% perfect close to point force 0,0,0
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Newton on the iPhone

Postby Julio Jerez » Wed Oct 01, 2008 4:35 pm

It looks to me liek he is convertion teh matroces to euler angle an dteh is a but some where in teh convetion.
Am I correct on assuming that?

It is possible to use the matrices passed by the enigne directly?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton on the iPhone

Postby Caleb Cannon » Wed Oct 01, 2008 6:00 pm

It looks to me liek he is convertion teh matroces to euler angle an dteh is a but some where in teh convetion.
Am I correct on assuming that?

It is possible to use the matrices passed by the enigne directly?


I'm passing the matrices to OpenGL directly
Code: Select all
   dMatrix m;
   NewtonBodyGetMatrix(objects[i].body, &m[0][0]);
   glMultMatrixf(&m[0][0]);


The moments of inertia are wrong for some objects. I'm using a cube moment for everything and it isn't scaled to the objects mass, e.g., NewtonBodySetMassMatrix(body, 1.0f, 1.0f/6.0f, 1.0f/6.0f, 1.0f/6.0f);

Another thing you guys might be noticing is that force isn't always aligned with the coordinate planes. The gravity vector in the video is always pointing at my feet and a lot of weird movements are actually the objects colliding with the 6 walls containing the scene. This was super easy to pull off with the iPhone.

Code: Select all
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
   float dt = [NSDate timeIntervalSinceReferenceDate] - lastAccelTime;
   lastAccelTime = [NSDate timeIntervalSinceReferenceDate];
   
   float kLowPassFilterFactor = 0.1;
   float kHighPassFilterFactor = 0.1;
   
   // Use a basic low-pass filter to keep only the gravity component of each axis.
   gX = (acceleration.x * kLowPassFilterFactor) + (gX * (1.0 - kLowPassFilterFactor));
   gY = (acceleration.y * kLowPassFilterFactor) + (gY * (1.0 - kLowPassFilterFactor));
   gZ = (acceleration.z * kLowPassFilterFactor) + (gZ * (1.0 - kLowPassFilterFactor))
}

void  PhysicsApplyForceAndTorque (const NewtonBody* body, dFloat timestep, int threadIndex)
{   
   dFloat Ixx;
   dFloat Iyy;
   dFloat Izz;
   dFloat mass;
   
   NewtonBodyGetMassMatrix (body, &mass, &Ixx, &Iyy, &Izz);

   // I also normalize [gX,...]
   dVector force = dVector ( gX*gravity*mass, gY*gravity*mass, gZ*gravity*mass );
   
   NewtonBodySetForce (body, &force.m_x);
}

Caleb Cannon
 
Posts: 3
Joined: Sat Sep 27, 2008 4:28 pm

Re: Newton on the iPhone

Postby Julio Jerez » Sat Oct 04, 2008 2:54 pm

Caleb Cannon wrote:The moments of inertia are wrong for some objects. I'm using a cube moment for everything and it isn't scaled to the objects mass, e.g., NewtonBodySetMassMatrix(body, 1.0f, 1.0f/6.0f, 1.0f/6.0f, 1.0f/6.0f);


I asume you are using tjhsi to have a quick demo, but maybe you sould use the ulitity funtions that calculate the principal inertial
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton on the iPhone

Postby kayanat » Fri Mar 13, 2009 3:45 am

Wow!! it's looks cool on my i phone. I really love it. I hope you guys will come up with new exciting stuffs in future.
kayanat
 
Posts: 1
Joined: Mon Mar 09, 2009 6:17 am


Return to User Gallery

Who is online

Users browsing this forum: No registered users and 14 guests

cron