【Unity3D赛车游戏】【六】如何在Unity中为汽车添加发动机和手动挡变速?

在这里插入图片描述


👨‍💻个人主页:@元宇宙-秩沅

👨‍💻 hallo 欢迎 点赞👍 收藏⭐ 留言📝 加关注✅!

👨‍💻 本文由 秩沅 原创

👨‍💻 收录于专栏:Unity游戏demo

🅰️Unity3D赛车游戏



文章目录

    • 🅰️Unity3D赛车游戏
    • 前言
      • 常见问题
    • 🎶(==A==)车辆模型——绘制发动机马力与转速曲线
        • 😶‍🌫️添加并绘制AnimationCurve 动画曲线
        • 😶‍🌫️AnimationCurve .EvaluateAPI
    • 🎶(==B==)车辆模型——发动机和手动挡位的初步实现
        • 😶‍🌫️添加发动机相关的属性
        • 😶‍🌫️更新输入控制脚本增添换挡输入
        • 😶‍🌫️换挡管理,挡位比率
    • 🎶(==C==)车辆模型——脚本记录
        • 😶‍🌫️CarMoveControl
        • 😶‍🌫️CameraContorl
        • 😶‍🌫️UIContorl
        • 😶‍🌫️ InputManager


前言


😶‍🌫️版本: Unity2021
😶‍🌫️适合人群:Unity初学者
😶‍🌫️学习目标:3D赛车游戏的基础制作
😶‍🌫️技能掌握:


常见问题


🎶(A车辆模型——绘制发动机马力与转速曲线


😶‍🌫️添加并绘制AnimationCurve 动画曲线


shift控制Y轴伸缩,ctrl控制x轴伸缩

在这里插入图片描述

  • 跑车发动机一般是7百左右,我们就按照跑车的最大功率来做
    在这里插入图片描述

😶‍🌫️AnimationCurve .EvaluateAPI


通过X轴获取Y轴值

在这里插入图片描述


🎶(B车辆模型——发动机和手动挡位的初步实现


😶‍🌫️添加发动机相关的属性


在这里插入图片描述
在这里插入图片描述

发动机功率=扭矩转速n

知识百科:说到汽车发动机,要了解几个参数。排量,功率,扭矩,转速。那么这里和参数之间的关系如何,
排量,就是发动机气缸排出气体的多少。因此说到排量,不管四缸,三缸,二缸,一缸,只要大小一样,排量就相同。
功率,单位时间内做功的多少。那么排量越大,单位时间做功就会越多,因此,排量越大,功率也会越大。
扭矩,它的单位是N·M,所以它是力运动单位距离的结果。它反应的是加速度。扭矩越大,加速能力就越强。
转速,它是单位时间内齿轮转动的圈数。齿轮转的越快,传输给轮胎的转速就越高,车子就跑的越快。

  • 关键代码
    //汽车引擎发动机相关public void CarEnginePower(){WheelRPM();//将轮轴的转速获取// 扭矩力(发动机功率) =  功率=扭矩*转速*nmotorflaot = -enginePowerCurve.Evaluate(engineRPM)* gears[gerrsNurrentNum] * InputManager.InputManagerment.vertical;float velocity = 0.0f;//发动机的转速 与 车轮转速 和 挡位比率 成比例engineRPM = Mathf.SmoothDamp(engineRPM, 1000 + Mathf.Abs(wheelsRPM) * 3.6f * (gears[gerrsNurrentNum]), ref velocity, smoothTime);print(engineRPM);VerticalContorl(); //驱动管理}

在这里插入图片描述


😶‍🌫️更新输入控制脚本增添换挡输入


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//-------------------------------------
//—————————————————————————————————————
//___________项目:       
//___________功能: 输入控制管理器
//___________创建者:秩沅_______________
//_____________________________________
//-------------------------------------
public class InputManager : MonoBehaviour
{//单例模式管理static private InputManager inputManagerment;static public InputManager InputManagerment => inputManagerment;public float horizontal;  //水平方向动力值public float vertical;    //垂直方向动力值public bool  handbanl;    //手刹动力值public bool shiftSpeed;   //加速shift键//public float clutch;    //离合器public bool addGears;     //升档public bool lowGears;     //降档void Awake(){inputManagerment = this;}void FixedUpdate(){//与Unity中输入管理器的值相互对应horizontal = Input.GetAxis("Horizontal");vertical = Input.GetAxis("Vertical");handbanl = Input.GetAxis("Jump")!= 0 ? true :false ; //按下空格键时就是1,否则为0shiftSpeed = Input.GetKey(KeyCode.LeftShift) ? true : false;//clutch   = Input.GetKey(KeyCode.LeftShift) ? 0 : Mathf.Lerp(clutch ,1,Time .deltaTime);addGears   = Input.GetKeyDown(KeyCode.E ) ? true : false;lowGears   = Input.GetKeyDown(KeyCode.Q ) ? true : false;}
}

😶‍🌫️换挡管理,挡位比率


在这里插入图片描述

    //换挡管理public void shifterGearsChange(){if(InputManager.InputManagerment .addGears ) //如果按下E键,加挡{if(gerrsNurrentNum < gears.Length - 1  )gerrsNurrentNum++;}if(InputManager.InputManagerment.lowGears ) //如果按下Q键,减档{if (gerrsNurrentNum > 0)gerrsNurrentNum--;}}

🎶(C车辆模型——脚本记录


在这里插入图片描述
在这里插入图片描述

😶‍🌫️CarMoveControl

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//-------------------------------------
//—————————————————————————————————————
//___________项目:       ______________
//___________功能:  车轮的运动
//___________创建者:_______秩沅________
//_____________________________________
//-------------------------------------//驱动模式的选择
public enum EDriveType
{frontDrive,   //前轮驱动backDrive,    //后轮驱动allDrive      //四驱
}public class CarMoveControl : MonoBehaviour
{//-------------------------------------------[Header("----------轮碰撞器特征-------------")]//四个轮子的碰撞器public WheelCollider[] wheels;[SerializeField]//网格的获取private GameObject[] wheelMesh;//四个轮胎扭矩力的大小public float f_right;public float f_left;public float b_right;public float b_left;//车轮打滑参数识别public float[] slip;//初始化三维向量和四元数private Vector3 wheelPosition = Vector3.zero;private Quaternion wheelRotation = Quaternion.identity;//-------------------------------------------//驱动模式选择 _默认前驱public EDriveType DriveType = EDriveType.frontDrive;[Header("----------车辆属性特征-------------")]//车刚体public Rigidbody rigidbody;//轮半径public float radius = 0.25f;//扭矩力度public float motorflaot = 8000f;//刹车力public float brakVualue = 800000f;//速度:每小时多少公里public int Km_H;//加速的速度增量public float shiftSpeed = 4000;//下压力public float downForceValue = 1000f;//质心public Vector3 CenterMass;[Header("----------发动机属性特征-------------")]//发动机马力与转速曲线public AnimationCurve enginePowerCurve;//车轮的RPM平均转速public float wheelsRPM;//发动机转速public float engineRPM;//汽车齿轮比(挡位)public float[] gears;//当前的挡位public int gerrsNurrentNum = 0;//差速比public float diffrirentialRation;//离合器private float clutch;//平滑时间参数private float smoothTime = 0.09f;//一些属性的初始化private void Start(){rigidbody = GetComponent<Rigidbody>();slip = new float[4];}private void FixedUpdate(){VerticalAttribute();//车辆物理属性管理WheelsAnimation(); //车轮动画CarEnginePower(); //汽车发动机HorizontalContolr(); //转向管理HandbrakControl(); //手刹管理ShiftSpeed();//加速相关}//车辆物理属性相关public void VerticalAttribute(){//---------------速度实时---------------//1m/s = 3.6km/hKm_H = (int)(rigidbody.velocity.magnitude * 3.6);Km_H = Mathf.Clamp(Km_H, 0, 200);   //油门速度为 0 到 200 Km/H之间//--------------扭矩力实时---------------//显示每个轮胎的扭矩f_right = wheels[0].motorTorque;f_left = wheels[1].motorTorque;b_right = wheels[2].motorTorque;b_left = wheels[3].motorTorque;//-------------下压力添加-----------------//速度越大,下压力越大,抓地更强rigidbody.AddForce(-transform.up * downForceValue * rigidbody.velocity.magnitude);//-------------质量中心同步----------------//质量中心越贴下,越不容易翻rigidbody.centerOfMass = CenterMass;}//垂直轴方向运动管理(驱动管理)public void VerticalContorl(){switch (DriveType){case EDriveType.frontDrive://选择前驱if (InputManager.InputManagerment.vertical != 0) //当按下WS键时生效{for (int i = 0; i < wheels.Length - 2; i++){//扭矩力度wheels[i].motorTorque = InputManager.InputManagerment.vertical * (motorflaot / 2); //扭矩马力归半}}else{for (int i = 0; i < wheels.Length - 2; i++){//扭矩力度wheels[i].motorTorque = 0;}}break;case EDriveType.backDrive://选择后驱if (InputManager.InputManagerment.vertical != 0) //当按下WS键时生效{for (int i = 2; i < wheels.Length; i++){//扭矩力度wheels[i].motorTorque = InputManager.InputManagerment.vertical * (motorflaot / 2); //扭矩马力归半}}else{for (int i = 2; i < wheels.Length; i++){//扭矩力度wheels[i].motorTorque = 0;}}break;case EDriveType.allDrive://选择四驱if (InputManager.InputManagerment.vertical != 0) //当按下WS键时生效{for (int i = 0; i < wheels.Length; i++){//扭矩力度wheels[i].motorTorque = InputManager.InputManagerment.vertical * (motorflaot / 4); //扭矩马力/4}}else{for (int i = 0; i < wheels.Length; i++){//扭矩力度wheels[i].motorTorque = 0;}}break;default:break;}}//水平轴方向运动管理(转向管理)public void HorizontalContolr(){if (InputManager.InputManagerment.horizontal > 0){//后轮距尺寸设置为1.5f ,轴距设置为2.55f ,radius 默认为6,radius 越大旋转的角度看起来越小wheels[0].steerAngle = Mathf.Rad2Deg * Mathf.Atan(2.55f / (radius + (1.5f / 2))) * InputManager.InputManagerment.horizontal;wheels[1].steerAngle = Mathf.Rad2Deg * Mathf.Atan(2.55f / (radius - (1.5f / 2))) * InputManager.InputManagerment.horizontal;}else if (InputManager.InputManagerment.horizontal < 0){wheels[0].steerAngle = Mathf.Rad2Deg * Mathf.Atan(2.55f / (radius - (1.5f / 2))) * InputManager.InputManagerment.horizontal;wheels[1].steerAngle = Mathf.Rad2Deg * Mathf.Atan(2.55f / (radius + (1.5f / 2))) * InputManager.InputManagerment.horizontal;}else{wheels[0].steerAngle = 0;wheels[1].steerAngle = 0;}}//手刹管理public void HandbrakControl(){if (InputManager.InputManagerment.handbanl){//后轮刹车wheels[2].brakeTorque = brakVualue;wheels[3].brakeTorque = brakVualue;}else{wheels[2].brakeTorque = 0;wheels[3].brakeTorque = 0;}//------------刹车效果平滑度显示------------for (int i = 0; i < slip.Length; i++){WheelHit wheelhit;wheels[i].GetGroundHit(out wheelhit);slip[i] = wheelhit.forwardSlip; //轮胎在滚动方向上打滑。加速滑移为负,制动滑为正}}//车轮动画相关public void WheelsAnimation(){for (int i = 0; i < wheels.Length; i++){//获取当前空间的车轮位置 和 角度wheels[i].GetWorldPose(out wheelPosition, out wheelRotation);//赋值给wheelMesh[i].transform.position = wheelPosition;wheelMesh[i].transform.rotation = wheelRotation * Quaternion.AngleAxis(90, Vector3.forward);}}//加速以及动画相关public void ShiftSpeed(){//按下shift加速键时if (InputManager.InputManagerment.shiftSpeed){//向前增加一个力rigidbody.AddForce(-transform.forward * shiftSpeed);}else{rigidbody.AddForce(transform.forward * 0);}}//汽车引擎发动机相关public void CarEnginePower(){WheelRPM();//将轮轴的转速获取// 扭矩力(发动机功率) =  功率=扭矩*转速*nmotorflaot = -enginePowerCurve.Evaluate(engineRPM) * gears[gerrsNurrentNum];float velocity = 0.0f;//发动机的转速 与 车轮转速 和 挡位比率 成比例engineRPM = Mathf.SmoothDamp(engineRPM, 1000 + Mathf.Abs (wheelsRPM) * 3.6f * (gears[gerrsNurrentNum]), ref velocity, smoothTime);print(engineRPM);VerticalContorl();    //驱动管理shifterGearsChange(); //换挡管理}//获得车轮的转速public void WheelRPM(){float sum = 0;for (int i = 0; i < 4; i++){sum += wheels[i].rpm;}//四个车轮轮轴的平均转速wheelsRPM = sum / 4;}//换挡管理public void shifterGearsChange(){if(InputManager.InputManagerment .addGears ) //如果按下E键,加挡{if(gerrsNurrentNum < gears.Length - 1  )gerrsNurrentNum++;}if(InputManager.InputManagerment.lowGears ) //如果按下Q键,减档{if (gerrsNurrentNum > 0)gerrsNurrentNum--;}}
}

😶‍🌫️CameraContorl

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//-------------------------------------
//—————————————————————————————————————
//___________项目:       ______________
//___________功能: 相机的管理
//___________创建者:秩沅_______________
//_____________________________________
//-------------------------------------
public class CameraContorl : MonoBehaviour
{//目标物体public Transform target;private CarMoveControl Control;public float  speed;[Header("----------相机基础属性-------------")]//鼠标滑轮的速度public float ScrollSpeed = 45f;public  float Ydictance = 0f;private float  Ymin = 0f;private float  Ymax  = 4f;public   float Zdictance = 4f;private float Zmin = 4f;private float Zmax = 15f;//相机看向的角度 和最終位置public float angle = -25 ;private Vector3 lastPosition;private Vector3 lookPosition;[Header("----------加速时相机属性-------------")]//加速时的跟随力度[Range(1, 5)]public float shiftOff;//目标视野 (让其显示可见)[SerializeField ]private float addFov;//当前视野private float startView;public float off = 20;//为一些属性初始化private void Start(){startView = Camera.main.fieldOfView; //将相机的开始属性赋入addFov = 30;}void LateUpdate(){FllowEffect(); //相机属性显示CameraAtrribute(); //相机跟随功能FOXChange();  //加速时相机视野的变化}//相机属性显示public void CameraAtrribute(){//实时速度Control = target.GetComponent<CarMoveControl>();speed = Mathf .Lerp (speed , Control.Km_H / 4 ,Time.deltaTime ) ;speed = Mathf.Clamp(speed, 0, 55);   //对应最大200公里每小时}//相机跟随功能public void FllowEffect()  {//Z轴和Y轴的距离和鼠标滑轮联系Ydictance += Input.GetAxis("Mouse ScrollWheel") * ScrollSpeed * Time.deltaTime;//平滑效果Zdictance += Input.GetAxis("Mouse ScrollWheel") * ScrollSpeed * Time.deltaTime*2;//設置Y軸和x轴的滚轮滑动范围 Ydictance = Mathf.Clamp(Ydictance, Ymin, Ymax);Zdictance = Mathf.Clamp(Zdictance, Zmin, Zmax);//确定好角度,四元数 * 三维向量 = 三维向量 和最终位置lookPosition = Quaternion.AngleAxis(angle, target.right) * -target.forward;lastPosition = target.position + Vector3.up * Ydictance - lookPosition * Zdictance;差值更新位置,速度越快镜头跟随越快,速度越慢镜头跟随越慢transform.position = lastPosition;    //更新角度transform.rotation = Quaternion.LookRotation(lookPosition);}//加速时相机视野的变化public void FOXChange(){if(Input.GetKey(KeyCode.LeftShift) ) //按下坐标shift键生效{Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView , startView + addFov ,Time .deltaTime * shiftOff );}else{Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView, startView, Time.deltaTime * shiftOff);}}}

😶‍🌫️UIContorl

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//-------------------------------------
//—————————————————————————————————————
//___________项目:       ______________
//___________功能:  UI相关的脚本管理
//___________创建者:_______秩沅________
//_____________________________________
//-------------------------------------
public class UIContorl : MonoBehaviour
{//------------------仪表盘----------------//速度指针开始角度和最终角度private float startAngel = 215, ednAngel = -35;//速度指针偏差角度private float offAngel;//获取速度的对象public CarMoveControl control;//速度指针组件public Transform node;//----------------------------------------void Update(){//偏差角度 = 每度(速度)旋转的角度 * 速度offAngel = (startAngel - ednAngel) / 180 * control.Km_H;//offAngel = (startAngel - ednAngel)  * control.engineRPM /10000;//仪表盘的管理,与速度同步node.eulerAngles = new Vector3 (0, 0, startAngel -offAngel);}
}

😶‍🌫️ InputManager

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//-------------------------------------
//—————————————————————————————————————
//___________项目:       ______________
//___________功能: 输入控制管理器
//___________创建者:秩沅_______________
//_____________________________________
//-------------------------------------
public class InputManager : MonoBehaviour
{//单例模式管理static private InputManager inputManagerment;static public InputManager InputManagerment => inputManagerment;public float horizontal;  //水平方向动力值public float vertical;    //垂直方向动力值public bool  handbanl;    //手刹动力值public bool shiftSpeed;   //加速shift键//public float clutch;    //离合器public bool addGears;     //升档public bool lowGears;     //降档void Awake(){inputManagerment = this;}void FixedUpdate(){//与Unity中输入管理器的值相互对应horizontal = Input.GetAxis("Horizontal");vertical = Input.GetAxis("Vertical");handbanl = Input.GetAxis("Jump")!= 0 ? true :false ; //按下空格键时就是1,否则为0shiftSpeed = Input.GetKey(KeyCode.LeftShift) ? true : false;//clutch   = Input.GetKey(KeyCode.LeftShift) ? 0 : Mathf.Lerp(clutch ,1,Time .deltaTime);addGears   = Input.GetKeyDown(KeyCode.E ) ? true : false;lowGears   = Input.GetKeyDown(KeyCode.Q ) ? true : false;}
}

⭐【Unityc#专题篇】之c#进阶篇】

⭐【Unityc#专题篇】之c#核心篇】

⭐【Unityc#专题篇】之c#基础篇】

⭐【Unity-c#专题篇】之c#入门篇】

【Unityc#专题篇】—进阶章题单实践练习

⭐【Unityc#专题篇】—基础章题单实践练习

【Unityc#专题篇】—核心章题单实践练习


你们的点赞👍 收藏⭐ 留言📝 关注✅是我持续创作,输出优质内容的最大动力!


在这里插入图片描述


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

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

相关文章

【【STM32分析IO该设置什么模式的问题】】

STM32分析IO该设置什么模式的问题 我们分析而言 我们对于PA0 的设计就从此而来 对于边沿触发的选择我们已经有所了解了 我们下拉&#xff0c;但是当我们摁下开关的时候 从0到1 导通了 所以这个是下拉 上升沿触发 而对于KEY0 我们摁下是使得电路从原来悬空高阻态到地就是0 所以…

龙芯2K1000LA移植交叉编译环境以及QT

嵌入式大赛结束了&#xff0c;根据这次比赛中记的凌乱的笔记&#xff0c;整理了一份龙芯2K1000LA的环境搭建过程&#xff0c;可能笔记缺少了一部分步骤或者错误&#xff0c;但是大致步骤可以当作参考。 一、交叉编译工具链 下载连接&#xff1a;龙芯 GNU 编译工具链 | 龙芯开…

几个nlp的小项目(文本分类)

几个nlp的小项目(文本分类) 导入加载数据类、评测类查看数据集精确展示数据测评方法设置参数tokenizer,token化的解释对数据集进行预处理加载预训练模型进行训练设置训练模型的参数一个根据任务名获取,测评方法的函数创建预训练模型开始训练本项目的工作完成了什么任务?导…

Flask 单元测试

如果一个软件项目没有经过测试&#xff0c;就像做的菜里没加盐一样。Flask 作为一个 Web 软件项目&#xff0c;如何做单元测试呢&#xff0c;今天我们来了解下&#xff0c;基于 unittest 的 Flask 项目的单元测试。 什么是单元测试 单元测试是软件测试的一种类型。顾名思义&a…

extern “C”关键字的作用

目录 概述C和C在函数调用和变量命名等方面的差异示例总结 概述 extern "C"是用于在C中声明使用C语言编写的函数和变量的关键字。C和C在函数调用和变量命名等方面存在一些差异&#xff0c;为了在C代码中正确地使用C语言的函数和变量&#xff0c;需要使用extern "…

Kubernetes-CKA考题详解

Kubernetes-CKA考题详解 考前须知:考试环境说明第一题:RBAC(4%)第二题:指定node设置为不可用(4%)第三题:升级kubernetes节点(7%)第四题:etcd备份还原(7%)第五题:创建NetworkPolicy(7%)第六题:创建svc(7%)第七题:创建ingress资源(7%)第八题:扩展deployme…

redis--集群

redis集群 Redis 集群是一种用于分布式存储和管理数据的解决方案&#xff0c;它允许将多个 Redis 实例组合成一个单一的逻辑数据库&#xff0c;提供更高的性能、容量和可用性。 redis集群的优点 高可用性&#xff1a; Redis集群使用主从复制和分片技术&#xff0c;使得数据可…

centos7安装hadoop 单机版

1.解压 &#xff08;1&#xff09;将hadoop压缩包复制到/opt/software路径下 &#xff08;2&#xff09;解压hadoop到/opt/module目录下 [rootkb135 software]# tar -zxvf hadoop-3.1.3.tar.gz -C /opt/module/ &#xff08;3&#xff09;修改hadoop属主和属组 [rootkb135 m…

MySQL索引 事物 存储引擎

一 索引 索引的概念 索引就是一种帮助系统能够更快速的查找信息的结构 索引的作用 索引的副作用 创建索引的规则 MySQL的优化 哪些字段/场景适合创建索引 哪些不适合 小字段唯一性强的字段更新不频繁&#xff0c;但查询率比较高的字段表记录超过 300行主键&#xff0c;外键…

【HCIP】15.MPLS基础

多协议标签交换 MPLS位于TCP/IP协议栈中的数据链路层和网络层之间&#xff0c;可以向所有网络层提供服务。 通过在数据链路层和网络层之间增加额外的MPLS头部&#xff0c;基于MPLS头部实现数据快速转发。 术语 MPLS域&#xff08;MPLS Domain&#xff09;&#xff1a;一系列…

排序算法:归并排序

约翰冯诺伊曼在 1945 年提出了归并排序。在讲解归并排序之前&#xff0c;我们先一起思考一个问题&#xff1a;如何将两个有序的列表合并成一个有序的列表&#xff1f; 将两个有序的列表合并成一个有序的列表 这太简单了&#xff0c;笔者首先想到的思路就是&#xff0c;将两个列…

【AndroidStudio】java.nio.charset.MalformedInputException: Input length = 1

java.nio.charset.MalformedInputException: Input length 1 可以参考这个文章处理下编码格式&#xff1a;https://blog.csdn.net/twotwo22222/article/details/124605029java.nio.charset.MalformedInputException: Input length 1是因为你的配置文件里面有中文或者是你的编…

结构型模式-适配器模式

适配器模式理论 将一个类的接口转换目标接口。使得原本由于接口不兼容而不能一起工作的那些类可以一起工作。 适配器模式案例 #include <iostream> #include <vector> #include <algorithm> using namespace std;//适配器模式 就是将已经写好的接口&#x…

Docker 将容器打包成镜像推送镜像到仓库

Docker 将容器打包成镜像&推送镜像到仓库 一、将容器打包成镜像 $ docker commit <容器ID> <镜像名称:标签>示例&#xff1a; $ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS …

cmd - 如何在不重启的情况下让修改后的hosts生效

cmd - 如何在不重启的情况下让修改后的hosts生效 亲测有效 一般在修改了hosts文件后&#xff0c;需要重启电脑才能生效&#xff1b;其实可以不通过重启电脑也可以令其生效&#xff0c;方法如下&#xff1a; 打开cmd窗口输入​​ipconfig /flushdns​​&#xff0c;然后回车。…

postgresql 内核源码分析 btree索引的增删查代码基本原理流程分析,索引膨胀的原因在这里

B-Tree索引代码流程分析 ​专栏内容&#xff1a; postgresql内核源码分析手写数据库toadb并发编程 ​开源贡献&#xff1a; toadb开源库 个人主页&#xff1a;我的主页 管理社区&#xff1a;开源数据库 座右铭&#xff1a;天行健&#xff0c;君子以自强不息&#xff1b;地势坤&…

对建造者模式理解

当对象成员变量太多时&#xff0c;使用建造方法给变量赋值往往变得很臃肿&#xff0c;所以可以这样做 public class Something {private String a;private String b;private String c;private String d;private String e;public Something(Builder builder) {this.a builder.…

Qt 自定义菜单 托盘菜单

托盘菜单实现&#xff1a;通过QSystemTrayIconQMenuQAction即可完美实现&#xff01; 实现方式&#xff1a;createActions用于创建菜单、菜单项,translateActions用于设置文本、实现多语化&#xff0c;translateAccount用于设置用户空间配额。 void TrayMenu::createActions(…

基于Pytorch的神经网络部分自定义设计

一、基础概念&#xff08;学习笔记&#xff09; &#xff08;1&#xff09;训练误差和泛化误差[1] 本质上&#xff0c;优化和深度学习的目标是根本不同的。前者主要关注的是最小化目标&#xff0c;后者则关注在给定有限数据量的情况下寻找合适的模型。训练误差和泛化误差通常不…

WinPlan经营大脑:精准预测,科学决策,助力企业赢得未来

近年,随着国内掀起数字化浪潮,“企业数字化转型”成为大势所趋下的必选项。但数据显示,大约79%的中小企业还处于数字化转型初期,在“企业经营管理”上存在着巨大的挑战和风险。 WinPlan经营大脑针对市场现存的企业经营管理难题,提供一站式解决方案,助力企业经营管理转型…