ChaseCamera rocking

I'm not sure that I quite understand the ChaseCamera.  Occasionally, when I don't even have the game window in focus and the node it is watching is not moving, the camera will begin to rock back and forth - starting small and making ever larger sweeps over the top of the node.  Obviously this only happens when setEnableSpring is true.



Additionally, I also noticed that if my camera and model are not initially in the same place in proper position, the camera will immediately be rocking wildly when the rendering starts.  That in itself does not surprise me - I figure it's from moving quickly a large distance.  The part I find odd is that it never stops oscillating - I've let it run for a few minutes and it's still going!



Finally, just as an attempt to fix the problem, I thought I'd try to use a lookAt() call on the camera - followed up by an update to the camera and the chasecamera.  This resulted in a satisfactory result, until I started moving the model (using ThirdPersonHandler) - and then it started oscillating massively again.  This strikes me as odd, considering the camera looks like it is in the right position while sitting still.



I am using the default values for spring and damp from the rencontroleditor. (I've also tried pushing the damp values really high, but to no avail)  I'm pretty frustrated at this point, mainly because I don't understand why the rocking starts, so I can't fix it properly.


Is it a DynamicPhysics node that the camera is looking at?



I found that the chase camera did not like looking at one in OSX (even the testAdvancedVehicle goes nuts for me)…

Nope, I don't use any physics (yet).  One odd thing I did notice though, is if I take out the code for the WaterRenderPass, it doesn't go wild.  My water is very similar to TestProjectedWater.  Very odd.

I think there is also an issue with the ChaseCamera with low frame rates, maybe that has something to do with it.

Yeah, springs are very tricky in low frame rates.  Maybe if we took the relaxation method from the cloth code it would be more stable.  Also, make sure you read the javadoc for ChaseCamera's update method noting the part about ideal dampingK to springK ratio.

ive experienced the same problem before. and i was running at 400+ fps.



the camera just bounces back and forth between +10000 and -10000 or something like that.



i checked and my spring constant and damping constatnt ratio is indeed 1.

Maybe you could provide a test case. :slight_smile:

This could be an unrelated issue, but I kind of doubt it.  Remember how earlier I said the camera starts majorly oscillating if I turn on the water?  Well, I have two cameras, and one of them does not look at the right area when water is turned on as well.



This second camera is supposed to look at a rectangle box from the top, and stay above it while it moves.  When I turn on the water it always looks at whatever the main game camera looks at…



Here are two pictures to help better explain:

Correct way (with water off): http://shadowquest.net/images/cam_correct.jpg

Wrong way (Enabled water): http://shadowquest.net/images/cam_wrong.jpg





EDIT:

I did a bit more testing - commenting out code and such - and the problem does not come from the WaterRenderPass - it comes from the ProjectedGrid.  If I create the ProjectedGrid but do not add it to the root node everything is fine.  However, once it is added, the camera becomes much more unstable.  (not quite as unstable as when the water texture is rendered on it, but that may be a framerate issue).  Adding it to the root node is also what is causing my other camera to look in the wrong direction.



Wrong way (Enabled PG): http://shadowquest.net/images/cam_wrong2.jpg


      PG = new ProjectedGrid( "ProjectedGrid", GameCamera, 100, 70, 0.01f, new WaterHeightGenerator() );
      RootNode.attachChild( PG );

This is maybe because ProjectedGrid modifies the modelview matrix via gluLookAt?  Seems like we could change that to at least push and pop the matrix to prevent changes.

Let me know when the changes are in the cvs and I'll check to see if it fixes one or both of the issues

MrCoder is looking into this now.

Were these changes ever applied to the 1.x version?  I diffed a few things and couldn't find any relevant changes (I'm waiting until things stabilize with 2.0 to upgrade to that…)

bump…