Implementing lua scripts for temperature adjustments

For topics related to the creation of simulation objects (SimObjects). This includes development of aircraft, ground, and maritime vehicles.
tauseefAhmed
Posts: 6
Joined: Wed Jul 31, 2019 4:56 pm

Implementing lua scripts for temperature adjustments

Postby tauseefAhmed » Wed Jul 31, 2019 5:47 pm

A friendly hello to all!
For past few days I've been trying to figure out how IR (Black Hot & White Hot) sensor works in P3d.
Since the actual IR sensor on a system (i.e FLIR Brite Star) reads heat signatures of ground entities to distinguish them in IR mode, P3D must be doing something similar. While I was going through the learning center, I found about Lua scripting and some of my questions were answered.
The only thing I don't understand is how do we integrate lua with P3d such that it assigns temperature value to the ground entities (i.e vehicles, Buildings, Water bodies etc).
I'm creating AI objects using simConnect and number of simObjects would vary at times. Is there any possibility to assign temperature value to an object at runtime?
I know how lua uses variables to get and set values in p3d and I have also worked on ActionScript to modify guages and targeting Pod. I just need a little help to figure out how do I assign heat value to individual entities.

I would really appreciate if LM guides me through this.

Thank you for your attention.

Best Regards,
Tauseef

Clifton Crane
Lockheed Martin
Posts: 988
Joined: Tue Sep 25, 2012 2:34 pm

Re: Implementing lua scripts for temperature adjustments

Postby Clifton Crane » Wed Jul 31, 2019 10:20 pm

Hello,

One way to dynamically modify how IR renders an object is by scripting it into the 3D model.

The model's materials have a Temperature Scale setting that can be used to adjust the brightness of the material in an IR view. This Temperature Scale value can also be modified by a lua script attached to the material (see IR Scenery Object sample in the SDK and Learning Center).

Another option would be to visibility script parts on and off where each part could have different Temperature Scale values in their material (i.e. cold wheel, warm wheel, hot wheel).

Unfortunately there is no overall heat setting that can be applied to the entire SimObject.
Clifton Crane
Prepar3D® Software Engineer

tauseefAhmed
Posts: 6
Joined: Wed Jul 31, 2019 4:56 pm

Re: Implementing lua scripts for temperature adjustments

Postby tauseefAhmed » Thu Aug 01, 2019 7:05 pm

Hello! Thank you for your attention.

Yeah I've gone through the IRSceneryObject example. It applies temperature scale on the entire scenery right?
I want to set different temperature scale for different entities in a scenery, for example a tank may have higher temperature than a jeep, and a jeep may have higher temperature scale than a motorcycle.

Setting the temperature using 3D modeling tool won't be the ideal solution for me as the temperature may be different during day/night as well as when it is a sunny day vs when there's a snowfall going on. I need to set the temperature when scenery is loaded and after checking the weather conditions. And yes, changing the temperature scale of entire Object is not possible, neither is it necessary so far.

Do I have to write a separate lua script for each of the entities (i.e in SimObjects\Airplanes\F-16 Base\Scripts\script.lua)?

Clifton Crane
Lockheed Martin
Posts: 988
Joined: Tue Sep 25, 2012 2:34 pm

Re: Implementing lua scripts for temperature adjustments

Postby Clifton Crane » Thu Aug 01, 2019 7:47 pm

I've gone through the IRSceneryObject example. It applies temperature scale on the entire scenery right?
Yes. That sample is set to use a single material for the entire model. However it is possible to script individual materials within the model.
Setting the temperature using 3D modeling tool won't be the ideal solution for me as the temperature may be different during day/night as well as when it is a sunny day vs when there's a snowfall going on. I need to set the temperature when scenery is loaded and after checking the weather conditions.
The lua script can access weather information as well as time of day, so it would be possible to script the material's temperature scalar based on different conditions. You may want to have a look at Object Variables and Environment Variables in the Learning Center for the list of available variables.
Do I have to write a separate lua script for each of the entities (i.e in SimObjects\Airplanes\F-16 Base\Scripts\script.lua)?
Material scripts can be shared between objects. There is a global Scripts directory in the Prepar3D application directory. Scripts added here can be accessed by any object. Additional Script directories can be added using the Add-On method, which is the preferred method. Scripts added under SimObject directories will only be accessible by that specific SimObject. Note that these directories also work in a fallback manner, so a SimObject may also look for scripts from with in the global directory.

So you can write generic scripts that can be used by multiple SimObjects as long as the files are in the correct location.

Hope this helps!
Clifton Crane
Prepar3D® Software Engineer

tauseefAhmed
Posts: 6
Joined: Wed Jul 31, 2019 4:56 pm

Re: Implementing lua scripts for temperature adjustments

Postby tauseefAhmed » Fri Aug 02, 2019 8:06 am

Thank you very much. Really appreciate your help.
I'll follow your instructions.
I hope you won't mind if I come back with another question (if any) regarding this issue.


Return to “Simulation Object Development Questions”

Who is online

Users browsing this forum: No registered users and 3 guests