Is there something like the opposite of the Sky Bucket? Make it always in front of others, since I have this problem:
In this case, the player’s holding a sword. I want all of it visible. Or is this not how objects which the player’s holding works in first-person games?
Thats a common problem you see in games. If it were me, I would put the sword in a separate transparent viewport above the main viewport, then your guaranteed to always see it. You can try put it in the guiNode also, but i don’t recommend it. There may be other ways to achieve it tho
@wezrule thanks for the quick reply! I’m not familiar with viewports n’ such, but I’ll go study’em. But before that, will the object still be affected by lighting and shadows?
if they are in that viewport as well yes. Using a own geomtry comparator or and mainpulating the zchecks might help as well
I investigated the source code of SimpleWaterProcessor and later TestMultiViews which used multiple viewports. I got a little on how to use viewports. , but I get this:
where I want the white background to be transparent. I set the background color for that viewport to 0, 0, 0, 0, but that didn’t seem to work. Am I supposed to use that thing called stencils?
Also, if I add the shadow processor to that viewport, I’m going to have to add the shadow-casting objects to that one, right? Which is some of the cause of the cut-off, which defeats the purpose. So putting a transparent viewport above the main viewport wouldn’t work, right?
@EmpirePhoenix So how do I do your method? Do I extend a class, override a method, etc?
@seann999 have you tried putting the weapon in the Translucent Bucket ?
Something else you could try it to shoot a ray from the tip of the sword and if hits something withing X units (or inside) move the sword aside or just stop the player from moving farther into the object. I’d personally vote for moving the sword aside, would look a lot better.
@thetoucher yes, I noticed before that translucent objects are rendered last (or something like that). And it did make it in front of everything else, but it didn’t seem to be affected by shadows.
@madjack if all else fails, I’ll probably do that.
The problem with multiple viewports is that filters don’t play too well…
you can try to disable depth test on the sword material and set it in the transparent bucket.
sword.getMaterial().getadditionalRenderTest().setDepthText(false);
@nehon said:
you can try to disable depth test on the sword material and set it in the transparent bucket.
sword.getMaterial().getadditionalRenderTest().setDepthText(false);
"setDepthTest"
true
getAdditionalRenderState
@nehon said:
you can try to disable depth test on the sword material and set it in the transparent bucket.
sword.getMaterial().getadditionalRenderTest().setDepthText(false);
"getAdditionalRenderState"
rha damn it…
@nehon I got the closest to what I wanted by disabling depth test and setting the object in the transparent bucket. But now the post-process shadows are drawn over the object:
I then tried this:
[java]
Geometry model1 = model.clone();
model1.scale(0.99f);
model1.setQueueBucket(Bucket.Transparent);
model1.setShadowMode(ShadowMode.Off);
model1.getMaterial().getAdditionalRenderState().setDepthTest(false);
rightHand.attachChild(model1);
Geometry model2 = model.clone();
model2.scale(1.00f);
model2.setQueueBucket(Bucket.Opaque);
model2.setShadowMode(ShadowMode.CastAndReceive);
model2.getMaterial().getAdditionalRenderState().setDepthTest(true);
rightHand.attachChild(model2);[/java]
which did what I wanted. But is there still a “cleaner” way to do it?
Mhh…yeah place it in the translucent bucket then
It then doesn’t receive any shadows, even if I’m under a tree or something
Not sure if this has been suggested already but maybe try putting it in the transparent (not translucent) bucket and turning off depth test for the object:
http://hub.jmonkeyengine.org/javadoc/com/jme3/material/RenderState.html#setDepthTest(boolean)
If you have other transparent objects that it is clipping then you can set your own comparator on the transparent bucket that always sorts it last so that it will be drawn last.
Though I think you will always have some kinds of problems trying to have an object in the 3D scene that is not really in the 3D scene… but is still in the 3D scene. The above is probably simpler than making the sword physical so that it can’t penetrate stuff.