Holy crap, that's awesome.
Now I need to make a humanoid robot, hook it up to a WSR, and we can explore distant servers!
So with my work recently on making different ranger-based eyes, I've been in need of a more in-depth way of discerning the quality of their results, which isn't really possible if all I'm seeing is a bunch of holos of various colours in a circle or somesuch in midair. So with that in mind, I decided to try and translate to a player-viewable experience what the eye was actually seeing.
After quite a bit of frustration and a quick translation from wires to wirelinks where possible, here we have the Eye Code Testing System (ECTS for short).
The way ECTS works is that you wire up your potential eye code to the ECTS chip and then once in the attached pod you see black emptiness. Within this black emptiness, you can turn left and right and go backwards and forwards, but what you can actually percieve is entirely based on what your eye code can see. Various holograms inside the blackness tell what the eye can tell you, such as where they hit, how far away, and to some degree what they hit. Exactly what you do with this view is up to you, you could use it to try and navigate a maze or explore a map or attack enemy units based on what you can see of them.
The eye itself can output the arrays or there can be an intermediary chip translating the ranger outputs to arrays, so long as the eye views based on an angle and a world position (Or can at least be readily modified to do so) it can be tested by the player with this system. Simply wirelink a cam controller and adv. pod controller to the E2 and wire up in the array inputs. The system can test variable focusing, entity-detection, as well as distance, hit, and colour recognition.
And now, the code:[highlight=e2]@name Eye Code Testing System (ECTS)
@inputs [Posit Hit HNorm Ent]:array
@inputs [Cam Pod]:wirelink
@outputs Pos:vector Ang:angle Range Foc
@persist [RHit Colour Distance Entities Norm Rel] Speed
@persist Box:entity Max [In Po]:vector On
@persist [PoA HiA HNA EnA]:array
@persist T M B Inc
@trigger none
if(first()){
#====Functional Variables====#
Range=200
Speed=5
Distance=1 #Can the eye distinguish distances?
RHit=1 #Can the eye tell if it's hit something?
Colour=0 #Can the eye discern colour?
Entities=1 #Can the eye discern entities?
#Colour & Entities override one another
Norm=1 #Can the eye discern the hitnormal?
Rel=1 #Does the eye produce local vectors?
#============================#
#=======Function Start=======#
#============================#
T=Posit:count() #It helps to wire up Posit & refresh here
B=T+1 #Box hologram number
M=1
Foc=Range/4 #Default focus
Inc=Range/100 #Focus shift increment
Po=vec(0,0,2000) #Location of Box hologram
Pos=rangerOffset(600,vec(),vec(0,0,-1))osition()+vec(0,0,64)
In=Pos #Default start position for the eye
}
if(M<=B & !tickClk()){
interval(1000)
N=0
while(N<=10 & M<=B){
holoCreate(M,Po)
holoModel(M,(Norm ? "hqcone" : "hqicosphere2"))
if(M==B){
D=Range*2.5
holoScaleUnits(B,vec(1,1,1)*-D)
holoModel(B,"hqicosphere2")
holoColor(B,vec())
Box=holoEntity(B)
Max=200
}
else{
holoScale(M,vec(1,1,1)/2)
}
M++,N++
}
}
else{
runOnTick(1)
}
On=Pod["Active",number]
Cam["Activated",number]=On
if(!On & $On){
Pos=In
Ang=ang()
Foc=Range/4
Cam["Angle",angle]=Ang
}
elseif(On){
Po=Box:toWorld(Box:boxCenter())
Cam["Position",vector]=Po
W=Pod["W",number] S=Pod["S",number]
A=Pod["A",number] D=Pod["D",number]
#View direction rotation
if(A|D){
Ang+=ang(0,1,0)*(A-D)
Cam["Angle",angle]=Ang
}
Look=vec(1,0,0):rotate(Ang)
#Motion application
if(W|S){
Look*=5
Pos+=Look*(W-S)
Pos=rangerOffset(600,Pos,vec(0,0,-1))osition()+vec(0,0,64)
}
#User focus variation
Ne=Pod["NextWeapon",number] Pr=Pod["PrevWeapon",number]
Al=Pod["Alt",number]
if(Al){Foc=Range/4}
else{Foc+=Inc*(Ne-Pr)}
N=1
while(M<=T & N<=10){
#Location
H=PoA[M,vector]
H-=Pos*!Rel
R=(Distance ? H:length()/Range : 1)
H=H:normalized()*(Max*R)
holoPos(M,Box:toWorld(H))
if(RHit){
#Colouration
D=(255*R)
Ba=vec(1,1,1)*D
CE=Entities|Colour
if(EnA[M,entity] & CE){
E=EnA[M,entity]
if(Entities & !Colour){
if(E:type():lower():find("prop")){
holoColor(M,vec(0,1,0)*D)
}
elseif(E:isNPC()){holoColor(M,vec(1,0,0)*D)}
else{holoColor(M,Ba)}
}
elseif(Colour & !Entities){
Col=E:getColor()
holoColor(M,Col*D)
}
}
elseif(HiA[M,number]){holoColor(M,Ba)}
else{holoColor(M,vec())}
#Hit Normal
if(Norm){
An=HNA[M,vector]:toAngle()+ang(90,0,0)
holoAng(M,An)
}
else{holoAng(M,ang())}
}
M++,N++
}
if(M>=T){
M=1
PoA=Posit
HiA=Hit
HNA=HNorm
EnA=Ent
T=Posit:count()
}
}[/highlight]NOTE: Because of the way e2 highlighting presently works on the forums, I recommend you quote this post and copy the code from there, not straight from the post.
Guide to the different inputs:Each entry in the provided arrays must exist whether it contains anything or not.
- Posit is the result of RD:position()
- Combined with Rel, allows for distance recognition and holo placement
- MUST be connected!
- Hit is the result of RD:hit()
- Fundamental, used to enable Ent and Colour
- Ent is the result of RD:entity()
- Used for Colour and Entity recognition
- HNorm is the result of RD:hitNormal() for each ranger trace
- Used for the HitNorm angling of the holos to the traced landscape
Last edited by Lyinginbedmon; 02-11-2010 at 07:29 PM. Reason: Added support for hitNormal(), converted to e2 highlighting
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
Holy crap, that's awesome.
Now I need to make a humanoid robot, hook it up to a WSR, and we can explore distant servers!
Just went and fixed the minor bugs with the Wirelinks, plus some If functions to reduce ops kinda broke motion vs rotation so I fixed that as well. Should be perfectly functional now.
As a point of note it is possible to network more than one eye chip together and view the results here, by grouping the results from all concerned eyes together into the input arrays and slightly modifying the input positions and angles. This is good because I've learned that one eye, even with the distance vision, has terrible depth perception![]()
Last edited by Lyinginbedmon; 02-09-2010 at 08:06 AM.
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
Ranger based "eyes"?
I'm assuming you mean ranger based systems of environment exploration for robots and the like.
Please elaborate more on the exact format an eye needs to output to be usable with this.
The eye itself can output either the arrays or pure ranger information, so long as ECTS gets arrays. The "eye" being a code that outputs ranger data (or these arrays of ranger results) with the goal of gathering information across an area, like the human eye does. I personally investigate such codes for use in more intelligent drones but they could also be used for security fields and spacebuild astronomy and such (The latter seriously requires focusing given the distances involved).
The arrays need to be:If the eye has multiple rangers (which is why the system uses arrays), the entries must be included for each one regardless of whether they are positive or exist. (an entity or NULL)
- Hit = the RD:hit() result for the ranger (a number of 1 or 0)
- Posit = the RD:position() result (Remember to check the Rel persist for whether the eye translates this to local vectors or not) (a vector)
- Ent = the RD:entity() result
I might add in support for RD:hitNormal() if I have some free time today, wouldn't take much, just another array, a model change and some rotating.
This has inspired me to make one of these in Gmod...
I'm having some issues getting this to work.
I had to wire the active input on the cam controller to the pod controller directly, because it's not controlled in your expression. Minor note, but still.
More importantly, it doesn't' seem to update the eye data. Here's the code I'm using for an eye, maybe I've structured it wrong.
It only displays dots if I run in Local mode (in both chips, of course), but those dots do not update. Whatever positions it reads off the first time stay there.Code:@name Eye @outputs [Positions Hit Ent]:array @persist Index #runOnTick(1) interval(200) ################################################### E = entity() O = owner() Count = 5 Ops = 100 Range=500 FOV=50 Local=1 ################################################### if (first()){ for (I=1,Count){ holoCreate(I) holoColor(I,hsv2rgb(randint(0,360),1,1)) } } while (minquota() > Ops) { Index++ rangerFilter(O) Ranger = rangerOffset(Range,E:pos(),E:up():rotate(ang(randint(-FOV/2,FOV/2),randint(-FOV/2,FOV/2),randint(-FOV/2,FOV/2)))) RangerDist = Ranger:distance() Positions[Index,vector] = Local ? E:toLocal(Ranger:position()):rotate(-90,0,0) : Ranger:position() Hit[Index,number] = Ranger:hit() Ent[Index,entity] = Ranger:entity() holoPos(Index,Ranger:position()) if (Index==Count){Index=0 break} }
I set Range the same in both chips.
Other than that, it seems to be working, but it's kind of hard to do anything if the dots are static.
With just setting the array entries as it runs through my codes work just fine, I think it's probably an issue with your code (I'm thinking probably the Positions). I also can't see what you're using RangerDist for.
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
RangerDist is a leftover variable. I was going to make it draw beams for the rangers, but ended up just using boxes at the endpoints instead.
The array is updating. If I debug your chip, it shows all the values changing. If it is my code, I dunno what to change, other than naming the array Posit in my eye.
GOT IT.
Have to clear the array each execution, dunno why...
Bump, added support for hitNormal() (Untested, but can't see how it could be too far off).
Might be able to fix the array clearing issue with some ECTS-only code though that'll need to wait until I can get to a Gmod-able computer in a couple hours. The fundamental problem I suppose is that the RD data type can't be stored, not in arrays or globals or anywhere, so we need to break it apart and store it in these different arrays.
I'll post up some of my eye codes tonight too, give something to work from or to really give an example of what this system does. Will nab some screenshots too.
For those still wondering, I guess it's simplest to define ECTS as a way of taking a bunch of built-in rangers and giving them a visible result for the player. Or, alternatively, a way for the player to see what the code is seeing.
Last edited by Lyinginbedmon; 02-09-2010 at 07:31 AM.
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