chandlerprall / Physijs

Physics plugin for Three.js
MIT License
2.77k stars 456 forks source link

REQUEST: Feature ideas for forthcoming vehicle physics system... #27

Closed jayfield1979 closed 11 years ago

jayfield1979 commented 12 years ago

Hey @chandlerprall

You may have already thought of these before but as someone who is very interested in the possibility of your proposed vehicle physics and a casual game developer I thought I'd share some suggestions with you based on the questions I've asked of other physics systems (as I am not up to coding one myself):

Articulation - for simple lorry/trailer action More than 4 wheels - say a six wheeled ATV or a lorry Rear-wheel turn - forklift trucks etc. Different sized wheels - like on a tractor

As I mentioned earlier I would be happy to help test and provide models and 'situations' to help develop this system what you've created so far appears very simple to use - this could be a good one!

p.s. hope development is going well

chandlerprall commented 12 years ago

Physijs is built on top of Ammo.js (Bullet Physics), as long as that library supports these features I have no problem including them. From what I have seen of Bullet's vehicle system I don't think any of the above will be a problem - maybe the rear-wheel turning, but I think that can be worked around.

The articulation would have to come from a Point2Point constraint between two vehicle systems -- I'm working on finishing up the constraints now and should have them ready before too long.

jayfield1979 commented 12 years ago

That's awesome news!

I can't wait to give it a go!

chandlerprall commented 11 years ago

Vehicle system now is in place and should support everything in your list - vehicle example

jayfield1979 commented 11 years ago

That's fantastic! When I get some time I will check it out. Very much looking forward to experimenting!

Thanks for taking the time to let me know.

James

On 22 Oct 2012, at 08:25, Chandler notifications@github.com wrote:

Vehicle system now is in place and should support everything in your list - vehicle example

— Reply to this email directly or view it on GitHub.

jayfield1979 commented 11 years ago

Hi,

Just been looking at the examples on your github home page and was wondering why they are now running so slowly:

http://chandlerprall.github.com/Physijs/examples/vehicle.html

There appears to be 2 FPS counters? Is this normal?

I still haven't had chance to play with or dissect the example code but thought I'd drawn your attention to it.

James

chandlerprall commented 11 years ago

The 2 FPS counters represent the graphics framerate (top) and the physics framerate (bottom). Which is running slow for you?

jayfield1979 commented 11 years ago

Hi,

It's the bottom rate that rarely exceeds 12fps - is this normal? Is 12fps on the physics adequate I understand that it's obviously not bound to the fps. Do they run on separate threads? I'm on a top spec MacBook pro now.

James

Date: Sat, 27 Oct 2012 01:54:02 -0700 From: notifications@github.com To: Physijs@noreply.github.com CC: jayfield1979@hotmail.co.uk Subject: Re: [Physijs] REQUEST: Feature ideas for forthcoming vehicle physics system... (#27)

The 2 FPS counters represent the graphics framerate (top) and the physics framerate (bottom). Which is running slow for you?

          —

          Reply to this email directly or view it on GitHub.
chandlerprall commented 11 years ago

Few more questions: which example are you viewing and with what browser? Do you have a dedicated GPU or are you using integrated graphics?

The physics does run in a separate thread so it does not get in the way of rendering.

jayfield1979 commented 11 years ago

My macBook Pro has NVIDIA GeForce GT 650M with 512MB of GDDR5 memory

On my iMac i7 which has a ATI Radeon HD 4850 512 MB, the bottom fps ranges from 12 - 25 fps

Both examples are of the car and boxes. It does look great!

Date: Tue, 30 Oct 2012 08:11:23 -0700 From: notifications@github.com To: Physijs@noreply.github.com CC: jayfield1979@hotmail.co.uk Subject: Re: [Physijs] REQUEST: Feature ideas for forthcoming vehicle physics system... (#27)

Few more questions: which example are you viewing and with what browser? Do you have a dedicated GPU or are you using integrated graphics?

The physics does run in a separate thread so it does not get in the way of rendering.

          —

          Reply to this email directly or view it on GitHub.
chandlerprall commented 11 years ago

What browser are you using?

jayfield1979 commented 11 years ago

I have another question... how feasible would it be to only have your phisyics simulation apply to objects that fall in a radius of say a car or character? A bit like LOD but either physics applied or not...

That would certainly speed up simulation...

Date: Tue, 30 Oct 2012 10:23:33 -0700 From: notifications@github.com To: Physijs@noreply.github.com CC: jayfield1979@hotmail.co.uk Subject: Re: [Physijs] REQUEST: Feature ideas for forthcoming vehicle physics system... (#27)

What browser are you using?

          —

          Reply to this email directly or view it on GitHub.
chandlerprall commented 11 years ago

That is up to the broadphase to determine, and the ones in Ammo are very efficient as it is.

What browser are you using?

jayfield1979 commented 11 years ago

I have finally got some time to play around with vehicle physics...

I have copied your code locally and replaced the models with my own...

My question is could you annotate the following properties so I know what I'm changing:

vehicle = new Physijs.Vehicle(mesh, new Physijs.VehicleTuning( 10.88, 1.83, 0.28, 500, 10.5, 6000 ));

My meshes work (car & wheel) but their displacement is wrong (as the values I assume are based on your supplied Mustang model).

It is working very well but just looks odd :)

Very much looking forward to getting something cool out of this!

James

Date: Fri, 2 Nov 2012 13:25:25 -0700 From: notifications@github.com To: Physijs@noreply.github.com CC: jayfield1979@hotmail.co.uk Subject: Re: [Physijs] REQUEST: Feature ideas for forthcoming vehicle physics system... (#27)

That is up to the broadphase to determine, and the ones in Ammo are very efficient as it is.

What browser are you using?

          —

          Reply to this email directly or view it on GitHub.
chandlerprall commented 11 years ago

The parameters to VehicleTuning are, in order:

suspension_stiffness
suspension_compression
suspension_damping
max_suspension_travel_cm
friction_slip
max_suspension_force
jayfield1979 commented 11 years ago

Thanks for that!

I have managed to get my models working with your example and changed a few settings to better fit the models:

http://frontier.lincoln.ac.uk/3d/development/Stage3/CarWPhysics/v2.html

There are some issues, which if you could help me with, I'd be grateful:

1) The car works ok but appears to hit invisible objects along the way. I assume this is something to do with maybe setting the diameter of the wheels but as the example I adapted uses your "addWheel" function, I can't see how I can change this.

2) My wheels face the same direction on both sides of the car.. wheels on the right need rotating 180 degrees - is this something I can specify without altering your script?

3) Is it easy enough to get my car to reverse?

Thanks in advance...

jayfield1979 commented 11 years ago

p.s. I have resolved the issue 1 by removing the noise applied to the ground plane and changing it from a HeightField to a simple Plane.

My question remains however... do you have to manually enter a value for the diameter of the wheels or is it calculated?

jayfield1979 commented 11 years ago

also... when creating a new vehicle can you pass other arguments to specify max power, steering offset, acceleration, etc...