Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

USARBot.ERSpaw


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
///////////////////////////////////////////////////////////////////////////
// Simple Touch sensor for AIBO paws based on RangeSensor
// Mapping:
// Contact = true  if (0 < range <= MaxRange)
// Contact = false if (range > MaxRange)
//
// by Marco Zaratti - marco.zaratti@gmail.com
///////////////////////////////////////////////////////////////////////////

class ERSpaw extends RangeSensor config (USARBot);

function ConvertParam(USARConverter converter)
{
    if (converter!=NONE) {
        uuMaxRange = converter.LengthToUU(MaxRange);
        uuMinRange = converter.LengthToUU(MinRange);
    }
    else {
        uuMaxRange = MaxRange;
        uuMinRange = MinRange;
    }
}

function float GetRange()
{
    local vector HitLocation,HitNormal;
    local float range;

    if (Trace(HitLocation, HitNormal, Location + uuMaxRange*vector(curRot), Location, true)==NONE)
        return 0;
    else
    {
        range = VSize(HitLocation-Location);
        if (converter!=None)
            range=converter.LengthFromUU(range);
    }

    if (range <= MaxRange)
        return 1;

    return 0;
}

function String GetData()
{
    local string outstring;
    curRot=Rotation;
    if(GetRange() > 0)
        outstring="{Name "$ItemName$" Touch true}";
    else
        outstring="{Name "$ItemName$" Touch false}";
    return outstring;
}

defaultproperties
{
    bUseGroup=True
    ItemType="Touch"
    MaxRange=0.0248 //2.48cm
    MinRange=0
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Sa 16.9.2006 21:12:24.000 - Creation time: Mo 16.4.2007 11:20:47.015 - Created with UnCodeX