Core.Object | +--Engine.Actor | +--Engine.Effects | +--XIDMaps.CableLink
CableEnd
EndPoint
float
LinkLength
CableLink
NextLink
PrevLink
CableStart
StartPoint
fLinkIndex
int
iLinkIndex
vector
vPerturbation
OldvEnd,
vStart
void
CreateNextLink()
//_____________________________________________________________________________ // ELR create all the links, each doing nothing waiting the CableStart to be triggered
FreeMove(float dT)
//_____________________________________________________________________________
SetUpfLinkIndex(int MaxLink)
00001 //----------------------------------------------------------- 00002 // 00003 //----------------------------------------------------------- 00004 class CableLink extends Effects; 00005 00006 var CableStart StartPoint; 00007 var CableEnd EndPoint; 00008 var CableLink NextLink; 00009 var CableLink PrevLink; 00010 var float LinkLength; 00011 var vector vEnd, OldvEnd, vStart; 00012 var int iLinkIndex; // Index of the link in the chain 00013 var float fLinkIndex; // Weight of the link (Index / LastIndex) 00014 var vector vPerturbation; // To avoid similar behaviours between cables 00015 00016 //_____________________________________________________________________________ 00017 // ELR create all the links, each doing nothing waiting the CableStart to be triggered 00018 function CreateNextLink() 00019 { 00020 if (PrevLink == none) 00021 iLinkIndex = 0; 00022 else 00023 iLinkIndex = PrevLink.iLinkIndex + 1; 00024 vStart = Location - 0.5 * LinkLength * vector(rotation); 00025 OldvEnd = Location + 0.5 * LinkLength * vector(rotation); 00026 vEnd = OldvEnd; 00027 vPerturbation = vRand() * 0.5 * LinkLength; 00028 00029 if ( vSize(Location - EndPoint.Location) < LinkLength ) 00030 { 00031 fLinkIndex = 1.0; 00032 if (PrevLink != none) 00033 PrevLink.SetUpfLinkIndex(iLinkIndex); 00034 return; 00035 } 00036 NextLink = spawn(class'CableLink',self,,Location + LinkLength * Normal(EndPoint.Location - Location), rotator(EndPoint.Location - Location)); 00037 if ( NextLink != none ) 00038 { 00039 NextLink.StartPoint = StartPoint; 00040 NextLink.EndPoint = EndPoint; 00041 NextLink.PrevLink = self; 00042 NextLink.CreateNextLink(); 00043 } 00044 } 00045 00046 //_____________________________________________________________________________ 00047 function SetUpfLinkIndex(int MaxLink) 00048 { 00049 fLinkIndex = float(iLinkIndex / MaxLink); 00050 if (PrevLink != none) 00051 PrevLink.SetUpfLinkIndex(MaxLink); 00052 } 00053 00054 //_____________________________________________________________________________ 00055 function FreeMove(float dT) 00056 { 00057 local vector vDir; 00058 00059 // If LinkIndex == 0 else get vEnd from prev link. 00060 if ( PrevLink == none ) 00061 vStart = StartPoint.Location; 00062 else 00063 vStart = PrevLink.vEnd; 00064 00065 /* 00066 if (NextLink != none) 00067 // vEnd = (OldvEnd + ( OldvEnd + (NextLink.Location+Location)/2.0 )/2.0)/2.0 - vect(0,0,2) * dT * LinkLength * fLinkIndex; 00068 vEnd = ( OldvEnd + (NextLink.Location+Location)/2.0 )/2.0 - vect(0,0,5) * dT * LinkLength * fLinkIndex; 00069 else 00070 { 00071 vEnd = OldvEnd - vect(0,0,2) * dT * LinkLength; 00072 // Log(iLinkIndex$"# OldvEnd="$OldvEnd@"vEnd="$vEnd); 00073 } 00074 */ 00075 if ( PrevLink == none ) 00076 { 00077 vEnd = (vStart - vect(0,0,1)*LinkLength + vPerturbation) + OldvEnd * (0.2/dT); 00078 vEnd /= (0.2/dT + 1.0); 00079 vPerturbation *= 0.95; // no need to make it slowly return to 0,0,0 00080 } 00081 else 00082 { 00083 vEnd = (vStart - normal(PrevLink.Location-vStart)*LinkLength) + OldvEnd * (0.3/dT); 00084 vEnd /= (0.3/dT + 1.0); 00085 } 00086 OldvEnd = vEnd; 00087 00088 vDir = vEnd - vStart; 00089 vEnd = vStart + normal(vDir) * LinkLength; 00090 00091 OldvEnd = vEnd; 00092 SetRotation( rotator(vDir) ); 00093 SetLocation( vStart + normal(vDir) * LinkLength * 0.5); 00094 00095 if ( NextLink != none ) 00096 NextLink.FreeMove(dT); 00097 } 00098 00099 //_____________________________________________________________________________ 00100 event Destroyed() 00101 { 00102 if ( NextLink != none ) 00103 NextLink.Destroy(); 00104 } 00105 00106 00107 00108 defaultproperties 00109 { 00110 LinkLength=200.000000 00111 bUnlit=False 00112 RemoteRole=ROLE_SimulatedProxy 00113 DrawType=DT_StaticMesh 00114 StaticMesh=StaticMesh'MeshArmesPickup.Telecable' 00115 DrawScale=2.000000 00116 DrawScale3D=(Y=6.000000,Z=6.000000) 00117 }