This is something I've been putting together today for a larger project (Predominantly because it's dang near impossible to make hands on the proper scale out of actual props, but holos have no physics).
You can change whether it's a lefty or a righty, by changing the LR input between 1 and -1. Initial tests say it shouldn't matter how or where you spawn the chip, the holo should remain stable. The fingers are nonfunctional at the moment but the hand should still point it's palm ominously towards the input Entity.
After that, you use the State input to determine the mode of the glove, state 1 holds objects and moves them around, whereas state 2 allows you to rotate them (Naturally I recommend two gloves for that reason). There's no player user interface so I'm afraid you're on your own for that right now.
And now, onto the code:
@name Alarei Telekinetic Applications Glove
@inputs State Entity:entity LR Posi:vector
@inputs LockA Ang:angle
@inputs LockP Dif:vector Vel
@persist [Pos Sca Angle Mod Par]:array H Mat:string Start
@persist An:angle
@persist [V Col]:vector A:angle Core:entity
##MANUAL##
#Input 1 into LR for a Right hand, -1 for a Left hand
#State 1 is positioning, state 2 is angling
#In either state, the glove only affects the input Entity
#Positioning
#Flip LockP to freeze the entity relative to the glove
#Input a Dif to move it in a given direction on grabbing
#Vel adds the Dif each tick for sustained velocity
#Angling
#Flip LockA to freeze the entity's rotational movement
#Input Ang to rotate the entity to a desired angle
#LockA overrides Ang if both are input
if(first()){
Pos:pushVector(vec()) Sca:pushVector(vec(0.5,0.417,0.333)) Angle:pushAngle(ang()) Mod:pushString("hqtorus2") Par:pushNumber(1)
Pos:pushVector(vec()) Sca:pushVector(vec(0.417,0.417,0.10)) Angle:pushAngle(ang()) Mod:pushString("hqicosphere2") Par:pushNumber(1)
Pos:pushVector(vec(0,2*LR,-0.5)) Sca:pushVector(vec(0.249,0.249,0.124)) Angle:pushAngle(ang()) Mod:pushString("hqicosphere2") Par:pushNumber(1)
Pos:pushVector(vec(0,0,-0.143)) Sca:pushVector(vec(0.457,0.457,0.124)) Angle:pushAngle(ang(180,0,0)) Mod:pushString("dome2") Par:pushNumber(1)
Pos:pushVector(vec(0,3*LR,-0.5)) Sca:pushVector(vec(0.083,0.083,0.083)) Angle:pushAngle(ang()) Mod:pushString("hqicosphere2") Par:pushNumber(4)
Pos:pushVector(vec(1,3*LR,-0.5)) Sca:pushVector(vec(0.167,0.167,0.333)) Angle:pushAngle(ang(90,0,0)) Mod:pushString("hqcylinder") Par:pushNumber(5)
Pos:pushVector(vec(2,-2*LR,0)) Sca:pushVector(vec(0.083,0.083,0.083)) Angle:pushAngle(ang()) Mod:pushString("hqicosphere2") Par:pushNumber(1)
Pos:pushVector(vec(3,-2*LR,0)) Sca:pushVector(vec(0.167,0.167,0.333)) Angle:pushAngle(ang(90,0,0)) Mod:pushString("hqcylinder") Par:pushNumber(7)
Pos:pushVector(vec(5,-2*LR,0)) Sca:pushVector(vec(0.083,0.083,0.083)) Angle:pushAngle(ang()) Mod:pushString("hqicosphere2") Par:pushNumber(8)
Pos:pushVector(vec(6,-2*LR,0)) Sca:pushVector(vec(0.167,0.167,0.333)) Angle:pushAngle(ang(90,0,0)) Mod:pushString("hqcylinder") Par:pushNumber(9)
Pos:pushVector(vec(3,LR,0)) Sca:pushVector(vec(0.083,0.083,0.083)) Angle:pushAngle(ang()) Mod:pushString("hqicosphere2") Par:pushNumber(1)
Pos:pushVector(vec(4,LR,0)) Sca:pushVector(vec(0.167,0.167,0.333)) Angle:pushAngle(ang(90,0,0)) Mod:pushString("hqcylinder") Par:pushNumber(11)
Pos:pushVector(vec(6,LR,0)) Sca:pushVector(vec(0.083,0.083,0.083)) Angle:pushAngle(ang()) Mod:pushString("hqicosphere2") Par:pushNumber(12)
Pos:pushVector(vec(7,LR,0)) Sca:pushVector(vec(0.167,0.167,0.333)) Angle:pushAngle(ang(90,0,0)) Mod:pushString("hqcylinder") Par:pushNumber(13)
H=1
Mat="models/combine_scanner/scanner_eye"
}
if(Pos:count()){interval(1000)}
else{runOnTick(1)}
if(!Start){
N=0
while(N<=10 & Pos:count()){
P=entity():toWorld(vec(0,0,30))+Pos[1,vector]
S=Sca[1,vector]
A=Angle[1,angle]
M=Mod[1,string]
Pa=Par[1,number]
holoCreate(H,P,S,A)
holoModel(H,M)
holoParent(H,Pa)
H++,N++
Pos:remove(1)
Sca:remove(1)
Angle:remove(1)
Mod:remove(1)
Par:remove(1)
if(!Pos:count()){H=1}
}
GM=holoEntity(14):getMaterial()
while(!Pos:count() & GM!=Mat & N<=10){
holoMaterial(H,Mat)
H++,N++
}
if(!Pos:count() & GM==Mat){
Start=1
Core=holoEntity(2)
}
}
if(LR & $LR){reset()}
if(Start){
if(Posi){holoPos(1,Posi)}
else{holoPos(1,entity():toWorld(vec(0,0,30)))}
holoMaterial(2,(State ? "models/props_combine/tpballglow" : ""))
Co=Core:getColor()
if(Co!=Col){
Core:soundPlay(1,1,"buttons/button9.wav")
Col=Co
}
Box=Entity:toWorld(Entity:boxCenter())
if(Entity & State){
An=(Box-holoEntity(1):pos()):toAngle()
holoAng(1,A:setRoll(0)-ang(22.5,0,0))
}
#Relative locking mechanism
LP=LockP & $LockP & State==1
#Positional locking
if(LP){
V=Core:toLocal(Box)
V+=Dif
}
elseif(!LockP){
V=Core:toLocal(Box)
}
#Angular locking
if(LockA & Entity & $LockA|!LockA){
A=Entity:angles()
}
Mass=Entity:mass() VelW=Entity:vel()
if(State==1){ #Positioning
holoColor(2,vec(0,1,0)*255)
V+=Dif*Vel #Application of applied velocity
Des=Core:toWorld(V)
Vec=Des-Box
Vec*=Mass
Vec-=VelW/2
Entity:applyForce(Vec*Mass)
}
elseif(State==2){ #Angling
holoColor(2,vec(1,0,1)*255)
Ine=Entity:inertia() AVel=Entity:angVelVector()
Ag=(LockA ? A : Ang)
Q1=quat(Entity)
Q2=quat(Ag)
Q=Q2/Q1
Torq=Entity:toLocal(rotationVector(Q)+Box)*Mass^2
Torq-=AVel*Mass
Torq*Ine
Entity:applyTorque(Torq)
}
else{
holoColor(2,vec(0,1,1)*255)
}
}
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment