+ Reply to Thread
Results 1 to 8 of 8

Thread: EGP Aim-Pos based Mouse

  1. #1
    Wire Sofaking Rybec's Avatar
    Join Date
    Apr 2008
    Location
    Denver
    Posts
    648

    Default EGP Aim-Pos [Or eyepod] based Mouse

    EGP Mouse

    EDIT:EXAMPLE BUTTON ADDED
    Features rollover and click animations.


    EDIT:Eye-Pod alternative added.
    Allows keyboard input as well, good as a computer base. See bottom of post.


    Not much to explain here, yeah?
    Works for any screen in the dropdown menu.
    Uses aimpos of nearest player, but only if they're close enough.
    Uses the Use key to click, but that can easily be changed/added to.
    Given the kind of power inside of EGP, I wouldn't be surprised to see right-click menus....

    Started off using the offset data from this:E2 ConsoleScreen To grapics Tab

    However, I've tweaked some of the values slightly to be more accurate, and added the other EGP screens, as well as converted it to using vec2s

    [ame="http://www.youtube.com/watch?v=jdLgnRZJu0o"]YouTube- EGP mouse[/ame]


    Handy-snazzy position reference grid included at no extra charge. Great for planning where to put things, although it won't be long before this is merged into EGP for Dummies, at which point a full-blown CAD package and probably an interface designer isn't far off.

    [highlight="e2"]
    @name EGP Mouse
    @inputs EGP:wirelink
    @outputs Coords:vector2 Click
    @persist [Coords1 Coords2]:vector2 Dir E:entity RepeatTime
    interval(200)

    if( first() | duped() | ~EGP | changed(numPlayers())) {
    E=EGP:entity()
    RepeatTime=1000

    #BG
    EGP:egpBox(1,vec2(),vec2(512,512),vec4(0,200,255,2 55))

    #Button1
    EGP:egpBox(2,vec2(66,386),vec2(132,68),vec4(0,0,0, 255))
    EGP:egpBox(3,vec2(64,384),vec2(128,64),vec4(0,100, 255,255))
    EGP:egpText(4,"Test",vec2(80,395),vec4(0,255,50,25 5))
    EGP:egpSetFont(4,"coolvetica",50)

    #Offsets
    if( E:model() == "models/props/cs_office/tv_plasma.mdl") {
    Coords1=vec2(-28.5,36)
    Coords2=vec2(28.5,2)
    Dir=1
    }
    elseif( E:model() == "models/props/cs_office/computer_monitor.mdl") {
    Dir=1
    Coords1=vec2(-10.5,24.7)
    Coords2=vec2(10.5,8.6)
    }
    elseif( E:model() == "models/props_lab/monitor01b.mdl") {
    Dir=1
    Coords1=vec2(-5.535,5.091)
    Coords2=vec2(3.5,-4.1)
    }
    elseif( E:model() == "models/kobilica/wiremonitorsmall.mdl") {
    Dir=1
    Coords1=vec2(-4.4,9.5)
    Coords2=vec2(4.5,0.6)
    }
    elseif( E:model() == "models/kobilica/wiremonitorbig.mdl") {
    Dir=1
    Coords1=vec2(-11.6,24.5)
    Coords2=vec2(11.6,1.5)
    }
    elseif( E:model() == "models/hunter/plates/plate2x2.mdl" ){
    Dir=2
    Coords1=vec2(-46.5,-46.5)
    Coords2=vec2(46.5,46.5)
    }
    elseif( E:model() == "models/hunter/plates/plate4x4.mdl" ){
    Dir=2
    Coords1=vec2(-94.8,-94.8)
    Coords2=vec2(94.8,94.8)
    }
    elseif( E:model() == "models/hunter/plates/plate1x1.mdl" ){
    Dir=2
    Coords1=vec2(-23,-23)
    Coords2=vec2(23,23)
    }
    elseif( E:model() == "models/hunter/plates/plate8x8.mdl" ){
    Dir=2
    Coords1=vec2(-189.8,-189.8)
    Coords2=vec2(189.8,189.8)
    }
    }

    #Find closest player
    findByClass("player")
    findSortByDistance(E:massCenter())
    Ply = find()
    Aim = E:toLocal(Ply:aimPos())

    if (Dir==1){
    Coords=(Coords1 - vec2(Aim:y(),Aim:z()))/(Coords1-Coords2)*513
    Z = Aim:x()
    }
    elseif (Dir==2) {
    Coords=(Coords1 - vec2(Aim:y(),Aim:x()))/(Coords1-Coords2)*513
    Z = Aim:z()
    }

    Dist=Ply:shootPos():distance(E:massCenter())
    IsAimingOn=(Dist<max(E:radius()*2,30) & Ply:aimEntity()==E & inrange(Coords,vec2(1,1),vec2(513,513)))

    if (IsAimingOn) {
    Click=Ply:keyUse()
    }
    else {
    Coords=vec2()
    }

    if (inrange(Coords,vec2(64,384),vec2(192,448))) {
    EGP:egpBox(3,vec2(65,385),vec2(128,64),vec4(0,100, 200,255))
    EGP:egpText(4,"Test",vec2(81,396),vec4(0,255,50,25 5))
    EGP:egpSetFont(4,"coolvetica",50)
    if (Click){
    EGP:egpBox(3,vec2(66,386),vec2(128,64),vec4(200,10 0,0,255))
    EGP:egpText(4,"Test",vec2(82,397),vec4(0,255,50,25 5))
    EGP:egpSetFont(4,"coolvetica",50)
    if ($Click) {
    soundPlay(0,0,"buttons/blip1.wav")
    }
    }
    }
    else {
    EGP:egpBox(3,vec2(64,384),vec2(128,64),vec4(0,100, 255,255))
    EGP:egpText(4,"Test",vec2(80,395),vec4(0,255,50,25 5))
    EGP:egpSetFont(4,"coolvetica",50)
    }

    EGP:egpTriangle(40,Coords,Coords+vec2(6,5),Coords+ vec2(0,10),Click ? vec4(255,0,0,200) : vec4(0,0,255,200))
    EGP:egpDraw()

    [/highlight]

    About the Eyepod version:
    Zip file contains the expression, as well as a dupe of a completed setup. Example chip (the computer) is wirelinked to a keyboard, but does not use it yet. Button goes boop when pressed. The eyepod itself is hiding invisible inside the mouse prop, if you want to do anything with it.
    Attached Thumbnails Attached Thumbnails EGP Aim-Pos based Mouse-egp-desk-front.jpg  
    Attached Files Attached Files
    Last edited by Rybec; 12-22-2009 at 01:05 AM. Reason: Added example button, Added eyepod version

  2. #2
    goluch
    Guest goluch's Avatar

    Default Re: EGP Aim-Pos based Mouse

    RYBEC I LOVE YOU!
    I might even integrate this into the lua code and make it built in.

  3. #3
    Wire Sofaking Rybec's Avatar
    Join Date
    Apr 2008
    Location
    Denver
    Posts
    648

    Default Re: EGP Aim-Pos based Mouse

    Ehhhh....

    If you're going to implement it directly, the cursor shouldn't count towards the total shape count. A way of manually setting the cursor position would be nice too.
    It's my intent to, when working with Jacoby on making his EGP designer mouse-based, to make the cursor snap to existing elements. What if we want to click with attack1 and 2?
    The amount of control we need to have over that cursor really makes it such that it should just be left up to the end-coder. On the other hand, built-in mouse support means you would also build in the ability to check what element the cursor is over, making buttons easier, but it gets to the point where you need to decide what the main point of the project is. Is it creating a display device, or an interface device?

    Plus, you could make an actual MOUSE mouse by using an eyepod. The number of layered interactions involved at moving that cursor across the screen at that point kinda blows my mind. I mean, you have a device measuring movement, moving the real cursor, the motion of which is then in turn interpreted by Source, which is then used to rotate a view, which is, itself, measured for change.....
    And there's the whole bit where EGP could potentially be used to realize the pipe dream of Gmod in Gmod, and then what if you have a moused surface in that.....

    Gaaah. My head hurts.
    EDIT: May make my head hurt, but boy was it simple to implement.
    Last edited by Rybec; 12-22-2009 at 01:06 AM.

  4. #4
    Wire Sofaking feha's Avatar
    Join Date
    Sep 2009
    Location
    Here
    Posts
    1,156

    Default Re: EGP Aim-Pos based Mouse

    Wait! Rybec just implemented gmod in egp?

    And dont make cursor exist by default, make a Cursor input that when it get any other number then 0, turns on a cursor. This could be used both to make something without a ugly cursor, or something with a neat cursor that you also can turn off.

    It should output both x and y pos, but also index of the shape you hover. Perhaps even who uses it.

    Making it detect if the user is pressing use, mouse 1 or whatever would be quite unnecesary, as with the user output e2 easily does that.
    However a user override would be good to, so you can give it owner() or Pod:driver().

  5. #5
    Wire Sofaking Rybec's Avatar
    Join Date
    Apr 2008
    Location
    Denver
    Posts
    648

    Default Re: EGP Aim-Pos based Mouse

    Quote Originally Posted by feha View Post
    Wait! Rybec just implemented gmod in egp?
    I was joking. However, after I get more interface elements figured out, I AM going to be making a 3D renderer, so some sort of 3D game may be possible.


    On the topic of interface elements, I've got a working slider!

    Don't have a pic of it yet though.
    Slider works both ways, dragging it around changes the value, and changing the value moves the slider.

    Press Test to start/stop the sound, slider adjusts pitch. Press the 100 button to set the slider to 100.
    Attached Files Attached Files
    Last edited by Rybec; 12-22-2009 at 02:22 PM.

  6. #6
    Wire Noob oompa loompa's Avatar
    Join Date
    Nov 2009
    Location
    CA
    Posts
    16

    Default Re: EGP Aim-Pos based Mouse

    still dont understand wut i could use this 4.

  7. #7
    Wire Sofaking Unsmart's Avatar
    Join Date
    Dec 2008
    Location
    Belgium OR BANland
    Posts
    1,965

    Default Re: EGP Aim-Pos based Mouse

    -.- If you have no idea whats EGP, leave the thread
    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

  8. #8
    goluch
    Guest goluch's Avatar

    Default Re: EGP Aim-Pos based Mouse

    Egp-egp-egp-egp!

+ Reply to Thread

LinkBacks (?)

  1. 01-27-2010, 12:19 PM

Similar Threads

  1. Mouse-based movement
    By Lyinginbedmon in forum Expression 2 Discussion & Help
    Replies: 7
    Last Post: 12-10-2009, 04:50 AM
  2. Pod angles not based around pod
    By bobthe2lol in forum Expression 2 Discussion & Help
    Replies: 5
    Last Post: 11-16-2009, 05:42 PM
  3. C++/lua based gate
    By turck3 in forum Ideas & Suggestions
    Replies: 65
    Last Post: 05-11-2009, 04:31 AM
  4. Prop-based speedometers
    By IEF015 in forum Ideas & Suggestions
    Replies: 1
    Last Post: 07-07-2008, 04:31 AM
  5. Distance Based Teleporter
    By chinoto in forum Finished contraptions
    Replies: 14
    Last Post: 06-26-2008, 01:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots