1. Post #1
    grobov13's Avatar
    July 2007
    236 Posts
    Hello, Im wondering is there a way to 'mirror' clientside models? (for example how viewmodel can be mirrored by ViewModelFlip)

    Im trying to bonemerge clientside hands with CSS viewmodels and the problem occurs when my CSS viewmodel is flipped - clientside model looks like its turned from inside out.

  2. Post #2
    CmdrMatthew's Avatar
    August 2010
    1,179 Posts
    You could try to scale it with a -1 value Entity.SetModelScale , this would reverse all the triangles. The problem with this is it will reverse the order of the vertices, causing the engine to cull (not draw) the ones on the outside because they are now counter clockwise. This would make the inside vertices clockwise, since the engine doesn't cull these, they would be visible.
    The reason the engine does this is to optimize rendering. When triangles are facing the camera, their vertices are clockwise, when they are facing the oposite direction, they are counter clockwise. It is far cheaper to check if vertices are clockwise than to render the triangle, so it improves FPS and rastering time.

    You would have to find a way to disable or reverse (make it cull clockwise vertices) culling for this.

    Though, if you scale it negatively in only one direction I am not sure what would exactly happen, but I think it would still have culling issues.

  3. Post #3
    Dragon Dildoes
    Dennab
    April 2009
    4,432 Posts
    render.CullMode
    Reply With Quote Edit / Delete Reply Windows 7 Germany Show Events Informative Informative x 1 (list)

  4. Post #4
    im gay
    _Kilburn's Avatar
    July 2007
    3,589 Posts
    Hello, Im wondering is there a way to 'mirror' clientside models? (for example how viewmodel can be mirrored by ViewModelFlip)

    Im trying to bonemerge clientside hands with CSS viewmodels and the problem occurs when my CSS viewmodel is flipped - clientside model looks like its turned from inside out.
    I'm having this problem as well. Nothing fixes it. Tried SetModelScale, render.CullMode, every possible combination of the two, it doesn't make a single difference, the culling issue still happens. If someone has a working solution, that would be really nice.

  5. Post #5
    CmdrMatthew's Avatar
    August 2010
    1,179 Posts
    I'm having this problem as well. Nothing fixes it. Tried SetModelScale, render.CullMode, every possible combination of the two, it doesn't make a single difference, the culling issue still happens. If someone has a working solution, that would be really nice.
    Did you set it to MATERIAL_CULLMODE_CCW? If you set it to MATERIAL_CULLMODE_CW, it doesn't do anything at all because that's what its set to by default.
    ent = ClientsideModel("your model here", RENDERGROUP_OPAQUE)
    ent:SetModelScale(Vector(-1,1,1)) //to flip on the x-axis (I think that's what you want, if it doesn't work try the y-axis.
    function DrawModel()
        render.CullMode(MATERIAL_CULLMODE_CCW)
        ent:DrawModel()
        render.CullMode(MATERIAL_CULLMODE_CW)
    end

    EDIT: Or is it the other way around? I am confuzzled today.

  6. Post #6
    grobov13's Avatar
    July 2007
    236 Posts
    Did you set it to MATERIAL_CULLMODE_CCW? If you set it to MATERIAL_CULLMODE_CW, it doesn't do anything at all because that's what its set to by default.

    ent = ClientsideModel("your model here", RENDERGROUP_OPAQUE)
    ent:SetModelScale(Vector(-1,1,1)) //to flip on the x-axis (I think that's what you want, if it doesn't work try the y-axis.
    function DrawModel()
        render.CullMode(MATERIAL_CULLMODE_CCW)
        ent:DrawModel()
        render.CullMode(MATERIAL_CULLMODE_CW)
    end

    EDIT: Or is it the other way around? I am confuzzled today.
    This code actually works on clientside model unless I apply EF_BONEMERGE to it :/

  7. Post #7
    im gay
    _Kilburn's Avatar
    July 2007
    3,589 Posts
    Did you set it to MATERIAL_CULLMODE_CCW? If you set it to MATERIAL_CULLMODE_CW, it doesn't do anything at all because that's what its set to by default.
    ent = ClientsideModel("your model here", RENDERGROUP_OPAQUE)
    ent:SetModelScale(Vector(-1,1,1)) //to flip on the x-axis (I think that's what you want, if it doesn't work try the y-axis.
    function DrawModel()
        render.CullMode(MATERIAL_CULLMODE_CCW)
        ent:DrawModel()
        render.CullMode(MATERIAL_CULLMODE_CW)
    end

    EDIT: Or is it the other way around? I am confuzzled today.
    Of course I tried both ways. It just doesn't work when the model is bonemerged to another.