You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The vertices table contains `Vector`s with the position of each vertex of the polygon **RELATIVE** to the starting position. The starting position will be automatically added to each vertex position, doing so manually will lead to unexpected results.
236
+
A minimum of 2 vertices (which would result in a line) are required to draw a polygon primitive. A console error will be printed and drawing will be skipped if less are provided.
237
+
There may be a limit for the number of vertices in `PolygonFillPrimitive` because it has different handling but it was not reached during testing.
238
+
239
+
The order of vertices is of high importance. Bad ordering will lead to unexpected results.
240
+
For example: `{ Vector(10, 0), Vector(10, 10), Vector(0, 10), Vector(0, 0) }` will result in a square, while `{ Vector(10, 0), Vector(0, 10), Vector(10, 10), Vector(0, 0) }` will result in an hourglass shape.
241
+
Note that **all** vertices of the shape must be specified, as the last vertex will be connected to the first vertex and not to the starting position (whether it is used as center or as a corner) to complete the shape.
242
+
Omitting the last `Vector(0, 0)` in the above example would result in a right angle triangle.
243
+
244
+
**The `Vector`s in the vertices table are single use! They will be deleted after being drawn, so they cannot be re-used!**
- Added blended drawing functions to `PrimitiveMan`:
266
+
There are 10 blending modes available to produce different color and transparency effects for both true primitives and bitmap based primitives.
267
+
Blended drawing effects are not the same as post-processing (glows), as they are all drawn in indexed color mode and will produce widely different results.
268
+
269
+
**Note that blended drawing is very expensive and chugs FPS like no tomorrow. It should not be abused!**
This is the fully fledged blended drawing function which allows individual control over each color channel blend amount.
275
+
Blend amounts are in percentages, where 0 means no blending and 100 means full blending (e.g. `blendAmountA = 100` will result in a fully transparent primitive, as if it was not drawn at all).
276
+
The blend mode and amounts will be applied to all the primitives in the primitive table.
277
+
Note that blend amounts are internally rounded to multiples of 5 (e.g. 32 will round to 30, 33 will round to 35) to reduce memory usage and because smaller steps are hardly noticeable.
- New `Vector` Lua (R/O) property `SqrMagnitude` which returns the squared magnitude of the `Vector`.
212
363
Should be used for more efficient comparison with `vector.SqrMagnitude > (floatValue * floatValue)` over `vector.Magnitude > floatValue`.
213
364
@@ -321,6 +472,9 @@ This can be accessed via the new Lua (R/W) `SettingsMan` property `AIUpdateInter
321
472
322
473
- Added Lua access (R/W) to `Attachable` property `DeleteWhenRemovedFromParent`, which determines whether the given `Attachable` should delete itself when it's removed from its current parent.
323
474
475
+
- Added Lua convenience function `RoundToNearestMultiple(num, multiple)` which returns a number rounded to the nearest specified multiple.
476
+
Note that this operates on integers, so fractional parts will be truncated towards zero by type conversion.
477
+
324
478
</details>
325
479
326
480
<details><summary><b>Changed</b></summary>
@@ -460,6 +614,9 @@ This can be accessed via the new Lua (R/W) `SettingsMan` property `AIUpdateInter
460
614
461
615
- The keyboard shortcut for clearing the console is now `F10`, since `F5` is used for quick-saving (`F9` quick-loads).
462
616
617
+
-`BitmapPrimitive` drawing functions now accept `MOSprite` instead of `Entity` for the object they get the bitmap to draw from.
618
+
This changes nothing regarding the bindings, but will now print an error to the console when attempting to draw a non-`MOSprite` based object (e.g. `MOPixel`), instead of silently skipping it.
Copy file name to clipboardExpand all lines: Lua/LuaAdapterDefinitions.h
+72Lines changed: 72 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@
20
20
#include"Box.h"
21
21
#include"Controller.h"
22
22
#include"DataModule.h"
23
+
#include"GraphicalPrimitive.h"
23
24
24
25
#include"GUIBanner.h"
25
26
#include"BuyMenuGUI.h"
@@ -437,6 +438,77 @@ namespace RTE {
437
438
};
438
439
#pragma endregion
439
440
441
+
#pragma region PrimitiveMan Lua Adapters
442
+
structLuaAdaptersPrimitiveMan {
443
+
/// <summary>
444
+
/// Schedule to draw a polygon primitive.
445
+
/// </summary>
446
+
/// <param name="primitiveMan">A reference to PrimitiveMan, provided by Lua.</param>
447
+
/// <param name="centerPos">Position of primitive's center in Scene coordinates.</param>
448
+
/// <param name="color">Color to draw primitive with.</param>
449
+
/// <param name="verticesTable">A Lua table that contains the positions of the primitive's vertices, relative to the center position.</param>
450
+
staticvoidDrawPolygonPrimitive(PrimitiveMan &primitiveMan, const Vector ¢erPos, int color, const luabind::object &verticesTable);
451
+
452
+
/// <summary>
453
+
/// Schedule to draw a polygon primitive visible only to a specified player.
454
+
/// </summary>
455
+
/// <param name="primitiveMan">A reference to PrimitiveMan, provided by Lua.</param>
456
+
/// <param name="player">Player screen to draw primitive on.</param>
457
+
/// <param name="centerPos">Position of primitive's center in Scene coordinates.</param>
458
+
/// <param name="color">Color to draw primitive with.</param>
459
+
/// <param name="verticesTable">A Lua table that contains the positions of the primitive's vertices, relative to the center position.</param>
460
+
staticvoidDrawPolygonPrimitiveForPlayer(PrimitiveMan &primitiveMan, int player, const Vector ¢erPos, int color, const luabind::object &verticesTable);
461
+
462
+
/// <summary>
463
+
/// Schedule to draw a filled polygon primitive.
464
+
/// </summary>
465
+
/// <param name="primitiveMan">A reference to PrimitiveMan, provided by Lua.</param>
466
+
/// <param name="startPos">Start position of the primitive in Scene coordinates.</param>
467
+
/// <param name="color">Color to draw primitive with.</param>
468
+
/// <param name="verticesTable">A Lua table that contains the positions of the primitive's vertices, relative to the center position.</param>
469
+
staticvoidDrawPolygonFillPrimitive(PrimitiveMan &primitiveMan, const Vector &startPos, int color, const luabind::object &verticesTable);
470
+
471
+
/// <summary>
472
+
/// Schedule to draw a filled polygon primitive visible only to a specified player.
473
+
/// </summary>
474
+
/// <param name="primitiveMan">A reference to PrimitiveMan, provided by Lua.</param>
475
+
/// <param name="player">Player screen to draw primitive on.</param>
476
+
/// <param name="startPos">Start position of the primitive in Scene coordinates.</param>
477
+
/// <param name="color">Color to draw primitive with.</param>
478
+
/// <param name="verticesTable">A Lua table that contains the positions of the primitive's vertices, relative to the center position.</param>
479
+
staticvoidDrawPolygonFillPrimitiveForPlayer(PrimitiveMan &primitiveMan, int player, const Vector &startPos, int color, const luabind::object &verticesTable);
480
+
481
+
/// <summary>
482
+
/// Schedules to draw multiple primitives of varying type with transparency enabled.
483
+
/// </summary>
484
+
/// <param name="primitiveMan">A reference to PrimitiveMan, provided by Lua.</param>
485
+
/// <param name="transValue">The transparency value the primitives should be drawn at. From 0 (opaque) to 100 (transparent).</param>
486
+
/// <param name="primitivesTable">A Lua table of primitives to schedule drawing for.</param>
487
+
staticvoidDrawPrimitivesWithTransparency(PrimitiveMan &primitiveMan, int transValue, const luabind::object &primitivesTable);
488
+
489
+
/// <summary>
490
+
/// Schedule to draw multiple primitives of varying type with blending enabled.
491
+
/// </summary>
492
+
/// <param name="primitiveMan">A reference to PrimitiveMan, provided by Lua.</param>
493
+
/// <param name="blendMode">The blending mode the primitives should be drawn with. See DrawBlendMode enumeration.</param>
494
+
/// <param name="blendAmount">The blending amount for all the channels. 0-100.</param>
495
+
/// <param name="primitivesTable">A Lua table of primitives to schedule drawing for.</param>
496
+
staticvoidDrawPrimitivesWithBlending(PrimitiveMan &primitiveMan, int blendMode, int blendAmount, const luabind::object &primitivesTable);
497
+
498
+
/// <summary>
499
+
/// Schedule to draw multiple primitives of varying type with blending enabled.
500
+
/// </summary>
501
+
/// <param name="primitiveMan">A reference to PrimitiveMan, provided by Lua.</param>
502
+
/// <param name="blendMode">The blending mode the primitives should be drawn with. See DrawBlendMode enumeration.</param>
503
+
/// <param name="blendAmountR">The blending amount for the Red channel. 0-100.</param>
504
+
/// <param name="blendAmountG">The blending amount for the Green channel. 0-100.</param>
505
+
/// <param name="blendAmountB">The blending amount for the Blue channel. 0-100.</param>
506
+
/// <param name="blendAmountA">The blending amount for the Alpha channel. 0-100.</param>
507
+
/// <param name="primitivesTable">A Lua table of primitives to schedule drawing for.</param>
508
+
staticvoidDrawPrimitivesWithBlendingPerChannel(PrimitiveMan &primitiveMan, int blendMode, int blendAmountR, int blendAmountG, int blendAmountB, int blendAmountA, const luabind::object &primitivesTable);
0 commit comments