Hello everybody
Ok, as you know, i am creating a fps. I am now trying to solve some problem cient-side, and one of them is the fact that when you are too close to a wall you weapon go through it. It’s only a visual problem, as bullets are shot from the “camera” point.
I read things about it, and there is mainly 2 approach: disable the depth test and use a different viewport. The first one is not really a “fix” as it creates new problems with non-convex models.
For the second one, there is different approach.
- Create a new camera at a fixed position, set it to the viewport then add the weapon to the scene of this viewport. The problem with this approach is light. I GUESS this, as I didn’t test it. As the spatial is at a fixed position, the lighting will not change on it.
- Use the old camera with the same viewport. I prefer this one, as the weapon’s node is already attached to the client, so I don’t need to change anything. But … well, here is a picture of the result:
I use the toonshader. The problem is : the weapon is rendered twice. I know that because the toonshader is still visible at “1” and not visible at “2”. (btw, if someone want a toon shader that only outline objects it is a way to do it ) So, what I want to do now is to avoid the rendering of the weapon for the “normal” viewport and only render it in the “new” viewport. I tried this in the controlRender of a control attached to the weapon:
@Override
protected void controlRender(RenderManager rm, ViewPort vp)
{
if ( vp != theNewViewPort )
{
spatial.setCullHint(Spatial.CullHint.Always);
}
else
{
spatial.setCullHint(Spatial.CullHint.Never);
}
}
However, the only result is that the weapon is always culled (for both viewport).
So, do you know a way to “skip” the rendering of a spatial for a viewport ?
Hope you have an idea.