UE5数字孪生系列笔记(三)

C++创建Pawn类玩家

  • 创建一个GameMode蓝图用来加载我们自定义的游戏Mode
  • 新建一个Pawn的C++,MyCharacter类作为玩家,新建一个相机组件与相机臂组件,box组件作为根组件
// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "MyCharacter.generated.h"UCLASS()
class CITYTWIN_API AMyCharacter : public APawn
{GENERATED_BODY()public:// Sets default values for this pawn's propertiesAMyCharacter();//box作为根组件UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")class UBoxComponent* CollisionBox;//相机组件UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")class UCameraComponent* FollowCamera;//相机臂组件UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")class USpringArmComponent* CameraBoom;protected:// Called when the game starts or when spawnedvirtual void BeginPlay() override;public:	// Called every framevirtual void Tick(float DeltaTime) override;// Called to bind functionality to inputvirtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;};
  • 声明创建组件,硬编码一些基本属性
// Fill out your copyright notice in the Description page of Project Settings.#include "MyCharacter.h"
#include "Components/BoxComponent.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"// Sets default values
AMyCharacter::AMyCharacter()
{// Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.PrimaryActorTick.bCanEverTick = true;CollisionBox = CreateDefaultSubobject<UBoxComponent>(TEXT("CollisionBox"));CollisionBox->SetupAttachment(GetRootComponent());CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));CameraBoom->SetupAttachment(CollisionBox);CameraBoom->TargetArmLength = 1500.f;CameraBoom->bUsePawnControlRotation = false;CameraBoom->bEnableCameraLag = true;//摄像机臂平滑CameraBoom->bEnableCameraRotationLag = true;//启用相机旋转延迟CameraBoom->bDoCollisionTest = false;//关闭摄像机臂碰撞FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));FollowCamera->SetupAttachment(CameraBoom);FollowCamera->bUsePawnControlRotation = false;
}// Called when the game starts or when spawned
void AMyCharacter::BeginPlay()
{Super::BeginPlay();}// Called every frame
void AMyCharacter::Tick(float DeltaTime)
{Super::Tick(DeltaTime);}// Called to bind functionality to input
void AMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{Super::SetupPlayerInputComponent(PlayerInputComponent);}
  • 创建这个Pawn类的蓝图进行之前登录页面动画的视角旋转方向问题的解决
  • 首先将蓝图生成对齐到视角
    在这里插入图片描述
  • 将Pawn类自动接收玩家0
    在这里插入图片描述
  • 然后删除PlayerStart
    在这里插入图片描述
  • 运行结果
    请添加图片描述

移动增强输入系统

  • 在项目建立.cs文件中添加这个模块
    在这里插入图片描述
  • 绑定增强输入系统操作
  • MyCharacter.h
// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "../../../../UE_5.2.1/UE_5.2/Engine/Plugins/EnhancedInput/Source/EnhancedInput/Public/InputActionValue.h"
#include "MyCharacter.generated.h"UCLASS()
class CITYTWIN_API AMyCharacter : public APawn
{GENERATED_BODY()public:// Sets default values for this pawn's propertiesAMyCharacter();//box作为根组件UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")class UBoxComponent* CollisionBox;//相机组件UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")class UCameraComponent* FollowCamera;//相机臂组件UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")class USpringArmComponent* CameraBoom;//绑定映射UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")class UInputMappingContext* MappingContext;//移动绑定UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")class UInputAction* LeftButtonAction;protected:// Called when the game starts or when spawnedvirtual void BeginPlay() override;//鼠标按下操作事件void LeftMouseDown(const FInputActionValue& value);void LeftMouseUp(const FInputActionValue& value);public:	// Called every framevirtual void Tick(float DeltaTime) override;// Called to bind functionality to inputvirtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;};
  • MyCharacter.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyCharacter.h"
#include "Components/BoxComponent.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "EnhancedInputSubsystems.h"
#include "EnhancedInputComponent.h"// Sets default values
AMyCharacter::AMyCharacter()
{// Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.PrimaryActorTick.bCanEverTick = true;CollisionBox = CreateDefaultSubobject<UBoxComponent>(TEXT("CollisionBox"));CollisionBox->SetupAttachment(GetRootComponent());CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));CameraBoom->SetupAttachment(CollisionBox);CameraBoom->TargetArmLength = 1500.f;CameraBoom->bUsePawnControlRotation = false;CameraBoom->bEnableCameraLag = true;//摄像机臂平滑CameraBoom->bEnableCameraRotationLag = true;//启用相机旋转延迟CameraBoom->bDoCollisionTest = false;//关闭摄像机臂碰撞FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));FollowCamera->SetupAttachment(CameraBoom);FollowCamera->bUsePawnControlRotation = false;
}
// Called when the game starts or when spawned
void AMyCharacter::BeginPlay()
{Super::BeginPlay();APlayerController* PlayerController = Cast<APlayerController>(Controller);if (PlayerController){UEnhancedInputLocalPlayerSubsystem* Subsystem =ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer());if (Subsystem){Subsystem->AddMappingContext(MappingContext, 0);}}
}
void AMyCharacter::LeftMouseDown(const FInputActionValue& value)
{
}void AMyCharacter::LeftMouseUp(const FInputActionValue& value)
{
}
// Called every frame
void AMyCharacter::Tick(float DeltaTime)
{Super::Tick(DeltaTime);}
// Called to bind functionality to input
void AMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{Super::SetupPlayerInputComponent(PlayerInputComponent);UEnhancedInputComponent* EnhancedInputConponent = Cast<UEnhancedInputComponent>(PlayerInputComponent);if (EnhancedInputConponent){EnhancedInputConponent->BindAction(LeftButtonAction, ETriggerEvent::Started, this, &AMyCharacter::LeftMouseDown);EnhancedInputConponent->BindAction(LeftButtonAction, ETriggerEvent::Completed, this, &AMyCharacter::LeftMouseUp);}
}

获取鼠标位置坐标与鼠标移动后的差量

  • 使用GetMousePosition函数来获取鼠标的坐标点
  • MyCharacter.h中新建一个函数专门用来获取鼠标的坐标点的函数
	//鼠标的坐标点FVector2D MousePos = FVector2D::ZeroVector;void GetMousePosition();
  • MyCharacter.cpp中实现此方法
void AMyCharacter::GetMousePosition()
{GetWorld()->GetFirstPlayerController()->GetMousePosition(MousePos.X, MousePos.Y);//打印鼠标信息到屏幕GEngine->AddOnScreenDebugMessage(-1, 1, FColor::Red, FString::Printf(TEXT("%f,%f"), MousePos.X, MousePos.Y));
}
  • 获取鼠标变化差量,当我们鼠标变化时,我们要获取到这个变化的差量值,我们可以定义两个变量,一个变量存储用来作为变化之前的绝对位置减去变化之后的当前绝对位置,然后另外两个变量来存储变化之后当前的绝对位置
	//鼠标的坐标点FVector2D MousePos = FVector2D::ZeroVector;//记录的鼠标变化差量FVector2D MouseVariationDifference = FVector2D::ZeroVector;//记录变化之后的鼠标坐标float MouseX = 0.f;float MouseY = 0.f;void AMyCharacter::GetMousePosition()
{//获取当前鼠标移动坐标GetWorld()->GetFirstPlayerController()->GetMousePosition(MousePos.X, MousePos.Y);//记录的鼠标变化差量MouseVariationDifference = MousePos - FVector2D(MouseX, MouseY);//记录变化后的鼠标位置MouseX = MousePos.X;MouseY = MousePos.Y;//打印鼠标信息到屏幕GEngine->AddOnScreenDebugMessage(1, 1, FColor::Red, FString::Printf(TEXT("%f,%f"), MousePos.X, MousePos.Y));GEngine->AddOnScreenDebugMessage(2, 1, FColor::Yellow, FString::Printf(TEXT("%f,%f"), MouseVariationDifference.X, MouseVariationDifference.Y));
}

设置滑动鼠标实现旋转视角效果

  • 通过获取的移动的鼠标差量进行鼠标滑动移动视角
  • 新建一个鼠标视角移动速度变量,用来控制鼠标实现视角旋转的移动速度
	//鼠标视角移动速度float MouseSpeed = 0.1f;
  • 新建一个鼠标视角移动函数,函数逻辑
  • ActorRotator.Pitch + (MouseVariationDifference.Y * MouseSpeed):Pitch是虚幻中的抬头与低头,在直角坐标系中用来Y来描述
  • ActorRotator.Yaw + (MouseVariationDifference.X * MouseSpeed * -1.f):Yaw是摇头转向,在直角坐标系中用来X来描述,实践中得乘以-1使用,估计是因为虚幻默认以右方向为正方向的原因
	//鼠标移动视角移动事件void MouseMove();void AMyCharacter::MouseMove()
{FRotator ActorRotator = GetActorRotation();FRotator NewActorRotator = FRotator(ActorRotator.Pitch + (MouseVariationDifference.Y * MouseSpeed),ActorRotator.Yaw + (MouseVariationDifference.X * MouseSpeed * -1.f), ActorRotator.Roll);SetActorRotation(NewActorRotator);
}
  • 调用函数
// Called every frame
void AMyCharacter::Tick(float DeltaTime)
{Super::Tick(DeltaTime);//获取鼠标坐标GetMousePosition();//鼠标移动视角MouseMove();}
  • 运行结果
    请添加图片描述

鼠标左键视觉拖动效果

  • 将滑动鼠标实现旋转视角效果设置为鼠标左键按下后才能实现
  • 添加一个布尔变量用来标识是否要开启鼠标旋转视角事情
	//标识鼠标左键是否按下bool bIsMouseLeftDown = false;void AMyCharacter::MouseMove()
{if (bIsMouseLeftDown){FRotator ActorRotator = GetActorRotation();//限制一下视角度数带来的错误FRotator NewActorRotator = FRotator(FMath::Clamp((ActorRotator.Pitch + (MouseVariationDifference.Y * MouseSpeed)),-80.f,-10.f),ActorRotator.Yaw + (MouseVariationDifference.X * MouseSpeed * -1.f), ActorRotator.Roll);SetActorRotation(NewActorRotator);}
}void AMyCharacter::LeftMouseDown(const FInputActionValue& value)
{bIsMouseLeftDown = true;
}void AMyCharacter::LeftMouseUp(const FInputActionValue& value)
{bIsMouseLeftDown = false;
}

鼠标右键视角移动效果

  • 添加右键的输入操作
    在这里插入图片描述
  • 新建右键是否按下的标识布尔变量,创建右键操作的输入行为,即绑定函数
	//移动绑定UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")class UInputAction* RightButtonAction;//标识鼠标右键是否按下bool bIsMouseRightDown = false;// Called to bind functionality to input
void AMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{Super::SetupPlayerInputComponent(PlayerInputComponent);UEnhancedInputComponent* EnhancedInputConponent = Cast<UEnhancedInputComponent>(PlayerInputComponent);if (EnhancedInputConponent){EnhancedInputConponent->BindAction(LeftButtonAction, ETriggerEvent::Started, this, &AMyCharacter::LeftMouseDown);EnhancedInputConponent->BindAction(LeftButtonAction, ETriggerEvent::Completed, this, &AMyCharacter::LeftMouseUp);EnhancedInputConponent->BindAction(RightButtonAction, ETriggerEvent::Started, this, &AMyCharacter::RightMouseDown);EnhancedInputConponent->BindAction(RightButtonAction, ETriggerEvent::Completed, this, &AMyCharacter::RightMouseUp);}
}void AMyCharacter::RightMouseDown(const FInputActionValue& value)
{bIsMouseRightDown = true;
}void AMyCharacter::RightMouseUp(const FInputActionValue& value)
{bIsMouseRightDown = false;
}
  • 新建鼠标右键移动速度变量,编写鼠标右键移动逻辑
	//鼠标右键移动速度float MouseRightSpeed = 100.f;void AMyCharacter::MouseMove()
{if (bIsMouseLeftDown){FRotator ActorRotator = GetActorRotation();//限制一下视角度数带来的错误FRotator NewActorRotator = FRotator(FMath::Clamp((ActorRotator.Pitch + (MouseVariationDifference.Y * MouseSpeed)),-80.f,-10.f),ActorRotator.Yaw + (MouseVariationDifference.X * MouseSpeed * -1.f), ActorRotator.Roll);SetActorRotation(NewActorRotator);}if (bIsMouseRightDown){FVector SpeedMove = FVector(MouseVariationDifference.Y * MouseRightSpeed,-1.0 * MouseRightSpeed * MouseVariationDifference.X, 0);AddActorLocalOffset(SpeedMove);//限制z轴FVector Location = GetActorLocation();FVector NewLocation = FVector(Location.X, Location.Y, 4520);SetActorLocation(NewLocation);}
}

鼠标中键控制摄像机臂长度,缩放地图效果

  • 新建鼠标中键的操作行为,添加一个鼠标中键移动速度变量,然后在鼠标中键操作事件中完成逻辑,逻辑是获取相机臂的长度,用获取鼠标滚轮的量值乘以鼠标中键移动速度变量被获取的相机臂原长度减去
	//移动绑定UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")class UInputAction* MiddleButtonAction;//鼠标中键移动速度float MouseMiddleSpeed = 1000.f;void AMyCharacter::MiddleMouseSlide(const FInputActionValue& value)
{float Axis = value.Get<float>();float CameraArm = CameraBoom->TargetArmLength;//限制相机臂长度CameraBoom->TargetArmLength = FMath::Clamp((CameraArm - Axis * MouseMiddleSpeed), 1000.f, 30000.f);
}
  • 运行结果
    请添加图片描述

源码

MyCharacter.h

// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "../../../../UE_5.2.1/UE_5.2/Engine/Plugins/EnhancedInput/Source/EnhancedInput/Public/InputActionValue.h"
#include "MyCharacter.generated.h"UCLASS()
class CITYTWIN_API AMyCharacter : public APawn
{GENERATED_BODY()public:// Sets default values for this pawn's propertiesAMyCharacter();//box作为根组件UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")class UBoxComponent* CollisionBox;//相机组件UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")class UCameraComponent* FollowCamera;//相机臂组件UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")class USpringArmComponent* CameraBoom;//绑定映射UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")class UInputMappingContext* MappingContext;//移动绑定UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")class UInputAction* LeftButtonAction;//移动绑定UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")class UInputAction* RightButtonAction;//移动绑定UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")class UInputAction* MiddleButtonAction;//鼠标的坐标点FVector2D MousePos = FVector2D::ZeroVector;//记录的鼠标变化差量FVector2D MouseVariationDifference = FVector2D::ZeroVector;//记录变化之后的鼠标坐标float MouseX = 0.f;float MouseY = 0.f;//鼠标视角移动速度float MouseSpeed = 0.1f;//鼠标右键移动速度float MouseRightSpeed = 100.f;//鼠标中键移动速度float MouseMiddleSpeed = 1000.f;//标识鼠标左键是否按下bool bIsMouseLeftDown = false;//标识鼠标右键是否按下bool bIsMouseRightDown = false;protected:// Called when the game starts or when spawnedvirtual void BeginPlay() override;//鼠标按下操作事件void LeftMouseDown(const FInputActionValue& value);void LeftMouseUp(const FInputActionValue& value);void RightMouseDown(const FInputActionValue& value);void RightMouseUp(const FInputActionValue& value);void MiddleMouseSlide(const FInputActionValue& value);//鼠标移动视角移动事件void MouseMove();public:	// Called every framevirtual void Tick(float DeltaTime) override;// Called to bind functionality to inputvirtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;void GetMousePosition();
};

MyCharacter.cpp

// Fill out your copyright notice in the Description page of Project Settings.#include "MyCharacter.h"
#include "Components/BoxComponent.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "EnhancedInputSubsystems.h"
#include "EnhancedInputComponent.h"
#include "Engine/Engine.h"// Sets default values
AMyCharacter::AMyCharacter()
{// Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.PrimaryActorTick.bCanEverTick = true;CollisionBox = CreateDefaultSubobject<UBoxComponent>(TEXT("CollisionBox"));CollisionBox->SetupAttachment(GetRootComponent());CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));CameraBoom->SetupAttachment(CollisionBox);CameraBoom->TargetArmLength = 1500.f;CameraBoom->bUsePawnControlRotation = false;CameraBoom->bEnableCameraLag = true;//摄像机臂平滑CameraBoom->bEnableCameraRotationLag = true;//启用相机旋转延迟CameraBoom->bDoCollisionTest = false;//关闭摄像机臂碰撞FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));FollowCamera->SetupAttachment(CameraBoom);FollowCamera->bUsePawnControlRotation = false;
}// Called when the game starts or when spawned
void AMyCharacter::BeginPlay()
{Super::BeginPlay();APlayerController* PlayerController = Cast<APlayerController>(Controller);if (PlayerController){UEnhancedInputLocalPlayerSubsystem* Subsystem =ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer());if (Subsystem){Subsystem->AddMappingContext(MappingContext, 0);}}
}void AMyCharacter::LeftMouseDown(const FInputActionValue& value)
{bIsMouseLeftDown = true;
}void AMyCharacter::LeftMouseUp(const FInputActionValue& value)
{bIsMouseLeftDown = false;
}void AMyCharacter::RightMouseDown(const FInputActionValue& value)
{bIsMouseRightDown = true;
}void AMyCharacter::RightMouseUp(const FInputActionValue& value)
{bIsMouseRightDown = false;
}void AMyCharacter::MiddleMouseSlide(const FInputActionValue& value)
{float Axis = value.Get<float>();float CameraArm = CameraBoom->TargetArmLength;//限制相机臂长度CameraBoom->TargetArmLength = FMath::Clamp((CameraArm - Axis * MouseMiddleSpeed), 1000.f, 30000.f);
}void AMyCharacter::MouseMove()
{if (bIsMouseLeftDown){FRotator ActorRotator = GetActorRotation();//限制一下视角度数带来的错误FRotator NewActorRotator = FRotator(FMath::Clamp((ActorRotator.Pitch + (MouseVariationDifference.Y * MouseSpeed)),-80.f,-10.f),ActorRotator.Yaw + (MouseVariationDifference.X * MouseSpeed * -1.f), ActorRotator.Roll);SetActorRotation(NewActorRotator);}if (bIsMouseRightDown){FVector SpeedMove = FVector(MouseVariationDifference.Y * MouseRightSpeed,-1.0 * MouseRightSpeed * MouseVariationDifference.X, 0);AddActorLocalOffset(SpeedMove);//限制z轴FVector Location = GetActorLocation();FVector NewLocation = FVector(Location.X, Location.Y, 4520);SetActorLocation(NewLocation);}
}// Called every frame
void AMyCharacter::Tick(float DeltaTime)
{Super::Tick(DeltaTime);//获取鼠标坐标GetMousePosition();//鼠标移动视角MouseMove();}// Called to bind functionality to input
void AMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{Super::SetupPlayerInputComponent(PlayerInputComponent);UEnhancedInputComponent* EnhancedInputConponent = Cast<UEnhancedInputComponent>(PlayerInputComponent);if (EnhancedInputConponent){EnhancedInputConponent->BindAction(LeftButtonAction, ETriggerEvent::Started, this, &AMyCharacter::LeftMouseDown);EnhancedInputConponent->BindAction(LeftButtonAction, ETriggerEvent::Completed, this, &AMyCharacter::LeftMouseUp);EnhancedInputConponent->BindAction(RightButtonAction, ETriggerEvent::Started, this, &AMyCharacter::RightMouseDown);EnhancedInputConponent->BindAction(RightButtonAction, ETriggerEvent::Completed, this, &AMyCharacter::RightMouseUp);EnhancedInputConponent->BindAction(MiddleButtonAction, ETriggerEvent::Triggered, this, &AMyCharacter::MiddleMouseSlide);}
}void AMyCharacter::GetMousePosition()
{//获取当前鼠标移动坐标GetWorld()->GetFirstPlayerController()->GetMousePosition(MousePos.X, MousePos.Y);//记录的鼠标变化差量MouseVariationDifference = MousePos - FVector2D(MouseX, MouseY);//记录变化后的鼠标位置MouseX = MousePos.X;MouseY = MousePos.Y;//打印鼠标信息到屏幕/*GEngine->AddOnScreenDebugMessage(1, 1, FColor::Red, FString::Printf(TEXT("%f,%f"), MousePos.X, MousePos.Y));GEngine->AddOnScreenDebugMessage(2, 1, FColor::Yellow, FString::Printf(TEXT("%f,%f"), MouseVariationDifference.X, MouseVariationDifference.Y));*/
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/577377.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

安科瑞智慧安全用电综合解决方案

概述 智慧用电管理云平台是智慧城市建设的延伸成果&#xff0c;将电力物联网技术与云平台的大数据分析功能相结合&#xff0c;实现用电信息的可视化管理&#xff0c;可帮助用户实现安全用电&#xff0c;节约用电&#xff0c;可靠用电。平台支持web&#xff0c;app&#xff0c;微…

HarmonyOS 应用开发之进程模型

系统的进程模型如下图所示。 应用中&#xff08;同一Bundle名称&#xff09;的所有UIAbility、ServiceExtensionAbility和DataShareExtensionAbility均是运行在同一个独立进程&#xff08;主进程&#xff09;中&#xff0c;如下图中绿色部分的“Main Process”。应用中&#x…

stm32定时器中断函数回调函数

方式一&#xff1a;stm32定时器中断可以直接在硬件中断函数TIM3_IRQHandler执行。 在HAL库中可以注册回调函数&#xff0c;在定时器中断发生时调用注册的函数&#xff0c;这样可以统一接口&#xff0c;大大提高函数可读性&#xff0c;和硬件解耦提高程序可移植性。 使用过程如…

爬取b站音频和视频数据,未合成一个视频

一、首先找到含有音频和视频的url地址 打开一个视频&#xff0c;刷新后&#xff0c;找到这个包&#xff0c;里面有我们所需要的数据 访问这个数据包后&#xff0c;获取字符串数据&#xff0c;用正则提取&#xff0c;再转为json字符串方便提取。 二、获得标题和音频数据后&…

Python基础:标准库 -- pprint (数据美化输出)

1. pprint 库 官方文档 pprint --- 数据美化输出 — Python 3.12.2 文档 pprint — Data pretty printer — Python 3.12.2 documentation 2. 背景 处理JSON文件或复杂的嵌套数据时&#xff0c;使用普通的 print() 函数可能不足以有效地探索数据或调试应用程序。下面通过一…

PHP实现单列内容快速查重与去重

应用场景:excel一列内容比如身份证号&#xff0c;可能有重复的&#xff0c; 则用此工具快速查询那些重复及显示去重后内容。 使用&#xff1a;粘贴一列数据&#xff0c;然后提交发送。 <?php $tm "单列查重去重(粘贴Excel中1列内容查重)!";function tipx($str…

攻防世界-baby_web

题目信息 相关知识 使用bp进行抓包 解题过程 题目界面如下所示: 试图找index界面&#xff1a; 发现又跳转到http://61.147.171.105:51201/1.php页面&#xff0c;因此说明61.147.171.105:51201/index.php是存在的&#xff08;因为笔者试了&#xff0c;不存在的页面会直接报…

Linux 常用命令(1)

&#x1f607;作者介绍&#xff1a;一个有梦想、有理想、有目标的&#xff0c;且渴望能够学有所成的追梦人。 &#x1f386;学习格言&#xff1a;不读书的人,思想就会停止。——狄德罗 ⛪️个人主页&#xff1a;进入博主主页 &#x1f5fc;专栏系列&#xff1a;Linux 随笔集合 …

第十四届蓝桥杯JavaA组省赛真题 - 特殊日期

解题思路&#xff1a; 暴力秒了 public class Main {public static void main(String[] args) {int cnt 0;for (int i 1900; i < 9999; i) {for (int j 1; j < 12; j) {for (int k 1; k < days(i, j); k) {if (sum(i) sum(j) sum(k)) cnt;}}}System.out.print…

YOLOV8逐步分解(2)_DetectionTrainer类初始化过程

接上篇文章yolov8逐步分解(1)--默认参数&超参配置文件加载继续讲解。 1. 默认配置文件加载完成后&#xff0c;创建对象trainer时&#xff0c;需要从默认配置中获取类DetectionTrainer初始化所需的参数args&#xff0c;如下所示 def train(cfgDEFAULT_CFG, use_pythonFalse…

1.5-数组-059. 螺旋矩阵 II★★

59. 螺旋矩阵II ★★ 力扣题目链接&#xff0c;给你一个正整数 n &#xff0c;生成一个包含 1 到 n 2 n^2 n2 所有元素&#xff0c;且元素按顺时针顺序螺旋排列的 n x n 正方形矩阵 matrix 。1 < n < 20 示例 1&#xff1a; 输入&#xff1a;n 3 输出&#xff1a;[[1,…

Vant Weapp小程序 van-uploader 文件上传点击无反应,删除无反应

Vant Weapp 1.0 版本开始支持van-uploader组件&#xff0c;请先确认好版本号和引用路径正确&#xff01;&#xff01; <van-uploader file-list"{{ fileList }}" deletable"{{ true }}" />1. 上传无反应 微信小程序用了van-uploader&#xff0c;但是…