当前位置:网站首页>Digital twin: third person mouse operation
Digital twin: third person mouse operation
2022-06-10 22:38:00 【xosg】
Recently, we have made out of the box UE5 Mouse components , Copy directly into a file , Then drag it to the scene , You can use it , You can control the translation of the camera 、 rotate 、 The zoom , See the following for details demo.
Usage method :
Copy Third-Person.uasset To the project directory ( Bailai KB)
Drag and drop Third-Person To the initial position in the scene
adjustment Target Arm Length To the appropriate arm length ( Optional )
Start the game

In digital twins / Meta universe / In 3D visualization scene , The most common mode of user interaction is third person based mouse operation , This includes translation ( Move horizontally )、 rotate ( Go round an object )、 The zoom ( Forward / back off ), The following is a detailed record of the writing process .
The difference between the first person and the third person
The core difference between the first person and the third person is , Whether the person is separated from the camera : Man machine integration is the first person , Man machine separation is the third person . But anyway , figure (pawn) With the camera (camera) As a whole , The origin and rotation center of the object are located on the person , The distance between the person and the camera is called arm length ( Spring arm used spring arm), A change in arm length is called scaling (zoom).
| The correspondence between keyboard and mouse operation and geometric transformation | |
| left-click +X Axis | Move along the weft line |
| left-click +Y Axis | Move along the longitude |
| Right click +X Axis 、 keyboard AD | Or so mobile |
| Right click +Y Axis | Move back and forth ( level ) |
| Mouse wheel 、 keyboard WS | Move back and forth |
| Press the mouse wheel | Fly to the target position |
| keyboard QE | Move up and down |
| keyboard ZC | adjustment FoV size |
Blueprint structure

The blueprint type is a pawn, The root element is a spring arm (spring arm), such zoom When the arm Length can , Very convenient . A camera hangs under the spring arm , Hang a light under the camera , In case of moving to an enclosed space , It can illuminate the surroundings , Finally, add one more Floating Pawn Movement, It makes sports more “ inertia ”.
Activate the mouse

pawn The mouse cursor should be displayed during initialization , And enable click events , Only in this way can subsequent operations be meaningful .
Back and Forward (zoom)

Because the orientation of the camera is always collinear with the spring arm , So the camera is always facing pawn, Moving forward means shortening the arm length ( near pawn), Backward means to extend the arm length ( Stay away from pawn), The common practice of digital twins is to use the mouse wheel 2 Two directions to represent zoom, So we have the logic in the diagram : If it is detected that the roller is moving forward, multiply the arm length by 0.9, If the roller moves backward, multiply the arm length by 1.1, The speed of such scaling is positively related to the length of the arm length , Finally, limit the arm length to 1m To 1km Between , It meets our needs .
Instant movement

Usually players also need to fly quickly to the place where the mouse clicks , So use the middle mouse button as a jump button , Emit a ray to lock the click position , Fly over again , Because there is FloatingPawnMovement The existence of , It's not “ teleport ” In the past , But in a few hundred milliseconds , Better user experience .
Rotate around the object (orbit)

An important difference between 3D visualization and role-playing games is , The former revolves around the object , The latter revolves around itself , This is also the difference between the third person and the first person . Rotating around an object can be abstracted into a longitude and latitude network : The center of a sphere is an object , The arm length is the radius , Camera's yaw( Weft ) and pitch( Meridians ) They all move on a sphere .

The object around is pawn In itself , And focus , When the camera rotates , The object rotates with it , It's just that they all rotate around the focus . We play third person RPG In the game , The camera is always behind the characters , When rotating , The character turns in place , But the camera follows the trajectory (orbit).

Because the virtual sphere is two-dimensional , So the camera rotation is also two-dimensional , Only Elevation( Lifting ) And Azimuth( Horizontal rotation ) These two dimensions ( The mouse pad is also two-dimensional ), For the ahead pawn That is to say Pitch( pitch ) and Yaw( Yaw ), The essence is the same .

Final , The camera moves like this , Used so many vivid pictures , Have you learned ?

We use left - or right-click drag to achieve , The code is simple : A continuous parameter that is directly input with a two digit mouse (Mouse XY 2D-Axis) Convert to its own rotation increment .

Move horizontally
Mentioned earlier , The mouse pad is two-dimensional , But three-dimensional rotation has 3 Dimensions , So one dimension must be sacrificed , So the camera can only yaw (yaw)、 pitch (pitch), Unable to roll (roll). Empathy , Three dimensional movement also has 3 Dimensions (x、y、z), The mouse can only realize horizontal translation (x、y), Discard the vertical movement (z).

When the mouse moves along the horizontal axis , Just need to make pawn Along its own coordinate system Y Just move the axis , But when the vertical axis of the mouse moves , It's a little more complicated ,pawn You need to move along the horizontal line of the world in front of you , That is, when pitching , The intersection of the plane swept by the spring arm and the horizontal plane , Then calculate the line's position in its own coordinate system X、Z component ( And Y The axis is vertical ). Then you have the blueprint code in the figure above .
There's another thing to be aware of , Want to Third-Person.uasset Drag directly into the scene to use , Must be on “ Automatic activation ” The option to :Auto Process Player

边栏推荐
- Management solution for whale conference smart scenic spot
- 【TcaplusDB知识库】TcaplusDB推送配置介绍
- Different ways to create four indexes in MySQL
- Differences between disk serial number, disk ID and volume serial number
- [py] the failure of interface signature verification may be due to ensure_ ASCII problems
- GMPNN:Drug-drug interaction prediction with learnable size-adaptive molecular substructures.
- Solution de gestion de la zone pittoresque intelligente pour la réunion des baleines
- Back to table query of MySQL? How to avoid it?
- QT custom delegation
- 在D天内送达包裹的能力[抽象类二分--抽象判定方式]
猜你喜欢

What are MySQL clustered indexes and nonclustered indexes?

Opencv_100问_第三章 (11-15)

鯨會務智慧景區管理解决方案

C语言内功修炼【整型在内存中的存储】

Latex error: file ‘xxx.sty‘ not found

Latex error: file ‘xxx. sty‘ not found

GMPNN:Drug-drug interaction prediction with learnable size-adaptive molecular substructures.

leetcode 130. Surrounded Regions 被围绕的区域(中等)

Mmcv Config class introduction

Modify frontsortinglayer variable of spritemask
随机推荐
[applet] the vant wearp radio radio radio component cannot trigger the bind:change event
Modify frontsortinglayer variable of spritemask
【Py】接口签名校验失败可能是由于ensure_ascii的问题
【TcaplusDB知识库】TcaplusDB巡检统计介绍
Latex error: file ‘xxx.sty‘ not found
笔记(五)- JVM
鲸会务为智能化防疫工作赋能
[debug] could not find ref wiht POC XXX
Opencv_100问_第三章 (11-15)
鯨會務智慧景區管理解决方案
A number that appears only once in an array
dc_labs--lab1的学习与总结
【TcaplusDB知识库】TcaplusDB机器初始化和上架介绍
Innovation and exploration are added layer by layer, and the field model of intelligent process mining tends to be mature
LeetCode - 5. Longest Palindromic Substring
Ability to deliver packages within D days [abstract class dichotomy -- Abstract judgment method]
Shell基础概念
How small and micro enterprises build micro official websites at low cost
C语言内功修炼【整型在内存中的存储】
TcaplusDB君 · 行业新闻汇编(一)