Graphics::drawSpotLight: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
 
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Parameters:<br>* pos - coordinate where the spotlight is located<br>* dir - the direction vector the spotlight should aim at from its current position<br>* r,g,b - color of the spotlight<br>* distance - the maximum distance the light can reach<br>* brightness - the brightness of the light<br>* roundness - 'smoothness' of the circle edge<br>* radius - the radius size of the spotlight<br>* falloff - the falloff size of the light's edge (example: www.i.imgur.com/DemAWeO.jpg)<br><br>Example in C# (spotlight aims at the closest vehicle):<br>Vector3 myPos = Game.Player.Character.Position;<br>Vehicle nearest = World.GetClosestVehicle(myPos , 1000f);<br>Vector3 destinationCoords = nearest.Position;<br>Vector3 dirVector = destinationCoords - myPos;<br>dirVector.Normalize();<br>Function.Call(Hash.DRAW_SPOT_LIGHT, pos.X, pos.Y, pos.Z, dirVector.X, dirVector.Y, dirVector.Z, 255, 255, 255, 100.0f, 1f, 0.0f, 13.0f, 1f);==Syntax==<syntaxhighlight lang="javascript">graphics.drawSpotLight(posX, posY, posZ, dirX, dirY, dirZ, colorR, colorG, colorB, distance, brightness, roundness, radius, falloff);</syntaxhighlight>=== Required Arguments ===*'''posX:''' float*'''posY:''' float*'''posZ:''' float*'''dirX:''' float*'''dirY:''' float*'''dirZ:''' float*'''colorR:''' int*'''colorG:''' int*'''colorB:''' int*'''distance:''' float*'''brightness:''' float*'''roundness:''' float*'''radius:''' float*'''falloff:''' float===Return value===*'''Undefined'''==Example==<syntaxhighlight lang="javascript">todo</syntaxhighlight>==See also=={{Graphics_function_c}}[[Category:Clientside API]][[Category:TODO: Example]]
Parameters:<br>* pos - coordinate where the spotlight is located<br>* dir - the direction vector the spotlight should aim at from its current position<br>* r,g,b - color of the spotlight<br>* distance - the maximum distance the light can reach<br>* brightness - the brightness of the light<br>* roundness - 'smoothness' of the circle edge<br>* radius - the radius size of the spotlight<br>* falloff - the falloff size of the light's edge (example: www.i.imgur.com/DemAWeO.jpg)<br><br>Example in C# (spotlight aims at the closest vehicle):<br>Vector3 myPos = Game.Player.Character.Position;<br>Vehicle nearest = World.GetClosestVehicle(myPos , 1000f);<br>Vector3 destinationCoords = nearest.Position;<br>Vector3 dirVector = destinationCoords - myPos;<br>dirVector.Normalize();<br>Function.Call(Hash.DRAW_SPOT_LIGHT, pos.X, pos.Y, pos.Z, dirVector.X, dirVector.Y, dirVector.Z, 255, 255, 255, 100.0f, 1f, 0.0f, 13.0f, 1f);
==Syntax==
<syntaxhighlight lang="javascript">mp.game.graphics.drawSpotLight(posX, posY, posZ, dirX, dirY, dirZ, colorR, colorG, colorB, distance, brightness, roundness, radius, falloff);</syntaxhighlight>
=== Required Arguments ===
*'''posX:''' float
*'''posY:''' float
*'''posZ:''' float
*'''dirX:''' float
*'''dirY:''' float
*'''dirZ:''' float
*'''colorR:''' int
*'''colorG:''' int
*'''colorB:''' int
*'''distance:''' float
*'''brightness:''' float
*'''roundness:''' float
*'''radius:''' float
*'''falloff:''' float
===Return value===
*'''Undefined'''
==Example==
This example creates an illumination on top of the player and reflecting on the ground as well, light is flashing blue
{{ClientsideCode|
<syntaxhighlight lang="javascript">
 
let lightRender
function switchLight() {
  if (!lightRender) {
    // light ON
    lightRender = new mp.Event('render', ()=> {
      let pos = mp.players.local.position
      mp.game.graphics.drawSpotLight(pos.x,pos.y,pos.z+10, 0,0,-1, 0,0,255, 20,20,5,10,1)
    })
  } else {
    // light OFF
    lightRender.destroy()
    lightRender = null
  }
}
let lightInterval = setInterval(switchLight, 500)
</syntaxhighlight>
}}
 
==See also==
{{Graphics_s_function_c}}
[[Category:Clientside API]]
[[Category:TODO: Example]]

Latest revision as of 20:00, 28 August 2019

Parameters:
* pos - coordinate where the spotlight is located
* dir - the direction vector the spotlight should aim at from its current position
* r,g,b - color of the spotlight
* distance - the maximum distance the light can reach
* brightness - the brightness of the light
* roundness - 'smoothness' of the circle edge
* radius - the radius size of the spotlight
* falloff - the falloff size of the light's edge (example: www.i.imgur.com/DemAWeO.jpg)

Example in C# (spotlight aims at the closest vehicle):
Vector3 myPos = Game.Player.Character.Position;
Vehicle nearest = World.GetClosestVehicle(myPos , 1000f);
Vector3 destinationCoords = nearest.Position;
Vector3 dirVector = destinationCoords - myPos;
dirVector.Normalize();
Function.Call(Hash.DRAW_SPOT_LIGHT, pos.X, pos.Y, pos.Z, dirVector.X, dirVector.Y, dirVector.Z, 255, 255, 255, 100.0f, 1f, 0.0f, 13.0f, 1f);

Syntax

mp.game.graphics.drawSpotLight(posX, posY, posZ, dirX, dirY, dirZ, colorR, colorG, colorB, distance, brightness, roundness, radius, falloff);

Required Arguments

  • posX: float
  • posY: float
  • posZ: float
  • dirX: float
  • dirY: float
  • dirZ: float
  • colorR: int
  • colorG: int
  • colorB: int
  • distance: float
  • brightness: float
  • roundness: float
  • radius: float
  • falloff: float

Return value

  • Undefined

Example

This example creates an illumination on top of the player and reflecting on the ground as well, light is flashing blue

Client-Side
let lightRender
function switchLight() {
  if (!lightRender) {
    // light ON
    lightRender = new mp.Event('render', ()=> {
      let pos = mp.players.local.position
      mp.game.graphics.drawSpotLight(pos.x,pos.y,pos.z+10, 0,0,-1, 0,0,255, 20,20,5,10,1)
    })
  } else {
    // light OFF
    lightRender.destroy()
    lightRender = null
  }
}
let lightInterval = setInterval(switchLight, 500)

See also