Home Showcase
Welcome to the new Diaspora forums, please let us know if you see anything broken! Notice: Some users may need to reupload their avatars due to an issue during forum setup!

360 arc panning ship view

KatelynKatelyn Registered, Administrator Posts: 171
edited July 2011 in Showcase #1
This chip is easy to install on a ship with a gyropod. You wirelink it to your advance pod controller and then to your gyro, and get in. It allows you to zoom in and out with the mouse wheel, and is handy on ships of all sizes. Very little coding is required to get it operational. You will have to set the Minzoom and Maxzoom at the top to a good size.

Update 1.0.3
You now have an Override variable that will let you bypass the automatic ship scan and let you place your own values for min and max zoom. You can link a gyro to it and it will always default to that as the center. If you don't it will use the e2 if override is enabled, and it will act like it has been if it is disabled. The code now uses a modded version of steeveeo's parenting e2 steps so that larger ships don't error out. I wrote this all in the post so I don't know if there are any errors.

Update 1.0.4
Smarter auto-center finding. It now excludes smaller wire props, so it should get a more accurate center. Cleaner gyro input detection as well. Uses the yield command to see if there is an input
@name External panning camera
@inputs [Apc Gyro]:wirelink
@persist Zoom Minzoom Maxzoom Zoomrate Override End Step
@persist [Center Min Max Total]:vector
@persist Bear Elev Active Count
@persist [Driver, Dump]:entity
@persist [Ship]:array

#By Katelyn
#AIM: Consta135
#E-mail: Katelyn135@gmail.com

#Version 1.0.4

interval(50)

if (first() | dupefinished())
{
    #Override lets you set the zoom values yourself. 
    #If you have problems try enabling this. Set it to one to override
    Override = 0
    Count = 0
    if (Override)
    {
        #Edit these if you have override enabled.
        Minzoom = 100
        Maxzoom = Minzoom * 10
        Center = (->Gyro ? entity():pos() - Gyro:entity():pos() : vec())
        Zoom = Minzoom
        Zoomrate = Maxzoom / 5
        End = 1
    }
    else
    {
        timer("First",100)
        Ship = entity():getConstraints()
        Min = entity():pos()
        Max = Min
        Total = vec()
    }
   
    rangerDefaultZero(0)
    rangerIgnoreWorld(0)
    rangerHitWater(1)
    rangerHitEntities(1)
    rangerFilter(entity():getConstraints())
    rangerPersist(1)
}
if(clk("First"))
{
    Index = 1+(10*Step)
    End = 0
    while(Index <= 10+(10*Step))
    {
        if(Index != Ship:count()+1)
        {
            if (Ship[Index, entity]:volume() >= 10000)
            {
                 K = Ship[Index, entity]:aabbMin() + Ship[Index, entity]:pos()
                 Min = min(Min, K)
                 K = Ship[Index, entity]:aabbMax() + Ship[Index, entity]:pos()
                 Max = max(Max, K)
                 Total = Ship[Index, entity]:pos() + Total
                 Count++
            }
   
            if (Ship[Index, entity]:type() == "gmod_wire_adv_pod")
            {
                Apc = Ship[Index, entity]:getWirelink()
                print("Linked")
            }
            Index++
        }
        else
        {
            Minzoom = Max:distance(Min) / 3
            Maxzoom = Minzoom * 10
            Center = (->Gyro ? entity():pos() - Gyro:entity():pos() : entity():pos() - (Total / Count))
            Zoom = Minzoom
            Zoomrate = Maxzoom / 5
            End = 1
            break
        }
    }
   

    if(!End)
    {
        Step++
        timer("First",100)
    }
}
if (End)
{
    Driver = Apc["Entity", entity]
    Zoom = Zoom + ((Apc["NextWeapon", number] - Apc["PrevWeapon", number]) * Zoomrate)
    Zoom = clamp(Zoom, Minzoom, Maxzoom)
    Active = (Zoom != Minzoom & Apc["Active", number] ? 1 : 0)
    
    #Bear = Driver:eyeAngles():yaw()
    #Elev = Driver:eyeAngles():pitch() + 90
    
    Bear = Apc["Bearing", number] - 180
    Elev = Apc["Elevation", number] - 90
    
    X = Zoom * cos(Bear) * sin(Elev)
    Y = Zoom * sin(Bear) * sin(Elev)
    Z = Zoom * cos(Elev)
    
    if (Apc["Active", number])
    {
        Bear = Apc["Bearing", number]
        Elev = -Apc["Elevation", number] + 90
       
        Pos = entity():pos() - Center
       
        #Ranger = rangerOffset(Zoom + 50, Pos, Pos - vec(X, Y, Z))
        Driver:setView(Active, Pos - vec(X, Y, Z), ang(Elev - 90, Bear, 0))
    
       
       
    #[   
        if ((Gyro:entity():pos() - vec(X, Y, Z)):isInWorld())
        {
            Driver:setView(Active, Gyro:entity():pos() - vec(X, Y, Z), ang(Elev - 90, Bear, 0))
        }
        else
        {
            Ranger = rangerOffset(Gyro:entity():pos(), Gyro:entity():pos() - vec(X, Y, Z))
            Driver:setView(Active, Ranger:position(), ang(Elev - 90, Bear, 0))
        }
        ]#
}
if (changed(Driver:driver()))
{
    Zoom = Minzoom
    Dump:setView(0, vec(), ang())
    Dump = Driver
}
#x = r * cos(s) * sin(t)
#y = r * sin(s) * sin(t)
#z = r * cos(t)
}

Comments

  • KatelynKatelyn Registered, Administrator Posts: 171
    I am going to release a new version of this soon. It will auto-detect the center point of your ship as well as make appropriate zoom settings and perhaps even auto-wire the pod controller. The version after that will support giving it an entity, allowing you to use it with target finders.
  • Alex4921Alex4921 Registered Posts: 139
    Impressive.
    This version is already very good,there are few ways to make it better.
    The quieter you are,the more you are able to hear.
  • KatelynKatelyn Registered, Administrator Posts: 171
    I'm open to suggestions on any of my chips, or even new projects.
  • Alex4921Alex4921 Registered Posts: 139
    One niggle is that this camera appears a bit "Jumpy",not sure if this is fixable but it would be nice to not have it as jumpy.
    Also another suggestion would be to detect if ship is inside a planets atmosphere,and if it is don't let your camera zoom out the atmosphere which stops you seeing your ship.
    Atmosphere detection is not too far fetched,but the checking planet radius might be.
    The quieter you are,the more you are able to hear.
  • Mouldy_TacoMouldy_Taco Registered, Moderator Posts: 133
    Saw you working on this today, best of luck on getting your ship-center code working!
    "If this works, it'll keep us from getting' caught. If it doesn't, it'll keep us from gettin' old," -- MacGyver
  • KatelynKatelyn Registered, Administrator Posts: 171
    I can do those things. It is jumpy because I forgot to comment some code I was adding to it out that wasn't complete. It doesn't bother it from working but it might cause some jumping.
  • KatelynKatelyn Registered, Administrator Posts: 171
    [UPDATE]
    -Wireless addition
    --You can just apply the chip to your ship and it is done.
    --It auto-detects am advanced pod controller and uses it. Multiple pod controllers will be a problem, but most ships don't have them. Next version will support overriding the auto-detect.
    --It auto-finds the center of your ship and adjusts the zoom.
  • roychookroychook Registered Posts: 23
    i have tried over and over and even had some higher up people with more experience than me try but it just doesnt want to work on my ship care to take a look some time or has it just been broken?
  • KanzukeKanzuke Registered, Moderator Posts: 181
    I just get a script error when ever I paste the E2, it gets enough time to link to the pod but then just gets a script error:

    Expression 2 (External panning camera): entities/gmod_wire_expression2/core/vector.lua:145: attempt to index local 'rv1' (a nil value)

    Any Ideas?

    Lambda217: oh oh i am kanzuke and i love my little pony and now i'll make all the brandonphysics myself cause i know fuckin everything because now i'll make a big pony fighter drone squad and a big fuckin portal ship and i am a fuckin idiot
  • KatelynKatelyn Registered, Administrator Posts: 171
    Update it. Unfortunately this happens sometimes. Since I made this for myself I never actually tried to fix that since updating it fixes it.
  • KatelynKatelyn Registered, Administrator Posts: 171
    Updated 1.0.4

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file