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

USARBot.IRSensor


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
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
// This class is basically the same as the USARSim RangeSensor class
// For the moment only the Range and output curve parameters are changed
//	author: Erik Winter
//  created: 2005-02-24	Created the class from the USARSim RangeSensor class
//
//  modified:	2005-03-07	Made the IR look straight through transparent materials
//				2005-03-15  If the IR hits a transparent material it now sends out a new trace from the HitLocation recursively
//							until it hits a non-transparent material or reaches MaxRange
//
//	Todo:
//		- Apply the fact that the IR can see through, and though miss glass walls
//			* halfly done, if it hits a transparent material it returns maxRange. On these maps it should be an okay simplification, Fully Done

class IRSensor extends RangeSensor config (USARBot);

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


    range=0;
    locTmp=Location;

    while(range<uuMaxRange){
        if (Trace(HitLocation, HitNormal, locTmp + uuMaxRange*vector(curRot), locTmp, true, vect(0,0,0), mtrl)==NONE){
            range=MaxRange;
            break;
        }
        else {
            range=VSize(HitLocation-Location);
            if (converter!=None)
                range=converter.LengthFromUU(range);
        }

        if(InStr(string(mtrl), "Trans")==-1){ // The IR hitted a non-transparent material.

            break;

        }
        else
            locTmp+=FMax(VSize(HitLocation-locTmp), uuMinRange)*vector(curRot);// If locTmp is within a material Trace will return the same location again
                                                                             // To avoid this infinite loop move the location with MinRange

    }
    if (range>MaxRange) range=MaxRange;
    if (range<MinRange) range=MinRange;
    if (OutputCurve.Points.length>0)
        range=InterpCurveEval(OutputCurve, range);
    range += RandRange(-Noise,Noise)*range;

    if (range>MaxRange) range=MaxRange;
    if (range<MinRange) range=MinRange;



    return range;

}

function String GetData()
{
    local string outstring;
    curRot=Rotation;
    outstring="{Name "$ItemName$" Range "$converter.FloatString(GetRange())$"}";
    return outstring;
}

defaultproperties
{
//Scaled with 4.762 at Mon Sep 25 14:21:51 EDT 2006
    bUseGroup=True
    ItemType="IR"
    HiddenSensor=false
    MaxRange=.8 // 0.80 m
    MinRange=.1 // 0.10 m
    OutputCurve=(Points=((InVal=0.000000,OutVal=0.000000),(InVal=0.800000,OutVal=0.800000)))
    drawscale=0.4762
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Di 26.9.2006 15:50:10.000 - Creation time: Mo 16.4.2007 11:20:49.000 - Created with UnCodeX