by date
PhysX FlyingVehicle Prototype (+video)
PhysX FlyingVehicle Prototype (+video)
| Name: | Henry Todd | |
|---|---|---|
| Date Posted: | Dec 12, 2007 | |
| Rating: | Not Rated | |
| Public: | YES | |
| Comments: | YES | |
| RSS Feed: | or Subscribe with . | |
| Profile Page: | View profile page for Henry Todd |
Blog post
Spent the night on this one. Couldn't tear myself away once I got started.
As with my previous Player example, I altered the Vehicle class to inherit from PhysXActor instead of ShapeBase. Once you clear out the extraneous addtoscene/removefromscene calls (this already gets handled in PhysXActor), it'll load without crashing. Comment out a few calls to setPosition inside vehicle.cc, and a FlyingVehicle should now drop into the scene as a PhysXActor. It won't do anything, but it'll be in the scene.
At this point, I went through updateForces and attempted to replace every reference to mRigid with the equivalent call to mActor. During this process, I found out a few fun things about FlyingVehicle physics explaining why they're so strange. UpdateForces produces a bizarre mix of mass-less and with-mass force values, and adds in an extra copy of the gravity force for good measure (probably to counter the hover force, which adds an absurd upward velocity to the object that never stops, no matter the altitude!). Anyway, a bit of clean-up was needed here, but in the end I came up with an equivalent flight model that actually feels a lot more realistic than the default. You can also recreate the stock low-gravity vehicle by enabling the hover force above the set hover height.
This particular vehicle is too fast, turns too slowly, and doesn't have any hover force, but it's fun to fly.
I'd discuss the details more, but I'm legally brain-dead right now. Have a video:
www.youtube.com/watch?v=_Jo6tHPdOiA
Sorry about the YouTube, but Google Video likes to claim videos are live and make you wait another hour to view them. If it ever actually goes live, this one might be slightly better looking:
video.google.com/videoplay?docid=-3855399327398376594&hl=en
It's using an absurdly oversized collision box right now, but you can see that there was a box sitting on top of the vehicle when it started that fell off due to the acceleration. Also, notice how well it handles that high speed impact with the terrain (no glitching).
I'm relying on PhysXActor's interpolation right now, which isn't very good. Vehicle's is much better, and I should replace all the Vehicle interpolation code references to mRigid with mActor. It's solid in single-player, but I believe that Vehicle's warp/interpolation code would be a perfect replacement for the PhysX network interpolation.
The original resources limitations on terrain collision are more obvious with access to this much speed. It misses certain terrain details, especially at larger squaresize and with higher detail, and stops terrain collision outside the central page. I'm not qualified to solve this problem, but I may still have a look at it and see what I can do.
As with my previous Player example, I altered the Vehicle class to inherit from PhysXActor instead of ShapeBase. Once you clear out the extraneous addtoscene/removefromscene calls (this already gets handled in PhysXActor), it'll load without crashing. Comment out a few calls to setPosition inside vehicle.cc, and a FlyingVehicle should now drop into the scene as a PhysXActor. It won't do anything, but it'll be in the scene.
At this point, I went through updateForces and attempted to replace every reference to mRigid with the equivalent call to mActor. During this process, I found out a few fun things about FlyingVehicle physics explaining why they're so strange. UpdateForces produces a bizarre mix of mass-less and with-mass force values, and adds in an extra copy of the gravity force for good measure (probably to counter the hover force, which adds an absurd upward velocity to the object that never stops, no matter the altitude!). Anyway, a bit of clean-up was needed here, but in the end I came up with an equivalent flight model that actually feels a lot more realistic than the default. You can also recreate the stock low-gravity vehicle by enabling the hover force above the set hover height.
This particular vehicle is too fast, turns too slowly, and doesn't have any hover force, but it's fun to fly.
I'd discuss the details more, but I'm legally brain-dead right now. Have a video:
www.youtube.com/watch?v=_Jo6tHPdOiA
Sorry about the YouTube, but Google Video likes to claim videos are live and make you wait another hour to view them. If it ever actually goes live, this one might be slightly better looking:
video.google.com/videoplay?docid=-3855399327398376594&hl=en
It's using an absurdly oversized collision box right now, but you can see that there was a box sitting on top of the vehicle when it started that fell off due to the acceleration. Also, notice how well it handles that high speed impact with the terrain (no glitching).
I'm relying on PhysXActor's interpolation right now, which isn't very good. Vehicle's is much better, and I should replace all the Vehicle interpolation code references to mRigid with mActor. It's solid in single-player, but I believe that Vehicle's warp/interpolation code would be a perfect replacement for the PhysX network interpolation.
The original resources limitations on terrain collision are more obvious with access to this much speed. It misses certain terrain details, especially at larger squaresize and with higher detail, and stops terrain collision outside the central page. I'm not qualified to solve this problem, but I may still have a look at it and see what I can do.
Recent Blog Posts
| List: | 12/12/07 - PhysX FlyingVehicle Prototype (+video) 11/16/07 - (Video) PhysXActor Derived Player Class |
|---|
Submit your own resources!| Dave Young (Dec 12, 2007 at 15:03 GMT) |
| Affectworks (Dec 12, 2007 at 15:06 GMT) |
| Jonathan (Dec 12, 2007 at 18:51 GMT) |
| Chris Harpan (Dec 13, 2007 at 03:35 GMT) |
| Christopher J. White (Dec 13, 2007 at 12:15 GMT) |
| Henry Todd (Dec 14, 2007 at 05:31 GMT) |
At the moment I'm debating how to handle WheeledVehicle. The best solution would be to have the wheels handled as PhysX actors, however there's no reason to actually have them exist in scene and get ghosted; I just want to place them at the location the existing wheel code defines, apply torque to them, and use their interaction with the terrain/whatever surface to create the force. This will get us a much nicer, more realistic wheel force which should remove the "gliding" we often see in the wheeled vehicles. I am concerned about the terrain collision resolution here; in Player, poor terrain resolution results in the Player standing in spots technically a few inches above or below the terrain, which in turn breaks the code that determines if you're on a valid move surface. This same thing would happen with the wheels. Again, this is something that needs to be fixed in the original resource, so I won't be designing around it.
A much quicker solution would be to use the PhysX Actor for the rigid body and just use the existing wheel code. I still need to figure out what the correct conversion of forces is, however; my FlyingVehicle uses completely different force scales than stock as I've removed a lot of the more hacky physics code from updateForces.
Hopefully someone with more experience with the guts of this type of code will be able to spot the base issues with the PhysX resource (maybe having access to some playable PhysX objects will help with debugging? :P), or we'll see a 0.4 release with fixes in the near future. I've got a lot on my todo list, but I'll try to look into these core issues when I have time.
I attempted to apply Vehicle's interpolation code to the PhysX body, but I must not have rigged it up correctly; the resulting interpolation behaved like a Rigid object's bounding box, bouncing back and forth as it moved, instead of the smooth interpolated render position I expected. Running the client-side PhysX world has still been my best solution so far, but it doesn't properly handle the warps created when new server positions are significantly offset from client positions.
That said, it works really well in multiplayer so long as the connection stays decent and you don't expect to ghost 40 physics objects at once. It could be argued that the laggy movement introduced when dozens of PhysXActors are getting position updates is no worse than the same lag introduced when large numbers of Rigid objects get updates. Having 10 or 15 vehicles in a map at once is completely safe as long as everyone's got a broadband connection and you've upped the packet rates/sizes a bit, and even games like the Battlefield series don't expect that many vehicles to exist per map. Expecting to have 64-players all controlling PhysX objects will require some smarter network code.
| Adam Beer (Dec 27, 2007 at 17:23 GMT) |
| Dave Young (Jan 08, 2008 at 18:50 GMT) |
| Michael Perry (Feb 04, 2008 at 21:38 GMT) |
| Adam Beer (Feb 04, 2008 at 21:45 GMT) |
| Michael Perry (Feb 04, 2008 at 21:46 GMT) |
2. Ragdoll
I made my own attempt at inheriting Player from PhysXActor...but Torque is giving me a big middle finger right now.
Edited on Feb 04, 2008 21:47 GMT
| Adam Beer (Feb 04, 2008 at 21:48 GMT) |
| Michael Perry (Feb 04, 2008 at 21:50 GMT) |
Haven't decided on anything yet. Gotta integrate it into Henry's stuff, then polish the dynamic stuff to make the code work with custom rigs and not just Kork
| Adam Beer (Feb 04, 2008 at 21:52 GMT) |
| Michael Perry (Feb 04, 2008 at 22:31 GMT) |
Something like this:
head = "BIP01 Head" // <--Node, name in model
torso = "BIP01 Torso" // <--Node, name in model
neck = head,torso 3 // <---Joint, node1,node2, constraint
This way, the ragdoll skeleton can be set up dynamically to work for whatever rig your artist creates for your game. Nifty, huh?
*note*-sample does not reflect end code
| Ron Nelson (May 08, 2008 at 06:02 GMT) |
| Ron Nelson (Oct 21, 2008 at 03:30 GMT) |
You must be a member and be logged in to either append comments or rate this resource.


Not Rated


