Hi,
All my congratulations for your outstanding work.
I'm looking for some code samples explaining the use of the checkCameraCollision() method.
Can you help me?
Well, have a look at the Bounce-example and replace
if (zoomin) {theWorld.getCamera().moveCamera(Camera.CAMERA_MOVEIN, zoomSpeed);}
if (zoomout) {theWorld.getCamera().moveCamera(Camera.CAMERA_MOVEOUT, zoomSpeed);}
if (shiftleft) {theWorld.getCamera().moveCamera(Camera.CAMERA_MOVELEFT, zoomSpeed);}
if (shiftright) {theWorld.getCamera().moveCamera(Camera.CAMERA_MOVERIGHT, zoomSpeed);}
if (shiftdown) {theWorld.getCamera().moveCamera(Camera.CAMERA_MOVEDOWN, zoomSpeed);}
if (shiftup) {theWorld.getCamera().moveCamera(Camera.CAMERA_MOVEUP, zoomSpeed);}
with this:
if (zoomin) {theWorld.checkCameraCollision(Camera.CAMERA_MOVEIN, zoomSpeed, Camera.DONT_SLIDE);}
if (zoomout) {theWorld.checkCameraCollision(Camera.CAMERA_MOVEOUT, zoomSpeed, Camera.DONT_SLIDE);}
if (shiftleft) {theWorld.checkCameraCollision(Camera.CAMERA_MOVELEFT, zoomSpeed, Camera.DONT_SLIDE);}
if (shiftright) {theWorld.checkCameraCollision(Camera.CAMERA_MOVERIGHT, zoomSpeed, Camera.DONT_SLIDE);}
if (shiftdown) {theWorld.checkCameraCollision(Camera.CAMERA_MOVEDOWN, zoomSpeed, Camera.DONT_SLIDE);}
if (shiftup) {theWorld.checkCameraCollision(Camera.CAMERA_MOVEUP, zoomSpeed, Camera.DONT_SLIDE);}
and remove the
cube.rotateZ(0.005f);
some lines above (to prevent the cube from spinning). This should show the basic usage of the camera collision (you can navigate using the num-pad in this example btw). The Camera.SLIDE option doesn't really work as it should...i'll have to fix this in a later version, but anyway...
I hope this helps. If it doesn't, feel free to ask again. Keep in mind that jPCT uses a ray/triangle-collision scheme for camera-collisions.
Depending on the scale of your world, you may have to adjust Config.collideOffset accordingly, but for Bounce, it should work fine the way it is.