All pastes #2054078 Raw Edit

mib

public text v1 · immutable
#2054078 ·published 2011-05-05 05:02 UTC
rendered paste body
class AwesomeMobileActor extends Actor
    placeable;

var() StaticMeshComponent MyMesh;
var Material TappedMaterial;
var float globalTime;
var() StaticMeshComponent StaticMesh;
var AwesomeMobileHud amh;


var() float mmass;  //Declare the mass
var() float k1;   //Declare spring constant on first spring
var() float k2;   //Declare spring constant on second spring
var() float posinit; //Declare the initial displacement
var() float b; //Declare damping constant
var() float logInterval; //Declare interval for writing to log file.

var bool running;             // Declare boolean "running"

var vector u1old;  //Declare old position
var vector u2old;  // Declare old velocity
var vector u1new;  //Declare new position
var vector u2new;   //Declare new velocity
var vector delpos;
var vector oldlocation;
var vector newlocation;
var float omegasquared;
var float poschange;
var float pos;
var int i;

var bool DEBUG; 
var bool bIAmTapped;





// Change our material.
function Tapped(bool bIsTapped)
{
    MyMesh.SetMaterial(0, bIsTapped ? TappedMaterial : None );
	bIAmTapped = bIsTapped;
	

}





//Set the initial conditions
function PostBeginPlay() {

running = true;
omegasquared=(k1+k2)/pi;
u2old=vect(0,0,0);
u1old=self.location;
u1old.X+=posinit;
DEBUG=false;
pos=u1old.X;
i=0;
}

function float getPos(){
	return pos;
}

simulated event PostRenderFor (PlayerController PC, Canvas Canvas, Vector CameraPosition, Vector CameraDir) 
{ Canvas.SetPos(100,100);
 Canvas.DrawText(self@":Hello, World");
 }





//////////////////////////////  Euler's Method:  ///////////////////////////


function Tick(float dT){
	

  if(running == true) {

  
	if(bIAmTapped == false){
  
	u1old = self.location;
	

    globalTime += dT;
	
	
    u2new.X=u2old.X-(omegasquared*u1old.X+b*u2old.X)*dT;
    u1new.X=u1old.X+u2new.X*dT;
	
	

  
	self.SetLocation(u1new);
	
  
	u1old=u1new;
    u2old=u2new;
	}

	
	
	
	
	pos=u1old.X;
	amh.posit=pos;
	
 }

}

//////////////////////////////////////////////////////////////////////////////////



defaultproperties
{
    TappedMaterial=Material'CastleEffects.TouchToMoveArrowMaterial'
    bCollideActors=True
    bCanBeDamaged=true
    bProjTarget=true

    Begin Object Class=StaticMeshComponent Name=MyStaticMesh
        StaticMesh=StaticMesh'EditorMeshes.TexPropCube'
    End Object
    MyMesh=MyStaticMesh
    CollisionComponent=MyStaticMesh
    Components.Add(MyStaticMesh)
}