Hello Garry,
Garry Hoberg wrote:
I have the same problem as Telmo. The WalkNavigator "walks" me into a wall and
then gets stuck (it can still turn but not "walk" any more; I only noticed
actually being inside the wall after setting the near clipping plane to
0.0001 and turning 90 degrees). In my case the collision model and the drawn
one are the same nodes.
Large values didn't change anything. To me it seems like either the
_wallDistance, _fatness and _width properites are collectively ignored or the
IntersectAction's _hitT property value is set or returned falsely.
well, not quite, but the ray shot into the scene was aimed in the wrong
direction and as it turns out from the old position not the one the user
tries to move to (which made it impossible to just go backwards to get
away from a wall) -- why did I never see this when looking at the code
earlier, arghh
I managed to work around this but I'd like to be able to fully rely on the
collision detection.
hm, the collision detection code is rather simple in what it does, i.e.
it only shoots a few rays into the scene, it does not consider real
volumes, so there are limits to what it can do. For a walkthrough with a
not too demanding model it should do fine though.
Since I'm a little behind the schedule for my diploma
thesis, I won't have the time to rewrite the library to find the bug myself.
Anyways, the changes are in the cvs now (and analogous changes to
OSGWalkEngine.cpp for 2.0 in svn), the patch is attached [1]. Hope it
works better now, good luck with your thesis,
regards,
Carsten
[1] It also cleans the formatting, which makes it hard to see what has
actually changed - sorry about that.
Index: Source/System/Window/OSGWalkNavigator.cpp
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Window/OSGWalkNavigator.cpp,v
retrieving revision 1.7
diff -u -r1.7 OSGWalkNavigator.cpp
--- Source/System/Window/OSGWalkNavigator.cpp 9 Jun 2008 07:30:43 -0000 1.7
+++ Source/System/Window/OSGWalkNavigator.cpp 11 Nov 2008 23:12:33 -0000
@@ -108,7 +108,7 @@
{
_wallDistance=wallDistance;
}
-
+
void WalkNavigator::setPersonDimensions(Real32 height,Real32 width,Real32 fatness)
{
_height = height;
@@ -125,7 +125,7 @@
{
FlyNavigator::rotate(deltaX, deltaY);
}
-
+
/*! "walks" forward
*/
@@ -145,40 +145,43 @@
sv.crossThis(upn);
sv.normalize();
- Pnt3f rFrom = _rFrom + step*mv;
- Pnt3f rAt = _rAt + step*mv;
+ Pnt3f rFrom = _rFrom + step * mv;
+ Pnt3f rAt = _rAt + step * mv;
Real32 dist;
Line line(rFrom, -upn);
//keep the walker at a constant distance from the ground
- _act->setLine(line);
- _act->apply(_ground);
+ _act->setLine(line );
+ _act->apply (_ground);
- if (_act->didHit()) {
+ if(_act->didHit())
+ {
dist = _act->getHitT();
- if (dist >= _height) {
- rFrom = rFrom + (_groundDistance-dist+_height)*upn;
- rAt = rAt + (_groundDistance-dist+_height)*upn;
+ if(dist >= _height)
+ {
+ rFrom = rFrom + (_groundDistance - dist + _height) * upn;
+ rAt = rAt + (_groundDistance - dist + _height) * upn;
}
else return 0.0; //can't jump so high
}
//finally check if the move is correct or not
- line.setValue(_rFrom, mv);
- _act->setLine(line);
- _act->apply(_world);
+ line.setValue(rFrom, -mv);
+ _act->setLine(line );
+ _act->apply (_world);
- if (_act->didHit()) {
+ if(_act->didHit())
+ {
dist = _act->getHitT();
- if (dist <= (rFrom-_rFrom).length()+_fatness+_wallDistance)
+ if(dist <= _fatness + _wallDistance)
return 0.0; //running against a wall
}
//move was ok, store new values
_rFrom = rFrom;
- _rAt = rAt;
+ _rAt = rAt;
return step;
}
@@ -208,39 +211,42 @@
sv.crossThis(upn);
sv.normalize();
- Pnt3f rFrom = _rFrom + step*sv;
- Pnt3f rAt = _rAt + step*sv;
+ Pnt3f rFrom = _rFrom + step * sv;
+ Pnt3f rAt = _rAt + step * sv;
Real32 dist;
Line line(rFrom, -upn);
//keep the walker at a constant distance from the ground
- _act->setLine(line);
- _act->apply(_ground);
+ _act->setLine(line );
+ _act->apply (_ground);
- if (_act->didHit()) {
+ if(_act->didHit())
+ {
dist = _act->getHitT();
- if (dist >= _height) {
- rFrom = rFrom + (_groundDistance-dist+_height)*upn;
- rAt = rAt + (_groundDistance-dist+_height)*upn;
+ if(dist >= _height)
+ {
+ rFrom = rFrom + (_groundDistance - dist + _height) * upn;
+ rAt = rAt + (_groundDistance - dist + _height) * upn;
}
else return 0.0; //can't jump so high
}
//finally check if the move is correct or not
- line.setValue(_rFrom, sv);
- _act->setLine(line);
- _act->apply(_world);
+ line.setValue(rFrom, sv);
+ _act->setLine(line );
+ _act->apply (_world);
- if (_act->didHit()) {
+ if(_act->didHit())
+ {
dist = _act->getHitT();
- if (dist <= (rFrom-_rFrom).length()+_fatness+_wallDistance)
+ if (dist <= _fatness + _wallDistance)
return 0.0; //running against a wall
}
//move was ok, store new values
_rFrom = rFrom;
- _rAt = rAt;
+ _rAt = rAt;
return step;
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users