Centering a rotating texture

Discussion in 'Mapping Questions & Discussion' started by Werewolf, Jan 1, 2016.

  1. Werewolf

    aa Werewolf Probably not a real Werewolf

    Messages:
    788
    Positive Ratings:
    233
    I have been trying to make a rotating fan texture, and used the example code posted on the 'Dynamic Materials with Proxies' guide on nodraw.net to do so. However when I test it I find it is rotating around a point to the side, not the center.

    Unless I am mistaken, it's fair to assume that $center is the parameter I need to edit which I have tried doing already. The setting on the guide has it at [-0.5 -0.5] and I have tried changing these values to the following vaules:
    • [-0.5 -0.5]
    • [0 0]
    • [1 1]
    • [-1 -1]
    • [160 160] (because the brush it is applied to is 320x320)
    • [-160 -160]
    • [256 256] (because the texture is 512x512)
    • -256 -256]
    None of these have worked so I am out of ideas on this. Anyone got any ideas how I to do this? If it makes any difference I am using a 512x512 texture on a 320x320 circular brush

    Here is my .vmt as it currently stands:
    Code:
    "LightmappedGeneric"
    {
        "$basetexture" "custom/fan_spinning"
        "$surfaceprop" "metal"
        "$translucent" "1"
        "$envmap" "env_cubemap"
    
        "$angle" 0.0
        "$translate" "[0.0 0.0]"
        "$center" "[-1 -1]"
    
        "Proxies"
        {
            "LinearRamp"
            {
                "rate" 5
                "initialValue" 0.0
                "resultVar" "$angle"
            }
    
            "TextureTransform"
            {
                "translateVar" "$translate" // we don't need this, but it's not optional
                "rotateVar" "$angle"
                "centerVar" "$center"
                "resultVar" "$basetexturetransform"
            }
        }
    }
     
    Last edited: Jan 1, 2016
  2. lunarpumpkin

    lunarpumpkin L2: Junior Member

    Messages:
    72
    Positive Ratings:
    12
    no repsonces ... rip
     
  3. Dr. Orange

    Dr. Orange L6: Sharp Member

    Messages:
    368
    Positive Ratings:
    278
    Have you tried [0.5 0.5]?

    EDIT: Oh, didn't see the date on original post. Oops.
     
  4. lunarpumpkin

    lunarpumpkin L2: Junior Member

    Messages:
    72
    Positive Ratings:
    12
    dosent work
     
  5. Werewolf

    aa Werewolf Probably not a real Werewolf

    Messages:
    788
    Positive Ratings:
    233
    Necro-posting, but with the solution! As @Dr. Orange said, the key was to use [0.5 0.5] for the $center. However you can't just put the texture on a brush face, you need to use a infodecal or info_overlay.
     
  6. Pocket

    aa Pocket func_croc

    Messages:
    4,489
    Positive Ratings:
    2,219
    So it still gets the origin wrong if you try to use it on a brush? And doesn't do anything different no matter how you adjust the values?
     
  7. Werewolf

    aa Werewolf Probably not a real Werewolf

    Messages:
    788
    Positive Ratings:
    233
    I didn't try adjusting the values to be honest, but I did try placing my texture on face next to the same texture applied as a decal and an overlay, and the only one that didn't rotate properly was the one applied to the face.
     
  8. Tumbolisu

    aa Tumbolisu  I ⌄ I 

    Messages:
    949
    Positive Ratings:
    936
    Every material has it's origin point, and that origin point depends on the origin of the object it's placed. For any world brush, that is the world origin. Brush entities use their own origins. Point entities have some kind of UV space. This means decals, overlays and models. [0.5 0.5] is the center for those, as [0 0] is one corner and [1 1] is the other.

    This means that, as long as you keep your texture on a worldbrush or func_detail, you will need to use very large values. Playing around with face orientation (oriented to face or world) as well as using negative stuff might be neccessary.
     
    • Like Like x 1
  9. Werewolf

    aa Werewolf Probably not a real Werewolf

    Messages:
    788
    Positive Ratings:
    233
    I assumed that, but found it only rotated around the top-left corner of the texture, aka the [0 0]. That was on world brushes, func_detail and func_brush brushes. I tried the func_brush as I was experimenting weather the origin of that effected the rotation of the material and it does not.