Hud weapon sticks into landscape

hi boys and girls,



to make it simple:

i use a simple node as the player, atatched an invisible box to it to give it something to check collisions (works) and a weapon. since i want to look through the players eyes and not his feet, i add an offset to the nodes y-position and put the camera there. the weapon still remained at the players feet. to fix this, i added the offset to the weapon as well.

now i run into one of these problems:

a) in my first version (camera at feet), i used a scaled down version of the weapon. it didn't look smaller at all, but didn't touch the landscape and all was good. but the model was static (it moved exactly where the camera was looking), there was no "i see a little bit more of the weapon if i look up"-effect like in many first person shooters. i don't like that.

b) in my second version (camera & weapon moved up), the weapon rotates around the camera when looking up/down. it's no longer stuck at the bottom of the screen. i undid the scaling, and the weapon looked fine again. i even got this "i see a little bit more of the weapon if i look up"-effect like in many first person shooters. i like that. disadvantage: the weapon is quite long and is not drawn if i look at the ground because it is further away than the ground. i need the weapon model to have it's own z-buffer and ignore anything that has been drawn yet. can this be done somehow?



i'm not fully understanding how "it" works, but i think when using no y-offset, the player node is rotated around it's origin, making the weapon rotate around the origin as well. so, if i translate both the camera and the weapon up, the weapon is still being rotated around the player nodes origin (because the mouse rotates this one) and not around it's own origin, resulting in the "i see a little bit more/less of the weapon if i look down/up"-effect.

so another solution would be to make the weapon rotate around its origin and not the player's. (i don't know how to do that either)

For the first problem- Make the weapon always pass the z-test:


ZBufferState zbuf = DisplaySystem.getDisplaySystem().getRenderer().createZBufferState();
zbuf.setFunction(ZBufferState.CF_ALWAYS);



Second- Try using a CameraNode and attaching the weapon to it. That way the weapon will rotate relative to the eye's position and thus always stay in the same spot on the screen.

well don't make the weapon a child of player, so it can rotate around it's own origin.

and about the z buffer, i have the same problem…

Momoko_Fan said:

For the first problem- Make the weapon always pass the z-test:


ZBufferState zbuf = DisplaySystem.getDisplaySystem().getRenderer().createZBufferState();
zbuf.setFunction(ZBufferState.CF_ALWAYS);



Second- Try using a CameraNode and attaching the weapon to it. That way the weapon will rotate relative to the eye's position and thus always stay in the same spot on the screen.


won't work - that way, i must presort all triangles inside my weapon model

well don't make the weapon a child of player, so it can rotate around it's own origin.
and about the z buffer, i have the same problem...


did that. worked.