Difference between revisions of "Lightpoint Tutorial"

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[[Cc]ategory:[ _]?Arma[ _]3:[ _]?([^|]*)]]" to "{{GameCategory|arma3|$1}}")
m (Some wiki formatting)
 
(9 intermediate revisions by 2 users not shown)
Line 4: Line 4:
 
A lightpoint (glowing light source) is a non-physical object that shines a light. Unlike projectors or vehicle headlights, this light type cannot be directed into a beam and can only glow uniformously. The glowing does not cast shadows (only the sun or the moon can) and can go through walls.
 
A lightpoint (glowing light source) is a non-physical object that shines a light. Unlike projectors or vehicle headlights, this light type cannot be directed into a beam and can only glow uniformously. The glowing does not cast shadows (only the sun or the moon can) and can go through walls.
  
{{Informative | Lightpoint notions and commands were introduced in {{arma1}}, some commands were later added in {{arma3}} (e.g [[setLightIntensity]], flare commands).}}
+
{{Feature | Informative | Lightpoint notions and commands were introduced in {{arma1}}, some commands were later added in {{arma3}} (e.g [[setLightIntensity]], flare commands).}}
  
A lightpoint is '''[[local]]''' to the computer where the script has been called; one player could see a light in the dark while another would not have such light "object" created.
+
A lightpoint is '''[[Multiplayer Scripting#Locality|local]]''' to the computer where the script has been called; one player could see a light in the dark while another would not have such light "object" created.
  
 
[[File:lightpoint_redColor_blueAmbient.jpg|thumb|left|200px|Lightpoint with {{Color|darkred|red}} colour, and {{Color|blue|blue}} ambient.
 
[[File:lightpoint_redColor_blueAmbient.jpg|thumb|left|200px|Lightpoint with {{Color|darkred|red}} colour, and {{Color|blue|blue}} ambient.
Line 17: Line 17:
  
 
Colour set ''via'' [[setLightAmbient]] determines the outer colour shone by the lightpoint.
 
Colour set ''via'' [[setLightAmbient]] determines the outer colour shone by the lightpoint.
{{Important | Light colour does not affect AI, but ambient '''does'''.}}
+
{{Feature | important | Light colour does not affect AI, but ambient '''does'''.}}
  
 
=== Flare ===
 
=== Flare ===
  
 
The flare is the "colour point" centre that emits light. It can be visible or invisible (set by [[setLightUseFlare]]).
 
The flare is the "colour point" centre that emits light. It can be visible or invisible (set by [[setLightUseFlare]]).
{{Informative |  Flare is '''not''' visible by day, even using [[setLightDayLight]].}}
+
{{Feature | Informative |  Flare is '''not''' visible by day, even using [[setLightDayLight]].}}
  
  
== How to ==
+
== How To ==
  
 
The list of all lightpoint commands can be found in the [[:Category:Command Group: Lights|Lights command group]] category.
 
The list of all lightpoint commands can be found in the [[:Category:Command Group: Lights|Lights command group]] category.
  
=== Create a lightpoint ===
+
=== Create a Lightpoint ===
  
[[private]] _lightpoint = '''"#lightpoint"''' [[createVehicleLocal]] [[player]] [[modelToWorld]] [0,2,1.5];
+
<sqf>private _lightpoint = "#lightpoint" createVehicleLocal player modelToWorld [0, 2, 1.5];</sqf>
  
{{Informative | A lightpoint is '''local''' (and all the lightpoint commands take a local argument too), hence [[createVehicleLocal]] usage.}}
+
{{Feature | Informative | A lightpoint is '''local''' (and all the lightpoint commands take a local argument too), hence [[createVehicleLocal]] usage.}}
  
=== Set light colour ===
+
=== Set Light Colour ===
  
 
==== Colour ====
 
==== Colour ====
_lightpoint [[setLightColor]] [0.25, 1, 1]; {{cc|also defines [[#Set flare|Flare]] colour}}
+
<sqf>_lightpoint setLightColor [0.25, 1, 1]; // also defines Flare colour</sqf>
  
 
==== Ambient Colour ====
 
==== Ambient Colour ====
_lightpoint [[setLightAmbient]] [1, 1, 1]; {{cc|sets the colour applied to the surroundings}}
+
<sqf>_lightpoint setLightAmbient [1, 1, 1]; // sets the colour applied to the surroundings</sqf>
  
=== Set flare ===
+
=== Set Flare ===
  
{{Informative | For the flare to be visible, all the following values (use flare, size, visibility) must be defined and light colour [[#Colour_2|set by]] [[setLightColor]] must not be [0,0,0].}}
+
{{Feature | Informative | For the flare to be visible, all the following values (use flare, size, visibility) must be defined and light colour [[#Colour_2|set by]] [[setLightColor]] must not be [0,0,0].}}
  
{{ArgTitle|Enable flare|4|{{GVI|arma3|0.50}}}}
+
{{ArgTitle|4|Enable Flare|{{GVI|arma3|0.50}}}}
_lightpoint [[setLightUseFlare]] [[true]];
+
<sqf>_lightpoint setLightUseFlare true;</sqf>
  
{{ArgTitle|Set flare size|4|{{GVI|arma3|0.50}}}}
+
{{ArgTitle|4|Set Flare Size|{{GVI|arma3|0.50}}}}
_lightpoint [[setLightFlareSize]] 1; {{cc|in meter}}
+
<sqf>_lightpoint setLightFlareSize 1; // in meter</sqf>
  
{{ArgTitle|Set flare visibility|4|{{GVI|arma3|0.50}}}}
+
{{ArgTitle|4|Set Flare Visibility|{{GVI|arma3|0.50}}}}
_lightpoint [[setLightFlareMaxDistance]] 100; {{cc|in meter}}
+
<sqf>_lightpoint setLightFlareMaxDistance 100; // in meter</sqf>
  
=== Set light brightness ===
+
=== Set Light Brightness ===
  
==== Set brightness ====
+
==== Set Brightness ====
_lightpoint [[setLightBrightness]] 8;
+
<sqf>_lightpoint setLightBrightness 8;</sqf>
  
{{ArgTitle|Set intensity|4|{{GVI|arma3|0.50}}}}
+
{{ArgTitle|4|Set intensity|{{GVI|arma3|0.50}}}}
_lightpoint [[setLightIntensity]] 3000;
+
<sqf>_lightpoint setLightIntensity 3000;</sqf>
  
{{ArgTitle|Set attenuation|4|{{GVI|arma3|0.50}}}}
+
{{ArgTitle|4|Set attenuation|{{GVI|arma3|0.50}}}}
_lightpoint [[setLightAttenuation]] [0, 2, 4, 4, 0, 9, 10]; {{cc|[start, constant, linear, quadratic, hardLimitStart, hardLimitEnd]}}
+
<sqf>_lightpoint setLightAttenuation [0, 2, 4, 4, 0, 9, 10]; // [start, constant, linear, quadratic, hardLimitStart, hardLimitEnd]</sqf>
{{Informative | Formula is {{Inline code|1 / (constant + linear × dist + quadratic × dist × dist)}} - see [[setLightAttenuation]] for more information.}}
+
{{Feature | Informative | Formula is {{hl|1 / (constant + linear × dist + quadratic × dist × dist)}} - see [[setLightAttenuation]] for more information.}}
  
{{ArgTitle|Make light visible by day|3|{{GVI|arma3|0.50}}}}
+
{{ArgTitle|3|Make light visible by day|{{GVI|arma3|0.50}}}}
  
_lightpoint [[setLightDayLight]] [[true]]; {{cc|only for the light itself, not the flare}}
+
<sqf>_lightpoint setLightDayLight true; // only for the light itself, not the flare</sqf>
  
=== Delete lightpoint ===
+
=== Delete Lightpoint ===
  
[[deleteVehicle]] _lightpoint; {{cc|as simple as that}}
+
<sqf>deleteVehicle _lightpoint; // as simple as that</sqf>
  
== Full examples ==
+
 
 +
== Examples ==
  
 
=== Dark Souls ===
 
=== Dark Souls ===
  
[[skipTime]] -[[daytime]];
+
<sqf>
+
skipTime -dayTime;
_lightpoint = "#lightpoint" [[createVehicleLocal]] [0,0,0];
+
 
_lightpoint [[attachTo]] [<nowiki/>[[player]], [0, 0, 1.5]];
+
_lightpoint = "#lightpoint" createVehicleLocal [0,0,0];
_lightpoint [[setLightColor]] [0,0,0];
+
_lightpoint attachTo [player, [0, 0, 1.5]];
_lightpoint [[setLightAmbient]] [1,0.8, 0.25];
+
_lightpoint setLightColor [0,0,0];
_lightpoint [[setLightBrightness]] 0.15;
+
_lightpoint setLightAmbient [1,0.8, 0.25];
 +
_lightpoint setLightBrightness 0.15;
 +
</sqf>
  
 
=== Contact ===
 
=== Contact ===
  
[[skipTime]] -[[daytime]];
+
<sqf>
+
skipTime -dayTime;
[[private]] _position = [[player]] [[modelToWorld]] [0, 20, 1.5];
+
 
[[private]] _lightpoint = "#lightpoint" [[createVehicleLocal]] _position;
+
private _position = player modelToWorld [0, 20, 1.5];
_lightpoint [[setLightColor]] [0,1,1];
+
private _lightpoint = "#lightpoint" createVehicleLocal _position;
_lightpoint [[setLightAmbient]] [0.2,0.0,0.3];
+
_lightpoint setLightColor [0,1,1];
_lightpoint [[setLightUseFlare]] [[true]];
+
_lightpoint setLightAmbient [0.2,0.0,0.3];
_lightpoint [[setLightFlareSize]] 3;
+
_lightpoint setLightUseFlare true;
_lightpoint [[setLightFlareMaxDistance]] 3.5;
+
_lightpoint setLightFlareSize 3;
_lightpoint [[setLightBrightness]] 4;
+
_lightpoint setLightFlareMaxDistance 3.5;
_lightpoint [[setLightDayLight]] [[true]];
+
_lightpoint setLightBrightness 4;
+
_lightpoint setLightDayLight true;
_lightpoint [[spawn]] {
+
 
[[while]] { sleep 0.05; [[player]] [[distance]] [[_this]] > 2 } [[do]]
+
_lightpoint spawn {
{
+
while { sleep 0.05; player distance _this > 2 } do
[[_this]] [[setLightBrightness]] 4 [[max]] (40 / ([[player]] [[distance]] [[_this]]));
+
{
};
+
_this setLightBrightness 4 max (40 / (player distance _this));
[[deleteVehicle]] [[_this]];
+
};
};
+
deleteVehicle _this;
 +
};
 +
</sqf>
  
  
== See also ==
+
== See Also ==
  
 
* [[:Category:Command Group: Lights|Command Group: Lights]]
 
* [[:Category:Command Group: Lights|Command Group: Lights]]
Line 118: Line 123:
 
[[Category:Arma Scripting Tutorials]]
 
[[Category:Arma Scripting Tutorials]]
 
{{GameCategory|arma2|Tutorials}}
 
{{GameCategory|arma2|Tutorials}}
{{GameCategory|arma3| Tutorials}}
+
{{GameCategory|arma3|Tutorials}}

Latest revision as of 18:05, 25 July 2022

Basics

A lightpoint (glowing light source) is a non-physical object that shines a light. Unlike projectors or vehicle headlights, this light type cannot be directed into a beam and can only glow uniformously. The glowing does not cast shadows (only the sun or the moon can) and can go through walls.

Lightpoint notions and commands were introduced in Armed Assault, some commands were later added in Arma 3 (e.g setLightIntensity, flare commands).

A lightpoint is local to the computer where the script has been called; one player could see a light in the dark while another would not have such light "object" created.

Lightpoint with red colour, and blue ambient. Note how the red and blue hues mix to create purple.

Colour

Colour set via setLightColor determines the lens flare effect colour, as well as light's first colour.

Ambient

Colour set via setLightAmbient determines the outer colour shone by the lightpoint.

Light colour does not affect AI, but ambient does.

Flare

The flare is the "colour point" centre that emits light. It can be visible or invisible (set by setLightUseFlare).

Flare is not visible by day, even using setLightDayLight.


How To

The list of all lightpoint commands can be found in the Lights command group category.

Create a Lightpoint

private _lightpoint = "#lightpoint" createVehicleLocal player modelToWorld [0, 2, 1.5];

A lightpoint is local (and all the lightpoint commands take a local argument too), hence createVehicleLocal usage.

Set Light Colour

Colour

_lightpoint setLightColor [0.25, 1, 1]; // also defines Flare colour

Ambient Colour

_lightpoint setLightAmbient [1, 1, 1]; // sets the colour applied to the surroundings

Set Flare

For the flare to be visible, all the following values (use flare, size, visibility) must be defined and light colour set by setLightColor must not be [0,0,0].

Enable Flare

_lightpoint setLightUseFlare true;

Set Flare Size

_lightpoint setLightFlareSize 1; // in meter

Set Flare Visibility

_lightpoint setLightFlareMaxDistance 100; // in meter

Set Light Brightness

Set Brightness

_lightpoint setLightBrightness 8;

Set intensity

_lightpoint setLightIntensity 3000;

Set attenuation

_lightpoint setLightAttenuation [0, 2, 4, 4, 0, 9, 10]; // [start, constant, linear, quadratic, hardLimitStart, hardLimitEnd]

Formula is 1 / (constant + linear × dist + quadratic × dist × dist) - see setLightAttenuation for more information.

Make light visible by day

_lightpoint setLightDayLight true; // only for the light itself, not the flare

Delete Lightpoint

deleteVehicle _lightpoint; // as simple as that


Examples

Dark Souls

skipTime -dayTime; _lightpoint = "#lightpoint" createVehicleLocal [0,0,0]; _lightpoint attachTo [player, [0, 0, 1.5]]; _lightpoint setLightColor [0,0,0]; _lightpoint setLightAmbient [1,0.8, 0.25]; _lightpoint setLightBrightness 0.15;

Contact

skipTime -dayTime; private _position = player modelToWorld [0, 20, 1.5]; private _lightpoint = "#lightpoint" createVehicleLocal _position; _lightpoint setLightColor [0,1,1]; _lightpoint setLightAmbient [0.2,0.0,0.3]; _lightpoint setLightUseFlare true; _lightpoint setLightFlareSize 3; _lightpoint setLightFlareMaxDistance 3.5; _lightpoint setLightBrightness 4; _lightpoint setLightDayLight true; _lightpoint spawn { while { sleep 0.05; player distance _this > 2 } do { _this setLightBrightness 4 max (40 / (player distance _this)); }; deleteVehicle _this; };


See Also