Line of Sight problem with 3dsmax model
by Kaj Eijlers · in Torque Game Engine · 03/20/2006 (3:08 am) · 3 replies
Hi all,
I first posed this as a raycast question in the 'getting started' section (http://www.garagegames.com/mg/forums/result.thread.php?qt=41418) but it soon turned out to be another problem entirely. Judging the problem became actually different enough to qualify as a different problem altogether (which still eludes me), I decided to re-post it.
Setting:
AIPlayer enters a triggerbox and calls containerRaycast from the point of entrance towards the center of this triggerbox:
*******************
function AIPlayer::CheckLOS(%this, %player, %trigger)
{
%eyeTrans = %player.getEyeTransform();
%eyeEnd = %trigger.getWorldBoxCenter();
%searchMasks = $TypeMasks::PlayerObjectType | $TypeMasks::StaticTSObjectType;
%searchResult = containerRayCast(%eyeTrans, %eyeEnd, %searchMasks,%player);
echo("searchresult: " @ %searchResult);
return %searchResult;
}
********************
The objective is to detect any (static) object blocking this raytrace.
Proposed solution:
put a simple .dts model in and do the check.
I use the world-editor from the tutorial to put these models in, by the way.
The Problem:
Although the player's movement is blocked by the object, it does not always detect it.
It DOES detect a simple wall model, but DOES NOT detect a model of a computerscreen (just a testmodel). Both are 3dsmax models, having square bounding boxes that encompass the full model, and have the following structure:
bounds
base01
|- start01
| |- shape2 (actually this is wall2 and computerunit2)
| |- Col-1
|
|- detail2
|
|- Collision-1
So the problem is: both the wall and computer-object 'collide' with my AIplayer as it cannot move through. But it sees only the wall, and not the computer-object.
What I thought to be possible causes for the problem:
a) the raycast call
b) wrong typemask
c) wrong collision box (convex etc)
d) missing line-of-sight markers
e) incorrect placement in the world
f) wrong model (model itself should be convex???)
What I already eliminated:
a) The raycast call above works fine with a simple wall-shape. It also detects my own player-model when I block the ray. So this is not the cause.
b) See a), it correctly sees both the item and the player-model. The other item has the same class (as checked in the .mis file), namely TSStatic and therefore 'should' be detected if this was the cause. Alas, it is not.
c) I double checked the collision boxes, resized them to be absolutely sure it encompasses the full model, exported again and still got the same problem. As a last resort, I even downloaded & used the simple script of Magnus Blikstad (http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7872) to make sure it is done correctly :)
The problem remains, so this is ruled out.
d) I stripped out the line-of-sight markers I started to put in because of some (old) forum posts about LOS and LOSCol markers (which are also still in the documentation btw), exported the models with only the structure given above. Still got the same problem: the wall is seen, the computer unit is not.
e) since I could have been looking towards the wrong line of sight, I tried ALL of the above but then really 'plastering' the line with my models (or actually, the computer model since the wall already was detected, so no need to redo that) to make sure the line was BLOCKED. Alas, no result (would love it to be my own stupidity at this point).
f) so I'm down to the last one I can think of: wrong model. But what could possibly be wrong with it... the collision only checks the bounds and the collision-markers are just copies of the full model... and I cannot imagine that Torque demands a model to have only convex surfaces or something like that (imagine this with a hairbrush :D)
So... does anyone has any clue about what the possible solution to this problem could be? A method to circumvent this problem -albeit not so nice- would also be highly appreciated at this point :)
I first posed this as a raycast question in the 'getting started' section (http://www.garagegames.com/mg/forums/result.thread.php?qt=41418) but it soon turned out to be another problem entirely. Judging the problem became actually different enough to qualify as a different problem altogether (which still eludes me), I decided to re-post it.
Setting:
AIPlayer enters a triggerbox and calls containerRaycast from the point of entrance towards the center of this triggerbox:
*******************
function AIPlayer::CheckLOS(%this, %player, %trigger)
{
%eyeTrans = %player.getEyeTransform();
%eyeEnd = %trigger.getWorldBoxCenter();
%searchMasks = $TypeMasks::PlayerObjectType | $TypeMasks::StaticTSObjectType;
%searchResult = containerRayCast(%eyeTrans, %eyeEnd, %searchMasks,%player);
echo("searchresult: " @ %searchResult);
return %searchResult;
}
********************
The objective is to detect any (static) object blocking this raytrace.
Proposed solution:
put a simple .dts model in and do the check.
I use the world-editor from the tutorial to put these models in, by the way.
The Problem:
Although the player's movement is blocked by the object, it does not always detect it.
It DOES detect a simple wall model, but DOES NOT detect a model of a computerscreen (just a testmodel). Both are 3dsmax models, having square bounding boxes that encompass the full model, and have the following structure:
bounds
base01
|- start01
| |- shape2 (actually this is wall2 and computerunit2)
| |- Col-1
|
|- detail2
|
|- Collision-1
So the problem is: both the wall and computer-object 'collide' with my AIplayer as it cannot move through. But it sees only the wall, and not the computer-object.
What I thought to be possible causes for the problem:
a) the raycast call
b) wrong typemask
c) wrong collision box (convex etc)
d) missing line-of-sight markers
e) incorrect placement in the world
f) wrong model (model itself should be convex???)
What I already eliminated:
a) The raycast call above works fine with a simple wall-shape. It also detects my own player-model when I block the ray. So this is not the cause.
b) See a), it correctly sees both the item and the player-model. The other item has the same class (as checked in the .mis file), namely TSStatic and therefore 'should' be detected if this was the cause. Alas, it is not.
c) I double checked the collision boxes, resized them to be absolutely sure it encompasses the full model, exported again and still got the same problem. As a last resort, I even downloaded & used the simple script of Magnus Blikstad (http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7872) to make sure it is done correctly :)
The problem remains, so this is ruled out.
d) I stripped out the line-of-sight markers I started to put in because of some (old) forum posts about LOS and LOSCol markers (which are also still in the documentation btw), exported the models with only the structure given above. Still got the same problem: the wall is seen, the computer unit is not.
e) since I could have been looking towards the wrong line of sight, I tried ALL of the above but then really 'plastering' the line with my models (or actually, the computer model since the wall already was detected, so no need to redo that) to make sure the line was BLOCKED. Alas, no result (would love it to be my own stupidity at this point).
f) so I'm down to the last one I can think of: wrong model. But what could possibly be wrong with it... the collision only checks the bounds and the collision-markers are just copies of the full model... and I cannot imagine that Torque demands a model to have only convex surfaces or something like that (imagine this with a hairbrush :D)
So... does anyone has any clue about what the possible solution to this problem could be? A method to circumvent this problem -albeit not so nice- would also be highly appreciated at this point :)
#2
Made a copy of the bounds box (which is a simple convex shape), renamed it Col-1, replaced the 'old' Col-1 object with it in the hierarcy and presto! My object got detected :)
ps how'd you knew that I copied my Col-1 objects from my model? Or is this a common mistake since the only docu 'howto' describes a simple shape where this is done :)
.. or did you guess it since my wall worked fine?
Anyways, mucho gracias, I can continue!
03/20/2006 (4:21 am)
Magnus, you are a hero.Made a copy of the bounds box (which is a simple convex shape), renamed it Col-1, replaced the 'old' Col-1 object with it in the hierarcy and presto! My object got detected :)
ps how'd you knew that I copied my Col-1 objects from my model? Or is this a common mistake since the only docu 'howto' describes a simple shape where this is done :)
.. or did you guess it since my wall worked fine?
Anyways, mucho gracias, I can continue!
#3
Glad you got it sorted.
03/20/2006 (4:48 am)
Quote:the collision-markers are just copies of the full modelNot sure if what you actually ment with that was that you copied the mesh, but yes; That is a fairly common mistake so I just assumed.
Glad you got it sorted.
Torque Owner Magnus Blikstad
Then; The Col-1 object DOES have to be convex, it should NOT be a copy of your mesh. It should be a convex shape that is similar enough to your shape. This is what will be collided against. Not sure if LOSCol is needed, but for ray tests it might be but this one can be simply a copy of the convex Col geometry.