How make a ray to see through objects

Hello, i think the title say it all but if its not clear enough, here what am trying to do : I want to be able to make my character visible through walls or objects, preferably all the time. I have play a lot of games in my life and these situations when you can’t see where you are because of the wall are just awful, and i would love to keep that from happening. I would also love to be able to set some object transparent when am working on my map editor kinda thing, so I would be able to see what the hell am doing, avoiding areas to be accessible when they should not only because I could not see what was going on backStage.

I saw something about the setAlphaTest, I have also play a bit whit the bucket and the tile am using are all transparent, looking a bit like that :
movementMat2 = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md"); movementMat2.setBoolean("UseMaterialColors", true); movementMat2.setColor("Ambient", new ColorRGBA(0.02f, 0.40f, 0.02f, 0.8f)); movementMat2.setColor("Diffuse", new ColorRGBA(0.1f, 0.45f, 0.1f, 0.8f)); movementMat2.setFloat("Shininess", 128f); // [0,128] movementMat2.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off); movementMat2.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);

but this probably would not help. Funny enouf i have seen a lot of people having bugs that cause what i want, but i still don’t have any idear of how i could do it on the fly. Anyone have a idear?

http://javadoc.jmonkeyengine.org/com/jme3/material/RenderState.html#setDepthTest(boolean)
?

I am a bit confuse? Am suppose to put this render state on my whole scene or something? I have found the so said range in the DepthRange like this

this.renderManager.getRenderer().setDepthRange(0, 100); ;

But what i am suppose to do whit it?

You see where you are setting all of that RenderState stuff. You see how the method I show is on RenderState

Let me put your question a different way “How do I keep my object from getting obscured even when it’s depth is farther away than the near objects’ depth?”

Edit: and you will need to put the object in the translucent bucket, also.

1 Like

Also, you might want to render your character to a separate Off screen buffer with it’s own depth test… on the Preprocess bucket… that way there would be an “easy check” to see if anything would obscure it or not.

1 Like

Alright so i did as you said, and it seem to be working just fine, the only problem i have now is that I don’t know how to acces my Material for my caracter. I load it that way :

forme = a.loadModel(asset);

Where “forme” is a spatial and “asset” is a string give in the contrustor, in this case Models/Oto/Oto.mesh.xml. But in no place do i have acess to the material. I did a little .setMaterial() on that spatial whit a specaly made material to make the test and it work, but i kinda want to keep the spatial material already set.

Also i now wonder, if i wanted to put a “aura” of visibility around my caracter, shoud a creat a invisible box around my caracter and set im also in the deeprange(false)? Because right now it do work, but it look kinda wierd

On a final note after some reading in the API i am still a bit confuse about what the variable is setDepthRange suppose to do. I do underthand that it suppose to set the starting range and the ending range but… what kinda range o_o’’’ It might sound a bit newby but i am realy confuse right now. Setting the variable to a (10,20) seem to work but i would kinda love to know why.

…do not call this. It does not at all do anything that you think it does… and anyway it’s not really meant to be called by regular code. Just pretend that it doesn’t exist until you’ve read about 10 articles on depth buffers.

Regarding the other… go through your hierarchy and find the geometry objects. Cast them to Geometry and get the material. It’s kind of basic Java at that point.

You can use a SceneGraphVisitor to make it a bit easier, though. See the javadoc.

oh, well… if you do not specify a material… I believe that the default is: Lighting.j3md. It would be like saying:

   Material mat_default2 = new Material( 
        assetManager, "Common/MatDefs/Light/Lighting.j3md");
   teapot.setMaterial(mat_default2);

That would be your “spatial material already set”… you should be able to make your adjusted material off of that OpenGL code, if you like the way it looks.

“Spatial” on left has undeclared Material, “Geometry” in the middle has “Unshaded.j3md” explicitly declared, “Spatial” on right has “Lighting.j3md” explicitly declared

@pspeed Has it right on the money for SetDepthRange… you should read up on the depth buffers and rendering in OpenGL to fully understand it… I will give you the clue that the value has to with the “Distance from the Camera” and “How WhiteVsBlack it gets on the Depth Buffer”. You can see this in action if you’ve seen some of the tests by building the tests project in JME.

This will help, big time.

and in the same spirit of “keep learning, you can do this” the “aura” can be made. The clues that I will drop for ya are “The Character has it’s own Z-buffer”, “The Character’s Z-buffer has the same depth Range as the Main Z-buffer”, “You will be making special .j3md, .vert, and .frag files”, and “There will be a “Post Process” step(“The Aura”) to combine an OffScreen Rendering of the normal scene and an OffScreen Rendering where everything is drawn (including the character), except for stuff in front of the Character”
edit: I say OffScreen for both, mainly because I’m a bit “deferred” for my mindset.

So @SimonBedard, Go hit the books! You can dooo eeeet! :smile:

And make sure to strut your stuff, and show it off to others who are learning, as well. I’d like to see what you decide to go with for your “aura” effect!

First, thanks for the help, I must say
i’m always happily surprised to see how fast I get answers on this
forum, I really love the JME community, even if I got a feeling soon
you guys will only answer to me in riddles :smile: . I guess its a good
though, I have learned a lot with those little bits of advice, and
still am.

Yet, I can see now that this problem is a bit bigger than I first
expected it too be. I mean I have some result, and they are looking
pretty good, but to get them at the level I want them to be, it would
take much more time than what I can spend on it right now,
considering I also have a lot more about the rest of the program to
develop. I’ll get back to it later and will happily share the results
on the forum, I promise x)

Anyway here is some picture of the
combatMapEditor am building, and the effect setdepthTest have on it.
If you are wondering, yes, those wierd words are french xD

befaure

after

So ya, thanks, il get back too it soon enouf, just need too finish so stuff befaure! xD

I love what you’ve got, and seeing the pictures helps define it even better!

It looks like both of those items are on the Translucent bucket/queue, for the second picture. Is this correct?

If so… you might want to play with just turning off the Depth Test for the important thing that you want to see behind anything. It might be just as simple as that…

edit: otherwise known as @pspeed’s original setDepthTest suggestion waaaay back up there towards the very beginning, :wink:

Looks to me like only the proper object is in the translucent queue… it’s a trick to get the object to draw last. You have to have depth test off and draw the object last for it to be sure to show up.

…it’s almost like I’ve done this before. :wink:

1 Like