About Store Forum Documentation Contact
Donations:
327$/mo



Post Reply 
First Person Shooter gun clipping
Author Message
Rollcage Offline
Member

Post: #1
First Person Shooter gun clipping
What is the best way to prevent gun from appearing to clip through walls in a FPS? I know drawBehind() can be used but that fills the mesh with solid colours.
Is there anything similar to drawBehind or does the mesh need a special shader/material that does the same thing?

cheers.

Edit: calling mesh.drawBlen() from case RM_BEHIND apperas to achieve this effect. Are there any other ways?
(This post was last modified: 10-06-2011 06:18 AM by Rollcage.)
10-06-2011 06:14 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: First Person Shooter gun clipping
rotate the gun towards up direction, or increase player controller radius
10-06-2011 11:14 AM
Find all posts by this user Quote this message in a reply
Rollcage Offline
Member

Post: #3
RE: First Person Shooter gun clipping
1) Can a shader be applied to the weapon material that would allow the mesh to be rendered over everything else in the world?

Also:
2) I'm using a lerp function to adjust the mesh matrix for the weapon when it is moved.
The weapon follows the orientation of a point on the character skeleton.
I use
Code:
Vec v1 = Lerp(anim.matrix().pos, point.pos, 0.9f);
anim.matrix(Matrix().setPosDir(v1 , point.cross(), point.dir));

This works however the gun moving is not smooth sometimes. Is there some way that I can get it smoother?

Thanks
10-06-2011 11:47 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: First Person Shooter gun clipping
as I've mentioned your other thread, gun behind wall would get partially rendered shadowed (it would not look good), so it is not supported
I recommend rotating gun (I've seen it in some game, and it looked good)
10-06-2011 11:51 AM
Find all posts by this user Quote this message in a reply
Rollcage Offline
Member

Post: #5
RE: First Person Shooter gun clipping
I'll give it a try, however I can see problems when the player is trying to aim the weapon around a corner, and it rotates up instead.
10-06-2011 11:58 AM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #6
RE: First Person Shooter gun clipping
Normally you would clear the z-buffer after rendering the scene and then render your fps weapon. This will ensure that your weapon is always rendered over the top of the scene.
10-06-2011 02:36 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #7
RE: First Person Shooter gun clipping
Is it possible to draw the world, clear the depth, and then draw the gun? All my tests thus far have failed.

This works, but messes with some effects and, at times, can drop the framerate in half:

Code:
Renderer(world);

// Draw anything that relies on the world's depth here (e.g. D.textDepth)..

Renderer.combine = true;
Renderer(gun);
Renderer.combine = false;

// Draw GUI..

----------

EDIT: Actually, nevermind, it appears to be working great now! I forgot my gun object was also drawing the bullets and was giving a weird motion effect on them because of this. Switched the bullets to be drawn with the world and everything is fine now.

Not sure what was causing the framerate drop, though. However, it doesn't appear to be happening anymore, at the moment.
(This post was last modified: 11-10-2011 11:23 PM by Driklyn.)
11-10-2011 11:04 PM
Find all posts by this user Quote this message in a reply
Post Reply