def SetupScene(self, hangarScene): for obj in hangarScene.objects: if hasattr(obj, 'PlayAnimationEx'): obj.PlayAnimationEx('NormalLoop', 0, 0.0, 1.0) for obj in hangarScene.objects: if '_Traffic_' in obj.name: obj.RebuildBoosterSet() trafficStartEndArea = {} for obj in hangarScene.objects: if obj.__bluetype__ == 'trinity.EveStation2': for loc in obj.locators: if 'Traffic_Start_' in loc.name or 'Traffic_End_' in loc.name: trafficStartEndArea[loc.name] = geo2.Vec3Transform( (0.0, 0.0, 0.0), loc.transform) if len(trafficStartEndArea) == 6: for obj in hangarScene.objects: if '_Traffic_' in obj.name: obj.display = False obj.translationCurve = trinity.TriVectorCurve() obj.translationCurve.keys.append(trinity.TriVectorKey()) obj.translationCurve.keys.append(trinity.TriVectorKey()) obj.rotationCurve = trinity.TriRotationCurve() if random.randint(0, 1) == 0: obj.rotationCurve.value = geo2.QuaternionRotationSetYawPitchRoll( 0.5 * math.pi, 0.0, 0.0) else: obj.rotationCurve.value = geo2.QuaternionRotationSetYawPitchRoll( -0.5 * math.pi, 0.0, 0.0) uthreadObj = uthread.new(self.AnimateTraffic, obj, trafficStartEndArea) uthreadObj.context = 'HangarTraffic::SetupScene' self.threadList.append(uthreadObj)
def Translate(self, pos): self.position = pos for each in self.pair: each.avatar.translation = pos if pos[0] < -0.5: each.avatar.rotation = geo2.QuaternionRotationSetYawPitchRoll(0.2, 0.0, 0.0) elif pos[0] > 0.5: each.avatar.rotation = geo2.QuaternionRotationSetYawPitchRoll(-0.2, 0.0, 0.0)
def ProcessInput(self): if self.CanControl(): yaw, pitch = self.controls() else: yaw, pitch = (0, 0) currentYaw, currentPitch, _ = self.curve.GetQuaternionAt(blue.os.GetSimTime()).GetYawPitchRoll() currentPitch = max(-math.pi / 2.0, min(math.pi / 2.0, currentPitch + pitch)) current = geo2.QuaternionRotationSetYawPitchRoll(currentYaw, currentPitch, 0) rotation = geo2.QuaternionRotationSetYawPitchRoll(yaw, 0, 0) result = geo2.QuaternionMultiply(rotation, current) self.direction = geo2.QuaternionTransformVector(result, (0, 0, 1)) if not self.controlling: self.controlling = bool(yaw or pitch)
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)
def NewDirectionObstacleCheck(self, destYaw, heading): entity = self.entityClient.GetPlayerEntity() gw = GameWorld.Manager.GetGameWorld(long(entity.scene.sceneID)) posComp = entity.GetComponent('position') movComp = entity.GetComponent('movement') start = posComp.position start = geo2.Vec3Add( start, (0.0, self.AVATAR_COLLISION_DETECTION_CAPSULE_HEIGHT_MOD * movComp.characterController.height, 0.0)) yaw, pitch, roll = geo2.QuaternionRotationGetYawPitchRoll( posComp.rotation) direction = geo2.QuaternionRotationSetYawPitchRoll(yaw + destYaw, 0, 0) end = heading end = geo2.QuaternionTransformVector(direction, end) direction = end = geo2.Vec3Scale( end, self.AVATAR_COLLISION_DETECTION_FEELER_LENGTH) end = geo2.Vec3Add(end, start) hitResult = gw.SweptSphere( start, end, self.AVATAR_COLLISION_DETECTION_FEELER_RADIUS) result = False if hitResult: dotProduct = geo2.Vec3Dot(direction, hitResult[1]) if abs(dotProduct) > self.AVATAR_COLLISION_RESTRICTION_ANGLE_DP: result = True return result
def GetSafeSpotTransformMatrix(self): rotQuat = geo2.QuaternionRotationSetYawPitchRoll( self.GetSafeSpotYaw(), 0, 0) rotMatrix = geo2.MatrixRotationQuaternion(rotQuat) rotMatrix = geo2.MatrixInverse(rotMatrix) transMatrix = geo2.MatrixTranslation(*self.GetSafeSpotPosition()) return geo2.MatrixMultiply(rotMatrix, transMatrix)
def TransformAccumulatedAnimFromPos(curPos, curRot, offsetTranslation, offsetYaw): offsetYaw = offsetYaw * math.pi / 180.0 trajRot = geo2.QuaternionRotationSetYawPitchRoll(offsetYaw, 0.0, 0.0) offsetPosRotated = geo2.QuaternionTransformVector(curRot, offsetTranslation) newPos = geo2.Vec3Add(curPos, offsetPosRotated) newRot = geo2.QuaternionMultiply(trajRot, curRot) return (newPos, newRot)
def NewDirectionObstacleCheck(self, destYaw, heading): """ Calculates the direction we want to move in, performs a raycast to a specified length. The compares the collision normal if there is one with the direction vector to determine if angle between them is such where we will allow the character to walk and graze the wall. """ entity = self.entityClient.GetPlayerEntity() gw = GameWorld.Manager.GetGameWorld(long(entity.scene.sceneID)) posComp = entity.GetComponent('position') movComp = entity.GetComponent('movement') start = posComp.position start = geo2.Vec3Add( start, (0.0, self.AVATAR_COLLISION_DETECTION_CAPSULE_HEIGHT_MOD * movComp.characterController.height, 0.0)) yaw, pitch, roll = geo2.QuaternionRotationGetYawPitchRoll( posComp.rotation) direction = geo2.QuaternionRotationSetYawPitchRoll(yaw + destYaw, 0, 0) end = heading end = geo2.QuaternionTransformVector(direction, end) direction = end = geo2.Vec3Scale( end, self.AVATAR_COLLISION_DETECTION_FEELER_LENGTH) end = geo2.Vec3Add(end, start) hitResult = gw.SweptSphere( start, end, self.AVATAR_COLLISION_DETECTION_FEELER_RADIUS) result = False if hitResult: dotProduct = geo2.Vec3Dot(direction, hitResult[1]) if abs(dotProduct) > self.AVATAR_COLLISION_RESTRICTION_ANGLE_DP: result = True return result
def GetStaticRotation(self): rot = self.typeData.get('dunRotation', None) if rot: yaw, pitch, roll = map(math.radians, rot) return geo2.QuaternionRotationSetYawPitchRoll(yaw, pitch, roll) else: return (0.0, 0.0, 0.0, 1.0)
def AdjustYaw(self, delta): if self.controlStyle == CONTROL_NONE: return if self._rotateAvatar: delta = min(35.0, max(-35.0, delta)) * 0.005 yaw, pitch, roll = geo2.QuaternionRotationGetYawPitchRoll( self.avatar.rotation) yaw = yaw + delta if self.maxRotation is not None and self.minRotation is not None: if yaw < math.pi: yaw = min(yaw, self.minRotation) else: yaw = max(yaw, self.maxRotation) rotation = geo2.QuaternionRotationSetYawPitchRoll(yaw, pitch, roll) self.avatar.rotation = rotation charSvc = sm.GetService('character') if uiutil.GetAttrs(charSvc, 'sculpting', 'highlightGhost', 'avatar'): charSvc.sculpting.highlightGhost.avatar.rotation = rotation if uiutil.GetAttrs(charSvc, 'sculpting', 'bodyHighlightGhost', 'avatar'): charSvc.sculpting.bodyHighlightGhost.avatar.rotation = rotation self.Update() else: cameras.PolarCamera.AdjustYaw(self, delta * 0.005)
def CreateComponent(self, name, state): """ Initializes the component with the provided state dict. If the dict is not provided you will still need to set the position, rotation and worldspaceID attributes explicitly in order for the component to behave correctly. The structure of the state dict should be as followed: "position" - position, 3 tuple describing (x,y,z) "rotation" - rotation, 4 tuple describing the rotation quaternion. NOTE: Optionally, you can pass in a 3-tuple for yaw/pitch/roll and this will be properly converted to a quaternion. """ c = GameWorld.PositionComponent() try: c.position = state['position'] except KeyError: sys.exc_clear() try: r = state['rotation'] if len(r) == 3: r = geo2.QuaternionRotationSetYawPitchRoll(*r) c.rotation = r except KeyError: sys.exc_clear() return c
def Prepare(self, spaceMgr): spaceObject.DeployableSpaceObject.Prepare(self, spaceMgr) slimItem = sm.StartService('michelle').GetBallpark().GetInvItem( self.id) shipBall = None if hasattr(slimItem, 'launcherID'): shipBall = sm.StartService('michelle').GetBall(slimItem.launcherID) if shipBall is None or not hasattr(shipBall, 'model'): if hasattr(self.model, 'modelRotationCurve'): self.model.modelRotationCurve = trinity.TriRotationCurve() quat = geo2.QuaternionRotationSetYawPitchRoll( random.random() * 6.28, random.random() * 6.28, random.random() * 6.28) self.model.modelRotationCurve.value = quat else: self.model.rotationCurve = None self.model.rotation.SetYawPitchRoll(random.random() * 6.28, random.random() * 6.28, random.random() * 6.28) self.model.display = 1 self.delayedDisplay = 0 else: self.model.rotationCurve = None if hasattr(self.model, 'modelRotationCurve'): if shipBall.model is not None: if hasattr( shipBall.model, 'modelRotationCurve' ) and shipBall.model.modelRotationCurve is not None: self.model.modelRotationCurve = shipBall.model.modelRotationCurve else: self.model.modelRotationCurve = trinity.TriRotationCurve( ) quat = geo2.QuaternionRotationSetYawPitchRoll( shipBall.yaw, shipBall.pitch, shipBall.roll) self.model.modelRotationCurve.value = quat elif shipBall.model is not None: if hasattr(shipBall.model, 'rotation'): self.model.rotation = shipBall.model.rotation else: quat = geo2.QuaternionRotationSetYawPitchRoll( shipBall.yaw, shipBall.pitch, shipBall.roll) self.model.modelRotationCurve.value = quat shipBall.wreckID = self.id self.model.display = 0 self.delayedDisplay = 1 uthread.pool('Wreck::DisplayWreck', self.DisplayWreck, 3000)
def SetRotation(self, yaw, pitch, roll): if hasattr(self.model, 'modelRotationCurve'): self.model.modelRotationCurve = trinity.TriRotationCurve() quat = geo2.QuaternionRotationSetYawPitchRoll(yaw, pitch, roll) self.model.modelRotationCurve.value = quat else: self.model.rotationCurve = None self.model.rotation.SetYawPitchRoll(yaw, pitch, roll)
def GetUprightCapsulePosAndRot(curPos, curRot, floorHeight): yaw, trash, trash = geo2.QuaternionRotationGetYawPitchRoll(curRot) rot = geo2.QuaternionRotationSetYawPitchRoll(yaw, 0, 0) pos = geo2.Vector(*curPos) adjustment = geo2.QuaternionTransformVector(curRot, adjustment) pos = pos + adjustment pos.y = floorHeight return (pos, rot)
def GetNewQuatToFacePos(sourcePos, sourceRot, targetPos): """ Get the Quaternion needed to face a target position given a source position/rotation. """ deltaAngle = GetDeltaAngleToFaceTarget(sourcePos, sourceRot, targetPos) yaw, pitch, roll = geo2.QuaternionRotationGetYawPitchRoll(sourceRot) yaw += deltaAngle return geo2.QuaternionRotationSetYawPitchRoll(yaw, pitch, roll)
def _SpawnExplosion(self, warheadIdx): if not self.model: self.LogWarn('Missile::_SpawnExplosion no model') return explosionPosition = self._GetExplosionPosition(warheadIdx) self.warheadsReleased += 1 if self.exploded: return if self.warheadsReleased == self.totalWarheadCount: if self.model: self.model.target = None self.model.explosionCallback = None self.RemoveAndClearModel(self.model, self.globalsGlob.GetScene()) self.model = None if self.delayedBall: self.globalsGlob.DestroyClientBall(self.delayedBall) self.delayedBall = None self.exploded = True actualModel = self.explosionManager.GetExplosion( self.explosionPath, preloaded=True, callback=self.CleanupExplosion) if actualModel is None: self.LogError('missile::LoadModel failed to get explosion ' + str(self.explosionPath)) self.explosionManager.Cancel(self.explosionPath, 1) return explosionBall = None if self.enabled: explosionBall = self.globalsGlob.SpawnClientBall(explosionPosition) actualModel.translationCurve = explosionBall rndRotation = geo2.QuaternionRotationSetYawPitchRoll( random.random() * 2.0 * math.pi, random.random() * 2.0 * math.pi, random.random() * 2.0 * math.pi) actualModel.rotation = rndRotation scene = self.globalsGlob.GetScene() if scene is not None: scene.objects.append(actualModel) audio = audio2.AudEmitter('effect_source_%s' % str(id(self))) obs = trinity.TriObserverLocal() obs.front = (0.0, -1.0, 0.0) obs.observer = audio del actualModel.observers[:] actualModel.observers.append(obs) def AudioSetup(*args): for eachSet in actualModel.active.curveSets: for eachCurve in eachSet.curves: if eachCurve.__typename__ == 'TriEventCurve': audio.SendEvent(eachCurve.GetKeyValue(0)) break loadedEventHandler = blue.BlueEventToPython() loadedEventHandler.handler = AudioSetup actualModel.loadedCallback = loadedEventHandler shakeMagnitude = min(actualModel.boundingSphereRadius, 250) shakeMagnitude = max(shakeMagnitude, 50) self.globalsGlob.ShakeCamera(shakeMagnitude, explosionPosition)
def SetDungeonOrigin(self): bp = sm.StartService('michelle').GetBallpark() if not bp or not bp.ego: return ego = bp.balls[bp.ego] self.dungeonOrigin = trinity.EveTransform() self.dungeonOrigin.translation = geo2.Vector(ego.x, ego.y, ego.z) self.dungeonOrigin.rotation = geo2.QuaternionRotationSetYawPitchRoll( ego.yaw, ego.pitch, ego.roll)
def ShowIntersection(self, axis=None, side=None): if axis == 'xy': q = geo2.QuaternionRotationSetYawPitchRoll(0.0, 0.0, 0.0) self.intersection.rotation = q self.intersection.display = True if side == 0: self.intersection.translation = (0.0, 0.0, -2.0) else: self.intersection.translation = (0.0, 0.0, 2.0) elif axis == 'yz': q = geo2.QuaternionRotationSetYawPitchRoll(pi * 0.5, 0.0, 0.0) self.intersection.rotation = q self.intersection.display = True if side == 0: self.intersection.translation = (-2.0, 0.0, 0.0) else: self.intersection.translation = (2.0, 0.0, 0.0) else: self.intersection.display = False
def GetSelectionRotation(self): if self.currentCursor != 'Rotation' or not len(self.selection): return geo2.Vector(0, 0, 0, 1) if self.currentHardGroup in self.hardGroupRotations: return self.GetHardGroupRotation(self.currentHardGroup) if len(self.selection) > 1: return self.groupRotation ballID = self.selection[0] if ballID in self.fakeBallTransforms: targetBall = sm.GetService('michelle').GetBall(ballID) return geo2.QuaternionRotationSetYawPitchRoll( targetBall.yaw, targetBall.pitch, targetBall.roll)
def SetBallRotation(self, ball): self.model.rotationCurve = None if getattr(ball.model, 'modelRotationCurve', None) is not None: self.model.modelRotationCurve = ball.model.modelRotationCurve else: self.model.modelRotationCurve = trinity.TriRotationCurve() quat = geo2.QuaternionRotationSetYawPitchRoll( ball.yaw, ball.pitch, ball.roll) self.model.modelRotationCurve.value = quat ball.wreckID = self.id self.model.display = 0 uthread.pool('Wreck::DisplayWreck', self.DisplayWreck, 2000)
def GetActionObjectExits(self, actionObjectID, actionStationInstanceID): exits = [] aoRows = cfg.actionObjectExits.get(actionObjectID) if aoRows is not None: rows = aoRows.get(actionStationInstanceID) if rows is not None: for row in rows: quat = geo2.QuaternionRotationSetYawPitchRoll( row.rotY, row.rotX, row.rotZ) pos = (row.posX, row.posY, row.posZ) exits.append({'pos': pos, 'rot': quat}) return exits
def ApplyParticleEffect(self, *args): if not sm.GetService('device').GetAppFeatureState('Interior.ParticlesEnabled', True): return True entityID, effectFilePath, boneName, duration, xOffset, yOffset, zOffset = args[:7] yawOffset, pitchOffset, rollOffset, ignoreTransform, effectStringID = args[7:] effectID = self._GetNextEffectID() zaction.AddPropertyForCurrentPythonProc({effectStringID: effectID}) translation = geo2.MatrixTranslation(xOffset, yOffset, zOffset) rotation = geo2.MatrixRotationYawPitchRoll(math.radians(yawOffset), math.radians(pitchOffset), math.radians(rollOffset)) offset = geo2.MatrixMultiply(rotation, translation) with self.activeParticlesSemaphore: trinityObject = trinity.Load(effectFilePath) entity = self.entityClient.FindEntityByID(entityID) scene = self.graphicClient.GetScene(entity.scene.sceneID) scene.AddDynamic(trinityObject) curveSet = None positionComponent = entity.GetComponent('position') if boneName or positionComponent: curveSet = trinity.TriCurveSet() scene.AddCurveSetToScene(curveSet) if boneName: paperDollComponent = entity.GetComponent('paperdoll') model = paperDollComponent.doll.avatar curve = trinity.Tr2BoneMatrixCurve() curve.skinnedObject = model curve.bone = boneName if not ignoreTransform: offset = geo2.MatrixMultiply(offset, trinityObject.transform) curve.transform = offset else: curve = GameWorld.PositionComponentCurve() curve.positionComponent = positionComponent curve.positionOffset = geo2.Vector(xOffset, yOffset, zOffset) curve.rotationOffset = geo2.QuaternionRotationSetYawPitchRoll(yawOffset, pitchOffset, rollOffset) bind = trinity.TriValueBinding() bind.destinationObject = trinityObject bind.destinationAttribute = 'transform' bind.sourceObject = curve bind.sourceAttribute = 'currentValue' curveSet.curves.append(curve) curveSet.bindings.append(bind) curveSet.Play() expireTime = blue.os.GetWallclockTime() + duration * const.MSEC effectData = util.KeyVal(effectID=effectID, entityID=entityID, effectFilePath=effectFilePath, expireTime=expireTime, offset=offset, trinityObject=trinityObject, sceneID=entity.scene.sceneID, curveSet=curveSet) self.activeParticleEffects[effectID] = effectData if duration > 0: self.timedParticleEffects.append(effectData) self.timedParticleEffects.sort(key=lambda entry: entry.expireTime) self.updateTaskletLock.set() self._ConnectEffectCurveSets(effectData, effectStringID) return True
def RotateSelected(self, yaw, pitch, roll): slimItems = self.GetSelObjects() if len(slimItems) == 0: return yawRad = yaw / 180.0 * math.pi pitchRad = pitch / 180.0 * math.pi rollRad = roll / 180.0 * math.pi rotationToAdd = geo2.QuaternionRotationSetYawPitchRoll( yawRad, pitchRad, rollRad) posCtr = geo2.VectorD(0, 0, 0) for slimItem in slimItems: posCtr += geo2.VectorD(slimItem.dunX, slimItem.dunY, slimItem.dunZ) geo2.Scale(posCtr, 1.0 / len(slimItems)) for slimItem in slimItems: rot = getattr(slimItem, 'dunRotation', None) slimItemRotation = geo2.QuaternionIdentity() if rot is not None: yaw, pitch, roll = rot slimItemRotation = geo2.QuaternionRotationSetYawPitchRoll( yaw / 180.0 * math.pi, pitch / 180.0 * math.pi, roll / 180.0 * math.pi) y, p, r = geo2.QuaternionRotationGetYawPitchRoll(slimItemRotation) slimItemRotation = geo2.QuaternionMultiply(rotationToAdd, slimItemRotation) y, p, r = geo2.QuaternionRotationGetYawPitchRoll(slimItemRotation) y = y / math.pi * 180.0 p = p / math.pi * 180.0 r = r / math.pi * 180.0 translation = geo2.VectorD(slimItem.dunX, slimItem.dunY, slimItem.dunZ) translation -= posCtr geo2.QuaternionTransformVector(rotationToAdd, translation) translation += posCtr dungeonHelper.SetObjectPosition(slimItem.dunObjectID, translation.x, translation.y, translation.z) dungeonHelper.SetObjectRotation(slimItem.dunObjectID, y, p, r)
def SetRandomRotation(self): if hasattr(self.model, 'modelRotationCurve'): self.model.modelRotationCurve = trinity.TriRotationCurve() quat = geo2.QuaternionRotationSetYawPitchRoll( random.random() * 6.28, random.random() * 6.28, random.random() * 6.28) self.model.modelRotationCurve.value = quat else: self.model.rotationCurve = None self.model.rotation.SetYawPitchRoll(random.random() * 6.28, random.random() * 6.28, random.random() * 6.28) self.model.display = 1
def GetTargetPlaneNormal(self, ray): if self.activeManipAxis in ('y', ): camera = sm.GetService('sceneManager').GetRegisteredCamera( 'systemmap') y, p, r = geo2.QuaternionRotationGetYawPitchRoll( camera.rotationAroundParent) q = geo2.QuaternionRotationSetYawPitchRoll(y, 0.0, 0.0) return geo2.QuaternionTransformVector(q, (0.0, 0.0, 1.0)) elif self.activeManipAxis in ('x', 'z', 'xz'): return Y_AXIS elif self.activeManipAxis in ('y', 'xy'): return Z_AXIS else: return X_AXIS
def Start(self, duration): shipID = self.ballIDs[0] shipBall = self.fxSequencer.GetBall(shipID) here = sm.GetService('map').GetItem(session.solarsystemid2) there = sm.GetService('map').GetItem(self.graphicInfo[0]) yaw, pitch = mathCommon.GetYawAndPitchAnglesRad((here.x, here.y, here.z), (there.x, there.y, there.z)) quat = geo2.QuaternionRotationSetYawPitchRoll(yaw, pitch, 0) self.gfxModel.rotation = quat if eve.session.shipid == shipID: self.playerEffect = JumpTransitionCyno() self.playerEffect.Prepare(shipBall, self.graphicInfo[0], quat) self.playerEffect.SetScene(self.fxSequencer.GetScene()) self.playerEffect.Start() ShipEffect.Start(self, duration) uthread.new(self.DelayedHide, shipBall, 180)
def GetActionObjectStations(self, actionObjectID): rows = cfg.actionObjectStations.get(actionObjectID) stations = [] if rows is not None: for row in rows: quat = geo2.QuaternionRotationSetYawPitchRoll( row.rotY, row.rotX, row.rotZ) pos = (row.posX, row.posY, row.posZ) stations.append({ 'StationID': row.actionStationTypeID, 'InstID': row.actionStationInstanceID, 'pos': pos, 'rot': quat }) return stations
def SetStaticRotation(self): if self.model is None: return self.model.rotationCurve = None rot = self.typeData.get('dunRotation', None) if rot: yaw, pitch, roll = map(math.radians, rot) quat = geo2.QuaternionRotationSetYawPitchRoll(yaw, pitch, roll) if hasattr(self.model, 'rotation'): if type(self.model.rotation) == types.TupleType: self.model.rotation = quat else: self.model.rotation.SetYawPitchRoll(yaw, pitch, roll) else: self.model.rotationCurve = trinity.TriRotationCurve() self.model.rotationCurve.value = quat
def CreateComponent(self, name, state): c = GameWorld.PositionComponent() try: c.position = state['position'] except KeyError: sys.exc_clear() try: r = state['rotation'] if len(r) == 3: r = geo2.QuaternionRotationSetYawPitchRoll(*r) c.rotation = r except KeyError: sys.exc_clear() return c
def SetupComponent(self, entity, component): positionComponent = entity.GetComponent('position') if positionComponent: component.renderObject.position = positionComponent.position if hasattr(component.renderObject, 'SetRotationYawPitchRoll'): component.renderObject.SetRotationYawPitchRoll( geo2.QuaternionRotationGetYawPitchRoll( positionComponent.rotation)) if component.useBoundingBox: rotQuat = geo2.QuaternionRotationSetYawPitchRoll( component.bbRot[1], component.bbRot[0], component.bbRot[2]) mat = geo2.MatrixTransformation(None, None, component.bbScale, None, rotQuat, component.bbPos) component.renderObject.boundingBox.transform = mat self.ApplyShadowCasterType(entity) self.ApplyPerformanceLevelLightDisable(entity)