-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathStageLight.cpp
675 lines (560 loc) · 19.5 KB
/
StageLight.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
#include "StageLight.h"
#include "tinyxml2.h"
#include <vector>
#include <algorithm>
std::vector<GTAObject> sceneDirectorLightObject = {
getGTAObjectFromObjName("prop_sd_spot_01"),
getGTAObjectFromObjName("prop_sd_spot_02"),
getGTAObjectFromObjName("prop_sd_spot_03"),
getGTAObjectFromObjName("prop_sd_spot_04"),
getGTAObjectFromObjName("prop_sd_spot_05"),
getGTAObjectFromObjName("prop_sd_spot_06"),
getGTAObjectFromObjName("prop_sd_spot_07"),
getGTAObjectFromObjName("prop_sd_spot_08"),
getGTAObjectFromObjName("prop_sd_spot_09"),
getGTAObjectFromObjName("prop_sd_spot_10"),
getGTAObjectFromObjName("prop_sd_spot_11"),
getGTAObjectFromObjName("prop_sd_spot_12"),
getGTAObjectFromObjName("prop_sd_spot_13"),
getGTAObjectFromObjName("prop_sd_spot_14"),
getGTAObjectFromObjName("prop_sd_spot_15"),
};
std::string stageLightConfigFileName = "SceneDirectorStageLights_config.xml";
std::vector<StageLightRotationType> stageLightRotationTypes = { { "None", true } };
std::vector<StageLightMovementType> stageLightMovementTypes = { { "None", true } };
std::vector<StageLightFlickerType> stageLightFlickerTypes = { { "None", true } };
std::vector<GTAObject> getSceneDirectorLightObject() {
return sceneDirectorLightObject;
}
GTAObject getDefaultSceneDirectorLightObject() {
return getGTAObjectFromObjName("prop_sd_spot_01");
}
GTAObject getNextSceneDirectorLightObject(GTAObject lightObject) {
//see http://stackoverflow.com/questions/14225932/search-for-a-struct-item-in-a-vector-by-member-data
int foundIndex = std::find_if(sceneDirectorLightObject.begin(), sceneDirectorLightObject.end(), [=](GTAObject const& aLightObject) {
return (aLightObject.title.compare(lightObject.title) ==0) ;
}) - sceneDirectorLightObject.begin();
if (foundIndex + 1 >= sceneDirectorLightObject.size()) {//aLightObject not found or in last element
return sceneDirectorLightObject[0];
}
else {
return sceneDirectorLightObject[foundIndex + 1];
}
}
std::vector<StageLightRotationType> getStageLightRotationTypes()
{
return stageLightRotationTypes;
}
StageLightRotationType getDefaultStageLightRotationType()
{
return stageLightRotationTypes[0];
}
StageLightRotationType getNextStageLightRotationType(StageLightRotationType stageLightEvent)
{
//see http://stackoverflow.com/questions/14225932/search-for-a-struct-item-in-a-vector-by-member-data
int foundIndex = std::find_if(stageLightRotationTypes.begin(), stageLightRotationTypes.end(), [=](StageLightRotationType const& aStageLightEvent) {
return (aStageLightEvent.name.compare(stageLightEvent.name) == 0);
}) - stageLightRotationTypes.begin();
if (foundIndex + 1 >= stageLightRotationTypes.size()) {//aLightObject not found or in last element
return stageLightRotationTypes[0];
}
else {
return stageLightRotationTypes[foundIndex + 1];
}
}
std::vector<StageLightMovementType> getStageLightMovementTypes()
{
return stageLightMovementTypes;
}
StageLightMovementType getDefaultStageLightMovementType()
{
return stageLightMovementTypes[0];
}
StageLightMovementType getNextStageLightMovementType(StageLightMovementType stageLightEvent)
{
//see http://stackoverflow.com/questions/14225932/search-for-a-struct-item-in-a-vector-by-member-data
int foundIndex = std::find_if(stageLightMovementTypes.begin(), stageLightMovementTypes.end(), [=](StageLightMovementType const& aStageLightEvent) {
return (aStageLightEvent.name.compare(stageLightEvent.name) == 0);
}) - stageLightMovementTypes.begin();
if (foundIndex + 1 >= stageLightMovementTypes.size()) {//aLightObject not found or in last element
return stageLightMovementTypes[0];
}
else {
return stageLightMovementTypes[foundIndex + 1];
}
}
std::vector<StageLightFlickerType> getStageLightFlickerTypes()
{
return stageLightFlickerTypes;
}
StageLightFlickerType getDefaultStageLightFlickerType()
{
return stageLightFlickerTypes[0];
}
StageLightFlickerType getNextStageLightFlickerType(StageLightFlickerType stageLightEvent)
{
//see http://stackoverflow.com/questions/14225932/search-for-a-struct-item-in-a-vector-by-member-data
int foundIndex = std::find_if(stageLightFlickerTypes.begin(), stageLightFlickerTypes.end(), [=](StageLightFlickerType const& aStageLightEvent) {
return (aStageLightEvent.name.compare(stageLightEvent.name) == 0);
}) - stageLightFlickerTypes.begin();
log_to_file("NextFlicker size " + std::to_string(stageLightFlickerTypes.size()) + " found index : "+std::to_string(foundIndex));
if (foundIndex + 1 >= stageLightFlickerTypes.size()) {
return stageLightFlickerTypes[0];
}
else {
return stageLightFlickerTypes[foundIndex + 1];
}
}
void initializeStageLights()
{
log_to_file("initializeStageLights");
tinyxml2::XMLDocument doc = new tinyxml2::XMLDocument();
doc.LoadFile(stageLightConfigFileName.c_str());
if (doc.Error()) {
set_status_text("Save file " + stageLightConfigFileName + " could not be loaded. Error: " + doc.ErrorName());
return;
}
stageLightFlickerTypes.clear();
stageLightRotationTypes.clear();
stageLightMovementTypes.clear();
//Start with None null object
stageLightFlickerTypes.push_back({ "None", true });
stageLightRotationTypes.push_back({ "None",true });
stageLightMovementTypes.push_back({ "None",true });
tinyxml2::XMLElement* sceneDirectorElement = doc.RootElement();
for (tinyxml2::XMLElement* flickerTypeElement = sceneDirectorElement->FirstChildElement("FlickerType");
flickerTypeElement;
flickerTypeElement = flickerTypeElement->NextSiblingElement("FlickerType"))
{
StageLightFlickerType flickerType;
flickerType.name = flickerTypeElement->Attribute("name");
flickerType.isNull = false;
log_to_file("FlickerType " + flickerType.name);
std::vector<StageLightFlicker> lightEvents;
for (tinyxml2::XMLElement* flickerElement = flickerTypeElement->FirstChildElement("Flicker");
flickerElement;
flickerElement = flickerElement->NextSiblingElement("Flicker"))
{
StageLightFlicker flickerEvent;
flickerEvent.isOn = true;
int length = 10000;
tinyxml2::XMLError result = flickerElement->QueryIntAttribute("on", &length);
if (result == tinyxml2::XML_NO_ATTRIBUTE) {
tinyxml2::XMLError result = flickerElement->QueryIntAttribute("off", &length);
flickerEvent.isOn = false;
}
flickerEvent.length = length;
lightEvents.push_back(flickerEvent);
}
flickerType.flickerEvents = lightEvents;
stageLightFlickerTypes.push_back(flickerType);
}
for (tinyxml2::XMLElement* rotationTypeElement = sceneDirectorElement->FirstChildElement("RotationType");
rotationTypeElement;
rotationTypeElement = rotationTypeElement->NextSiblingElement("RotationType"))
{
StageLightRotationType rotationType;
rotationType.name = rotationTypeElement->Attribute("name");
rotationType.isNull = false;
std::vector<StageLightRotation> lightEvents;
for (tinyxml2::XMLElement* rotationElement = rotationTypeElement->FirstChildElement("Rotation");
rotationElement;
rotationElement = rotationElement->NextSiblingElement("Rotation"))
{
StageLightRotation rotationEvent;
rotationEvent.hasPitch = true;
rotationEvent.hasYaw = true;
float pitch = 0;
tinyxml2::XMLError result = rotationElement->QueryFloatAttribute("pitch", &pitch);
if (result == tinyxml2::XML_NO_ATTRIBUTE) {
rotationEvent.hasPitch = false;
}
else {
rotationEvent.pitch = pitch;
}
float yaw = 0;
result = rotationElement->QueryFloatAttribute("yaw", &yaw);
if (result == tinyxml2::XML_NO_ATTRIBUTE) {
rotationEvent.hasYaw = false;
}
else {
rotationEvent.yaw = yaw;
}
int length = rotationElement->IntAttribute("length");
rotationEvent.length = length;
lightEvents.push_back(rotationEvent);
}
rotationType.rotationEvents = lightEvents;
stageLightRotationTypes.push_back(rotationType);
}
for (tinyxml2::XMLElement* movementTypeElement = sceneDirectorElement->FirstChildElement("MovementType");
movementTypeElement;
movementTypeElement = movementTypeElement->NextSiblingElement("MovementType"))
{
StageLightMovementType movementType;
movementType.name = movementTypeElement->Attribute("name");
movementType.isNull = false;
std::vector<StageLightMovement> lightEvents;
for (tinyxml2::XMLElement* movementElement = movementTypeElement->FirstChildElement("Movement");
movementElement;
movementElement = movementElement->NextSiblingElement("Movement"))
{
StageLightMovement movementEvent;
Vector3 movementDelta;
float x = 0.0, y = 0.0, z = 0.0;
movementElement->QueryFloatAttribute("x", &x);
movementElement->QueryFloatAttribute("y", &y);
movementElement->QueryFloatAttribute("z", &z);
movementDelta.x = x;
movementDelta.y = y;
movementDelta.z = z;
int length = movementElement->IntAttribute("length");
movementEvent.length = length;
movementEvent.movementDelta = movementDelta;
float xyRatio = 0.0;
tinyxml2::XMLError result = movementElement->QueryFloatAttribute("xyRatio", &xyRatio);
if (result == tinyxml2::XML_SUCCESS) {
movementEvent.hasxyRatio = true;
movementEvent.xyRatio = xyRatio;
}
else {
movementEvent.hasxyRatio = false;
}
float yxRatio = 0.0;
result = movementElement->QueryFloatAttribute("yxRatio", &xyRatio);
if (result == tinyxml2::XML_SUCCESS) {
movementEvent.hasyxRatio = true;
movementEvent.yxRatio = yxRatio;
}
else {
movementEvent.hasyxRatio = false;
}
lightEvents.push_back(movementEvent);
}
movementType.movementEvents = lightEvents;
stageLightMovementTypes.push_back(movementType);
}
}
void StageLight::moveLight(Vector3 lightPosition)
{
m_lightPosition = lightPosition;
//update current position (rotation ignored for now)
if (m_lightObject.objReference != 0) {
ENTITY::SET_ENTITY_COORDS_NO_OFFSET(m_lightObject.objReference, m_lightPosition.x, m_lightPosition.y, m_lightPosition.z, 0, 0, 1);
}
}
void StageLight::moveInitialPosOfLight(Vector3 lightPosition)
{
m_initialLightPosition = lightPosition;
moveLight(m_initialLightPosition);
}
void StageLight::rotateLight(Vector3 lightRotation)
{
m_lightRotation = lightRotation;
//update current position (rotation ignored for now)
if (m_lightObject.objReference != 0) {
ENTITY::SET_ENTITY_ROTATION(m_lightObject.objReference, m_lightRotation.x + 180, 0, m_lightRotation.z, 2, true);
//log_to_file("Rotating light pitch:" + std::to_string(m_lightRotation.x + 180) + " yaw:"+ std::to_string(m_lightRotation.z));
}
}
void StageLight::rotateInitialRotationOfLight(Vector3 lightRotation)
{
m_initialLightRotation = lightRotation;
rotateLight(m_initialLightRotation);
}
void StageLight::swapLightObject(GTAObject newLightObject)
{
//update current position and rotation
if (m_lightObject.objReference == 0) {
Vector3 currentPosition = ENTITY::GET_ENTITY_COORDS(m_lightObject.objReference, true);
m_lightPosition = currentPosition;
}
//delete old object
if (m_lightObject.objReference != 0) {
OBJECT::DELETE_OBJECT(&m_lightObject.objReference);
}
m_lightObject = newLightObject;
//create object
if (m_lightObject.objHash == -1) {
m_lightObject.objHash = GAMEPLAY::GET_HASH_KEY(m_lightObject.objName);
}
STREAMING::REQUEST_MODEL(m_lightObject.objHash);
DWORD ticksStart = GetTickCount();
while (!STREAMING::HAS_MODEL_LOADED(m_lightObject.objHash))
{
WAIT(0);
if (GetTickCount() - ticksStart > 5000) {
log_to_file("Failed to load GTAObject name:" + std::string(m_lightObject.objName) + " Hash:" + std::to_string(m_lightObject.objHash));
set_status_text("Failed to load objects");
return;
}
}
int newObjectRef = OBJECT::CREATE_OBJECT(m_lightObject.objHash, m_lightPosition.x, m_lightPosition.y, m_lightPosition.z, true, true, false);
ENTITY::SET_ENTITY_ROTATION(newObjectRef, m_lightRotation.x + 180, 0, m_lightRotation.z, 2, true);
m_lightObject.objReference = newObjectRef;
}
void StageLight::resetToInitial()
{
moveLight(m_initialLightPosition);
if (m_lightRotation.x != m_initialLightRotation.x || m_lightRotation.z != m_initialLightRotation.z) {
rotateLight(m_initialLightRotation);
}
m_flickerStart = 0;
m_flickerIndex = 0;
m_rotationStart = 0;
m_rotationIndex = 0;
m_movementStart = 0;
m_movementIndex = 0;
}
void StageLight::setHasFlicker(std::vector<StageLightFlicker> flickerEvents)
{
m_hasFlicker = true;
m_flickerEvents = flickerEvents;
}
std::vector<StageLightFlicker> StageLight::getFlickerEvents()
{
return m_flickerEvents;
}
void StageLight::stopFlicker()
{
m_hasFlicker = false;
}
StageLight::StageLight(Vector3 lightPosition, Vector3 lightRotation, GTAObject lightObject)
{
m_lightPosition = lightPosition;
m_lightRotation = lightRotation;
m_lightObject = lightObject;
m_initialLightPosition = m_lightPosition;
m_initialLightRotation = m_lightRotation;
//create object
if (m_lightObject.objReference == 0) {
if (m_lightObject.objHash == -1) {
m_lightObject.objHash = GAMEPLAY::GET_HASH_KEY(m_lightObject.objName);
}
STREAMING::REQUEST_MODEL(m_lightObject.objHash);
DWORD ticksStart = GetTickCount();
while (!STREAMING::HAS_MODEL_LOADED(m_lightObject.objHash))
{
WAIT(0);
if (GetTickCount() - ticksStart > 5000) {
log_to_file("Failed to load GTAObject name:" + std::string(m_lightObject.objName) + " Hash:" + std::to_string(m_lightObject.objHash));
set_status_text("Failed to load objects");
return;
}
}
int newObjectRef = OBJECT::CREATE_OBJECT(m_lightObject.objHash, m_lightPosition.x, m_lightPosition.y, m_lightPosition.z, true, true, false);
m_lightObject.objReference = newObjectRef;
ENTITY::SET_ENTITY_AS_MISSION_ENTITY(newObjectRef, true, true);
ENTITY::SET_ENTITY_ROTATION(newObjectRef, m_lightRotation.x+180, 0, m_lightRotation.z, 2, true);
log_to_file("Init light rotation pitch:" + std::to_string(m_lightRotation.x + 180) + " yaw:" + std::to_string(m_lightRotation.z));
}
}
void StageLight::startTrackActor(Actor actor, int actorIndex)
{
m_doTrackPed = true;
m_trackPedId = actor.getActorPed();
m_trackActorIndex = actorIndex;
Vector3 currentActorPosition = ENTITY::GET_ENTITY_COORDS(m_trackPedId, true);
m_trackOffset.x = m_lightPosition.x - currentActorPosition.x;
m_trackOffset.y = m_lightPosition.y - currentActorPosition.y;
m_trackOffset.z = m_lightPosition.z - currentActorPosition.z;
}
void StageLight::startTrackActor(Actor actor, int actorIndex, Vector3 trackOffset)
{
m_doTrackPed = true;
m_trackPedId = actor.getActorPed();
m_trackActorIndex = actorIndex;
m_trackOffset = trackOffset;
}
void StageLight::stopTrackActor()
{
m_doTrackPed = false;
m_trackPedId = 0;
m_trackActorIndex = -1;
m_trackOffset = Vector3();
}
int StageLight::getTrackedActorIndex()
{
return m_trackActorIndex;
}
bool StageLight::isTrackingActor()
{
return m_doTrackPed;
}
bool StageLight::hasFlicker()
{
return m_hasFlicker;
}
void StageLight::removeLightObject()
{ //delete old object
if (m_lightObject.objReference != 0) {
OBJECT::DELETE_OBJECT(&m_lightObject.objReference);
}
}
void StageLight::turnOff()
{
if (m_lightObject.objReference != 0) {
//ENTITY::SET_ENTITY_ALPHA(m_lightObject.objReference, 0, false);
ENTITY::SET_ENTITY_VISIBLE(m_lightObject.objReference, false, false);
//log_to_file("Light off");
}
}
void StageLight::turnOn()
{
if (m_lightObject.objReference != 0) {
//ENTITY::SET_ENTITY_ALPHA(m_lightObject.objReference, 255, false);
ENTITY::SET_ENTITY_VISIBLE(m_lightObject.objReference, true, false);
//log_to_file("Light on");
}
}
bool StageLight::hasRotation()
{
return m_hasRotation;
}
void StageLight::setHasRotation(std::vector<StageLightRotation> rotationEvents)
{
m_rotationEvents = rotationEvents;
m_hasRotation = true;
}
std::vector<StageLightRotation> StageLight::getRotationEvents()
{
return m_rotationEvents;
}
void StageLight::stopRotation()
{
m_hasRotation = false;
}
bool StageLight::hasMovement()
{
return m_hasMovement;
}
void StageLight::setHasMovement(std::vector<StageLightMovement> movementEvents)
{
m_movementEvents = movementEvents;
m_hasMovement = true;
}
std::vector<StageLightMovement> StageLight::getMovementEvents()
{
return m_movementEvents;
}
void StageLight::stopMovement()
{
m_hasMovement = false;
}
void StageLight::actionOnTick(DWORD tick, std::vector<Actor>& actors)
{
if (m_doTrackPed) {
Vector3 currentActorPosition = ENTITY::GET_ENTITY_COORDS(m_trackPedId, true);
Vector3 newLightPosition;
newLightPosition.x = currentActorPosition.x + m_trackOffset.x;
newLightPosition.y = currentActorPosition.y + m_trackOffset.y;
newLightPosition.z = currentActorPosition.z + m_trackOffset.z;
if (newLightPosition.x != m_trackActorLastPos.x || newLightPosition.y != m_trackActorLastPos.y || newLightPosition.z != m_trackActorLastPos.z) {
moveLight(newLightPosition);
m_trackActorLastPos.x = newLightPosition.x;
m_trackActorLastPos.y = newLightPosition.y;
m_trackActorLastPos.z = newLightPosition.z;
}
}
if (m_hasFlicker) {
if (m_flickerStart == 0) {
m_flickerStart = tick;
m_flickerIndex = 0;
}
if (m_flickerIndex < m_flickerEvents.size()) {
StageLightFlicker flickerEvent = m_flickerEvents[m_flickerIndex];
if (tick - flickerEvent.length > m_flickerStart) {
m_flickerIndex++;
if (m_flickerIndex >= m_flickerEvents.size()) {
m_flickerIndex = 0;
}
m_flickerStart = tick;
flickerEvent = m_flickerEvents[m_flickerIndex];
if (flickerEvent.isOn) {
turnOn();
}
else {
turnOff();
}
}
else {
//log_to_file("Light not changed " + std::to_string(tick) + " vs " + std::to_string(m_flickerStart + flickerEvent.length));
}
}
}
if (m_hasRotation) {
if (m_rotationStart == 0) {
m_rotationStart = tick;
m_rotationIndex = 0;
}
if (m_rotationIndex < m_rotationEvents.size()) {
StageLightRotation rotationEvent = m_rotationEvents[m_rotationIndex];
if (tick - rotationEvent.length > m_rotationStart) {
m_rotationIndex++;
if (m_rotationIndex >= m_rotationEvents.size()) {
m_rotationIndex = 0;
}
m_rotationStart = tick;
}
//always rotate light
rotationEvent = m_rotationEvents[m_rotationIndex];
Vector3 rotation;
rotation.x = m_lightRotation.x;
rotation.z = m_lightRotation.z;
if (rotationEvent.hasPitch) {
rotation.x += rotationEvent.pitch;
}
if (rotationEvent.hasYaw) {
rotation.z += rotationEvent.yaw;
}
if (rotation.x != m_lightRotation.x || rotation.z != m_lightRotation.z) {
rotateLight(rotation);
}
}
}
if (m_hasMovement) {
if (m_movementStart == 0) {
m_movementStart = tick;
m_movementIndex = 0;
}
if (m_movementIndex < m_movementEvents.size()) {
StageLightMovement movementEvent = m_movementEvents[m_movementIndex];
if (tick - movementEvent.length > m_movementStart) {
m_movementIndex++;
if (m_movementIndex >= m_movementEvents.size()) {
m_movementIndex = 0;
}
m_movementStart = tick;
}
//always move light
movementEvent = m_movementEvents[m_movementIndex];
Vector3 newPosition;
newPosition.x = m_lightPosition.x + movementEvent.movementDelta.x;
newPosition.y = m_lightPosition.y + movementEvent.movementDelta.y;
newPosition.z = m_lightPosition.z + movementEvent.movementDelta.z;
//if xyRatio, always use x value as basis
if (movementEvent.hasxyRatio) {
newPosition.y = m_lightPosition.y + movementEvent.movementDelta.x * movementEvent.xyRatio;
}
if (newPosition.x != m_lightPosition.x || newPosition.y != m_lightPosition.y || newPosition.z != m_lightPosition.z) {
moveLight(newPosition);
}
}
}
}
Vector3 StageLight::getLightPosition()
{
return m_lightPosition;
}
Vector3 StageLight::getLightRotation()
{
return m_lightRotation;
}
GTAObject StageLight::getLightObject()
{
return m_lightObject;
}
Vector3 StageLight::getTrackedActorOffset()
{
return m_trackOffset;
}