Skip to main content

Node Visibility.

5 replies [Last post]
elberry
Offline
Joined: 2004-03-22

About a month ago, I posted an issue in my blog, that child nodes were being rendered in spite of their being not within the bounds of the JSGPanel. My test of this was simply checking each SGImage in my TileMap to see if it's visible (via the isVisible method) or not. My findings showed that all the SGImages were always marked as visible even though they weren't actually within the view area of the JSGPanel.

I've since updated my TileMap to go through and find out which Tiles (SGImage) are actually visible based on their location, and size.

However, I am curious as to why Scenegraph doesn't do this already? If each node knows of it's bounds in relation to it's parent, and knows of which JSGPanel it's in, shouldn't the visibility of nodes be based on this? Are my assumptions about the visible property correct? Does Scenegraph actually not render the nodes if they aren't actually within the panel's view? Did I not set the size on the JSGPanel correctly in order to get this functionality? If not, is this a valid feature request?

Thanks,
Eric

Original blog post: http://www.townsfolkdesigns.com/blog/elberry/2008/09/06/platform-1-2-til...

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
elberry
Offline
Joined: 2004-03-22

Jim answered back through email. This is correct, I don't need to worry about setting the off-screen SGImages to not visible as the painting is already optimized to ignore them.

Cheers,
Eric

Jim Graham

The setVisible() and isVisible() methods on SGNode control a property
that tells the system whether or not to render the nodes at all,
regardless of whether or not they are viewable in the panel. These
methods are there for you to tell us whether or not to draw something so
that you can have nodes in the scene that come and go depending on the
state of something else without having to reconstruct the scene to add
and remove them.

They are a "pretend I'm not here" or "go ahead and pretend I am here"
type of thing, not a "can be seen" type of thing. There are no methods
to ask the question "can this node be seen on the screen?".

Note that the painting is optimized to only visit the parts of the tree
that can be seen on the panel, so we shouldn't waste much time on the
nodes (or subtrees) that are completely off screen...

...jim

scenario@javadesktop.org wrote:
> About a month ago, I posted an issue in my blog, that child nodes were being rendered in spite of their being not within the bounds of the JSGPanel. My test of this was simply checking each SGImage in my TileMap to see if it's visible (via the isVisible method) or not. My findings showed that all the SGImages were always marked as visible even though they weren't actually within the view area of the JSGPanel.
>
> I've since updated my TileMap to go through and find out which Tiles (SGImage) are actually visible based on their location, and size.
>
> However, I am curious as to why Scenegraph doesn't do this already? If each node knows of it's bounds in relation to it's parent, and knows of which JSGPanel it's in, shouldn't the visibility of nodes be based on this? Are my assumptions about the visible property correct? Does Scenegraph actually not render the nodes if they aren't actually within the panel's view? Did I not set the size on the JSGPanel correctly in order to get this functionality? If not, is this a valid feature request?
>
> Thanks,
> Eric
>
> Original blog post: http://www.townsfolkdesigns.com/blog/elberry/2008/09/06/platform-1-2-til...
> [Message sent by forum member 'elberry' (elberry)]
>
> http://forums.java.net/jive/thread.jspa?messageID=313111
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
> For additional commands, e-mail: dev-help@scenegraph.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
For additional commands, e-mail: dev-help@scenegraph.dev.java.net

elberry
Offline
Joined: 2004-03-22

Jim,
Thank you for your reply.

In my situation the JSGPanel contains a SGGroup (TileMap) as it's scene. The group contains all the individual SGImages (Tiles). The SGGroup is larger than the JSGPanel, so I want to make sure that the SGImages that are not in view are not painted. From what you've said, it sounds like I do not actually need to worry about setting the off-screen SGImages to invisible, as the painting is already optimized to ignore them anyway. Is this correct?

Thanks again,
Eric

Jim Graham

Hi Eric,

Yes, you should not have to worry about this due to the existing
optimizations in Scenario...

...jim

scenario@javadesktop.org wrote:
> Jim,
> Thank you for your reply.
>
> In my situation the JSGPanel contains a SGGroup (TileMap) as it's scene. The group contains all the individual SGImages (Tiles). The SGGroup is larger than the JSGPanel, so I want to make sure that the SGImages that are not in view are not painted. From what you've said, it sounds like I do not actually need to worry about setting the off-screen SGImages to invisible, as the painting is already optimized to ignore them anyway. Is this correct?
>
> Thanks again,
> Eric
> [Message sent by forum member 'elberry' (elberry)]
>
> http://forums.java.net/jive/thread.jspa?messageID=313156
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
> For additional commands, e-mail: dev-help@scenegraph.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
For additional commands, e-mail: dev-help@scenegraph.dev.java.net

Eric Berry

Great! Thank you very much!

On Fri, Oct 24, 2008 at 12:41 PM, Jim Graham wrote:

> Hi Eric,
>
> Yes, you should not have to worry about this due to the existing
> optimizations in Scenario...
>
> ...jim
>
> scenario@javadesktop.org wrote:
>
>> Jim,
>> Thank you for your reply.
>>
>> In my situation the JSGPanel contains a SGGroup (TileMap) as it's scene.
>> The group contains all the individual SGImages (Tiles). The SGGroup is
>> larger than the JSGPanel, so I want to make sure that the SGImages that are
>> not in view are not painted. From what you've said, it sounds like I do not
>> actually need to worry about setting the off-screen SGImages to invisible,
>> as the painting is already optimized to ignore them anyway. Is this correct?
>>
>> Thanks again,
>> Eric
>> [Message sent by forum member 'elberry' (elberry)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=313156
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
>> For additional commands, e-mail: dev-help@scenegraph.dev.java.net
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
> For additional commands, e-mail: dev-help@scenegraph.dev.java.net
>
>

--
Learn from the past. Live in the present. Plan for the future.
11101000
http://www.townsfolkdesigns.com/blogs/elberry
[att1.html]