RuneI
Class MeshPoint

source: c:\runehov\RuneI\Classes\MeshPoint.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--RuneI.Accelerator
         |
         +--RuneI.MeshPoint
Direct Known Subclasses:None

class MeshPoint
extends RuneI.Accelerator

//============================================================================= // MeshPoint //=============================================================================
Variables
 name AdjacentTag[4]
           Tags of adjacent RopePoints
 MeshPoint Adjacent[4]
           Adjacent RopePoints
 float DampFactor
           Dampening factor [0..1] (0 = no dampening)
 float MaxVelocityPickup
           Maximum velocity transfer allowed from collision
 vector OriginalPos
           Equillibrium positon
 float SpringConstant
           Spring Tension constant [0..] (0 = no tension)
 bool bAnchored
           If this point is anchored in place
 bool bDrawRopes
           Draw rope between this and adjacents

States
Active, Inactive

Function Summary
 void DrawRopeBetween(Actor a1, Actor a2, float DeltaTime)
 void MeshPointTick(float DeltaSeconds)
 void PreBeginPlay()
 void Touch(Actor Other)
 void WakeUp()


State Active Function Summary
 void BeginState()
 void Tick(float DeltaTime)


State Inactive Function Summary
 void BeginState()



Source Code


00001	//=============================================================================
00002	// MeshPoint
00003	//=============================================================================
00004	class MeshPoint extends Accelerator
00005		native;
00006	
00007	var() bool bAnchored;					// If this point is anchored in place
00008	var() bool bDrawRopes;					// Draw rope between this and adjacents
00009	var() float SpringConstant;				// Spring Tension constant [0..] (0 = no tension)
00010	var() float DampFactor;					// Dampening factor [0..1] (0 = no dampening)
00011	var() float MaxVelocityPickup;			// Maximum velocity transfer allowed from collision
00012	var() name AdjacentTag[4];				// Tags of adjacent RopePoints
00013	
00014	var MeshPoint Adjacent[4];				// Adjacent RopePoints
00015	var vector OriginalPos;					// Equillibrium positon
00016	
00017	const maxAdjacents = 4;
00018	
00019	
00020	native(655) final function MeshPointTick(float DeltaSeconds);
00021	
00022	function PreBeginPlay()
00023	{
00024		local MeshPoint A;
00025		local int adj;
00026	
00027		// Validate user set variables
00028		DampFactor = FClamp(DampFactor, 0.0, 1.0);
00029		OriginalPos = Location;
00030	
00031		// Build adjacency graph by tags
00032		for (adj=0; adj<maxAdjacents; adj++)
00033		{
00034			Adjacent[adj] = None;
00035			if (AdjacentTag[adj] != '')
00036			{
00037				foreach AllActors(class'MeshPoint', A, AdjacentTag[adj])
00038				{
00039					Adjacent[adj] = A;
00040				}
00041			}
00042		}
00043		
00044		if (bAnchored)
00045		{	// Fix the anchor to the current location
00046			SetPhysics(PHYS_NONE);
00047		}
00048	}
00049	
00050	function Touch(actor Other)
00051	{
00052		if (!Other.IsA('MeshPoint'))
00053		{
00054			Velocity += Normal(Other.Velocity) * Min(VSize(Other.Velocity), MaxVelocityPickup);
00055			WakeUp();
00056		}
00057	}
00058	
00059	function DrawRopeBetween(actor a1, actor a2, float DeltaTime)
00060	{
00061	}
00062	
00063	
00064	function WakeUp()
00065	{
00066		local MeshPoint A;
00067	
00068		GotoState('Active');
00069		foreach AllActors(class'MeshPoint', A)
00070		{
00071			//if (A.Group == Group)
00072			A.GotoState('Active');
00073		}
00074	}
00075	
00076	state Inactive
00077	{
00078		ignores Tick;
00079	
00080		function BeginState()
00081		{
00082			SetPhysics(PHYS_NONE);
00083		}
00084	}
00085	
00086	
00087	auto state Active
00088	{
00089		function Tick(float DeltaTime)
00090		{
00091			MeshPointTick(DeltaTime);
00092	/*
00093			local vector Deviation,AdditionalVelocity;
00094			local int adj;
00095	
00096			//TODO: Update with beams
00097	
00098			if (!bAnchored)
00099			{
00100				// Apply spring acceleration to myself
00101				Deviation = OriginalPos - Location;
00102				AdditionalVelocity = Deviation * (SpringConstant * DeltaTime / Mass);
00103				Velocity += AdditionalVelocity;
00104				Velocity *= (1.0 - DampFactor);
00105			}
00106		
00107			// Propogate acceleration to adjacents
00108			for (adj=0; adj<maxAdjacents; adj++)
00109			{
00110				if (Adjacent[adj]!=None)
00111				{
00112					if ((!bAnchored) && (!Adjacent[adj].bAnchored))
00113						Adjacent[adj].Velocity -= AdditionalVelocity * 0.25;
00114		
00115					// handle seperate bool for each rope
00116					if (bDrawRopes)
00117						DrawRopeBetween(self, Adjacent[adj], DeltaTime);
00118				}
00119			}
00120	*/
00121	
00122			if (VSize(Velocity) < 0.1)
00123			{
00124				Velocity = vect(0,0,0);
00125				GotoState('Inactive');
00126			}
00127		}
00128	
00129		function BeginState()
00130		{
00131			if (!bAnchored)
00132				SetPhysics(PHYS_PROJECTILE);
00133		}
00134	}
00135	
00136	defaultproperties
00137	{
00138	     SpringConstant=2000.000000
00139	     DampFactor=0.100000
00140	     MaxVelocityPickup=100.000000
00141	     Physics=PHYS_Projectile
00142	     CollisionRadius=20.000000
00143	     CollisionHeight=20.000000
00144	     bCollideActors=True
00145	     bCollideWorld=True
00146	}

End Source Code