jonmiller
01-07-2008 19:28:39
I'm just starting to learn PhysX and NxOgre and I'm running into a few problems. My intended result is to make my camera collide with geometry on a moving object. I have a large ship and I'm trying to simulate a crew member walking around on the bridge, but i don't want him to walk through the stuff on the bridge, such as the console, chairs, walls etc. I have all the collision geometry stored in separate mesh files, so I'm loading in my ship then loading each piece of collision geometry separately so that i can build collision rects around them with NxOgre. Is there a better way to do it?
So far I am only loading in 1 piece to test with. I have created an Actor for the camera and the piece i am trying to collide with. They are both Kinematic because they need to move when the ship moves/rotates. I tried to set up an intersection to tell me when they collide. It kinda worked, but it didn't seem to be very accurate at all. Is that the best way to handle what I'm trying to do?
I have been looking at triggers also, but I'm not sure if that's what I want either. I thought I wanted contact reports, but it said that kinematic objects don't work with that. Eventually when I get a collision I'm going to have to back the camera up a little and it would be nice to have some information about how the camera collided with the walls or whatnot. Can anyone help put me on the right track? I'd appreciate any help I can get. Thanks
betajaen
01-07-2008 19:40:52
The Best way I've found is just to use a normal rigid actor that doesn't respond to gravity and has a high damping values. It works so well, I use it in Cake.
http://www.ogre3d.org/phpBB2addons/view ... 1773#41773
jonmiller
01-07-2008 19:59:04
So I shouldn't make them kinematic? And the intersection should work better that way?
Btw, thanks for quick response
betajaen
01-07-2008 20:09:49
Ahh. I've re-read what you wrote. I'm surprised you didn't try out the CharacterController but I'm afraid it probably won't work if you have a huge mesh moving around it. CharacterControllers are kinematic actors (which float just above the ground)
So a rigid body is probably the best choice. If you use a thin capsule, then freeze the rotation (so it won't unexpectedly turn when you move or hit a wall), and have a high linear damping, then add forces or set the velocity manually to move.
If your not planning to go ashore in the ship; I would advice keeping the ship stationary but move the ocean and sky around the ship to simulate movement. If you do move the ship, even up/down motion of the waves, the physics engine may slam your character into the ceilings and floors quite often; as well as anything on the ship that isn't nailed down! The illusion of buoyancy on smaller objects (flags or rope) can be simulated using force fields and possibly with the aid of dominance groups.
jonmiller
01-07-2008 20:49:33
Thanks for the tips. I am currently trying to create a controller as my camera to move it around and see if that works out better for me. Unfortunately I can't leave the ship stationary as it will have to eventually move with the ocean. I am sort of doing what you said where i render my ocean as a plane with my camera always at it's center, then move the ocean and camera around the world. So in a sense everything in the world in stationary, but when moving the ship around it moves independently and will have to react to waves. I'll try more tomorrow and post if I can come up with any solutions and of course more problems

Thanks
jonmiller
02-07-2008 21:25:01
Ok so I was actually able to make some progress. Probably not the best approach, but it's all I have for now. I was able to make my camera shape and collision shapes kinematic. I cleared the disable collision flag for both actors and turned off gravity for them for now. I was able to move my camera actor around by applying force to it. It works out that both objects won't go through each other. So now I am going to move the actor around via forces and have my camera node attached to the actor instead of the other way around. Now when the actor bumps into something it'll stop and keep the camera from moving forward. So provided I get that working tomorrow, I should be pretty much set. I just have another question. Is there any way to move the floor? I'd eventually like to turn gravity back on and move across the floor, but I need to keep it in place when the ship starts moving so I don't end up against the wall giving the illusion that the ship is going warp speed.
Thanks
betajaen
02-07-2008 22:39:59
The ground plane do you mean? It's size is infinite; so you wouldn't need to move it.
jonmiller
03-07-2008 13:39:06
Well I would need to move it up on the +Y because my ship sits on the water around Y = 0 and the floor of the bridge is much higher, about Y = 20ish. Plus I would need to pitch and roll the floor as the ship moved though the water and turned and what not. If it can't be done I can always just make a rectangle for the floor of the bridge.
betajaen
03-07-2008 14:45:27
I would make a rectangle for the floor of the bridge. If you move the plane, it can cause a bunch of possible problems; you should just treat it as the bottom of the ocean.