This looks cool! Ill give it a try tomorrow!
This is something I finished for the most part yesterday whilst messing around, and decided to complete today by adding an additional two states (Push & Pull).
Basically, this produces a holographic hand that can be used to manipulate an input entity in one of four ways.I initially put it together because I had trouble making prop-based hands in the scale I needed, but holograms don't have the necessary physics, this therefore is a way of achieving both and also allowing for significant versatility of use.
- Positioning - You can lock it in place relative to the hand, apply velocity to it, and by altering the Dif input you can also fine tune it's location
- Rotation - You can precisely orient the entity, both singularly and relative to the hand
- Push - You can push the entity away from the hand, or push the hand away from it (Provided the hand is parented to a Palm entity)
- Pull - Basically the reverse of Push
There is a built-in comment Manual at the beginning of the code, if you have any issues let me know.[highlight=e2]@name Holo apply glove
#Universal inputs
@inputs State [Entity Palm]:entity LR Posi:vector
#State inputs
@inputs LockA Ang:angle
@inputs LockP Dif:vector Vel
@inputs Pull
@inputs Push
#Functional persists
@persist [Pos Sca Angle Mod Par]:array H Mat:string Start
@persist An:angle M [Knucs Offs]:array SetF
@persist [V Col]:vector A:angle Core:entity Pa Get:array Seq
##MANUAL##
#Input 1 into LR for a Right hand, -1 for a Left hand
#Unless a Posi vector is input, the glove will attach to Palm
#State 1 - 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
#State 2 - 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
#State 3 - Pulling
#Input 1 into Push to pull Palm towards Entity
#Input -1 into Push to pull Entity towards Palm
#Requires a Palm entity
#State 4 - Pushing
#Input 1 into Push to shove Palm away from Entity
#Input -1 into Push to shove Entity away from Palm
#Requires a Palm entity
if(first()){
PosushVector(vec()) Sca
ushVector(vec(0.5,0.417,0.333)) Angle
ushAngle(ang()) Mod
ushString("hqtorus2") Par
ushNumber(1)
PosushVector(vec()) Sca
ushVector(vec(0.417,0.417,0.10)) Angle
ushAngle(ang()) Mod
ushString("hqicosphere2") Par
ushNumber(1)
PosushVector(vec(0,2*LR,-0.5)) Sca
ushVector(vec(0.249,0.249,0.124)) Angle
ushAngle(ang()) Mod
ushString("hqicosphere2") Par
ushNumber(1)
PosushVector(vec(0,0,-0.143)) Sca
ushVector(vec(0.457,0.457,0.124)) Angle
ushAngle(ang(180,0,0)) Mod
ushString("dome2") Par
ushNumber(1)
PosushVector(vec(0,3*LR,-0.5)) Sca
ushVector(vec(0.083,0.083,0.083)) Angle
ushAngle(ang()) Mod
ushString("hqicosphere2") Par
ushNumber(4)
PosushVector(vec(1,3*LR,-0.5)) Sca
ushVector(vec(0.167,0.167,0.333)) Angle
ushAngle(ang(90,0,0)) Mod
ushString("hqcylinder") Par
ushNumber(5)
PosushVector(vec(2,-2*LR,0)) Sca
ushVector(vec(0.083,0.083,0.083)) Angle
ushAngle(ang()) Mod
ushString("hqicosphere2") Par
ushNumber(1)
PosushVector(vec(3,-2*LR,0)) Sca
ushVector(vec(0.167,0.167,0.333)) Angle
ushAngle(ang(90,0,0)) Mod
ushString("hqcylinder") Par
ushNumber(7)
PosushVector(vec(5,-2*LR,0)) Sca
ushVector(vec(0.083,0.083,0.083)) Angle
ushAngle(ang()) Mod
ushString("hqicosphere2") Par
ushNumber(8)
PosushVector(vec(6,-2*LR,0)) Sca
ushVector(vec(0.167,0.167,0.333)) Angle
ushAngle(ang(90,0,0)) Mod
ushString("hqcylinder") Par
ushNumber(9)
PosushVector(vec(3,LR,0)) Sca
ushVector(vec(0.083,0.083,0.083)) Angle
ushAngle(ang()) Mod
ushString("hqicosphere2") Par
ushNumber(1)
PosushVector(vec(4,LR,0)) Sca
ushVector(vec(0.167,0.167,0.333)) Angle
ushAngle(ang(90,0,0)) Mod
ushString("hqcylinder") Par
ushNumber(11)
PosushVector(vec(6,LR,0)) Sca
ushVector(vec(0.083,0.083,0.083)) Angle
ushAngle(ang()) Mod
ushString("hqicosphere2") Par
ushNumber(12)
PosushVector(vec(7,LR,0)) Sca
ushVector(vec(0.167,0.167,0.333)) Angle
ushAngle(ang(90,0,0)) Mod
ushString("hqcylinder") Par
ushNumber(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]
Mo=Mod[1,string]
Pa=Par[1,number]
holoCreate(H,P,S,A)
holoModel(H,Mo)
holoParent(H,Pa)
H++,N++
Pos:remove(1)
Sca:remove(1)
Angle:remove(1)
Mod:remove(1)
Par:remove(1)
if(!Pos:count() & !Seq){
H=1
Seq++
}
}
if(Seq==1){
GM=holoEntity(14):getMaterial()
while(Seq==1 & GM!=Mat & N<=10){
holoMaterial(H,Mat)
H++,N++
}
if(GM==Mat){
Seq++
Core=holoEntity(2)
Get=Palm:getConstraints()
M+=Palm:mass()*0.9
}
}
elseif(Seq==2){
if(Get:count()){
N=0
while(Get:count() & N<=10){
M+=Get[1,entity]:mass()*0.9
N++
}
}
else{
Start++
KnucsushNumber(5) Offs
ushAngle(-ang(12,-9,0))
KnucsushNumber(7) Offs
ushAngle(-ang(12,0,0))
KnucsushNumber(9) Offs
ushAngle(ang())
KnucsushNumber(11) Offs
ushAngle(-ang(12,0,0))
KnucsushNumber(13) Offs
ushAngle(ang())
}
}
}
Pa=(Palm ? 1 : 0)
if(LR & $LR|Pa & $Pa){reset()}
if(Start){
#Core element
holoMaterial(2,(State ? "models/props_combine/tpballglow" : ""))
Col=Core:getColor()
if($Col){
Core:soundPlay(1,1,"buttons/button9.wav")
}
if(Posi){
holoPos(1,Posi)
holoUnparent(1)
}
elseif($Start){
E=(Palm ? Palm : entity())
Vec=E:toWorld(E:boxCenter())
holoPos(1,Vec+vec(0,0,10)*!Palm)
holoAng(1,E:angles())
holoParent(1,E)
}
#Hand angling
if(Entity & !Palm & !(LockA|LockP)){
Ve=Entityos()
Ve-=holoEntity(1)os()
holoAng(1,Ve:toAngle()-ang(22.5,0,0))
}
Box=Entity:toWorld(Entity:boxCenter())
#Digit angling
Y=Core:angles():yaw()
N=0
while(N<=Knucs:count()){
H=Knucs[N,number]
Hol=holoEntity(H)
Vec=Box-Holos()
A=Vec:toAngle():setYaw(Y)
A+=Offs[N,angle]
holoAng(H,(Entity ? A : Core:angles()))
N++
}
##Locking
#Relative locking mechanism
LP=LockP & $LockP & State==1
#Positional locking
if(LP & !SetF){
V=Core:toLocal(Box)
V+=Dif
SetF=1
}
elseif(!LockP){
V=Core:toLocal(Box+Entity:vel()/(Entity:mass()*2))
SetF=0
}
#Angular locking
if(LockA & Entity & $LockA|!LockA){
A=Entity:angles()
}
Mass=Entity:mass() VelW=Entity:vel()
if(State==1){ #Positioning
holoColor(2,vec(0,0,1)*255)
V+=Dif*Vel #Application of applied velocity
Des=Core:toWorld(V)
Vec=Des-Box
Vec*=Entity:mass()
Vec-=VelW/2
Entity:applyForce(Vec*Mass)
}
elseif(State==2){ #Angling
holoColor(2,vec(0,1,0)*255)
Ine=Entity:inertia() AVel=Entity:angVelVector()
Angs=Entity:angles() Mass=Entity:mass()
Ag=(LockA ? A : Ang) Ag=(!LockA & Ang ? Ang : Angs)
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)
}
elseif(State==3){ #Pulling
holoColor(2,vec(0,1,1)*255)
Vec=Box-Coreos()
if(Pull>0){ #Pull Palm towards
Vec*=M
Vec-=Palm:vel()
Palm:applyForce(Vec)
}
elseif(Pull<0){ #Pull Entity towards
Vec*=-1
Vec*=Entity:mass()
Vec-=Entity:vel()
Entity:applyForce(Vec)
}
}
elseif(State==4){ #Pushing
holoColor(2,vec(1,0,0)*255)
Vec=Box-Coreos()
if(Push>0){ #Push Palm away
Vec*=-1
Vec*=M
Vec-=Palm:vel()
Palm:applyForce(Vec)
}
elseif(Push<0){ #Push Entity away
Vec*=Entity:mass()
Vec-=Entity:vel()
Entity:applyForce(Vec)
}
}
else{
holoColor(2,vec(1,1,1)*255)
}
}[/highlight]
The Olympus Technologies drones, totally not SkyNet in Gmod form.
Cronus: The Ultimate Drone, definitely SkyNet in Gmod form.
The gBrain Project, the drone controls system that thinks it's better than you
This looks cool! Ill give it a try tomorrow!
New server IP: 89.238.160.17:27018
Hologram contraptions 1 Holo contraptions 2 EGP stuff Holo minigun Holo javelin rocket launcher
Unsmart: I doubt the intelligence of some people.
Drunkie: Nobody could have said that any better than Unsmart.
Unsmart: Solece, I totally did your mom yesterday
Solece: Who hasnt
Divran: there are more retarded people than there are clever people in this world
The force is strong in this one.
No matter how many Z's you put after Plz, you still spell as well as a piece of cheese.
http://somone77.net
Can you upload the .txt, that bbcode isn't good for copying.
Have you checked HERE first?
SVN Tutorial
My SVN:Get dropbox and get 250 MB extra space: DropboxCode:http://divranspack.googlecode.com/svn/trunk/%20divranspack/
@divran
It's too big to copy all in one.
SVN Tutorial
My SVN:Get dropbox and get 250 MB extra space: DropboxCode:http://divranspack.googlecode.com/svn/trunk/%20divranspack/
The Olympus Technologies drones, totally not SkyNet in Gmod form.
Cronus: The Ultimate Drone, definitely SkyNet in Gmod form.
The gBrain Project, the drone controls system that thinks it's better than you
Bookmarks