Interhaptics SDK for Unity 1.6
Loading...
Searching...
No Matches
HapticBodyPart.cs
Go to the documentation of this file.
1/* ​
2* Copyright (c) 2023 Go Touch VR SAS. All rights reserved. ​
3* ​
4*/
5
6using UnityEngine;
7using System.Collections.Generic;
10
11namespace Interhaptics
12{
13 [UnityEngine.AddComponentMenu("Interhaptics/HapticBodyPart")]
14 public class HapticBodyPart : MonoBehaviour
15 {
16
17 public GroupID BodyPart = GroupID.Hand;
18 public LateralFlag Side = LateralFlag.Global;
19
20 public List<CommandData> ToCommandData()
21 {
22 return new List<CommandData> { new CommandData(Operator.Plus, this.BodyPart, this.Side) };
23 }
24
25 public bool debugMode = false;
26 public int HapticMaterialId { get; set; }
27 [SerializeField]
28 private double targetIntensity = 1;
29
30 // Property for targetIntensity with a getter and a setter
31 public double TargetIntensity
32 {
33 get => targetIntensity;
34 set
35 {
36 targetIntensity = value;
37 }
38 }
39
40 public void DebugMode(string debugMessage)
41 {
42 if (debugMode)
43 {
44 Debug.Log(debugMessage);
45 }
46 }
47 public void UpdateTargetIntensity(double targetIntensityValue)
48 {
49 targetIntensity = targetIntensityValue;
50 // Create the CommandData array for this HapticBodyPart
51 CommandData[] commandDataArray = ToCommandData().ToArray();
52 // Update the target intensity for this HapticBodyPart
53 HAR.SetTargetIntensityMarshal(HapticMaterialId, commandDataArray, commandDataArray.Length, targetIntensity);
54 DebugMode("UpdateTargetIntensity: " + targetIntensity);
55 }
56
57 }
58}
59
void DebugMode(string debugMessage)
void UpdateTargetIntensity(double targetIntensityValue)
List< CommandData > ToCommandData()
GroupID
Enumeration for group identification in haptic command data.
Operator
Enumeration for operator signs in haptic command data.
LateralFlag
Enumeration for lateral flag in haptic command data.
Structure for command data in haptic systems.