- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpringFramework.lua
More file actions
Latest commit
363 lines (299 loc) · 21.5 KB
/
Copy pathSpringFramework.lua
File metadata and controls
363 lines (299 loc) · 21.5 KB
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
SpringFramework= {}
SpringFramework.SpringActions= {OUTSIDE_OF_CONFINES=1, MOVE_INTO_ALIGNMENT=2, APPLY_FORCES=3};
SpringFramework.OutsideOfConfinesOptions= {DO_NOTHING=1, BREAK_SPRING=2, MOVE_TO_REST_POSITION=3, CALLBACK=4};
functionSpringFramework.create(target1, target2, springConfig)
localspring=springConfig;
--------------------
--CONFIG VARIABLES--
--------------------
--spring.length = {min = #, rest = # (optional), max = #} OR {#, # (optional), #} --The minimum, optional resting and maximum length of the spring. Rest defaults to the middle of the spring, min and max are required
--spring.primaryTarget = false or 1 or 2 --The primary target for the spring, where false means neither. Used to determine the spring's midpoint for various calculations. Defaults to false
--spring.stiffness = # --The stiffness of the spring, which linearly affects how much force is applied by it. Defaults to 1
--spring.stiffnessMultiplier = {#, #} --How much to multiply the stiffness by when applying spring forces. Defaults to 1X for both targets
--spring.offsets = {Vector, Vector} --The offsets for object targets, to determine where the spring should be put vs the object's position. Defaults to Vector(0, 0) for both offsets
--spring.applyForcesAtOffset = true or false --Whether forces should be applied at the offset or directly at the target object's position. Defaults to true
--spring.rotAngle = # --The RotAngle for the spring, for springs that don't inherit RotAngle. Defaults to 0
--spring.inheritsRotAngle = false or 1 or 2 --The index of the object this should inherit RotAngle from or false to have a fixed RotAngle. Defaults to false
--spring.rotAngleOffset = # --An angle in radians to offset the spring's rotAngle from the object it inherits from, if there is one. Defaults to 0
--spring.lockToSpringRotation = true or false or 1 or 2 --Whether object positions should be locked to the spring's rotation. True means both, false means none, number means that one locks. Defaults to true
--spring.lockRotationVariance = {negativeAngle, positiveAngle} --The amount of positive and negative variation locked objects can have from the spring's RotAngle. Defaults to {0, 0}
--spring.confinesToCheck = {min = true or false, max = true or false, absolute = true or false} --Whether or not to check the given confines for outsideOfConfinesAction, absolute being the absolute distance from the rest position. Defaults to true for all
--spring.outsideOfConfinesAction = {1/2 = OutsideOfConfinesOptions.# or {type = OutsideOfConfinesOptions.#, callback = some_function_if_type_is_callback(spring, isOutsideOfConfines)}} --What to do when the spring is outside of its minimum or maximum confines. Options are DO_NOTHING, BREAK_SPRING which sets the spring to nil and returns, MOVE_TO_REST_POSITION which resets the position of the object to its rest position, CALLBACK which calls the function passed in as callback; said function is expected to take the spring and showing whether the object is outside of min, max and absolute confines as arguments, and return true if it did something or false if it didn't. Defaults to BREAK_SPRING for both
--spring.minimumValuesForActions = {SpringActions.OUTSIDE_OF_CONFINES = #, SpringActions.MOVE_INTO_ALIGNMENT = #, SpringActions.APPLY_FORCES = #} --The minimum values required to perform each action. For outside confines this means objects must be this far from the min or max extension positions of the spring. For moving into alignment this means objects must be this many pixels out of alignment with the spring. For applying forces this means objects need to be this far from their expected resting point. Defaults to calculated values based on the spring's values
--spring.maxForceStrength = {#, #} --The maximum non-impulse force the spring can apply to each object. Defaults to a calculated value based on the spring's values
--spring.showDebug = true or false --Whether or not to draw debug position and force lines. Defaults to false
------------------
--DEFAULT VALUES--
------------------
spring.length=SpringFramework.calculateSpringLengths(spring.length);
spring.primaryTarget=spring.primaryTarget~=falseand (spring.primaryTargetorfalse) orfalse;
spring.stiffness=spring.stiffnessor1;
spring.stiffnessMultiplier=spring.stiffnessMultiplieror {spring.stiffnessMultiplierandspring.stiffnessMultiplier[1] or1, spring.stiffnessMultiplierandspring.stiffnessMultiplier[2] or1};
if (type(spring.offsets) =="table") then
spring.offsets=#spring.offsets==2andspring.offsetsor {spring.offsets[1], Vector(0, 0)};
elseif (type(spring.offsets) =="userdata") then
spring.offsets= {spring.offsets, Vector(0, 0)};
else
spring.offsets= {Vector(0, 0), Vector(0, 0)};
end
spring.applyForcesAtOffset=spring.applyForcesAtOffset~=falseand (spring.applyForcesAtOffsetortrue) orfalse;
spring.rotAngle=spring.rotAngleor0;
spring.inheritsRotAngle=spring.inheritsRotAngle~=falseand (spring.inheritsRotAngleorfalse) orfalse;
spring.rotAngleOffset=spring.rotAngleOffsetor0;
spring.lockToSpringRotation=spring.lockToSpringRotation~=falseand (spring.lockToSpringRotationortrue) orfalse;
spring.lockRotationVariance=spring.lockRotationVarianceor {0, 0};
--Handle wrong argument ordering
if (spring.lockRotationVariance[2] <0andspring.lockRotationVariance[1] >0) then
localvariance=spring.lockRotationVariance[1];
spring.lockRotationVariance= {spring.lockRotationVariance[2], variance};
end
--Lock variance to be in correct ranges
spring.lockRotationVariance= {math.min(spring.lockRotationVariance[1], 0), math.max(spring.lockRotationVariance[2], 0)};
spring.outsideOfConfinesAction=type(spring.outsideOfConfinesAction=="table") andspring.outsideOfConfinesActionor {};
fori=1, 2do
spring.outsideOfConfinesAction[i] =spring.outsideOfConfinesAction[i] or {type=SpringFramework.OutsideOfConfinesOptions.BREAK_SPRING};
spring.outsideOfConfinesAction[i] =type(spring.outsideOfConfinesAction[i]) =="number" and {type=spring.outsideOfConfinesAction[i]} orspring.outsideOfConfinesAction[i];
if (spring.outsideOfConfinesAction[i].type==SpringFramework.OutsideOfConfinesOptions.CALLBACKandtype(spring.outsideOfConfinesAction[i].callback) ~="function") then
print("In order to use a callback for your Outside Of Confines Option, you must provide a function that takes the spring as an argument and returns true if it performed actions or false otherwise, under the key callback in the spring.outsideOfConfinesAction[#] table");
returnnil;
end
end
spring.confinesToCheck=type(spring.confinesToCheck) =="table" andspring.confinesToCheckor {};
spring.confinesToCheck.min=spring.confinesToCheck.min~=falseand (spring.confinesToCheck.minortrue) orfalse;
spring.confinesToCheck.max=spring.confinesToCheck.max~=falseand (spring.confinesToCheck.maxortrue) orfalse;
spring.confinesToCheck.absolute=spring.confinesToCheck.absolute~=falseand (spring.confinesToCheck.absoluteortrue) orfalse;
spring.minimumValuesForActions=spring.minimumValuesForActionsor {};
spring.minimumValuesForActions[SpringFramework.SpringActions.OUTSIDE_OF_CONFINES] =spring.minimumValuesForActions[SpringFramework.SpringActions.OUTSIDE_OF_CONFINES] orspring.length.difference*0.5;
spring.minimumValuesForActions[SpringFramework.SpringActions.MOVE_INTO_ALIGNMENT] =spring.minimumValuesForActions[SpringFramework.SpringActions.MOVE_INTO_ALIGNMENT] orspring.length.difference*0.1;
spring.minimumValuesForActions[SpringFramework.SpringActions.APPLY_FORCES] =spring.minimumValuesForActions[SpringFramework.SpringActions.APPLY_FORCES] orspring.length.difference*0.1;
spring.maxForceStrength=spring.maxForceStrengthor {spring.length.difference*0.5*spring.stiffness*spring.stiffnessMultiplier[1], spring.length.difference*0.5*spring.stiffness*spring.stiffnessMultiplier[2]};
spring.showDebug=spring.showDebug~=falseand (spring.showDebugorfalse) orfalse;
----------------------------------
--CALCULATED AND ASSIGNED VALUES--
----------------------------------
spring.targets= {target1, target2};
spring.targetIsVector= {target1.ClassName=="Vector", target2.ClassName=="Vector"};
if (spring.targetIsVector[1] andspring.targetIsVector[2]) then
print("You cannot connect two Vectors with springs");
returnnil;
end
spring.drawAngle=spring.rotAngle;
spring.pos= {};
spring.distances= {{}, {}};
spring.unrotatedDistances= {{}, {}};
spring.forceStrengths= {};
spring.forceVectors= {};
SpringFramework.updateCalculations(spring);
returnspring;
end
functionSpringFramework.calculateSpringLengths(lengthTable)
locallength= {min=lengthTable[1] orlengthTable.min, rest=lengthTable.rest, max=lengthTable[#lengthTable] orlengthTable.max};
localprevMax=length.max;
length.max=math.max(length.min, length.max);
length.min=math.min(length.min, prevMax);
length.difference=length.max-length.min;
length.mid=length.min+length.difference*0.5;
length.rest=length.restor (#lengthTable==3andmath.max(length.min, lengthTable[2]) orlength.mid);
returnlength;
end
functionSpringFramework.update(spring, noObjectUpdates)
if (spring==nilornext(spring) ==nil) then
print("Trying to update spring that doesn't exist or has been BROKEN");
returnnil;
end
SpringFramework.updateCalculations(spring);
if (noObjectUpdates~=true) then
SpringFramework.updateObjects(spring);
end
if (spring.showDebug==true) then
SpringFramework.drawDebugLines(spring);
end
returnnext(spring) ~=nilandspringornil;
end
functionSpringFramework.updateCalculations(spring)
spring.drawAngle= (spring.inheritsRotAngle==falseorspring.targetIsVector[spring.inheritsRotAngle]) andspring.drawAngleorspring.targets[spring.inheritsRotAngle].RotAngle;
spring.rotAngle=spring.drawAngle+ (spring.inheritsRotAngle~=falseandspring.rotAngleOffsetor0); --Rotangle 0 is Target1 on Left, Target2 on Right
SpringFramework.calculateAndUpdateTargetPositions(spring);
SpringFramework.calculateAndUpdateSpringPositionsAndDistances(spring);
SpringFramework.calculateAndUpdateForceValues(spring);
end
functionSpringFramework.calculateAndUpdateTargetPositions(spring)
spring.targetPos= {
(spring.targetIsVector[1] andspring.targets[1] orspring.targets[1].Pos) +Vector(spring.offsets[1].X, spring.offsets[1].Y):RadRotate(spring.drawAngle),
(spring.targetIsVector[2] andspring.targets[2] orspring.targets[2].Pos) +Vector(spring.offsets[2].X, spring.offsets[2].Y):RadRotate(spring.drawAngle)
};
spring.rotatedOffsets= {
Vector(spring.offsets[1].X, spring.offsets[1].Y):RadRotate(spring.rotAngle),
Vector(spring.offsets[2].X, spring.offsets[2].Y):RadRotate(spring.rotAngle)
};
end
functionSpringFramework.calculateAndUpdateSpringPositionsAndDistances(spring)
if (spring.targetIsVector[1]) then
spring.pos.mid=spring.targetPos[1] +Vector(spring.length.mid, 0):RadRotate(spring.rotAngle);
elseif (spring.targetIsVector[2]) then
spring.pos.mid=spring.targetPos[2] -Vector(spring.length.mid, 0):RadRotate(spring.rotAngle);
else
localdistance=SceneMan:ShortestDistance(spring.targetPos[1], spring.targetPos[2], SceneMan.SceneWrapsX);
if (spring.primaryTarget==false) then
spring.pos.mid=spring.targetPos[1] +distance*0.5;
else
spring.pos.mid=spring.targetPos[spring.primaryTarget] +distance* (spring.primaryTarget==1and0.5or-0.5);
end
end
spring.pos[1] = {
min=spring.pos.mid-Vector(spring.length.min*0.5, 0):RadRotate(spring.rotAngle),
rest=spring.pos.mid-Vector(spring.length.rest*0.5, 0):RadRotate(spring.rotAngle),
max=spring.pos.mid-Vector(spring.length.max*0.5, 0):RadRotate(spring.rotAngle)
};
spring.pos[2] = {
min=spring.pos.mid+Vector(spring.length.min*0.5, 0):RadRotate(spring.rotAngle),
rest=spring.pos.mid+Vector(spring.length.rest*0.5, 0):RadRotate(spring.rotAngle),
max=spring.pos.mid+Vector(spring.length.max*0.5, 0):RadRotate(spring.rotAngle)
};
fori=1, 2do
forposKey, posValueinpairs(spring.pos[i]) do
spring.distances[i][posKey] =SceneMan:ShortestDistance(posValue, spring.targetPos[i], SceneMan.SceneWrapsX);
spring.unrotatedDistances[i][posKey] =Vector(spring.distances[i][posKey].X, spring.distances[i][posKey].Y):RadRotate(-spring.rotAngle);
end
end
end
functionSpringFramework.calculateAndUpdateForceValues(spring)
fori=1, 2do
if (notspring.targetIsVector[i]) then
spring.forceStrengths[i] =math.min(spring.distances[i].rest.Magnitude*spring.stiffness*spring.stiffnessMultiplier[i], spring.maxForceStrength[i]);
spring.forceVectors[i] =spring.distances[i].rest.Normalized*-spring.forceStrengths[i];
end
end
end
functionSpringFramework.updateObjects(spring)
spring.actionsPerformed= {};
spring.actionsPerformed[SpringFramework.SpringActions.OUTSIDE_OF_CONFINES] =SpringFramework.handleOutsideOfConfines(spring);
if (spring.actionsPerformedandnotspring.actionsPerformed[SpringFramework.SpringActions.OUTSIDE_OF_CONFINES]) then
spring.actionsPerformed[SpringFramework.SpringActions.MOVE_INTO_ALIGNMENT] =SpringFramework.moveLockedObjectsIntoAlignment(spring);
if (notspring.actionsPerformed[SpringFramework.SpringActions.MOVE_INTO_CONFINES]) then
spring.actionsPerformed[SpringFramework.SpringActions.APPLY_FORCES] =SpringFramework.applyForcesToObjects(spring);
end
end
end
functionSpringFramework.handleOutsideOfConfines(spring)
localactionsPerformed=false;
localisOutsideOfConfines;
fori=1, 2do
if (spring.outsideOfConfinesAction[i].type~=SpringFramework.OutsideOfConfinesOptions.DO_NOTHING) then
isOutsideOfConfines= {
min=spring.confinesToCheck.min==trueand ((i==1andspring.unrotatedDistances[i].min.X>spring.minimumValuesForActions[SpringFramework.SpringActions.OUTSIDE_OF_CONFINES]) or (i==2andspring.unrotatedDistances[i].min.X<-spring.minimumValuesForActions[SpringFramework.SpringActions.OUTSIDE_OF_CONFINES])),
max=spring.confinesToCheck.max==trueand ((i==1andspring.unrotatedDistances[i].max.X<-spring.minimumValuesForActions[SpringFramework.SpringActions.OUTSIDE_OF_CONFINES]) or (i==2andspring.unrotatedDistances[i].max.X>spring.minimumValuesForActions[SpringFramework.SpringActions.OUTSIDE_OF_CONFINES])),
absolute=spring.confinesToCheck.absolute==trueand (spring.distances[i].rest.Magnitude> (spring.length.difference+spring.minimumValuesForActions[SpringFramework.SpringActions.OUTSIDE_OF_CONFINES]))
};
if (isOutsideOfConfines.minorisOutsideOfConfines.maxorisOutsideOfConfines.absolute) then
if (showDebug==true) then
localdebugString=isOutsideOfConfines.minand"< MIN" or (isOutsideOfConfines.maxand"> MAX" or"");
debugString=debugString..(isOutsideOfConfines.absoluteand (debugString.string.len() >0and" & > ABS" or"> ABS") or"").." Confines";
print(debugString);
ToGameActivity(ActivityMan:GetActivity()):AddObjectivePoint(debugString, spring.targetPos[i], Activity.TEAM_1, GameActivity.ARROWDOWN);
end
if (spring.outsideOfConfinesAction[i].type==SpringFramework.OutsideOfConfinesOptions.BREAK_SPRING) then
forkinpairs(spring) do
spring[k] =nil;
end
returntrue;
elseif (spring.outsideOfConfinesAction[i].type==SpringFramework.OutsideOfConfinesOptions.MOVE_TO_REST_POSITION) then
spring.targets[i].Pos=spring.pos[i].rest;
spring.targets[i]:ClearForces();
actionsPerformed=true;
elseif (spring.outsideOfConfinesAction[i].type==SpringFramework.OutsideOfConfinesOptions.CALLBACK) then
actionsPerformed=spring.outsideOfConfinesAction[i].callback(spring, isOutsideOfConfines);
end
end
end
end
if (actionsPerformed) then
SpringFramework.updateCalculations(spring);
end
returnactionsPerformed;
end
--TODO For the tank at least, we need a lot of horizontal force on object 1 to stop it from moving when the wheel doesn't align. However we don't want this
functionSpringFramework.moveLockedObjectsIntoAlignment(spring)
localactionsPerformed=false, unrotatedVel, forceVector;
fori=1, 2do
if (notspring.targetIsVector[i]) then
if (spring.lockToSpringRotation==trueorspring.lockToSpringRotation==i) then
--Lock travel impulse to spring alignment
if (spring.targets[i].TravelImpulse.Magnitude>0) then
localunrotatedTravelImpulse=spring.targets[i].TravelImpulse:RadRotate(-spring.rotAngle);
spring.targets[i].TravelImpulse=Vector(unrotatedTravelImpulse.X, 0):RadRotate(spring.rotAngle);
actionsPerformed=true;
end
if (spring.unrotatedDistances[i].rest.Y>=spring.minimumValuesForActions[SpringFramework.SpringActions.MOVE_INTO_ALIGNMENT]) then
--TODO add check wherein if distance is too far (set some default based on the spring's length) we reset it completely
unrotatedVel=Vector(spring.targets[i].Vel.X, spring.targets[i].Vel.Y):RadRotate(-spring.rotAngle);
forceVector=Vector(0, (-unrotatedVel.Y-spring.unrotatedDistances[i].rest.Y)):RadRotate(spring.rotAngle);
spring.targets[i]:AddImpulseForce(forceVector, spring.applyForcesAtOffsetandspring.rotatedOffsets[i] *FrameMan.MPPorVector(0, 0));
--if (spring.showDebug and i == 2) then
-- print("rotAngle: "..tostring(spring.rotAngle * 180 / math.pi)..", unrotatedDistance: "..tostring(spring.unrotatedDistances[i].rest)..", vel: "..tostring(spring.targets[i].Vel)..", unrotatedVel: "..tostring(unrotatedVel));
--end
if (spring.showDebug==true) then
localmaxForceStrength=spring.length.difference+5;
localforceLine=Vector(forceVector.X, forceVector.Y):SetMagnitude(50*forceVector.Magnitude/maxForceStrength);
localdrawStartPos=spring.applyForcesAtOffsetandspring.targetPos[i] orspring.targets[i].Pos;
SpringFramework.drawArrow(drawStartPos, drawStartPos+forceLine, spring.drawAngle, 7, forceVector.Magnitude>=maxForceStrengthand254or5);
end
actionsPerformed=true;
end
else
--TODO support unlocked springs
end
end
end
if (actionsPerformed) then
SpringFramework.updateCalculations(spring);
end
returnactionsPerformed;
end
functionSpringFramework.applyForcesToObjects(spring)
localactionsPerformed=false;
fori=1, 2do
if (notspring.targetIsVector[i] andspring.distances[i].rest.Magnitude>spring.minimumValuesForActions[SpringFramework.SpringActions.APPLY_FORCES]) then
spring.targets[i]:AddForce(spring.forceVectors[i], spring.applyForcesAtOffsetandspring.rotatedOffsets[i] *FrameMan.MPPorVector(0, 0));
actionsPerformed=true;
if (spring.showDebug==true) then
localmaxForceStrength=spring.maxForceStrength[i];
localforceLine=Vector(spring.forceVectors[i].X, spring.forceVectors[i].Y):SetMagnitude(50*spring.forceVectors[i].Magnitude/maxForceStrength);
localdrawStartPos=spring.applyForcesAtOffsetandspring.targetPos[i] orspring.targets[i].Pos;
SpringFramework.drawArrow(drawStartPos, drawStartPos+forceLine, spring.drawAngle, 7, spring.forceVectors[i].Magnitude>=maxForceStrengthand254or0);
end
end
end
returnactionsPerformed;
end
functionSpringFramework.drawDebugLines(spring)
fori=1, 2do
forj=-1, 1do
PrimitiveMan:DrawLinePrimitive(spring.pos.mid+Vector(-9, j):RadRotate(spring.drawAngle), spring.pos.mid+Vector(9, j):RadRotate(spring.drawAngle), 5);
PrimitiveMan:DrawLinePrimitive(spring.pos[i].min+Vector(-3, j):RadRotate(spring.drawAngle), spring.pos[i].min+Vector(3, j):RadRotate(spring.drawAngle), 5);
PrimitiveMan:DrawLinePrimitive(spring.pos[i].rest+Vector(-3, j):RadRotate(spring.drawAngle), spring.pos[i].rest+Vector(3, j):RadRotate(spring.drawAngle), 5);
PrimitiveMan:DrawLinePrimitive(spring.pos[i].max+Vector(-3, j):RadRotate(spring.drawAngle), spring.pos[i].max+Vector(3, j):RadRotate(spring.drawAngle), 5);
end
PrimitiveMan:DrawLinePrimitive(spring.targetPos[i] +Vector(-15, 0):RadRotate(spring.drawAngle), spring.targetPos[i] +Vector(15, 0):RadRotate(spring.drawAngle), 151);
PrimitiveMan:DrawLinePrimitive(spring.pos.mid+Vector(0, -spring.length.difference):RadRotate(spring.drawAngle), spring.pos.mid+Vector(0, spring.length.difference):RadRotate(spring.drawAngle), 151);
end
end
functionSpringFramework.drawArrow(startPos, endPos, rotAngle, width, colourIndex)
localdistance=SceneMan:ShortestDistance(startPos, endPos, SceneMan.SceneWrapsX);
endPos=startPos+distance;
locallineAngle= (distance.AbsDegAngle+360)%360;
localisHorizontal= (lineAngle>=315orlineAngle<=45) or (lineAngle>=135andlineAngle<=225);
localisVertical= (lineAngle>=45andlineAngle<=135) or (lineAngle>=225andlineAngle<=315);
localevenLineCount=width%2==0;
localmidCount=math.ceil(width*0.5);
localrotatedStartPos=Vector(startPos.X, startPos.Y):RadRotate(-rotAngle);
fori=1, width+ (evenLineCountand1or0) do
if (i==midCount) then
if (evenLineCount==false) then
PrimitiveMan:DrawLinePrimitive(startPos, endPos, colourIndex);
end
else
PrimitiveMan:DrawLinePrimitive(Vector(rotatedStartPos.X- (isVerticaland (midCount-i) or0), rotatedStartPos.Y- (isHorizontaland (midCount-i) or0)):RadRotate(rotAngle), endPos, colourIndex);
end
end
end