4 private InputManager m_pInputmanager =
null;
5 private bool m_InputMouseRotate =
false;
6 private bool m_InputMouseWheel =
false;
8 private WorkspaceWidget m_pWorkspaceWidget =
null;
9 private float m_fZoomInput = 0;
10 private vector m_vRotationInput = vector.Zero;
12 private bool CanProcessEvent(
int x,
int y)
14 if (m_pCharacterWidget)
18 m_pCharacterWidget.GetScreenSize(sizeX, sizeY);
19 m_pCharacterWidget.GetScreenPos(posX, posY);
20 return (x >= posX && x <= posX + sizeX && y >= posY && y <= posY + sizeY);
25 private void ProcessInput()
28 const float inputResetEpsilon = 10;
29 if (m_vRotationInput[0] * m_vRotationInput[0] < inputResetEpsilon)
31 m_vRotationInput[0] = 0;
33 if (m_vRotationInput[1] * m_vRotationInput[1] < inputResetEpsilon)
35 m_vRotationInput[1] = 0;
37 if (m_fZoomInput * m_fZoomInput < inputResetEpsilon)
42 if (m_InputMouseRotate)
44 m_vRotationInput[1] = m_vRotationInput[1] + m_pInputmanager.GetActionValue(
"Inventory_InspectPanX");
46 if (m_InputMouseWheel)
48 m_fZoomInput += 0.01 * m_pInputmanager.GetActionValue(
"Inventory_InspectZoom");
51 if (m_pInputmanager.GetLastUsedInputDevice() == EInputDeviceType.GAMEPAD)
53 m_vRotationInput[1] = 100.0 * m_vRotationInput[1] + m_pInputmanager.GetActionValue(
"Inventory_InspectPanX");
54 m_fZoomInput += 0.01 * m_pInputmanager.GetActionValue(
"Inventory_InspectZoom");
59 override bool OnMouseButtonDown(Widget w,
int x,
int y,
int button)
61 if (button == 0 && w.GetName() ==
"playerRender" )
63 m_InputMouseRotate = CanProcessEvent(x, y);
69 override bool OnMouseButtonUp(Widget w,
int x,
int y,
int button)
72 m_InputMouseRotate =
false;
76 override bool OnMouseWheel(Widget w,
int x,
int y,
int wheel)
78 m_InputMouseWheel = CanProcessEvent(x, y);
85 const float rotSensitivity = 0.5;
86 const float zoomSensitivity = -64.0;
87 const bool extrapolateInput =
false;
92 vector updatedRotation =
"0 0 0";
96 const float maxRotConsume = 400;
97 const float maxZoomConsume = 1;
98 const float easing = 0.1;
100 updatedRotation[0] = Math.Clamp(m_vRotationInput[0], -maxRotConsume, maxRotConsume);
101 updatedRotation[1] = Math.Clamp(m_vRotationInput[1], -maxRotConsume, maxRotConsume);
103 float rotXDelta = Math.AbsFloat(updatedRotation[1] / maxRotConsume);
104 float rotYDelta = Math.AbsFloat(updatedRotation[0] / maxRotConsume);
106 updatedRotation[1] = updatedRotation[1] * rotXDelta * Math.Pow(rotXDelta, easing);
107 updatedRotation[0] = updatedRotation[0] * rotYDelta * Math.Pow(rotYDelta, easing);
109 zoom = Math.Clamp(m_fZoomInput, -maxZoomConsume, maxZoomConsume);
111 float zoomAlpha = Math.AbsFloat(zoom / maxZoomConsume);
112 zoom = zoom * zoomAlpha * Math.Pow(zoomAlpha, easing);
116 const float interpolationAlpha = 0.15;
118 updatedRotation[0] = m_vRotationInput[0] * interpolationAlpha;
119 updatedRotation[1] = m_vRotationInput[1] * interpolationAlpha;
120 zoom = m_fZoomInput * interpolationAlpha;
123 m_vRotationInput[0] = m_vRotationInput[0] - updatedRotation[0];
124 m_vRotationInput[1] = m_vRotationInput[1] - updatedRotation[1];
126 updatedRotation[2] = 0;
128 m_fZoomInput -= zoom;
130 updatedRotation[1] = updatedRotation[1] * ts * rotSensitivity;
131 updatedRotation[0] = updatedRotation[0] * ts * rotSensitivity;
133 zoom = zoom * ts * zoomSensitivity;
135 bool changesApplied =
false;
137 if (updatedRotation[0] * updatedRotation[0] + updatedRotation[1] * updatedRotation[1] > 0)
139 const vector limitsMin =
"-30 -180 0";
140 const vector limitsMax =
"0 180 0";
141 playerRenderAttributes.RotateItemCamera(updatedRotation, limitsMin, limitsMax);
142 changesApplied =
true;
146 playerRenderAttributes.ZoomCamera(zoom);
147 changesApplied =
true;
150 return changesApplied;
157 if (m_pWorkspaceWidget)
159 m_pWorkspaceWidget.RemoveHandler(
this );
160 m_pWorkspaceWidget.RemoveFromHierarchy();
167 if( !charWidget || !ww)
170 m_pInputmanager =
GetGame().GetInputManager();
171 m_pWorkspaceWidget = ww;
172 m_pCharacterWidget = charWidget;
173 m_pWorkspaceWidget.AddHandler(
this);