Hi J-S,
On Mon, 2005-12-05 at 13:56 -0500, Jean-Sebastien Guay wrote:
> Now, one other thing. I tried using IntersectAction and it ended up being too
> slow for my needs. So I tried doing a volume intersection first, and then
> doing
> the IntersectAction to be sure the objects actually intersect :
>
> bool Arrow::hit( const Target *target ) {
> DynamicVolume arrow_volume = getRoot()->getVolume(false);
> DynamicVolume target_volume = target->getRoot()->getVolume(false);
>
> if ( arrow_volume.intersect( target_volume ) ) {
> // We should now check if the polygons actually intersect, maybe with
> // the IntersectAction, now that we know that the bounding boxes
> // intersect and have saved ourselves lots of time...
> return true;
> }
>
> return false;
> }
Note that these volumes are in local coordinate space, so they never
change unless you change Nodes underneath them. If you want world
volumes you need to call getWorldVolume();
> This works fine if my targets are immobile, but it doesn't work when they're
> moving.
>
> I expect this is because of the way I do the movement. Instead of moving the
> observer (which I found needlessly complicated, since the camera is not part
> of
> the scene graph [why isn't it, btw? It would make some things much easier,
> like
> moving the camera and avatar at the same time])
In a sense the Camera is part of the scene graph, at least the part that
matters: the beacon. The Observers are set on top of the camera, as they
need information that can't be extracted from the Beacon matrix.
> I move the scenery in the
> opposite direction. So for example, when the observer moves forward, I have a
> Transform node which has the whole scenery as its children, and I move that
> backwards by the same amount.
Hm, yes, that sounds complicated. What are you trying to achieve? Have a
third-person view, where the observer is always behind the avatar? You
can achieve that by putting the Avatar under the beacon Node. If using
the SSM the beacon is a little hidden, but you can get it from the SSM's
camera.
> What I suspect is happening is that the bounding volumes are staying at their
> original positions when I move the scenery (which the targets are part of).
> But
> how do I make them get updated? I tried using invalidateVolume() on many
> different nodes, and none made a difference...
They are invalidated automatically, you should never have to call this
by hand. But you never update them, so they are always out of date. If
you call getVolume(true); (or just getVolume();) they will be updated
and should be fine.
Hope it helps
Dirk
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users