How can we make a geometry completly invisible …

How can we make a geometry complete invisible , but still in the spatial node (not remove it from its parent), like visible/hidden or exclude in the render list???



Sorry if it 's a noob question, but I don’t really know how to get it in an easy way…

setCullHint(CullHint.Always)

3 Likes

Can I use setCullHint(CullHint.Always) for two pass of a Filter , like I want some geometries hide in pass1 _ render others then pass2 _ show them and render all ?

I guess you could but its generally not a good idea to modify the scene while its being rendered… Cant you just put them to different scenes?

I wanna do the X-ray effect like this:



So I want to render

pass1_the player and everything behind it (order by Z value)

pass2_everything that hide the player and monster from the camera and make it partial transparent with an alpha texture …



so in the first pass I want to hide the wall and rock (which I found by a collision ray check )

and in second pass show them …



Or I can do another way?

Yeah, I’d render the two scenes in different previews and then combine the two images with a post-process shader. No need to cull anything…

So I may ask about the theory of two preview :



A viewPort -“Attach”- a mainNode - “which has” - children Geometries and everything I want to render…

And a preview -“Attach” - a hideNode- “has” some wall,rock that I want to pre-render , which not in mainNode …



But I may ask if the structure of the scene is complex, then the work : add + remove spatial and reconstruct the scene can be a very hard job…



In my point of view, if there is a way to hide what i want to hide in some pass _ and reserve the structure of the scene is a good method.

Wheres the difference between finding the respective Spatials and changing its CullHint and finding it and attaching it to another scene? The actual finding and managing is the hard part…

What I want to said it’s difficult to reconstruct the scene…



For example :

frame1:

_ find : wall 1(child of Building1), wall2(child of B2), rock3(child of Mountain 3) that hide the player

_ remove them from mainNode and add them to hideNode

_render pass1 the mainNode

_render pass2 the hideNode

_attach them back to …(T_T) ???

frame2:…



And the Cull method :

frame1:

_ find : everything

_ hide the rock

_ render pass1

_ show them

_ render pass2

frame2:



Can you show me something more negative about Cull method why I shouldn’t use it.

You would have to store the current cullMode of the Spatials as well, otherwise you can use culling only for this one purpose, so you can also store the parent node… A little helper class and a list and all is good.

1 Like

hmm… you 're right. I’ll try two approach to compare the effective of two methods…



And I want to ask one more quick question:

How can I align the normal of a plane by a normal (Vector3f) ? _ I 've tried few times

[java]

Quaternion q = new Quaternion();

q.lookAt(contactNormal, Vector3f.UNIT_Y); // <= don’t really understand how it work

workingPlane.setLocalRotation(q);

[/java]

but failed !!!

Just recreate it with that normal? Plane.setOriginNormal(origin, normal)

Check out this:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math#plane

It’s OK with a Plane (a parameter one),



now I really want a Grid (a debug shape) to act like above Plane , cause the workingPlane is actually a Node which has a Plane and a Grid (for parameter surpose and visual surpose) how can I ?



Cause a Grid have no method to recreate via Origin and Normal vector , I have to Rotate it with Quaternion …??







Something like this ^

Yeah, zero rotation means looking in Z direction for a Spatial. Again, check the link, its all in there.

atomix said:
Can I use setCullHint(CullHint.Always) for two pass of a Filter , like I want some geometries hide in pass1 _ render others then pass2 _ show them and render all ?


I'm probably totally off base here, but I'm wondering if there is some way to render twice with different near/far clip and then combine the two images with the appropriate alpha area. ie: render once with the near clip set some distance out and then again with the near clip set close and the far clip set to the previous near clip.

Determining where to clip could be tricky for complicated scenes, I guess... since you wouldn't want to clip the players and other mobiles. And maybe that's where selective culling could help.

...was just something that popped into my head.
pspeed said:
I'm probably totally off base here, but I'm wondering if there is some way to render twice with different near/far clip and then combine the two images with the appropriate alpha area. ie: render once with the near clip set some distance out and then again with the near clip set close and the far clip set to the previous near clip.

Determining where to clip could be tricky for complicated scenes, I guess... since you wouldn't want to clip the players and other mobiles. And maybe that's where selective culling could help.

...was just something that popped into my head.

Oh, good idea, thats actually possible, its what the reflection render pass for water does to clip out the part below/above the water. You can define a clip plane so one "side" is not rendered, however its only a plane, I don't know if that would suffice here.. But for doing that actual image you posted it should work!
pspeed said:
I'm probably totally off base here, but I'm wondering if there is some way to render twice with different near/far clip and then combine the two images with the appropriate alpha area. ie: render once with the near clip set some distance out and then again with the near clip set close and the far clip set to the previous near clip.

Determining where to clip could be tricky for complicated scenes, I guess... since you wouldn't want to clip the players and other mobiles. And maybe that's where selective culling could help.

...was just something that popped into my head.

Someone already did this in jME3. You just create two viewports, the clipping is handled automatically through frustum culling.