The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by aubergine]

Dear All

I'm not too sure how to approach doing a 'full' view on the world. If I'm lost
in the middle of a scene with my view and I want to simply zoom back and
center, until the whole world is in view, how do I do this? Any ideas?

Thanks and regards
import-bot (20211) [Avatar] Offline
#2
Re: World View
[Originally posted by author]

One approach is to determine a bounding box around everything in your world,
and then, based on the viewing geometry (FOV, etc.), position the view such
that the entire world bounding box fits into the view frustum.

There are some utilities included with the code for computing the bounding box
given a node in the scenegraph (BoundsUtils). In this case, you want to
compute the bounding box starting with the root of everything in the scene
excluding views (i.e. the scene root in AppWorld).

hope this helps
--jon


> Dear All
>
> I'm not too sure how to approach doing a 'full' view on the world. If I'm lost
> in the middle of a scene with my view and I want to simply zoom back and
> center, until the whole world is in view, how do I do this? Any ideas?
>
> Thanks and regards
import-bot (20211) [Avatar] Offline
#3
Re: World View
[Originally posted by aubergine]

Forgot to mention the following:

1. When I do a simple AppWorld with a scene graph and then do a loop with
setLive(true/false), it works fine.

2. I hit this problem when I run the DndApp example and this is what I get ...

java.lang.NullPointerException
at javax.media.j3d.View.assignViewId(View.java:3075)
at javax.media.j3d.MasterControl.registerView(MasterControl.java:1639)
at javax.media.j3d.MasterControl.viewActivate(MasterControl.java:2166)
at
javax.media.j3d.MasterControl.handlePendingRequest(MasterControl.java:2623)
at javax.media.j3d.MasterControl.doWork(MasterControl.java:2565)
at javax.media.j3d.MasterControlThread.run(MasterControlThread.java:2smilie

> I've finally got around to trying to implement this and I'm finding that the
> setLive() routine in AppWorld causes an Exception when a 'setLive(true)' is
> executed.
>
> Sometimes it works OK for a couple of calls and then wham bam, other times it
> fails first time. I guess this is another j3d core problem?
>
> nick
>
>
> > One approach is to determine a bounding box around everything in your world,
> > and then, based on the viewing geometry (FOV, etc.), position the view such
> > that the entire world bounding box fits into the view frustum.
> >
> > There are some utilities included with the code for computing the bounding
box
> > given a node in the scenegraph (BoundsUtils). In this case, you want to
> > compute the bounding box starting with the root of everything in the scene
> > excluding views (i.e. the scene root in AppWorld).
> >
> > hope this helps
> > --jon
> >
> >
> > > Dear All
> > >
> > > I'm not too sure how to approach doing a 'full' view on the world. If I'm
> lost
> > > in the middle of a scene with my view and I want to simply zoom back and
> > > center, until the whole world is in view, how do I do this? Any ideas?
> > >
> > > Thanks and regards
import-bot (20211) [Avatar] Offline
#4
Re: World View
[Originally posted by aubergine]

I've finally got around to trying to implement this and I'm finding that the
setLive() routine in AppWorld causes an Exception when a 'setLive(true)' is
executed.

Sometimes it works OK for a couple of calls and then wham bam, other times it
fails first time. I guess this is another j3d core problem?

nick


> One approach is to determine a bounding box around everything in your world,
> and then, based on the viewing geometry (FOV, etc.), position the view such
> that the entire world bounding box fits into the view frustum.
>
> There are some utilities included with the code for computing the bounding box
> given a node in the scenegraph (BoundsUtils). In this case, you want to
> compute the bounding box starting with the root of everything in the scene
> excluding views (i.e. the scene root in AppWorld).
>
> hope this helps
> --jon
>
>
> > Dear All
> >
> > I'm not too sure how to approach doing a 'full' view on the world. If I'm
lost
> > in the middle of a scene with my view and I want to simply zoom back and
> > center, until the whole world is in view, how do I do this? Any ideas?
> >
> > Thanks and regards
import-bot (20211) [Avatar] Offline
#5
Re: World View
[Originally posted by aubergine]

OK everyone. Stop working on this and go back to what you were doing.

I should have done this at the beginning ... go back to an older version of
j3d. I went back to the previous version of j2d1.2 and everything works fine.
It may have cost me two man days of work trying to find out if I'd really made
a mess of my scene tree, but in the end it was our bugridden j3d.

Still, I'm a better man for it. God, how I love this.

Nick


> Forgot to mention the following:
>
> 1. When I do a simple AppWorld with a scene graph and then do a loop with
> setLive(true/false), it works fine.
>
> 2. I hit this problem when I run the DndApp example and this is what I get ...
>
> java.lang.NullPointerException
> at javax.media.j3d.View.assignViewId(View.java:3075)
> at javax.media.j3d.MasterControl.registerView(MasterControl.java:1639)
> at javax.media.j3d.MasterControl.viewActivate(MasterControl.java:2166)
> at
> javax.media.j3d.MasterControl.handlePendingRequest(MasterControl.java:2623)
> at javax.media.j3d.MasterControl.doWork(MasterControl.java:2565)
> at
javax.media.j3d.MasterControlThread.run(MasterControlThread.java:2smilie
>
> > I've finally got around to trying to implement this and I'm finding that the
> > setLive() routine in AppWorld causes an Exception when a 'setLive(true)' is
> > executed.
> >
> > Sometimes it works OK for a couple of calls and then wham bam, other times
it
> > fails first time. I guess this is another j3d core problem?
> >
> > nick
> >
> >
> > > One approach is to determine a bounding box around everything in your
world,
> > > and then, based on the viewing geometry (FOV, etc.), position the view
such
> > > that the entire world bounding box fits into the view frustum.
> > >
> > > There are some utilities included with the code for computing the bounding
> box
> > > given a node in the scenegraph (BoundsUtils). In this case, you want to
> > > compute the bounding box starting with the root of everything in the scene
> > > excluding views (i.e. the scene root in AppWorld).
> > >
> > > hope this helps
> > > --jon
> > >
> > >
> > > > Dear All
> > > >
> > > > I'm not too sure how to approach doing a 'full' view on the world. If
I'm
> > lost
> > > > in the middle of a scene with my view and I want to simply zoom back and
> > > > center, until the whole world is in view, how do I do this? Any ideas?
> > > >
> > > > Thanks and regards
import-bot (20211) [Avatar] Offline
#6
Re: World View
[Originally posted by author]

While writing the book I lost many an hour chasing down such "non-problems".
(Even worse, however, is when you chase down a "bug" in the API that Sun
didn't bother to implement or tell anyone that they didn't.)

I feel your pain. Good luck on getting the "home view" technique working .

--jon