示例#1
0
 def GetZoomValues(self, model, thread):
     rad = 300
     camera = self.sceneManager.GetRegisteredCamera(self.name)
     trinity.WaitForResourceLoads()
     rad = model.GetBoundingSphereRadius()
     center = model.boundingSphereCenter
     localBB = model.GetLocalBoundingBox()
     if localBB[0] is None or localBB[1] is None:
         log.LogError(
             "Failed to get bounding info for ship. Odds are the ship wasn't loaded properly."
         )
         localBB = (trinity.TriVector(0, 0, 0), trinity.TriVector(0, 0, 0))
     model.translationCurve = trinity.TriVectorCurve()
     negativeCenter = (-center[0], -localBB[0].y + 180.0, -center[2])
     model.translationCurve.value = negativeCenter
     cameraparent = self.GetCameraParent()
     if cameraparent.translationCurve is not None:
         keyValue = cameraparent.translationCurve.keys[1].value
         if self.staticEnv:
             keyValue = (keyValue[0], -localBB[0].y + 180.0, keyValue[2])
         cameraparent.translationCurve.keys[0].value = keyValue
         key1Value = cameraparent.translationCurve.keys[1].value
         key1Value = (key1Value[0], -localBB[0].y + 180.0, key1Value[2])
         cameraparent.translationCurve.keys[1].value = key1Value
         cameraparent.translationCurve.start = blue.os.GetSimTime()
     zoomMultiplier = 1.0
     aspectRatio = trinity.GetAspectRatio()
     if aspectRatio > 1.6:
         zoomMultiplier = aspectRatio / 1.6
     self.minZoom = (rad + camera.frontClip + 50) * zoomMultiplier
     self.maxZoom = 2050.0
     self.layer.maxZoom = self.maxZoom
     self.layer.minZoom = self.minZoom
     return (rad + camera.frontClip) * 2
    def TryPickSphereBorder(self):
        matches = []
        scannerWnd = Scanner.GetIfOpen()
        if scannerWnd:
            x, y = uicore.ScaleDpi(uicore.uilib.x), uicore.ScaleDpi(uicore.uilib.y)
            ray, start = GetRayAndPointFromScreen(x, y)
            pickRadiusRay, pickRadiusStart = GetRayAndPointFromScreen(x - 30, y)
            camera = sm.GetService('sceneManager').GetRegisteredCamera('systemmap')
            if camera is None:
                return
            viewDir = geo2.QuaternionTransformVector(camera.rotationAroundParent, (0.0, 0.0, 1.0))
            viewDir = geo2.Vec3Normalize(viewDir)
            targetPlaneNormal = geo2.Vector(*viewDir)
            scanSvc = sm.StartService('scanSvc')
            probeData = scanSvc.GetProbeData()
            probes = scannerWnd.GetProbeSpheres()
            for probeID, probeControl in probes.iteritems():
                if probeID not in probeData or probeData[probeID].state != const.probeStateIdle:
                    continue
                targetPlanePos = geo2.Vector(probeControl.locator.worldTransform[3][0], probeControl.locator.worldTransform[3][1], probeControl.locator.worldTransform[3][2])
                rad = list(probeControl.sphere.scaling)[0] * SYSTEMMAP_SCALE
                pos = RayToPlaneIntersection(start, ray, targetPlanePos, targetPlaneNormal)
                picRadiusPos = RayToPlaneIntersection(pickRadiusStart, pickRadiusRay, targetPlanePos, targetPlaneNormal)
                pickRad = (trinity.TriVector(*picRadiusPos) - trinity.TriVector(*pos)).Length()
                diffFromPickToSphereBorder = (trinity.TriVector(*targetPlanePos) - trinity.TriVector(*pos)).Length()
                if rad + pickRad > diffFromPickToSphereBorder > rad - pickRad:
                    matches.append((abs(rad - diffFromPickToSphereBorder), probeControl))

        if matches:
            matches = uiutil.SortListOfTuples(matches)
            return matches[0]
示例#3
0
    def ArrangeSelection(self, x, y, z):
        slimItems = self.GetSelObjects()
        if len(slimItems) < 2:
            return
        minV = trinity.TriVector(slimItems[0].dunX, slimItems[0].dunY,
                                 slimItems[0].dunZ)
        maxV = minV.CopyTo()
        commandArgs = []
        centreAxis = trinity.TriVector()
        for slimItem in slimItems:
            centreAxis.x = centreAxis.x + slimItem.dunX
            centreAxis.y = centreAxis.y + slimItem.dunY
            centreAxis.z = centreAxis.z + slimItem.dunZ

        centreAxis.Scale(1.0 / len(slimItems))
        stepCount = float(len(slimItems))
        totalOffset = trinity.TriVector(x * stepCount, y * stepCount,
                                        z * stepCount)
        totalOffset.Scale(-0.5)
        counter = 0
        for slimItem in slimItems:
            offset = trinity.TriVector(x, y, z)
            offset.Scale(counter)
            pos = centreAxis + totalOffset + offset
            counter += 1
            dungeonHelper.SetObjectPosition(slimItem.dunObjectID, pos.x, pos.y,
                                            pos.z)
示例#4
0
    def RotateSelected(self, yaw, pitch, roll):
        slimItems = self.GetSelObjects()
        if len(slimItems) == 0:
            return
        nq = trinity.TriQuaternion()
        nq.SetYawPitchRoll(yaw / 180.0 * pi, pitch / 180.0 * pi,
                           roll / 180.0 * pi)
        posCtr = trinity.TriVector()
        for slimItem in slimItems:
            posCtr += trinity.TriVector(slimItem.dunX, slimItem.dunY,
                                        slimItem.dunZ)

        posCtr.Scale(1.0 / len(slimItems))
        for slimItem in slimItems:
            q = trinity.TriQuaternion()
            rot = getattr(slimItem, 'dunRotation', None)
            if rot is not None:
                yaw, pitch, roll = rot
                q.SetYawPitchRoll(yaw / 180.0 * pi, pitch / 180.0 * pi,
                                  roll / 180.0 * pi)
            q.Multiply(nq)
            y, p, r = q.GetYawPitchRoll()
            y = y / pi * 180.0
            p = p / pi * 180.0
            r = r / pi * 180.0
            translation = trinity.TriVector(slimItem.dunX, slimItem.dunY,
                                            slimItem.dunZ)
            translation -= posCtr
            translation.TransformQuaternion(nq)
            translation += posCtr
            dungeonHelper.SetObjectPosition(slimItem.dunObjectID,
                                            translation.x, translation.y,
                                            translation.z)
            dungeonHelper.SetObjectRotation(slimItem.dunObjectID, y, p, r)
def GetPickIntersectionPoint(x=None, y=None):
    """
    Returns the point on the planet at (x, y) screen coordinates. This is done
    by casting a ray based on the screen coordinates (x, y) and the viewport
    and then finally calculating the intersection of that ray and a sphere (the planet).
    Method defaults to the current mouse coordinates if x and y arguments are None
    Returns None if the planet was not clicked.
    Arguments:
    x - the x coordinates in screen space
    y - the y coordinares in screen space
    """
    if None in (x, y):
        x, y = int(uicore.uilib.x * uicore.desktop.dpiScaling), int(
            uicore.uilib.y * uicore.desktop.dpiScaling)
    device = trinity.device
    proj, view, vp = uix.GetFullscreenProjectionViewAndViewport()
    ray, start = device.GetPickRayFromViewport(x, y, vp, view.transform,
                                               proj.transform)
    lineVec = trinity.TriVector(*ray)
    lineP0 = trinity.TriVector(*start)
    sphereP0 = trinity.TriVector(0.0, 0.0, 0.0)
    sphereRad = 1000.0
    pInt = GetSphereLineIntersectionPoint(lineP0, lineVec, sphereP0, sphereRad)
    if not pInt:
        return
    ret = SurfacePoint(pInt.x, pInt.y, pInt.z)
    ret.SetRadius(1.0)
    return ret
    def GetBoundingBoxInLocalSpace(self):
        if self.geometry.meshCount > 0:
            min, max = self.geometry.GetBoundingBox(0)
            for i in xrange(self.geometry.meshCount - 1):
                cMin, cMax = self.geometry.GetBoundingBox(i + 1)
                min.Minimize(cMin)
                max.Maximize(cMax)

            return (min, max)
        return (trinity.TriVector(), trinity.TriVector())
示例#7
0
def GetMyPos():
    bp = sm.GetService('michelle').GetBallpark()
    if bp and bp.ego:
        ego = bp.balls[bp.ego]
        myPos = trinity.TriVector(ego.x, ego.y, ego.z)
    elif eve.session.stationid:
        s = sm.GetService('map').GetStation(eve.session.stationid)
        myPos = trinity.TriVector(s.x, s.y, s.z)
    else:
        myPos = trinity.TriVector()
    return myPos
示例#8
0
 def CalculateHexagonParameters(self):
     mmin = trinity.TriVector(-1.0, 0.0, -0.866025447845459)
     mmax = trinity.TriVector(1.0, 0.0, 0.866025447845459)
     maxx = mmax.z / math.sin(math.radians(60.0))
     topRightX = math.cos(math.radians(60.0)) * maxx
     self.tileMin = Point(-maxx, mmin.z)
     self.tileMax = Point(maxx, mmax.z)
     self.hexPoints = (Point(topRightX,
                             self.tileMax.y), Point(self.tileMax.x, 0.0),
                       Point(topRightX, self.tileMin.y),
                       Point(-topRightX,
                             self.tileMin.y), Point(self.tileMin.x, 0.0),
                       Point(-topRightX, self.tileMax.y))
     self.tileWidth = maxx * 2.0 * 0.75
     self.tileHeight = mmax.z * 2.0
示例#9
0
 def Assemble(self):
     timecurves.ResetTimeCurves(self.model, self.id * 12345L)
     timecurves.ScaleTime(self.model, 5.0 + self.id % 20 / 20.0)
     x = 0.8 + 0.2 * random.random()
     y = 0.8 + 0.2 * random.random()
     z = 0.8 + 0.2 * random.random()
     self.model.scaling.SetXYZ(self.model.scaling.x * x,
                               self.model.scaling.y * y,
                               self.model.scaling.z * z)
     selfPos = trinity.TriVector(self.x * 1e-05, self.y * 1e-05,
                                 self.z * 1e-05)
     fwd = trinity.TriVector(0.0, 0.0, 1.0)
     selfPos.Normalize()
     self.model.rotationCurve = None
     self.model.rotation.SetRotationArc(fwd, selfPos)
示例#10
0
def GetPickIntersectionPoint(x = None, y = None):
    if None in (x, y):
        x, y = int(uicore.uilib.x * uicore.desktop.dpiScaling), int(uicore.uilib.y * uicore.desktop.dpiScaling)
    device = trinity.device
    proj, view, vp = uix.GetFullscreenProjectionViewAndViewport()
    ray, start = device.GetPickRayFromViewport(x, y, vp, view.transform, proj.transform)
    lineVec = trinity.TriVector(*ray)
    lineP0 = trinity.TriVector(*start)
    sphereP0 = trinity.TriVector(0.0, 0.0, 0.0)
    sphereRad = 1000.0
    pInt = GetSphereLineIntersectionPoint(lineP0, lineVec, sphereP0, sphereRad)
    if not pInt:
        return
    ret = planet.SurfacePoint(pInt.x, pInt.y, pInt.z)
    ret.SetRadius(1.0)
    return ret
示例#11
0
	def UpdateDirectionVector():
		bp = GetBallPark()
		myball = bp.GetBall(eve.session.shipid)	
		if not myball:
			LogMessage("ball doesnt exist")
			return
		if bp:
			balls = copy.copy(bp.balls)
			#\LogMessage("Copied Ballpark")
		else:
			LogMessage("Invalid Ballpark")
		
		tacticalSvc = sm.GetService("tactical")
		tacticalSvc.circles.ClearLines()
		color = (0.25,0.25,0.25,1)
		
		i = 0
		while (i < 50):
			blue.pyos.synchro.Sleep(500)
			tacticalSvc.circles.ClearLines()
			for ballid in balls.iterkeys():
				ball = bp.GetBall(ballid)
				slimItem = bp.GetInvItem(ballid)
				if (ball.maxVelocity != 0):
					currentDirection = ball.GetQuaternionAt(blue.os.GetTime())
					d = trinity.TriVector(0,0,1)
					d.TransformQuaternion(currentDirection)
					LogMessage(str(d.x) + " " + str(d.y) + "  " + str(d.z))
					d.x = d.x*10000
					d.y = d.y*10000
					d.z = d.z*10000
					tacticalSvc.circles.AddLine((ball.x-myball.x,ball.y-myball.y,ball.z-myball.z),color,(d.x+ball.x-myball.x,d.y+ball.y-myball.y,d.z+ball.z-myball.z),color)
					tacticalSvc.circles.SubmitChanges()
			i=i+1	
示例#12
0
	def ShowPathOfSelectedShipOnMyShip():
		tacticalSvc = sm.GetService("tactical")
		tacticalSvc.circles.ClearLines()
		color = (0.25,0.25,0.25,1)
		
		i = 0
		while (i < 50):
			blue.pyos.synchro.Sleep(500)
			currItem = eve.LocalSvc("registry").GetWindow("selecteditemview").itemIDs[0]
			bp = GetBallPark()
			currSelectedBall = bp.GetBall(currItem)	
			if not currSelectedBall:
				LogMessage("ball doesnt exist")
				return
			if bp:
				balls = copy.copy(bp.balls)
				LogMessage("Copied Ballpark")
			else:
				LogMessage("Invalid Ballpark")
			
			tacticalSvc.circles.ClearLines()
			currentDirection = currSelectedBall.GetQuaternionAt(blue.os.GetTime())
			d = trinity.TriVector(0,0,1)
			d.TransformQuaternion(currentDirection)
			
			d.x = d.x*1000
			d.y = d.y*1000
			d.z = d.z*1000
			LogMessage(str(d.x) + " " + str(d.y) + "  " + str(d.z))
			tacticalSvc.circles.AddLine((0,0,0),color,(d.x,d.y,d.z),color)
			tacticalSvc.circles.SubmitChanges()
			i=i+1	
示例#13
0
def SetObjectQuantity(objectID, quantity):
    scenario = sm.StartService('scenario')
    targetBall, slimItem = scenario.GetBallAndSlimItemFromObjectID(objectID)
    if slimItem is None:
        raise RuntimeError('No slim item?')
    targetModel = getattr(targetBall, 'model', None)
    if not targetModel:
        return
    if slimItem.categoryID == const.categoryAsteroid or slimItem.groupID in (
            const.groupHarvestableCloud, const.groupCloud):
        computedRadius = util.ComputeRadiusFromQuantity(
            slimItem.categoryID, slimItem.groupID, slimItem.typeID, quantity)
        if hasattr(targetModel, 'modelScale'):
            targetModel.modelScale = computedRadius
        elif hasattr(targetModel, 'scaling'):
            scaleVector = trinity.TriVector(computedRadius, computedRadius,
                                            computedRadius)
            targetModel.scaling = scaleVector
        else:
            raise RuntimeError('Model has neither modelScale nor scaling')
        slimItem.dunRadius = quantity
        scenario.UpdateUnsavedObjectChanges(slimItem.itemID,
                                            dungeonEditorTools.CHANGE_SCALE)
    else:
        raise RuntimeError("Can't scale type %d" % slimItem.categoryID)
示例#14
0
文件: map2D.py 项目: R4M80MrX/eve-1
    def GetMaxDist(self):
        maxdist = 0.0
        for item in self.mapitems:
            pos = trinity.TriVector(item.x, 0.0, item.z)
            maxdist = max(maxdist, pos.Length())

        return maxdist
示例#15
0
 def ShakeCamera(self, ball):
     ballpark = sm.GetService('michelle').GetBallpark()
     if ballpark is None:
         return
     speedVector = trinity.TriVector(ball.vx, ball.vy, ball.vz)
     speed = speedVector.Length()
     maxSpeed = ballpark.warpSpeed * const.AU - ball.maxVelocity
     speed = (speed - ball.maxVelocity) / maxSpeed
     speed = max(0.0, speed)
     rumbleFactor = 0.5 - 0.5 * cos(6.28 * pow(speed, 0.1))
     rumbleFactor = (rumbleFactor - 0.2) / 0.8
     rumbleFactor = max(rumbleFactor, 0.0)
     rumbleFactor = pow(rumbleFactor, 0.8)
     shakeFactor = 0.7 * rumbleFactor
     cam = self.GetCamera()
     noisescaleCurve = trinity.TriScalarCurve()
     noisescaleCurve.extrapolation = trinity.TRIEXT_CONSTANT
     noisescaleCurve.AddKey(0.0, cam.noiseScale, 0.0, 0.0,
                            trinity.TRIINT_LINEAR)
     noisescaleCurve.AddKey(0.5, shakeFactor * 2.0, 0.0, 0.0,
                            trinity.TRIINT_LINEAR)
     noisescaleCurve.AddKey(5.0, 0.0, 0.0, 0.0, trinity.TRIINT_LINEAR)
     noisescaleCurve.Sort()
     behavior = shaker.ShakeBehavior('Warp')
     behavior.scaleCurve = noisescaleCurve
     cam.shakeController.DoCameraShake(behavior)
示例#16
0
文件: Warp.py 项目: R4M80MrX/eve-1
 def ShakeCamera(self, ball):
     shakeEnabled = settings.user.ui.Get('cameraShakeEnabled', 1)
     camera = sm.GetService('sceneManager').GetRegisteredCamera('default')
     if camera is None:
         return
     if not shakeEnabled:
         camera.noise = 0
         return
     ballpark = sm.GetService('michelle').GetBallpark()
     if ballpark is None:
         return
     speedVector = trinity.TriVector(ball.vx, ball.vy, ball.vz)
     speed = speedVector.Length()
     maxSpeed = ballpark.warpSpeed * const.AU - ball.maxVelocity
     speed = (speed - ball.maxVelocity) / maxSpeed
     speed = max(0.0, speed)
     rumbleFactor = 0.5 - 0.5 * cos(6.28 * pow(speed, 0.1))
     rumbleFactor = (rumbleFactor - 0.2) / 0.8
     rumbleFactor = max(rumbleFactor, 0.0)
     rumbleFactor = pow(rumbleFactor, 0.8)
     shakeFactor = 0.7 * rumbleFactor
     if camera.noiseScaleCurve is None:
         noiseScale = 0.0
     else:
         noiseScale = camera.noiseScale
     noisescaleCurve = trinity.TriScalarCurve()
     noisescaleCurve.extrapolation = trinity.TRIEXT_CONSTANT
     noisescaleCurve.AddKey(0.0, noiseScale, 0.0, 0.0, trinity.TRIINT_LINEAR)
     noisescaleCurve.AddKey(0.5, shakeFactor * 2.0, 0.0, 0.0, trinity.TRIINT_LINEAR)
     noisescaleCurve.AddKey(5.0, 0.0, 0.0, 0.0, trinity.TRIINT_LINEAR)
     noisescaleCurve.Sort()
     camera.noiseScaleCurve = noisescaleCurve
     now = blue.os.GetSimTime()
     camera.noiseScaleCurve.start = now
     camera.noise = 1
示例#17
0
def GetDistance(slimItem = None, mapData = None, ball = None, transform = None):
    if ball:
        return ball.surfaceDist
    if slimItem:
        ballPark = sm.GetService('michelle').GetBallpark()
        if ballPark and slimItem.itemID in ballPark.balls:
            return ballPark.balls[slimItem.itemID].surfaceDist
    myPos = GetMyPos()
    if mapData:
        pos = trinity.TriVector(mapData.x, mapData.y, mapData.z)
    elif transform:
        pos = transform.translation
        if type(pos) == types.TupleType:
            pos = trinity.TriVector(*pos)
    else:
        return None
    return (pos - myPos).Length()
示例#18
0
 def GetMouseTravel(self):
     if self.mouseDownPos:
         x, y = uicore.uilib.x, uicore.uilib.y
         v = trinity.TriVector(float(x - self.mouseDownPos[0]),
                               float(y - self.mouseDownPos[1]), 0.0)
         return int(v.Length())
     else:
         return None
示例#19
0
    def SetDamageStateSingle(self, health):
        damage = 1.0 - health
        effectPosition = trinity.TriVector()
        if damage < 0.2:
            for each in list(self.model.children):
                if each.name == 'autoDamage':
                    self.model.children.remove(each)

            self.burning = False
        elif self.id == sm.StartService('state').GetExclState(state.lookingAt) and not self.burning:
            self.burning = True
            if len(self.model.damageLocators):
                furthestBack = self.model.damageLocators[0][0]
                for locator in self.model.damageLocators:
                    locatorTranslation = locator[0]
                    if locatorTranslation[2] > furthestBack[2]:
                        furthestBack = locatorTranslation

                effectPosition = furthestBack
            scale = math.sqrt(self.model.boundingSphereRadius / 30.0)
            effect = trinity.Load('res:/Emitter/Damage/fuel_low.red')
            effect.name = 'autoDamage'
            effect.translation = effectPosition
            effect.scaling = (1, 1, 1)
            prefix = 'owner.positionDelta'
            for curveSet in effect.curveSets:
                for binding in curveSet.bindings:
                    if binding.name[0:len(prefix)] == prefix:
                        binding.sourceObject = self.model.positionDelta

            generators = effect.Find('trinity.Tr2RandomUniformAttributeGenerator')
            for generator in generators:
                if generator.elementType == trinity.PARTICLE_ELEMENT_TYPE.LIFETIME:
                    generator.minRange = (generator.minRange[0],
                     generator.minRange[1] * scale,
                     0,
                     0)
                    generator.maxRange = (generator.maxRange[0],
                     generator.maxRange[1] * scale,
                     0,
                     0)
                elif generator.elementType == trinity.PARTICLE_ELEMENT_TYPE.CUSTOM and generator.customName == 'sizeDynamic':
                    generator.minRange = (generator.minRange[0] * scale,
                     generator.minRange[1] * scale,
                     0,
                     0)
                    generator.maxRange = (generator.maxRange[0] * scale,
                     generator.maxRange[1] * scale,
                     0,
                     0)

            generators = effect.Find('trinity.Tr2SphereShapeAttributeGenerator')
            for generator in generators:
                generator.minRadius = generator.minRadius * scale
                generator.maxRadius = generator.maxRadius * scale

            self.model.children.append(effect)
            effect = None
示例#20
0
 def _TransformContext(self, v):
     scenarioMgr = sm.StartService('scenario')
     michelleSvc = sm.StartService('michelle')
     dungeonOrigin = scenarioMgr.GetDungeonOrigin()
     toolPositionX, toolPositionY, toolPositionZ = sm.GetService('scenario').GetSelectionCenter()
     toolOffset = (self.toolPosition[0] - dungeonOrigin.x, self.toolPosition[1] - dungeonOrigin.y, self.toolPosition[2] - dungeonOrigin.z)
     godma = sm.GetService('godma')
     slimItems = scenarioMgr.GetSelObjects()
     for slimItem in slimItems:
         if slimItem.dunObjectID in sm.GetService('scenario').GetLockedObjects():
             if uicore.uilib.Key(uiconst.VK_CONTROL):
                 scenarioMgr.UnlockObject(slimItem.itemID, slimItem.dunObjectID, force=True)
             else:
                 continue
         targetBall = michelleSvc.GetBall(slimItem.itemID)
         targetModel = getattr(targetBall, 'model', None)
         if not targetModel:
             continue
         if slimItem.groupID in (const.groupHarvestableCloud, const.groupCloud) and hasattr(targetModel, 'scaling'):
             if slimItem.itemID not in self.initial_scaling:
                 self.initial_scaling[slimItem.itemID] = trinity.TriVector(targetModel.scaling.x, targetModel.scaling.y, targetModel.scaling.z)
             initialScaling = self.initial_scaling[slimItem.itemID]
             scaleVector = trinity.TriVector(initialScaling.x * self.scale.x, initialScaling.y * self.scale.y, initialScaling.z * self.scale.z)
             targetModel.scaling = scaleVector
             slimItem.dunRadius = ComputeQuantityFromRadius(slimItem.categoryID, slimItem.groupID, slimItem.typeID, targetModel.scaling.x / 2.0, godma)
             scenarioMgr.UpdateUnsavedObjectChanges(slimItem.itemID, CHANGE_SCALE)
         elif slimItem.categoryID == const.categoryAsteroid and hasattr(targetModel, 'modelScale'):
             if slimItem.itemID not in self.initial_scaling:
                 self.initial_scaling[slimItem.itemID] = targetModel.modelScale
             targetModel.modelScale = self.initial_scaling[slimItem.itemID] * self.scale.x
             slimItem.dunRadius = ComputeQuantityFromRadius(slimItem.categoryID, slimItem.groupID, slimItem.typeID, targetModel.modelScale, godma)
             scenarioMgr.UpdateUnsavedObjectChanges(slimItem.itemID, CHANGE_SCALE)
         if len(slimItems) > 1 and not uicore.uilib.Key(uiconst.VK_SHIFT):
             if slimItem.itemID not in self.initial_position:
                 self.initial_position[slimItem.itemID] = ((targetModel.translationCurve.x, targetModel.translationCurve.y, targetModel.translationCurve.z), (slimItem.dunX, slimItem.dunY, slimItem.dunZ))
             initialWorldPosition, initialDungeonPosition = self.initial_position[slimItem.itemID]
             relativeObjectPosition = trinity.TriVector(initialDungeonPosition[0] - toolOffset[0], initialDungeonPosition[1] - toolOffset[1], initialDungeonPosition[2] - toolOffset[2])
             scaledPosition = trinity.TriVector(relativeObjectPosition.x * self.scale.x, relativeObjectPosition.y * self.scale.y, relativeObjectPosition.z * self.scale.z)
             targetModel.translationCurve.x = scaledPosition.x + self.toolPosition[0]
             targetModel.translationCurve.y = scaledPosition.y + self.toolPosition[1]
             targetModel.translationCurve.z = scaledPosition.z + self.toolPosition[2]
             slimItem.dunX = scaledPosition.x + toolOffset[0]
             slimItem.dunY = scaledPosition.y + toolOffset[1]
             slimItem.dunZ = scaledPosition.z + toolOffset[2]
             scenarioMgr.UpdateUnsavedObjectChanges(slimItem.itemID, CHANGE_TRANSLATION)
示例#21
0
 def CalculateHexagonParameters(self):
     """
     Calculate the base bounding box for a tile along with each of the 6 vertices
     for intersection testing
     """
     mmin = trinity.TriVector(-1.0, 0.0, -0.866025447845459)
     mmax = trinity.TriVector(1.0, 0.0, 0.866025447845459)
     maxx = mmax.z / math.sin(math.radians(60.0))
     topRightX = math.cos(math.radians(60.0)) * maxx
     self.tileMin = Point(-maxx, mmin.z)
     self.tileMax = Point(maxx, mmax.z)
     self.hexPoints = (Point(topRightX,
                             self.tileMax.y), Point(self.tileMax.x, 0.0),
                       Point(topRightX, self.tileMin.y),
                       Point(-topRightX,
                             self.tileMin.y), Point(self.tileMin.x, 0.0),
                       Point(-topRightX, self.tileMax.y))
     self.tileWidth = maxx * 2.0 * 0.75
     self.tileHeight = mmax.z * 2.0
示例#22
0
 def PointCameraToPos(self,
                      camera,
                      shipPos,
                      itemPos,
                      panSpeed,
                      timeDelta,
                      trackingPoint=None):
     m, h = uicore.desktop.width / 2, uicore.desktop.height
     center = trinity.TriVector(
         uicore.ScaleDpi(m * (1 - camera.centerOffset)),
         uicore.ScaleDpi(h / 2), 0)
     v2 = shipPos - itemPos
     v2.Normalize()
     yzProj = trinity.TriVector(0, v2.y, v2.z)
     zxProj = trinity.TriVector(v2.x, 0, v2.z)
     yaw = self.CalcAngle(zxProj.z, zxProj.x)
     pitch = -math.asin(min(1.0, max(-1.0, yzProj.y)))
     oldYaw = camera.yaw
     oldPitch = self.clampPitch(camera.pitch)
     dx2 = 0.0
     dy2 = 0.0
     if trackingPoint is not None:
         dx2 = center.x - trackingPoint[0]
         dy2 = center.y - trackingPoint[1]
     alphaX = math.pi * dx2 * camera.fieldOfView / uicore.ScaleDpi(
         uicore.desktop.width)
     alphaY = math.pi * dy2 * camera.fieldOfView / uicore.ScaleDpi(
         uicore.desktop.width)
     dPitchTotal = pitch - oldPitch
     dYawTotal = (yaw - camera.yaw) % (2 * math.pi) - alphaX * 0.75
     clampedPitchTotal = min(2 * math.pi - dPitchTotal,
                             dPitchTotal) - alphaY * 0.75
     if dYawTotal > math.pi:
         dYawTotal = -(2 * math.pi - dYawTotal)
     arc = geo2.Vec2Length((dYawTotal, clampedPitchTotal))
     part = min(1, timeDelta * panSpeed)
     dYawPart = dYawTotal * part
     dPitchPart = clampedPitchTotal * part
     Yaw = oldYaw + dYawPart
     Pitch = oldPitch + dPitchPart
     camera.SetOrbit(Yaw, Pitch)
     return arc
示例#23
0
 def SetMyViewportLocation(self, maxdist):
     bp = sm.GetService('michelle').GetBallpark()
     if not bp:
         return
     myball = bp.GetBall(eve.session.shipid)
     pos = trinity.TriVector(myball.x, myball.y, myball.z)
     sizefactor = VIEWWIDTH / (maxdist * 2.0) * 0.75
     pos.Scale(sizefactor)
     me = self.sr.viewport.sr.me
     me.left = VIEWWIDTH / 2 + int(pos.x) - me.width / 2
     me.top = VIEWWIDTH / 2 + int(pos.z) - me.height / 2
示例#24
0
def GeoToTri(obj):
    if len(obj) == 3:
        return trinity.TriVector(*obj)
    if len(obj) == 4:
        if isinstance(obj[0], tuple):
            tempTuple = obj[0] + obj[1] + obj[2] + obj[3]
            return trinity.TriMatrix(*tempTuple)
        else:
            return trinity.TriQuaternion(*obj)
    else:
        raise TypeError('Unsupported type')
示例#25
0
 def _RenderCallback(self, evt):
     if not self.cursors[self.currentCursor] or not self.dungeonOrigin:
         self.HideCursor()
         return
     x, y, z = self.GetSelectionCenter()
     playerPos = self.GetPlayerOffset()
     self.cursors[self.currentCursor].Rotate(self.GetSelectionRotation())
     self.cursors[self.currentCursor].Translate(
         trinity.TriVector(x - playerPos.x, y - playerPos.y,
                           z - playerPos.z))
     self.cursors[self.currentCursor].Render()
示例#26
0
文件: map2D.py 项目: R4M80MrX/eve-1
    def AddChilds(self, parentX, parentY, parentRad, parentID, SIZE, draw, cords, parent, _x = None, _y = None):
        parentpos = trinity.TriVector(parent.x, parent.y, parent.z)
        sorted = []
        allchilds = self.GetChilds(parentID, [], 0)
        for child in allchilds:
            childpos = trinity.TriVector(child.x, child.y, child.z)
            diff = childpos - parentpos
            dist = diff.Length()
            sorted.append((dist, child))

        sorted = uiutil.SortListOfTuples(sorted)
        if self.allowAbstract and settings.user.ui.Get('solarsystemmapabstract', 0):
            done = []
            i = 1
            xi = 0
            for child in sorted:
                if child.itemID in done:
                    continue
                radius = 1
                step = max(12, radius * 4) - 2
                y = _y or parentY + parentRad + i * step
                x = _x or parentX + xi
                if y + step > SIZE:
                    i = 0
                    xi += step
                done.append(child.itemID)
                fill = self.GetColorByGroupID(child.groupID)
                draw.circle(x, SIZE - y, radius, radius, fill, fill)
                cords[child.itemID] = (x, SIZE - y, radius)
                i += 1

        else:
            for child in sorted:
                radius = 1
                pos = trinity.TriVector(child.x, 0.0, child.z)
                pos = pos + (pos - parentpos) * max(1.0, 4096 / SIZE)
                x = FLIPMAP * pos.x * self.sr.sizefactor + SIZE / 2
                y = pos.z * self.sr.sizefactor + SIZE / 2
                fill = self.GetColorByGroupID(child.groupID)
                draw.circle(x, SIZE - y, radius, radius, fill, fill)
                cords[child.itemID] = (x, SIZE - y, radius)
示例#27
0
文件: map2D.py 项目: R4M80MrX/eve-1
 def UpdateMyLocation(self):
     if not uiutil.IsUnder(self, uicore.desktop):
         return
     bp = sm.GetService('michelle').GetBallpark()
     if bp is None or self is None or self.destroyed:
         self.updatemylocationtimer = None
         return
     myball = bp.GetBall(eve.session.shipid)
     if myball is None:
         self.updatemylocationtimer = None
         return
     size = max(1, self.absoluteRight - self.absoluteLeft)
     if size == 1:
         uiutil.Update(self, 'Map2D::UpdateMyLocation')
         size = max(1, self.absoluteRight - self.absoluteLeft)
     x = y = None
     if self.allowAbstract and settings.user.ui.Get('solarsystemmapabstract', 0):
         if not len(self.orbs):
             return
         x, y = self.GetAbstractPosition(trinity.TriVector(myball.x, 0.0, myball.z), 1)
     elif self.sr.sizefactor is not None and self.sr.sizefactorsize is not None:
         maxdist = self.GetMaxDist()
         sizefactor = size / 2 / maxdist * self.fillSize
         x = FLIPMAP * myball.x * sizefactor / float(size) + 0.5
         y = -(myball.z * sizefactor) / float(size) + 0.5
     if x is not None and y is not None:
         self.imhere.sr.x = x
         self.imhere.sr.y = y
         self.imhere.state = uiconst.UI_DISABLED
     camera = sm.GetService('sceneManager').GetRegisteredCamera('default')
     if camera is None:
         return
     rot = geo2.QuaternionRotationGetYawPitchRoll(camera.rotationAroundParent)
     look = geo2.QuaternionRotationGetYawPitchRoll(camera.rotationOfInterest)
     if not self.fov:
         self.fov = Fov(parent=self.imhere)
     self.fov.SetRotation(rot[0] + look[0] - pi)
     actualfov = camera.fieldOfView * (uicore.desktop.width / float(uicore.desktop.height))
     degfov = actualfov - pi / 2
     self.fov.SetFovAngle(actualfov)
     if self.showingtempangle:
         if not self.tempAngleFov:
             self.tempAngleFov = Fov(parent=self.imhere, state=uiconst.UI_DISABLED, blendMode=trinity.TR2_SBM_ADDX2)
             self.tempAngleFov.SetColor((0.0, 0.3, 0.0, 1.0))
         self.tempAngleFov.display = True
         self.tempAngleFov.SetRotation(rot[0] + look[0] - pi)
         angle = self.showingtempangle
         self.tempAngleFov.SetFovAngle(angle)
     elif self.tempAngleFov:
         self.tempAngleFov.display = False
     self.RefreshOverlays()
 def GetRay(self, x, y):
     app = trinity.app
     aspect = float(app.width) / app.height
     fovTan = math.tan(self.fieldOfView * 0.5)
     dx = fovTan * (2.0 * x / app.width - 1.0) * aspect
     dy = fovTan * (1.0 - 2.0 * y / app.height)
     if trinity.IsRightHanded():
         startPoint = trinity.TriVector(self.frontClip * dx,
                                        self.frontClip * dy,
                                        -self.frontClip)
         endPoint = trinity.TriVector(self.backClip * dx,
                                      self.backClip * dy, -self.backClip)
     else:
         startPoint = trinity.TriVector(self.frontClip * dx,
                                        self.frontClip * dy, self.frontClip)
         endPoint = trinity.TriVector(self.backClip * dx,
                                      self.backClip * dy, self.backClip)
     invViewMatrix = util.ConvertTupleToTriMatrix(self.viewMatrix.transform)
     invViewMatrix.Inverse()
     startPoint.TransformCoord(invViewMatrix)
     endPoint.TransformCoord(invViewMatrix)
     startPoint = (startPoint.x, startPoint.y, startPoint.z)
     endPoint = (endPoint.x, endPoint.y, endPoint.z)
     return (startPoint, endPoint)
示例#29
0
    def MoveCursor_thread(self):
        self.isMoving = True
        lib = uicore.uilib
        while lib.leftbtn:
            if self.currentCursor:
                x, y, z = self.GetSelectionCenter()
                dungeonOrigin = self.GetDungeonOrigin()
                playerPos = self.GetPlayerOffset()
                try:
                    rotation = self.GetSelectionRotation()
                    singleObjectRotation = self.currentCursor == 'Rotation' and len(
                        self.selection) == 1
                    multipleObjectRotation = self.currentCursor == 'Rotation' and len(
                        self.selection) > 1
                    if singleObjectRotation:
                        self.cursors[self.currentCursor].Rotate(
                            (rotation[0], rotation[1], rotation[2],
                             rotation[3]))
                    elif multipleObjectRotation:
                        self.cursors[self.currentCursor].Rotate(
                            (rotation[0], rotation[1], rotation[2],
                             -rotation[3]))
                    self.cursors[self.currentCursor].Translate(
                        trinity.TriVector(x - playerPos.x, y - playerPos.y,
                                          z - playerPos.z))
                    self.cursors[self.currentCursor].Transform(
                        uicore.uilib.x, uicore.uilib.y)
                    if multipleObjectRotation:
                        rotation = self.cursors[
                            self.currentCursor].GetRotation()
                        self.SetGroupSelectionRotation(
                            (rotation[0], rotation[1], rotation[2],
                             -rotation[3]))
                except:
                    self.LogError(
                        'Error when attempting to move the dungeon editor object manipulation tool.'
                    )
                    log.LogException()
                    sys.exc_clear()
                    self.isMoving = False
                    return

            self.lastChangeTimestamp = blue.os.GetWallclockTime()
            blue.synchro.Yield()

        self.isMoving = False
        self.StopMovingCursor()
示例#30
0
 def surfaceDist(self):
     if not session.solarsystemid:
         return None
     
     bp = sm.GetService('michelle').GetBallpark(True)
     
     if bp:
         ball = bp.GetBallById(self.id)
         
         if ball:
             return ball.surfaceDist
         
         else:
             pos = trinity.TriVector(self.x, self.y, self.z)
             
             return (pos - maputils.GetMyPos()).Length()
     
     return