예제 #1
1
파일: esp.py 프로젝트: powergun/EHF
    def _run(self):
        # delayed init
        self.delayedInit()
        
        # figure out the time interval
        worldTransform = ehfmaths_functions.getIdMatrix()
        viewTransform = ehfmaths_functions.getViewMatrix(
                                                         self.appVars["upVec"], 
                                                         self.appVars["rightVec"], 
                                                         self.appVars["forwardVec"], 
                                                         self.appVars["viewOrigin"]
                                                         )
        viewOrigin = self.appVars["viewOrigin"].toPointVector4()
        
        if not self.miniMap:
            self.miniMap = widgets.SimpleMiniMap( 
                 # location control
                 centerX=200, centerY=200, boundaryX=160, boundaryY=160,
                 # color/drawing style
                 borderWidth=3, lineWidth=3, selfColor=0xFF00FF00, teamColor=0xFF1111FF, enemyColor=0xFFFF1111, boundaryColor=0xFFFF1111,
                 # size/scale control
                 scale=2, spotSize=3,
                 # other attributes
                 vecForward=self.appVars["forwardVec"]
                 )
        else:
            self.miniMap.setVecForward(self.appVars["forwardVec"])
            self.miniMap.setViewAxisZ(self.appVars["forwardVec"])

        self.miniMap.drawBoundary(self.getLine())
        self.miniMap.drawSelf(self.getLine())
        
        projectionTransform = ehfmaths_functions.getProjectionMatrix(
                                                                     self.appVars["zn"], 
                                                                     self.appVars["zf"], 
                                                                     self.appVars["fov_x"], 
                                                                     self.appVars["fov_y"]
                                                                     )
        
        hintColor = 0xFFFF11FF
        
        # loop through simple player objects
        for player in self.appVars["players"]:
            # don't draw "self"
            if player.address == self.appVars["localPlayerAddress"]:
                continue
            
            # skip team players
            if player.teamId == self.appVars["localPlayerTeamId"]:
                continue
                
            if not self._validatePlayer(player):
                continue
            
            _color = self.colorTeammate if player.teamId == self.appVars["localPlayerTeamId"] \
                                        else self.colorEnemy
            pos4 = player.position.toPointVector4()
            pos4TankAimAssist = player.position.toPointVector4()
            
            distant = (pos4 - viewOrigin)._length()
            deltaY = pos4.y - viewOrigin.y
            
            _posV = pos4.multToMat(worldTransform).multToMat(viewTransform)
            _posVP = _posV.multToMat(projectionTransform)
            _posV.x *= -1
            
            # ----------------get bullet drop
            aimCompensationY = naiveGetBulletDrop(distant, deltaY, GRAVITY, SPEED)
            # ----------------done getting bullet drop
            
            pos4TankAimAssist.y += aimCompensationY 
            posVTankAimAssist = pos4TankAimAssist.multToMat(worldTransform).multToMat(viewTransform)
            posVTankAimAssist = posVTankAimAssist.multToMat(projectionTransform)
            
            self.miniMap.drawPlayer(self.getLine(), _posV, player.teamId == self.appVars["localPlayerTeamId"])

            if abs(_posVP.w) < 0.001:
                continue
            if _posVP.z > 0:
                continue
            x = self.screenCenterX*(1+_posVP.x/_posVP.w)
            y = self.screenCenterY*(1+_posVP.y/_posVP.w)
            
            xAim = self.screenCenterX*(1+posVTankAimAssist.x/posVTankAimAssist.w)
            yAim = self.screenCenterY*(1+posVTankAimAssist.y/posVTankAimAssist.w)
            
            
            # ---------- draw player distance hint text ---------
            if player.teamId != self.appVars["localPlayerTeamId"]:
                ehfgraphics.drawStringLeft(self.getFont(), 
                                           x+5, 
                                           y+5, 
                                           10, 
                                           40, 
                                           _color, 
                                           "%0.1f" % distant)

            # ---------- draw a spot for tank aim assist -----------
                ehfgraphics.drawSpot(self.getLine(),
                                     xAim,
                                     yAim, 
                                     _color,
                                     size=1.5)
                
                ehfgraphics.drawLine(self.getLine(), x , y, xAim-x, yAim-y, 0.5, color=_color)
                
            # ---------- draw boxed esp -------------
            _width, _height = self.getWidthHeight(distant)
            if player.poseType:
                y = y + _height/2.0
            x = x - _width/2.0
            ehfgraphics.drawBox(self.getLine(), 
                                x, 
                                y, 
                                _width, 
                                _height, 
                                2, 
                                _color)
예제 #2
0
def simpleTest1():
    proj = ehfmaths_functions.getProjectionMatrix(nz=0.06, fz=2000.0601, fovH=1.2870, fovV=1.8546)
    print proj
#    idMat = SimpleMatrix()
#    idMat.setM(0,0,1.0)
#    idMat.setM(1,1,1.0)
#    idMat.setM(2,2,1.0)
#    idMat.setM(3,3,1.0)
    a = VECTOR3(0.0, 0.0, 1.0)
    b = VECTOR3(1.0, 0.0, 0.0)
    #   0.0       0.0       0.0    1.0000    0.9177       0.0   -0.3972       0.0
    #   -0.0366    0.9957   -0.0847       0.0    0.3955    0.0923    0.9138       0.0
    #   -123.5014   60.9055 -183.5093       0.0       0.0       inf    1.2870    0.9599
    upVec = VECTOR3(-0.0366,    0.9957,   -0.0847)
    forwardVec = VECTOR3(0.3955,    0.0923,    0.9138)
    transVec = VECTOR3(-123.5014,   60.9055, -183.5093)
    #print x
    #print y
    #print z
    viewM = ehfmaths_functions.getViewMatrix(forwardVec, transVec, upVec)
    print "\n\n", viewM
    
    print "\n\n", proj.multTo(viewM)
예제 #3
0
파일: esp.py 프로젝트: ieralt/EHF
    def _run(self):
        # delayed init
        self.delayedInit()
        worldTransform = ehfmaths_functions.getIdMatrix()
        viewTransform = ehfmaths_functions.getViewMatrix(
            self.appVars["upVec"], self.appVars["rightVec"],
            self.appVars["forwardVec"], self.appVars["viewOrigin"])

        if not self.miniMap:
            self.miniMap = widgets.SimpleMiniMap(
                # location control
                centerX=200,
                centerY=200,
                boundaryX=160,
                boundaryY=160,
                # color/drawing style
                borderWidth=3,
                lineWidth=3,
                selfColor=0xFF00FF00,
                teamColor=0xFF1111FF,
                enemyColor=0xFFFF1111,
                boundaryColor=0xFFFF1111,
                # size/scale control
                scale=2,
                spotSize=3,
                # other attributes
                vecForward=self.appVars["forwardVec"])
        else:
            self.miniMap.setVecForward(self.appVars["forwardVec"])
            self.miniMap.setViewAxisZ(self.appVars["forwardVec"])

        self.miniMap.drawBoundary(self.getLine())
        self.miniMap.drawSelf(self.getLine())

        projectionTransform = ehfmaths_functions.getProjectionMatrix(
            self.appVars["zn"], self.appVars["zf"], self.appVars["fov_x"],
            self.appVars["fov_y"])

        # loop through simple player objects
        for player in self.appVars["players"]:
            # don't draw "self"
            if player.address == self.appVars["localPlayerAddress"]:
                continue

            if not self._validatePlayer(player):
                continue
            _color = self.colorTeammate if player.teamId == self.appVars["localPlayerTeamId"] \
                                        else self.colorEnemy
            pos4 = player.position.toPointVector4()
            _posV = pos4.multToMat(worldTransform).multToMat(viewTransform)
            _posVP = _posV.multToMat(projectionTransform)
            _posV.x = _posV.x * -1
            self.miniMap.drawPlayer(
                self.getLine(), _posV,
                player.teamId == self.appVars["localPlayerTeamId"])

            if abs(_posVP.w) < 0.001:
                continue
            if _posVP.z > 0:
                continue
            x = self.screenCenterX * (1 + _posVP.x / _posVP.w)
            y = self.screenCenterY * (1 + _posVP.y / _posVP.w)
            ehfgraphics.drawSpot(self.getLine(), x, y, _color, size=4)
예제 #4
0
def test_validate_transform():
    """
    given the view origin P, and another space point T (for target),
    T is visually in front of P thus its camera space coord should be
    within the screen range
    
    order: right, up, forward

                Vec3 left;
                Vec3 up;
                Vec3 forward;
                Vec3 trans;

    forward ==> right                    ; right = old_forward
    right ==> back ==> forward inverse   ; forward = inverse old_right
    up ==> up                            ; up = old_up
    
    forward:
    before
    0.9135       0.0   -0.4069       0.0   -0.0158    0.9992   -0.0354       0.0
    0.4065    0.0387    0.9128       0.0 -104.2033  147.9466  689.8074       0.0
    after
    0.8917       0.0   -0.4526       0.0   -0.0229    0.9987   -0.0452       0.0
    0.4520    0.0506    0.8906       0.0 -108.8845  147.9466  680.7183       0.0

    right:                                                
    before
    0.9399       0.0   -0.3415       0.0   -0.0061    0.9998   -0.0168       0.0
    0.3414    0.0179    0.9397       0.0 -109.5459  147.9466  684.5769       0.0
    after
    0.9409       0.0   -0.3387       0.0   -0.0086    0.9997   -0.0238       0.0
    0.3386    0.0253    0.9406       0.0 -103.3640  147.9466  682.3727       0.0

    left:
    before
    0.9149       0.0   -0.4037       0.0   -0.0168    0.9991   -0.0382       0.0
    0.4033    0.0417    0.9141       0.0 -103.4697  147.9466  678.8103       0.0
    after
    0.9149       0.0   -0.4037       0.0   -0.0168    0.9991   -0.0382       0.0
    0.4033    0.0417    0.9141       0.0{-111.3338}{147.9466}{682.2825}       0.0

    """
    pointP = VECTOR4(-104.2033, 147.9466, 689.8074, 1.0)
    pointT = VECTOR4(-108.8845, 147.9466, 680.7183, 1.0)

    # note that the origin "right" is left-pointing! and forward is back-pointing
    up = VECTOR4(-0.0158, 0.9992, -0.0354, 0.0)
    forward = VECTOR4(0.4065, 0.0387, 0.9128, 0.0).scalar_mul(-1)
    right = VECTOR4(0.9135, 0.0, -0.4069, 0.0).scalar_mul(-1)
    print right
    viewTransformMat = ehfmaths_functions.getViewMatrix(
        up, right, forward, pointP)
    matT = numpy.matrix([[right.x, right.y, right.z, right.w],
                         [up.x, up.y, up.z, up.w],
                         [forward.x, forward.y, forward.z, forward.w],
                         [pointP.x, pointP.y, pointP.z, 1.0]])

    target = numpy.matrix([[-108.8845, 147.9466, 680.7183, 1.0]])

    # use VECTOR4.multToMat() to transform the point!!!
    # same with numpy, the order of compute transformed vector is: V * M
    pointT_v = pointT.multToMat(viewTransformMat)

    print pointT_v
예제 #5
0
    def _run(self):
        # delayed init
        self.delayedInit()

        # figure out the time interval
        worldTransform = ehfmaths_functions.getIdMatrix()
        viewTransform = ehfmaths_functions.getViewMatrix(
            self.appVars["upVec"], self.appVars["rightVec"],
            self.appVars["forwardVec"], self.appVars["viewOrigin"])
        viewOrigin = self.appVars["viewOrigin"].toPointVector4()

        if not self.miniMap:
            self.miniMap = widgets.SimpleMiniMap(
                # location control
                centerX=200,
                centerY=200,
                boundaryX=160,
                boundaryY=160,
                # color/drawing style
                borderWidth=3,
                lineWidth=3,
                selfColor=0xFF00FF00,
                teamColor=0xFF1111FF,
                enemyColor=0xFFFF1111,
                boundaryColor=0xFFFF1111,
                # size/scale control
                scale=2,
                spotSize=3,
                # other attributes
                vecForward=self.appVars["forwardVec"])
        else:
            self.miniMap.setVecForward(self.appVars["forwardVec"])
            self.miniMap.setViewAxisZ(self.appVars["forwardVec"])

        self.miniMap.drawBoundary(self.getLine())
        self.miniMap.drawSelf(self.getLine())

        projectionTransform = ehfmaths_functions.getProjectionMatrix(
            self.appVars["zn"], self.appVars["zf"], self.appVars["fov_x"],
            self.appVars["fov_y"])

        hintColor = 0xFFFF11FF

        # loop through simple player objects
        for player in self.appVars["players"]:
            # don't draw "self"
            if player.address == self.appVars["localPlayerAddress"]:
                continue

            # skip team players
            if player.teamId == self.appVars["localPlayerTeamId"]:
                continue

            if not self._validatePlayer(player):
                continue

            _color = self.colorTeammate if player.teamId == self.appVars["localPlayerTeamId"] \
                                        else self.colorEnemy
            pos4 = player.position.toPointVector4()
            pos4TankAimAssist = player.position.toPointVector4()

            distant = (pos4 - viewOrigin)._length()
            deltaY = pos4.y - viewOrigin.y

            _posV = pos4.multToMat(worldTransform).multToMat(viewTransform)
            _posVP = _posV.multToMat(projectionTransform)
            _posV.x *= -1

            # ----------------get bullet drop
            aimCompensationY = naiveGetBulletDrop(distant, deltaY, GRAVITY,
                                                  SPEED)
            # ----------------done getting bullet drop

            pos4TankAimAssist.y += aimCompensationY
            posVTankAimAssist = pos4TankAimAssist.multToMat(
                worldTransform).multToMat(viewTransform)
            posVTankAimAssist = posVTankAimAssist.multToMat(
                projectionTransform)

            self.miniMap.drawPlayer(
                self.getLine(), _posV,
                player.teamId == self.appVars["localPlayerTeamId"])

            if abs(_posVP.w) < 0.001:
                continue
            if _posVP.z > 0:
                continue
            x = self.screenCenterX * (1 + _posVP.x / _posVP.w)
            y = self.screenCenterY * (1 + _posVP.y / _posVP.w)

            xAim = self.screenCenterX * (
                1 + posVTankAimAssist.x / posVTankAimAssist.w)
            yAim = self.screenCenterY * (
                1 + posVTankAimAssist.y / posVTankAimAssist.w)

            # ---------- draw player distance hint text ---------
            if player.teamId != self.appVars["localPlayerTeamId"]:
                ehfgraphics.drawStringLeft(self.getFont(), x + 5, y + 5, 10,
                                           40, _color, "%0.1f" % distant)

                # ---------- draw a spot for tank aim assist -----------
                ehfgraphics.drawSpot(self.getLine(),
                                     xAim,
                                     yAim,
                                     _color,
                                     size=1.5)

                ehfgraphics.drawLine(self.getLine(),
                                     x,
                                     y,
                                     xAim - x,
                                     yAim - y,
                                     0.5,
                                     color=_color)

            # ---------- draw boxed esp -------------
            _width, _height = self.getWidthHeight(distant)
            if player.poseType:
                y = y + _height / 2.0
            x = x - _width / 2.0
            ehfgraphics.drawBox(self.getLine(), x, y, _width, _height, 2,
                                _color)
예제 #6
0
파일: esp.py 프로젝트: powergun/EHF
    def _run(self):
        # delayed init
        self.delayedInit()
        worldTransform = ehfmaths_functions.getIdMatrix()
        viewTransform = ehfmaths_functions.getViewMatrix(
                                                         self.appVars["upVec"], 
                                                         self.appVars["rightVec"], 
                                                         self.appVars["forwardVec"], 
                                                         self.appVars["viewOrigin"]
                                                         )
        
        if not self.miniMap:
            self.miniMap = widgets.SimpleMiniMap( 
                 # location control
                 centerX=200, centerY=200, boundaryX=160, boundaryY=160,
                 # color/drawing style
                 borderWidth=3, lineWidth=3, selfColor=0xFF00FF00, teamColor=0xFF1111FF, enemyColor=0xFFFF1111, boundaryColor=0xFFFF1111,
                 # size/scale control
                 scale=2, spotSize=3,
                 # other attributes
                 vecForward=self.appVars["forwardVec"]
                 )
        else:
            self.miniMap.setVecForward(self.appVars["forwardVec"])
            self.miniMap.setViewAxisZ(self.appVars["forwardVec"])

        self.miniMap.drawBoundary(self.getLine())
        self.miniMap.drawSelf(self.getLine())
        
        projectionTransform = ehfmaths_functions.getProjectionMatrix(
                                                                     self.appVars["zn"], 
                                                                     self.appVars["zf"], 
                                                                     self.appVars["fov_x"], 
                                                                     self.appVars["fov_y"]
                                                                     )

        # loop through simple player objects
        for player in self.appVars["players"]:
            # don't draw "self"
            if player.address == self.appVars["localPlayerAddress"]:
                continue
            
            if not self._validatePlayer(player):
                continue
            _color = self.colorTeammate if player.teamId == self.appVars["localPlayerTeamId"] \
                                        else self.colorEnemy
            pos4 = player.position.toPointVector4()
            _posV = pos4.multToMat(worldTransform).multToMat(viewTransform)
            _posVP = _posV.multToMat(projectionTransform)
            _posV.x = _posV.x * -1
            self.miniMap.drawPlayer(self.getLine(), _posV, player.teamId == self.appVars["localPlayerTeamId"])

            if abs(_posVP.w) < 0.001:
                continue
            if _posVP.z > 0:
                continue
            x = self.screenCenterX*(1+_posVP.x/_posVP.w)
            y = self.screenCenterY*(1+_posVP.y/_posVP.w)
            ehfgraphics.drawSpot(self.getLine(),
                                 x,
                                 y, 
                                 _color,
                                 size=4)
예제 #7
0
def test_validate_transform():
    """
    given the view origin P, and another space point T (for target),
    T is visually in front of P thus its camera space coord should be
    within the screen range
    
    order: right, up, forward

                Vec3 left;
                Vec3 up;
                Vec3 forward;
                Vec3 trans;

    forward ==> right                    ; right = old_forward
    right ==> back ==> forward inverse   ; forward = inverse old_right
    up ==> up                            ; up = old_up
    
    forward:
    before
    0.9135       0.0   -0.4069       0.0   -0.0158    0.9992   -0.0354       0.0
    0.4065    0.0387    0.9128       0.0 -104.2033  147.9466  689.8074       0.0
    after
    0.8917       0.0   -0.4526       0.0   -0.0229    0.9987   -0.0452       0.0
    0.4520    0.0506    0.8906       0.0 -108.8845  147.9466  680.7183       0.0

    right:                                                
    before
    0.9399       0.0   -0.3415       0.0   -0.0061    0.9998   -0.0168       0.0
    0.3414    0.0179    0.9397       0.0 -109.5459  147.9466  684.5769       0.0
    after
    0.9409       0.0   -0.3387       0.0   -0.0086    0.9997   -0.0238       0.0
    0.3386    0.0253    0.9406       0.0 -103.3640  147.9466  682.3727       0.0

    left:
    before
    0.9149       0.0   -0.4037       0.0   -0.0168    0.9991   -0.0382       0.0
    0.4033    0.0417    0.9141       0.0 -103.4697  147.9466  678.8103       0.0
    after
    0.9149       0.0   -0.4037       0.0   -0.0168    0.9991   -0.0382       0.0
    0.4033    0.0417    0.9141       0.0{-111.3338}{147.9466}{682.2825}       0.0

    """
    pointP = VECTOR4(-104.2033,  147.9466,  689.8074,   1.0)
    pointT = VECTOR4(-108.8845,  147.9466,  680.7183,   1.0)
    
    # note that the origin "right" is left-pointing! and forward is back-pointing
    up = VECTOR4( -0.0158,    0.9992,   -0.0354,       0.0)
    forward = VECTOR4(0.4065,    0.0387,    0.9128,       0.0).scalar_mul(-1)
    right = VECTOR4(0.9135,       0.0,   -0.4069,       0.0).scalar_mul(-1)
    print right
    viewTransformMat = ehfmaths_functions.getViewMatrix(up, right, forward, pointP)
    matT = numpy.matrix([[right.x, right.y, right.z, right.w],
                         [up.x, up.y, up.z, up.w],
                         [forward.x, forward.y, forward.z, forward.w],
                         [pointP.x, pointP.y, pointP.z, 1.0]])
    
    target = numpy.matrix( [[-108.8845,  147.9466,  680.7183,       1.0]] )
    
    # use VECTOR4.multToMat() to transform the point!!!
    # same with numpy, the order of compute transformed vector is: V * M
    pointT_v = pointT.multToMat(viewTransformMat)
    
    print pointT_v