コード例 #1
0
    def PickProbes(self, pickBorder = False):
        mouseInsideProbes = []
        borderPick = []
        probeHandler = self.GetProbeHandler()
        if probeHandler:
            probeData = sm.StartService('scanSvc').GetProbeData()
            cameraPosition = geo2.Vec3Add(self.mapView.camera.pointOfInterest, self.mapView.camera._eyePosition)
            probes = probeHandler.GetProbeControls()
            for probeID, probeControl in probes.iteritems():
                if probeID not in probeData or probeData[probeID].state != const.probeStateIdle:
                    continue
                targetPlanePos = probeControl.GetWorldPosition()
                cameraDistance = geo2.Vec3Length(geo2.Vec3Subtract(cameraPosition, targetPlanePos))
                rad = probeControl.GetRange() * SOLARSYSTEM_SCALE
                mousePositionOnCameraPlane = self.GetDotInCameraAlignedPlaneFromPosition(targetPlanePos)
                distanceFromCenter = geo2.Vec3Length(geo2.Vec3Subtract(targetPlanePos, mousePositionOnCameraPlane))
                if pickBorder:
                    pickRadiusPos = self.GetDotInCameraAlignedPlaneFromPosition(targetPlanePos, offsetMouse=(-10, 0))
                    pickRadius = geo2.Vec3Length(geo2.Vec3Subtract(pickRadiusPos, mousePositionOnCameraPlane))
                    if rad + pickRadius > distanceFromCenter > rad - pickRadius:
                        borderPick.append((abs(rad - distanceFromCenter), probeControl))
                elif distanceFromCenter <= rad:
                    mouseInsideProbes.append((cameraDistance, probeControl))

        if pickBorder:
            if borderPick:
                return SortListOfTuples(borderPick)[0]
            else:
                return None
        return SortListOfTuples(mouseInsideProbes)
コード例 #2
0
ファイル: baseCamera.py プロジェクト: connoryang/1v1dec
 def Transit(self,
             atPos0,
             eyePos0,
             atPos1,
             eyePos1,
             duration=1.0,
             smoothing=0.1,
             numPoints=1000,
             timeOffset=0.0,
             callback=None):
     newDir = geo2.Vec3Direction(eyePos1, atPos1)
     self.StopEyeAndAtAnimation()
     if self._atTransitOffset:
         atPos0 = geo2.Vec3Add(atPos0, self._atTransitOffset)
     if self._eyeTransitOffset:
         eyePos0 = geo2.Vec3Add(eyePos0, self._eyeTransitOffset)
     self.SetAtPosition(atPos1)
     self.SetEyePosition(eyePos1)
     self._atTransitOffset = geo2.Vec3Subtract(atPos0, atPos1)
     self._eyeTransitOffset = geo2.Vec3Subtract(eyePos0, eyePos1)
     uicore.animations.MorphVector3(self,
                                    '_atTransitOffset',
                                    self._atTransitOffset, (0, 0, 0),
                                    duration=duration,
                                    timeOffset=timeOffset,
                                    callback=callback)
     uicore.animations.MorphVector3(self,
                                    '_eyeTransitOffset',
                                    self._eyeTransitOffset, (0, 0, 0),
                                    duration=duration,
                                    timeOffset=timeOffset,
                                    callback=self.OnTransitEnd)
     self._transitDoneTime = blue.os.GetWallclockTime() + SEC * duration
コード例 #3
0
ファイル: tacticalCamera.py プロジェクト: connoryang/1v1dec
 def _EnforceMaximumDistanceDetached(self):
     dist = geo2.Vec3Length(self.eyePosition)
     if dist > evecamera.LOOKATRANGE_MAX_NEW and not self.IsInTransit():
         direction = geo2.Vec3Normalize(self.eyePosition)
         newEye = geo2.Vec3Scale(direction, evecamera.LOOKATRANGE_MAX_NEW)
         diff = geo2.Vec3Subtract(self.eyePosition, newEye)
         self.SetEyePosition(newEye)
         self.SetAtPosition(geo2.Vec3Subtract(self._atPosition, diff))
コード例 #4
0
 def PlerpVec3(self, start, end, timeLeft):
     doneSoFar = LERP_TIME - timeLeft
     percDone = doneSoFar / LERP_TIME
     if percDone > 1.0:
         return end
     percToEnd = math.sin(percDone * math.pi - math.pi / 2.0) / 2.0 + 0.5
     distance = geo2.Vec3Length(geo2.Vec3Subtract(end, start)) * percToEnd
     vector = geo2.Vec3Normalize(geo2.Vec3Subtract(end, start))
     currPoint = geo2.Vec3Add(start, (val * distance for val in vector))
     return currPoint
コード例 #5
0
ファイル: baseCamera.py プロジェクト: connoryang/1v1dec
 def _UpdateRotateOffset(self):
     if self._rotateOffset != (0.0, 0.0):
         yaw, pitch = self._rotateOffset
         rotMat = geo2.MatrixRotationAxis(self.upDirection, -yaw)
         eyeAtVec = geo2.Vec3Subtract(self._atPosition, self._eyePosition)
         vec = geo2.Vec3Transform(eyeAtVec, rotMat)
         axis = geo2.Vec3Normalize(geo2.Vec3Cross(vec, self.upDirection))
         rotMat = geo2.MatrixRotationAxis(axis, -pitch)
         vec = geo2.Vec3Transform(vec, rotMat)
         offset = geo2.Vec3Subtract(vec, eyeAtVec)
         self._AddToAtOffset(offset)
コード例 #6
0
def GetSynchedAnimStartLocation(sourcePos, sourceRot, targetPos, targetRot, animInfo):
    relVec = geo2.Vec3Subtract(sourcePos, targetPos)
    curDist = geo2.Vec3Length(relVec)
    if curDist <= 0.01:
        sourcePos = geo2.Vec3Add(targetPos, (0, 0, -1))
        relVec = geo2.Vec3Subtract(sourcePos, targetPos)
    entName = const.animation.ATTACKER_NAME
    if entName in animInfo and const.animation.METADATA_TURN_TO_FACE in animInfo[entName] and animInfo[entName][const.animation.METADATA_TURN_TO_FACE] == False:
        newSourceRot = sourceRot
    else:
        newSourceRot = GetQuatFromDirection(sourcePos, targetPos)
    entName = const.animation.VICTIM_NAME
    if entName in animInfo and const.animation.METADATA_TURN_TO_FACE in animInfo[entName] and animInfo[entName][const.animation.METADATA_TURN_TO_FACE] == False:
        newTargetRot = targetRot
        newTargetYaw, trash, trash = geo2.QuaternionRotationGetYawPitchRoll(targetRot)
    else:
        newTargetRot = GetQuatFromDirection(targetPos, sourcePos)
        if entName in animInfo and const.animation.METADATA_START_OFFSET_YAW in animInfo[entName]:
            degrees = animInfo[entName][const.animation.METADATA_START_OFFSET_YAW]
            offsetYaw = math.pi * -degrees / 180.0
            offsetRot = geo2.QuaternionRotationSetYawPitchRoll(offsetYaw, 0.0, 0.0)
            newTargetRot = geo2.QuaternionMultiply(newTargetRot, offsetRot)
    distance = 0.5
    if const.animation.METADATA_START_DISTANCE in animInfo:
        distance = animInfo[const.animation.METADATA_START_DISTANCE]
    entName = const.animation.VICTIM_NAME
    if entName in animInfo and const.animation.METADATA_START_OFFSET_YAW in animInfo[entName]:
        if '/righthanded' in blue.pyos.GetArg():
            front = (0, 0, distance)
        else:
            front = (0, 0, -distance)
        degrees = animInfo[entName][const.animation.METADATA_START_OFFSET_YAW]
        radians = math.pi * degrees / 180.0
        offsetRot = geo2.QuaternionRotationSetYawPitchRoll(radians, 0.0, 0.0)
        yawOffsetQuat = geo2.QuaternionMultiply(newTargetRot, offsetRot)
        radOffset = geo2.QuaternionTransformVector(yawOffsetQuat, front)
        newSourcePos = geo2.Vec3Add(targetPos, radOffset)
        newSourceRot = GetQuatFromDirection(newSourcePos, targetPos)
    else:
        direction = geo2.Vec3Normalize(relVec)
        newSourcePos = geo2.Vec3Add(targetPos, (distance * direction[0], distance * direction[1], distance * direction[2]))
    entName = const.animation.ATTACKER_NAME
    if entName in animInfo and const.animation.METADATA_START_OFFSET_YAW in animInfo[entName]:
        degrees = animInfo[entName][const.animation.METADATA_START_OFFSET_YAW]
        radians = math.pi * -degrees / 180.0
        offsetRot = geo2.QuaternionRotationSetYawPitchRoll(radians, 0.0, 0.0)
        newSourceRot = geo2.QuaternionMultiply(newSourceRot, offsetRot)
    return (newSourcePos,
     newSourceRot,
     targetPos,
     newTargetRot)
コード例 #7
0
 def update_line_position(posInfo):
     lineData = posInfo[2]
     lineID = lineData.lineID
     fromPosition = posInfo[0]
     if fromPosition is None:
         fromMapNode = GetNodeBySolarSystemID(lineData.fromSolarSystemID)
         fromPosition = fromMapNode.position
         posInfo[0] = fromPosition
     toPosition = posInfo[1]
     if toPosition is None:
         toMapNode = GetNodeBySolarSystemID(lineData.toSolarSystemID)
         toPosition = toMapNode.position
         posInfo[1] = toPosition
     if lineID in adjustLines:
         fromPosition = geo2.Vec3Add(fromPosition, adjustLines[lineID][0])
         toPosition = geo2.Vec3Add(toPosition, adjustLines[lineID][2])
     lineSet.ChangeLinePositionCrt(lineID, fromPosition, toPosition)
     if lineData.jumpType == JUMPBRIDGE_TYPE:
         linkVec = geo2.Vec3Subtract(toPosition, fromPosition)
         normLinkVec = geo2.Vec3Normalize(linkVec)
         rightVec = geo2.Vec3Cross(worldUp, normLinkVec)
         upVec = geo2.Vec3Cross(rightVec, normLinkVec)
         offsetVec = geo2.Vec3Scale(geo2.Vec3Normalize(upVec), geo2.Vec3Length(linkVec) * 1.0)
         midPos = geo2.Vec3Scale(geo2.Vec3Add(toPosition, fromPosition), 0.5)
         splinePos = geo2.Vec3Add(midPos, offsetVec)
         lineSet.ChangeLineIntermediateCrt(lineID, splinePos)
コード例 #8
0
ファイル: baseCamera.py プロジェクト: connoryang/1v1dec
 def SetYaw(self, yaw):
     rotMat = geo2.MatrixRotationY(yaw - math.pi)
     eyePos = geo2.Vec3Subtract(self._eyePosition, self._atPosition)
     x = math.sqrt(eyePos[0]**2 + eyePos[2]**2)
     vec = (0, eyePos[1], x)
     self._eyePosition = geo2.Vec3Add(geo2.Vec3Transform(vec, rotMat),
                                      self._atPosition)
コード例 #9
0
ファイル: stretchEffect.py プロジェクト: connoryang/1v1dec
 def CreateImpact(self, targetBall, source):
     blue.synchro.Sleep(100)
     damageDuration = 3000
     targetPos = targetBall.GetVectorAt(blue.os.GetSimTime())
     target = geo2.Vector(targetPos.x, targetPos.y, targetPos.z)
     direction = geo2.Vec3Normalize(geo2.Vec3Subtract(source, target))
     targetBall.model.CreateImpact(self.gfx.dest.damageLocatorIndex, direction, damageDuration * 0.001, 2.0)
コード例 #10
0
 def Update(self):
     self._UpdateAnchorPosition()
     BaseSpaceCamera.Update(self)
     if not self.lookAtBall or not self.ego:
         return
     zoomProp = self.GetZoomProportion()
     self._UpdateAtOffset()
     self._UpdateEyeOffset()
     newAtPos = self.GetTrackPosition(self.lookAtBall)
     atDiff = geo2.Vec3Subtract(newAtPos, self._atPosition)
     self.SetAtPosition(newAtPos)
     if self.IsChasing():
         self.SetEyePosition(
             self.trackLerper.GetValue(self._eyePosition,
                                       self.GetChaseEyePosition()))
     elif self.IsTracking():
         self.SetEyePosition(
             self.trackLerper.GetValue(self._eyePosition,
                                       self.GetTrackingEyePosition()))
     else:
         prop = self._GetEyePosDriftProporition()
         eyeOffset = geo2.Vec3Scale(atDiff, prop)
         self.SetEyePosition(geo2.Vec3Add(self._eyePosition, eyeOffset))
     if not self.IsInTransit():
         if self.GetItemID() == self.ego or self.IsTracking(
         ) or self.IsChasing():
             self.SetZoom(zoomProp)
         self.EnforceMinZoom()
     if not self.isManualFovEnabled and IsDynamicCameraMovementEnabled():
         self.SetFovTarget(self.GetDynamicFov())
コード例 #11
0
    def BuildEnlightenScene(self):
        trinity.WaitForResourceLoads()
        import CCP_P4 as p4
        import os
        for cell in self.cells:
            p4.PrepareFileForSave(blue.paths.ResolvePathForWriting(cell.shProbeResPath))
            for system in cell.systems:
                p4.PrepareFileForSave(blue.paths.ResolvePathForWriting(system.radSystemPath))

            cell.RebuildInternalData()
            lightVolumeRes = [ int(v) + 1 for v in geo2.Vec3Subtract(cell.maxBounds, cell.minBounds) ]
            cell.BuildLightVolume(*lightVolumeRes)
            uvResPath = 'res:/interiorCache/' + str(self.id) + '_' + str(cell.name) + '.uv'
            uvFileName = blue.paths.ResolvePathForWriting(uvResPath)
            p4.PrepareFileForSave(uvFileName)

        import app.Interior.EnlightenBuildProgressDialog as progress
        dlg = progress.EnlightenBuildDialog()
        if dlg.BuildEnlighten(self):
            self.SaveEnlighten()
            revisionsDB = INTERIOR_RES_PATH + str(self.id) + '.revisions'
            revisionsDB = blue.paths.ResolvePathForWriting(revisionsDB)
            p4.PrepareFileForSave(revisionsDB)
            currentRevs = sm.GetService('jessicaWorldSpaceClient').GetWorldSpace(self.id).GetWorldSpaceSpawnRevisionsList()
            if not os.access(revisionsDB, os.F_OK):
                file = open(revisionsDB, 'w')
                yaml.dump(currentRevs, file)
                file.close()
            else:
                with open(revisionsDB, 'w') as DB:
                    yaml.dump(currentRevs, DB)
        p4.AddFilesToP4()
        for cell in self.cells:
            self._SaveUVData(cell, cell.name)
コード例 #12
0
ファイル: systemMapHandler.py プロジェクト: connoryang/1v1dec
 def __init__(self, orbitID, position, parentPosition, parentTransform):
     self.orbitID = orbitID
     dirVec = geo2.Vec3Subtract(position, parentPosition)
     radius = geo2.Vec3Length(dirVec)
     dirVec = geo2.Vec3Normalize(dirVec)
     fwdVec = (-1.0, 0.0, 0.0)
     rotation = geo2.QuaternionRotationArc(fwdVec, dirVec)
     radius = radius / self.lineSetScaling
     lineSet = mapViewUtil.CreateLineSet()
     lineSet.scaling = (self.lineSetScaling, self.lineSetScaling, self.lineSetScaling)
     lineSet.translation = parentPosition
     lineSet.rotation = rotation
     parentTransform.children.append(lineSet)
     self.pixelLineSet = lineSet
     mapViewUtil.DrawCircle(lineSet, (0, 0, 0), radius, startColor=(1, 1, 1, 0.25), endColor=(1, 1, 1, 0.25), lineWidth=2.5)
     lineSet.SubmitChanges()
     lineSet = mapViewUtil.CreatePlanarLineSet()
     lineSet.scaling = (self.lineSetScaling, self.lineSetScaling, self.lineSetScaling)
     lineSet.translation = parentPosition
     lineSet.rotation = rotation
     parentTransform.children.append(lineSet)
     self.planarLineSet = lineSet
     orbitLineColor = (1, 1, 1, 0.25)
     self.planarLineIDs = mapViewUtil.DrawCircle(lineSet, (0, 0, 0), radius, startColor=orbitLineColor, endColor=orbitLineColor, lineWidth=radius / 150.0)
     lineSet.SubmitChanges()
コード例 #13
0
def CreateBehaviorFromMagnitudeAndPosition(magnitude, shakeOrigin, camera):
    timeFactor = pow(magnitude / 400.0, 0.7)
    noiseScaleCurve = trinity.TriScalarCurve()
    noiseScaleCurve.AddKey(0.0, 1.2, 0.0, 0.0, 3)
    noiseScaleCurve.AddKey(0.1, 0.1, 0.0, 0.0, 3)
    noiseScaleCurve.AddKey(1.5 * timeFactor, 0.13, 0.0, 0.0, 3)
    noiseScaleCurve.AddKey(2.0 * timeFactor, 0.0, 0.0, 0.0, 3)
    noiseScaleCurve.extrapolation = 1
    noiseDampCurve = trinity.TriScalarCurve()
    noiseDampCurve.AddKey(0.0, 80.0, 0.0, 0.0, 3)
    noiseDampCurve.AddKey(0.1, 20.0, 0.0, 0.0, 3)
    noiseDampCurve.AddKey(1.5 * timeFactor, 0.0, 0.0, 0.0, 3)
    noiseDampCurve.AddKey(2.0 * timeFactor, 0.0, 0.0, 0.0, 3)
    noiseDampCurve.extrapolation = 1
    distance = geo2.Vec3Length(geo2.Vec3Subtract(shakeOrigin, camera.pos))
    if isnan(distance):
        return
    if distance < 700.0:
        distance = 700.0
    elif distance > 2000000000:
        distance = 2000000000
    actualMagnitude = 0.7 * magnitude / pow(distance, 0.7)
    noiseScaleCurve.ScaleValue(actualMagnitude)
    noiseDampCurve.ScaleValue(actualMagnitude)
    if camera.noiseScaleCurve is not None and camera.noiseScaleCurve.value > noiseScaleCurve.keys[
            1].value:
        return
    behavior = camshake.ShakeBehavior()
    behavior.scaleCurve = noiseScaleCurve
    behavior.dampCurve = noiseDampCurve
    return behavior
コード例 #14
0
ファイル: controlPaths.py プロジェクト: connoryang/1v1dec
 def Update(self):
     sourcePoint = self.sourceFunction.GetValue()
     destPoint = self.destinationFunction.GetValue()
     d = geo2.Vec3Subtract(destPoint, sourcePoint)
     length = geo2.Vec3Length(d)
     self.model.scaling = (length, self.scaling, length)
     self.model.rotation = self.rotation
コード例 #15
0
 def Update(self):
     normalCamera = self._GetNonDebugCamera()
     if not self.IsUpdatingDebugCamera() and normalCamera:
         if normalCamera:
             normalCamera.Update()
     if self.IsShowingNormalCamera() and normalCamera:
         camPos = normalCamera.GetPosition()
         poi = normalCamera.GetPointOfInterest()
         vec = geo2.Vec3Subtract(poi, camPos)
         vec = geo2.Vec3Normalize(vec)
         vec = geo2.Vec3Scale(vec, 0.5)
         self.debugRenderClient.RenderCone(camPos,
                                           geo2.Vec3Add(camPos, vec),
                                           0.25,
                                           4278190335L,
                                           time=1)
         if self.lastCamPos is not None and camPos != self.lastCamPos:
             self.debugRenderClient.RenderRay(self.lastCamPos,
                                              camPos,
                                              4278190335L,
                                              4278255360L,
                                              time=1000,
                                              pulse=True)
         self.lastCamPos = camPos
     if self.translationVector != [0.0, 0.0, 0.0]:
         now = blue.os.GetWallclockTime()
         frameTime = float(now - self.lastUpdateTime) / const.SEC
         poi = cameras.PolarCamera.GetPointOfInterest(self)
         rotMatrix = geo2.MatrixRotationYawPitchRoll(
             math.pi / 2.0 - self.yaw, math.pi / 2.0 - self.pitch, 0.0)
         scaledVector = geo2.Vec3Scale(self.translationVector, frameTime)
         relativeVector = geo2.Vec3TransformCoord(scaledVector, rotMatrix)
         newPos = geo2.Vec3Add(poi, relativeVector)
         cameras.PolarCamera.SetPointOfInterest(self, newPos)
     cameras.PolarCamera.Update(self)
コード例 #16
0
ファイル: controlPaths.py プロジェクト: connoryang/1v1dec
 def Update(self):
     sourcePoint = self.sourceFunction.GetValue()
     destPoint = self.destinationFunction.GetValue()
     d = geo2.Vec3Subtract(destPoint, sourcePoint)
     length = geo2.Vec3Length(d)
     self.model.scaling = (self.radius, length, self.radius)
     self.model.rotation = geo2.QuaternionRotationArc((0, 1, 0), geo2.Vec3Normalize(d))
コード例 #17
0
ファイル: vectorFunctions.py プロジェクト: connoryang/1v1dec
 def SetOffsetWorldspace(self, worldPos):
     position = (0, 0, 0)
     if self.curve.parentPositionCurve is not None:
         position = _VectorToTuple(
             self.curve.parentPositionCurve.GetVectorAt(
                 blue.os.GetSimTime()))
     self.SetOffsetRelative(geo2.Vec3Subtract(worldPos, position))
コード例 #18
0
    def _WaitForAcceleration(self, accT=215000.0):
        shipBall = self.GetEffectShipBall()
        shipPosL = shipBall.GetVectorAt(blue.os.GetSimTime())
        shipPosL = (shipPosL.x, shipPosL.y, shipPosL.z)
        speedL = 0
        timeL = blue.os.GetSimTime()
        acc = 0
        while not self.abort:
            timeN = blue.os.GetSimTime()
            v = shipBall.GetVectorDotAt(timeN)
            speed = geo2.Vec3Length((v.x, v.y, v.z))
            shipPos = shipBall.GetVectorAt(blue.os.GetSimTime())
            shipPos = (shipPos.x, shipPos.y, shipPos.z)
            self.direction = geo2.Vec3Subtract(shipPos, shipPosL)
            shipPosL = shipPos
            timeDiffSec = blue.os.TimeDiffInMs(timeL, timeN) / 1000.0
            if timeDiffSec != 0.0:
                acc = (speed - speedL) / timeDiffSec
            speedL = speed
            timeL = timeN
            if acc > accT:
                break
            blue.synchro.Yield()

        return speedL
コード例 #19
0
ファイル: hangarCamera.py プロジェクト: connoryang/1v1dec
 def Update(self):
     BaseSpaceCamera.Update(self)
     if self.model and self.model.translationCurve:
         atPos = self.model.translationCurve.value
         diff = geo2.Vec3Subtract(atPos, self._atPosition)
         self.atPosition = atPos
         self.eyePosition = geo2.Vec3Add(self.eyePosition, diff)
コード例 #20
0
ファイル: baseSpaceCamera.py プロジェクト: connoryang/1v1dec
 def GetDynamicFov(self):
     if self._atTransitOffset:
         atPos = geo2.Vec3Subtract(self.atPosition, self._atTransitOffset)
     else:
         atPos = self.atPosition
     dist = geo2.Vec3Distance(self.eyePosition, atPos)
     return self.GetDynamicFovByDistance(dist)
コード例 #21
0
def GetSolidAroundLine(line, radius):
    rad = math.pi * 2.0 / 3.0
    triangle1 = []
    triangle1.append((math.cos(0) * radius, math.sin(0) * radius, 0.0))
    triangle1.append((math.cos(rad) * radius, math.sin(rad) * radius, 0.0))
    triangle1.append(
        (math.cos(2 * rad) * radius, math.sin(2 * rad) * radius, 0.0))
    dirOfLine = geo2.Vec3Normalize(geo2.Vec3Subtract(line[1], line[0]))
    if abs(geo2.Vec3Dot((0.0, 0.0, 1.0), dirOfLine)) != 1.0:
        rot = geo2.QuaternionRotationArc((0.0, 0.0, 1.0), dirOfLine)
    else:
        rot = geo2.QuaternionIdentity()
    rot = geo2.MatrixRotationQuaternion(rot)
    t1 = geo2.MatrixTranslation(*line[0])
    t2 = geo2.MatrixTranslation(*line[1])
    compA = geo2.MatrixMultiply(rot, t1)
    compB = geo2.MatrixMultiply(rot, t2)
    startTri = geo2.Vec3TransformCoordArray(triangle1, compA)
    endTri = geo2.Vec3TransformCoordArray(triangle1, compB)
    triangles = [
        startTri[1], endTri[0], startTri[0], endTri[1], endTri[0], startTri[1],
        startTri[2], endTri[1], startTri[1], endTri[2], endTri[1], startTri[2],
        startTri[0], endTri[2], startTri[2], endTri[0], endTri[2], startTri[0]
    ]
    return triangles
コード例 #22
0
 def _GetTrackAtOffset(self):
     trackOffset = geo2.Vec3Subtract(self.GetTrackPosition(self.trackBall),
                                     self._atPosition)
     length = geo2.Vec3Length(trackOffset)
     maxLen = 250000
     if length > maxLen:
         trackOffset = geo2.Vec3Scale(trackOffset, maxLen / length)
     return trackOffset
コード例 #23
0
ファイル: baseSpaceCamera.py プロジェクト: connoryang/1v1dec
 def GetTrackPosition(self, ball):
     if not ball:
         ret = (0, 0, 0)
     else:
         ret = GetBallPosition(ball)
     if self._anchorOffset:
         ret = geo2.Vec3Subtract(ret, self._anchorOffset)
     return ret
コード例 #24
0
def GetDeltaAngleToFaceTarget(sourcePos, sourceRot, targetPos):
    """
    Calculates the change in yaw angle necessary to face the targetPos given your sourcePos and your current rotation (sourceRot)
    """
    targetVec = geo2.Vec3Subtract(targetPos, sourcePos)
    theta = GetYawAngleFromDirectionVector(targetVec)
    yaw, trash, trash = geo2.QuaternionRotationGetYawPitchRoll(sourceRot)
    return GetLesserAngleBetweenYaws(yaw, theta)
コード例 #25
0
def GetMaxLookAtWeight_Facing(ent, targetPos):
    sourcePos = ent.GetComponent('position').position
    sourceRot = ent.GetComponent('position').rotation
    source2Target = geo2.Vec3Subtract(targetPos, sourcePos)
    source2Target = geo2.Vec3Normalize(source2Target)
    facingDir = mathCommon.CreateDirectionVectorFromYawAngle(geo2.QuaternionRotationGetYawPitchRoll(sourceRot)[0])
    dot = geo2.Vec3Dot(source2Target, facingDir)
    return max(dot, 0)
コード例 #26
0
ファイル: tacticalCamera.py プロジェクト: connoryang/1v1dec
 def SetAppropriateAtPositionForRotation(self, atPos):
     distanceToNewAtPos = geo2.Vec3Distance(self.eyePosition, atPos)
     distanceToNewAtPos = min(evecamera.LOOKATRANGE_MAX_NEW,
                              distanceToNewAtPos)
     lookVec = geo2.Vec3Scale(self.GetLookAtDirection(), distanceToNewAtPos)
     newAtPos = geo2.Vec3Subtract(self.eyePosition, lookVec)
     if newAtPos != self._eyePosition:
         self.SetAtPosition(newAtPos)
コード例 #27
0
 def DistanceFromSegment(self, p, p0, p1, v, c2):
     w = geo2.Vec3Subtract(p, p0)
     c1 = geo2.Vec3Dot(v, w)
     if c1 <= 0:
         return None
     if c2 <= c1:
         return geo2.Vec3Distance(p, p1)
     return geo2.Vec3Distance(p, geo2.Vec3Add(p0, geo2.Vec3Scale(v, c1 / c2)))
コード例 #28
0
ファイル: animUtils.py プロジェクト: connoryang/1v1dec
def GetRelativeLookAtVector(sourcePosition, sourceRotation, targetPosition):
    lookAtVector = geo2.Vec3Subtract(targetPosition, sourcePosition)
    yaw, trash, trash = geo2.QuaternionRotationGetYawPitchRoll(sourceRotation)
    yaw = -yaw
    relativeLookAtVector = (lookAtVector[0] * math.cos(yaw) +
                            lookAtVector[2] * math.sin(yaw), lookAtVector[1],
                            -lookAtVector[0] * math.sin(yaw) +
                            lookAtVector[2] * math.cos(yaw))
    return relativeLookAtVector
コード例 #29
0
def _GetViewAndProjectionUsingProjectedBoundingBox(
        calculateProjectedBoundingBox,
        scene=None,
        boundingSphereRadius=None,
        boundingSphereCenter=None,
        boundingBoxMin=None,
        boundingBoxMax=None,
        cameraAngle=None):
    """
    Fits an object in frame with view and projection matrices. We first do a rough fit
    using either the bounding sphere or bounding box. We then "zoom in" to the point where
    the projected bounding box fills 90% of the image.
    """
    cameraAngle = cameraAngle or GETPHOTO_ANGLE
    if boundingSphereRadius:
        radius = boundingSphereRadius
        center = boundingSphereCenter if boundingSphereCenter else (0.0, 0.0,
                                                                    0.0)
    else:
        center = geo2.Vec3Add(boundingBoxMin, boundingBoxMax)
        center = geo2.Vec3Scale(center, 0.5)
        radius = geo2.Vec3Length(
            geo2.Vec3Subtract(boundingBoxMax, boundingBoxMin))
    dist = _SphericalFit(radius)
    viewEyeAtUp = _GetViewMatrixFromAngle(cameraAngle, center, dist)
    projTransform = geo2.MatrixPerspectiveFovRH(*GETPHOTO_PROJECTION)
    viewTransform = geo2.MatrixLookAtRH(*viewEyeAtUp)
    combinedTransform = viewTransform
    combinedTransform = geo2.MatrixMultiply(combinedTransform, projTransform)
    safeMin, safeMax = calculateProjectedBoundingBox(combinedTransform)
    deltaX = safeMax[0] - safeMin[0]
    deltaY = safeMax[1] - safeMin[1]
    scalingFactor = 0.9 * (2.0 / max(deltaX, deltaY))
    try:
        if scene.backgroundEffect is not None:
            params = scene.backgroundEffect.Find(['trinity.Tr2FloatParameter'])
            for param in params:
                if param.name == 'ProjectionScaling':
                    param.value = scalingFactor

    except AttributeError:
        pass

    offsetX = -1 * scalingFactor * (safeMin[0] + safeMax[0]) / 2.0
    offsetY = -1 * scalingFactor * (safeMin[1] + safeMax[1]) / 2.0
    scale = 1.0 / tan(GETPHOTO_FOV / 2.0) * scalingFactor
    zn = 1.0
    zf = dist + radius * 2
    t = zn * (1 - offsetY) / scale
    b = -t * (1 + offsetY) / (1 - offsetY)
    r = zn * (1 - offsetX) / scale
    l = -r * (1 + offsetX) / (1 - offsetX)
    projection = trinity.TriProjection()
    projection.PerspectiveOffCenter(l, r, b, t, zn, zf)
    view = trinity.TriView()
    view.SetLookAtPosition(*viewEyeAtUp)
    return (view, projection)
コード例 #30
0
ファイル: tacticalCamera.py プロジェクト: connoryang/1v1dec
 def GetTrackingAtPosition(self):
     ballPos = GetBallPosition(self.trackBall)
     if geo2.Vec3Length(ballPos) > evecamera.LOOKATRANGE_MAX_NEW:
         direction = geo2.Vec3Normalize(
             geo2.Vec3Subtract(ballPos, self.eyePosition))
         ballPos = geo2.Vec3Add(
             self.eyePosition,
             geo2.Vec3Scale(direction, evecamera.LOOKATRANGE_MAX_NEW))
     return self.trackBallMorpher.GetValue(self.atPosition, ballPos)