def calcVisibleAreaRatio(self): points = [Math.Vector2(1, 1), Math.Vector2(1, -1), Math.Vector2(-1, -1), Math.Vector2(-1, 1)] dirsPos = [ getWorldRayAndPoint(point.x, point.y) for point in points ] planeXZ = Plane(Math.Vector3(0, 1, 0), 0) collisionPoints = [] for dir, begPos in dirsPos: endPos = begPos + dir * 1000 testResult = BigWorld.wg_collideSegment(BigWorld.player().spaceID, begPos, endPos, 3) collPoint = Math.Vector3(0, 0, 0) if collPoint is not None: collPoint = testResult[0] else: collPoint = planeXZ.intersectSegment(begPos, endPos) collisionPoints.append(collPoint) x0 = abs(collisionPoints[1].x - collisionPoints[2].x) x1 = abs(collisionPoints[0].x - collisionPoints[3].x) z0 = abs(collisionPoints[0].z - collisionPoints[1].z) z1 = abs(collisionPoints[3].z - collisionPoints[2].z) bb = BigWorld.player().arena.arenaType.boundingBox arenaBottomLeft = bb[0] arenaUpperRight = bb[1] arenaX = arenaUpperRight[0] - arenaBottomLeft[0] arenaZ = arenaUpperRight[1] - arenaBottomLeft[1] return ((x0 + x1) * 0.5 / arenaX, (z0 + z1) * 0.5 / arenaZ)
def calcVisibleAreaRatio(self): points = [ Math.Vector2(1, 1), Math.Vector2(1, -1), Math.Vector2(-1, -1), Math.Vector2(-1, 1) ] dirsPos = [getWorldRayAndPoint(point.x, point.y) for point in points] planeXZ = Plane(Math.Vector3(0, 1, 0), 0) collisionPoints = [] for dir, begPos in dirsPos: endPos = begPos + dir * 1000 testResult = BigWorld.wg_collideSegment(BigWorld.player().spaceID, begPos, endPos, 3) collPoint = Math.Vector3(0, 0, 0) if collPoint is not None: collPoint = testResult[0] else: collPoint = planeXZ.intersectSegment(begPos, endPos) collisionPoints.append(collPoint) x0 = abs(collisionPoints[1].x - collisionPoints[2].x) x1 = abs(collisionPoints[0].x - collisionPoints[3].x) z0 = abs(collisionPoints[0].z - collisionPoints[1].z) z1 = abs(collisionPoints[3].z - collisionPoints[2].z) bb = BigWorld.player().arena.arenaType.boundingBox arenaBottomLeft = bb[0] arenaUpperRight = bb[1] arenaX = arenaUpperRight[0] - arenaBottomLeft[0] arenaZ = arenaUpperRight[1] - arenaBottomLeft[1] return ((x0 + x1) * 0.5 / arenaX, (z0 + z1) * 0.5 / arenaZ)
def __getStopPlane(self, point, r0, v0, gravity): t = (point[0] - r0[0]) / v0[0] v = v0 + gravity.scale(t) v.normalise() d = v.dot(point) return Plane(v, d)