Problem with near clipping plane

Hi, i am currently generating an FPS, and have created my camera.  However my model doesnt display correctly ,i can see the insides due to it being next to the camera. My near clip is at 1,but even at 0.1 it still doesnt work properly.  Is there a way around this? Thanks in advance



PS.As my first post id also like to say how ace this engine and the support on offer is, woop

Hi and welcome :slight_smile:



What is your far plane at?



(there is only a finite amount of 'resolution' in the frustum, the greater the distance of the far plane it is the less accurate the depth tests are…)



(maybe just post your camera creation code)

Never made an FPS before, but I guess that the weapon is rendered separately from the rest of the world. The far frustum is probably reduced and the weapon is actually rendered a little bit in front of the camera so it doesn't get cut off. Also don't render it directly in front of the camera but to one side (like bottom or bottom-right).

Thanks for quick replies; my far clipping plane is 1000 but i thought it may be an issue an lowered it lower to test, but did not change.



Different parts of the model disappear and reappear as i move around camera.  Ill post some code if it helps :stuck_out_tongue:



I call this from my main update function

Quaternion camRot = new Quaternion();
      Vector3f camPos = new Vector3f();
      Vector3f gunBaseOffset = new Vector3f(0,0.0f,-1.1f);
      Vector3f tmpOffset = new Vector3f();
      
      camPos.set(cam.getLocation());
      camRot.fromAxes(cam.getLeft(),cam.getUp(),cam.getDirection());
      
        tmpOffset.set(gunBaseOffset);
       camPos.addLocal(tmpOffset);
       camRot.multLocal(tmpOffset);
      
      player.update(camRot,camPos);



And this is the update of player

public void update(Quaternion camRot, Vector3f camPos)
   {
      Quaternion q = new Quaternion();
        q.fromAngleAxis(225, new Vector3f(0,1,0));
        camRot = camRot.mult(q);
        q.fromAngleAxis(-90, new Vector3f(1,0,0));
        camRot = camRot.mult(q);
       gunModel.getLocalTranslation().set(camPos);
        gunModel.getLocalRotation().set(camRot);
   }



I'm aware the rotations shouldn't be done with floats, i'm just trying to get a working fps is all, to get used to programming with this engine.

Thanks :D

You will need bring the near plane closer to the camera. Or as Momoko_Fan suggested, scale your model up and render it further out, separate from the rest of the scene.

If i render the object further out though it doesn't stay in front of the camera.  For example; if i make it really far out,i can see the gun moving as i do,buts its not at my position.  I think this can be solved by some form of rotation, but my maths is a tad rusty :stuck_out_tongue: So any help would be appreciated

I think I would try rendering the weapon in a different pass, would probably make it easier to adjust the frustum and apply specific render states…



(also, I believe the rotations the fromAngleAxis() method uses radians rather than degrees…)