Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

МІНІСТЕРСТВО ОСВІТИ І НАУКИ УКРАЇНИ

СУМСЬКИЙ ДЕРЖАВНИЙ УНІВЕРСИТЕТ


КАФЕДРА ІНФОРМАЦІЙНИХ ТЕХНОЛОГІЙ

ЗВІТ З ЛАБОРАТОРНОЇ РОБОТИ №8


З дисципліни
«Комп’ютерна графіка реального часу»

Виконав: студент групи ІТм-11н


Проценко М.О.

Перевірив: Федотова Н.А.

2022
Порядок виконання:

Part 1:

Using the base project for this week, add haptic feedback to the lever.

1. Open the WorldInteractor (Blueprints -> InteractiveObjects).


2. To trigger the haptics in the lever each interactor will need to know what
hand it is attached to. To do this first create a new EController Hand variable
named Hand. This is the same Enum that the motion controller Components
use.
3. Set the Hand variable to Private.
This allows you to control access to the variable more.

4. In the Event Graph, create an Event Begin Play node.


5. Get this Component's parent by using the Get Attach Parent function.
6. Cast the Component’s parent to a MotionControllerComponent. (figure
1)
7. Drag off the As Motion Controller Component and get the Hand
variable.
8. Attach this getter to a new setter of this Component’s Hand variable.
This makes it so that if the World Interactor is attached to a motion controller, it
automatically gets the hand that it represents.

Because the Hand variable is private, you need a way to access it in other
Blueprints.

1. Create a new function named GetHand and mark it Pure.


2. Add a reference to the Hand variable and drag it to the Return Value node.
This creates a new return value and automatically sets the type.
The first step in adding haptic effects in UE4 is creating a new Haptic Feedback
Effect Curve

1. In the Blueprints folder, create a new folder named HapticEffects.


2. Create a new Haptic Feedback Effect Curve (Add New ->
Miscellaneous), and name this effect BasicHapticEffect. Place it in the
HapticEffects folder. (figure 2)
3. Set the frequency to a constant 1 (Shift + Click on the Frequency graph).
Haptic Feedback Effects have a frequency and an amplitude.
4. For the Amplitude, create three new key frames in the graph (Shift + Click
on the Frequency graph).
5. Set the times and values on the keyframes:
 First keyframe – time 0, value 0
 Second keyframe – time 0.125, value 1
 Third keyframe – time 0.25, value 0
1. Access the lever Blueprint (Blueprints -> InteractiveObjects ->
InteractiveLever).
2. After the setting of the initial lever rotation on Begin Play, drag in the
Pulled Event Dispatcher and choose Assign.
This creates a new Bind node and an Event automatically assigned to it.
(figure 3)

1. Call Get Player Controller to get a reference to the local player controller.
2. Drag off the return value for this node and call the Play Haptic Event
function.
3. Select the Haptic Effect you created as the Haptic Effect input to this node.
4. Get a reference to the Current Interactor Component variable, call the
Get Hand function on it and pass the output to the Hand input of the
haptic effect.
Part 2:

1. Using the project from the previous exercise as a base, create a new
Blueprint based on an Actor named InteractiveDrawer and place it in the
InteractiveObjects subfolder.
To represent the mesh of the drawer, a static mesh has been created using a
third-party tool.
2. Drag the Drawer mesh from the Meshes folder into the Blueprint’s
Component hierarchy. Make sure to enable Physics on this Static Mesh
Component.
3. Create a new Physics Constraint Component and set the Component
Name 1 to Drawer.
This ensures that the constraint affects the drawer mesh.

4. Set the XMotion Linear Limit to Limited and the Limit to 20.
This ensures that the drawer can only move in the local X direction by 20
units.
5. Expand the advanced options on the Linear Limits section and set the
Restitution to 0.05.

1. Set all the Angular Limits to Locked


1. Add a new Physics Handle Component. Leave it at its defaults.
2. Access the Class Settings and implement the World Interaction Interface.
3. Create a new variable named CurrentInteractor, with a type of
WorldInteractor.
This will be used later to handle the current interactor state.
4. In the Event Graph, drag off the Event BeginPlay node and call the Set
Constraint Reference Position function on the Physics Constraint
component.
5. Input the vector (X = -20, Y = 0, X = 0).
6. Open the On Drag Start Interface function and set the Current Interactor
variable to the Interactor input.
7. Create a reference to the Physics Handle Component, call the Grab
Component at Location function and pass in the Drawer Mesh
Component to the Component input.
8. Get the world location of the Current Interactor and pass that into the
Grab Location.
This makes the physics handle grab the drawer at the interactor location.

9. Open the On Drag End interface function and check that the Interactor
input equals the Current Interactor variable. If true, then call the Release
Component function on the physics handle. (figure 7)
This makes it so only the hand that is moving the drawer can release it.

1. Open the On Drag Interface function and check that the Current
Interactor variable is the Interactor input. If true, then call the Set Target
Location function on the physics handle and pass in the world location of
the Current Interactor variable.
This updates the physics handle’s location every frame that you are dragging
the drawer.

You might also like