Advertisement
ADVERTISEMENT
Guest

code

Sep 30th, 2026
9
0
Never
Not a member of GistPad yet? Sign Up, it unlocks many cool features!
None 176.50 KB | None | 0 0
  1. --------------------------------------------------------------------------------
  2. -- RE2 LIGHTPROBES CONTROL TEST
  3. -- TEST INTENSITY
  4. --
  5. -- 8 LIGHTPROBES
  6. -- CHECKBOX INDIVIDUELLE
  7. -- OPTION TOUT
  8. --
  9. -- READ + WRITE RUNTIME
  10. -- Aucun JSON
  11. -- Aucun changement permanent
  12. --------------------------------------------------------------------------------
  13.  
  14. --------------------------------------------------------------------------------
  15. -- LOG
  16. --------------------------------------------------------------------------------
  17.  
  18. local function test_log(message)
  19.  
  20. log.info(
  21. "[LIGHTPROBES-CONTROL-TEST] " ..
  22. tostring(message)
  23. )
  24.  
  25. end
  26.  
  27. --------------------------------------------------------------------------------
  28. -- LOAD LIGHTPROBES DATABASE
  29. --------------------------------------------------------------------------------
  30.  
  31. local function load_lightprobes_database()
  32.  
  33. local path =
  34. "Light/LightProbs/LightProbes.lua"
  35.  
  36.  
  37. test_log(
  38. "LOADING DATABASE: " ..
  39. path
  40. )
  41.  
  42.  
  43. local source =
  44. fs.read(
  45. path
  46. )
  47.  
  48.  
  49. if not source
  50. then
  51.  
  52. test_log(
  53. "DATABASE FILE NOT FOUND"
  54. )
  55.  
  56. return false
  57.  
  58. end
  59.  
  60.  
  61. test_log(
  62. "DATABASE FILE READ OK"
  63. )
  64.  
  65.  
  66. local chunk,
  67. error_message =
  68. load(
  69. source,
  70. "@LightProbs/LightProbes.lua"
  71. )
  72.  
  73.  
  74. if not chunk
  75. then
  76.  
  77. test_log(
  78. "DATABASE LUA COMPILE FAILED"
  79. )
  80.  
  81. test_log(
  82. tostring(
  83. error_message
  84. )
  85. )
  86.  
  87. return false
  88.  
  89. end
  90.  
  91.  
  92. local ok,
  93. result =
  94. pcall(
  95. chunk
  96. )
  97.  
  98.  
  99. if not ok
  100. then
  101.  
  102. test_log(
  103. "DATABASE LUA EXECUTION FAILED"
  104. )
  105.  
  106. test_log(
  107. tostring(
  108. result
  109. )
  110. )
  111.  
  112. return false
  113.  
  114. end
  115.  
  116.  
  117. if type(result) ~= "table"
  118. then
  119.  
  120. test_log(
  121. "DATABASE RETURN IS NOT A TABLE"
  122. )
  123.  
  124. test_log(
  125. "TYPE = " ..
  126. tostring(
  127. type(result)
  128. )
  129. )
  130.  
  131. return false
  132.  
  133. end
  134.  
  135.  
  136. LIGHTPROBES_DATABASE =
  137. result
  138.  
  139.  
  140. test_log(
  141. "DATABASE LOADED SUCCESSFULLY"
  142. )
  143.  
  144.  
  145. test_log(
  146. "DATABASE ENTRIES = " ..
  147. tostring(
  148. #LIGHTPROBES_DATABASE
  149. )
  150. )
  151.  
  152.  
  153. return true
  154.  
  155. end
  156.  
  157.  
  158.  
  159. --------------------------------------------------------------------------------
  160. -- ACTIVE LIGHTPROBES ZONE
  161. --------------------------------------------------------------------------------
  162.  
  163. local LIGHTPROBES_LIST =
  164. {
  165. }
  166.  
  167.  
  168. local LIGHTPROBES_ZONES =
  169. {
  170. }
  171.  
  172.  
  173. local selected_lightprobes_zone =
  174. nil
  175.  
  176.  
  177. local function build_lightprobes_zones()
  178.  
  179. LIGHTPROBES_ZONES =
  180. {
  181. }
  182.  
  183.  
  184. if type(LIGHTPROBES_DATABASE) ~= "table"
  185. then
  186.  
  187. return false
  188.  
  189. end
  190.  
  191.  
  192. for zone_name,
  193. zone_data
  194. in pairs(
  195. LIGHTPROBES_DATABASE
  196. )
  197. do
  198.  
  199. if type(zone_data) == "table"
  200. then
  201.  
  202. LIGHTPROBES_ZONES[
  203. #LIGHTPROBES_ZONES + 1
  204. ] =
  205. zone_name
  206.  
  207. end
  208.  
  209. end
  210.  
  211.  
  212. table.sort(
  213. LIGHTPROBES_ZONES
  214. )
  215.  
  216.  
  217. if #LIGHTPROBES_ZONES > 0
  218. then
  219.  
  220. selected_lightprobes_zone =
  221. LIGHTPROBES_ZONES[1]
  222.  
  223. end
  224.  
  225.  
  226. return true
  227.  
  228. end
  229.  
  230.  
  231. local function build_lightprobes_list_for_zone(
  232. zone_name
  233. )
  234.  
  235. LIGHTPROBES_LIST =
  236. {
  237. }
  238.  
  239.  
  240. if type(LIGHTPROBES_DATABASE) ~= "table"
  241. then
  242.  
  243. return false
  244.  
  245. end
  246.  
  247.  
  248. local zone_data =
  249. LIGHTPROBES_DATABASE[
  250. zone_name
  251. ]
  252.  
  253.  
  254. if type(zone_data) ~= "table"
  255. then
  256.  
  257. return false
  258.  
  259. end
  260.  
  261.  
  262. for i = 1,
  263. #zone_data
  264. do
  265.  
  266. local source =
  267. zone_data[i]
  268.  
  269.  
  270. if source
  271. and source.id
  272. and source.guid
  273. then
  274.  
  275. LIGHTPROBES_LIST[
  276. #LIGHTPROBES_LIST + 1
  277. ] =
  278. {
  279. zone = zone_name,
  280. name = source.id,
  281. guid = source.guid,
  282. selected = true
  283. }
  284.  
  285. end
  286.  
  287. end
  288.  
  289.  
  290. return true
  291.  
  292. end
  293.  
  294.  
  295. --------------------------------------------------------------------------------
  296. -- RUNTIME CACHE
  297. --------------------------------------------------------------------------------
  298.  
  299. local resolved_lightprobes =
  300. {
  301. }
  302.  
  303.  
  304. local original_intensity =
  305. {
  306. }
  307.  
  308. --------------------------------------------------------------------------------
  309. -- CONTROL VALUES
  310. --------------------------------------------------------------------------------
  311.  
  312. local control_intensity = 0.005
  313.  
  314. local control_red = 1.0
  315.  
  316. local control_green = 1.0
  317.  
  318. local control_blue = 1.0
  319.  
  320. local control_saturate = 0.0
  321.  
  322. local control_ambient_color_intensity = 1.0
  323.  
  324.  
  325.  
  326. --------------------------------------------------------------------------------
  327. -- GET CURRENT SCENE
  328. --------------------------------------------------------------------------------
  329.  
  330. local function get_current_scene()
  331.  
  332. local scene_manager =
  333. sdk.get_native_singleton(
  334. "via.SceneManager"
  335. )
  336.  
  337. if not scene_manager
  338. then
  339.  
  340. test_log(
  341. "SCENE MANAGER NOT FOUND"
  342. )
  343.  
  344. return nil
  345.  
  346. end
  347.  
  348.  
  349. local scene =
  350. nil
  351.  
  352.  
  353. local ok_scene,
  354. scene_result =
  355. pcall(
  356. function()
  357.  
  358. return sdk.call_native_func(
  359. scene_manager,
  360. sdk.find_type_definition(
  361. "via.SceneManager"
  362. ),
  363. "get_CurrentScene"
  364. )
  365.  
  366. end
  367. )
  368.  
  369.  
  370. if ok_scene
  371. and scene_result
  372. then
  373.  
  374. scene =
  375. scene_result
  376.  
  377. end
  378.  
  379.  
  380. if not scene
  381. then
  382.  
  383. local ok_call,
  384. result_call =
  385. pcall(
  386. function()
  387.  
  388. return scene_manager:call(
  389. "get_CurrentScene"
  390. )
  391.  
  392. end
  393. )
  394.  
  395.  
  396. if ok_call
  397. and result_call
  398. then
  399.  
  400. scene =
  401. result_call
  402.  
  403. end
  404.  
  405. end
  406.  
  407.  
  408. if not scene
  409. then
  410.  
  411. test_log(
  412. "CURRENT SCENE NOT FOUND"
  413. )
  414.  
  415. return nil
  416.  
  417. end
  418.  
  419.  
  420. return scene
  421.  
  422. end
  423.  
  424.  
  425.  
  426.  
  427.  
  428. --------------------------------------------------------------------------------
  429. -- RESOLVE ALL LIGHTPROBES
  430. --------------------------------------------------------------------------------
  431.  
  432. local function resolve_all_lightprobes()
  433.  
  434. resolved_lightprobes =
  435. {
  436. }
  437.  
  438. local scene =
  439. get_current_scene()
  440.  
  441. if not scene
  442. then
  443.  
  444. test_log(
  445. "CURRENT SCENE NOT FOUND"
  446. )
  447.  
  448. return false
  449.  
  450. end
  451.  
  452. test_log(
  453. "CURRENT SCENE FOUND"
  454. )
  455.  
  456. local ok_components,
  457. transforms =
  458. pcall(
  459. function()
  460.  
  461. return scene:call(
  462. "findComponents(System.Type)",
  463. sdk.typeof(
  464. "via.Transform"
  465. )
  466. )
  467.  
  468. end
  469. )
  470.  
  471. if not ok_components
  472. or not transforms
  473. then
  474.  
  475. test_log(
  476. "TRANSFORM ENUMERATION FAILED"
  477. )
  478.  
  479. return false
  480.  
  481. end
  482.  
  483. local ok_count,
  484. count =
  485. pcall(
  486. function()
  487.  
  488. return transforms:get_Count()
  489.  
  490. end
  491. )
  492.  
  493. if not ok_count
  494. or not count
  495. then
  496.  
  497. test_log(
  498. "TRANSFORM COUNT FAILED"
  499. )
  500.  
  501. return false
  502.  
  503. end
  504.  
  505. test_log(
  506. "TRANSFORMS = " ..
  507. tostring(
  508. count
  509. )
  510. )
  511.  
  512. local guid_to_index =
  513. {
  514. }
  515.  
  516. for i = 1,
  517. #LIGHTPROBES_LIST
  518. do
  519.  
  520. local entry =
  521. LIGHTPROBES_LIST[i]
  522.  
  523. if entry
  524. and entry.guid
  525. then
  526.  
  527. guid_to_index[
  528. tostring(
  529. entry.guid
  530. )
  531. ] =
  532. i
  533.  
  534. end
  535.  
  536. end
  537.  
  538. local guid_count =
  539. 0
  540.  
  541. for _,
  542. _ in pairs(
  543. guid_to_index
  544. )
  545. do
  546.  
  547. guid_count =
  548. guid_count + 1
  549.  
  550. end
  551.  
  552. test_log(
  553. "ACTIVE ZONE GUIDS = " ..
  554. tostring(
  555. guid_count
  556. )
  557. )
  558.  
  559. for i = 0,
  560. count - 1
  561. do
  562.  
  563. local ok_transform,
  564. transform =
  565. pcall(
  566. function()
  567.  
  568. return transforms:get_Item(
  569. i
  570. )
  571.  
  572. end
  573. )
  574.  
  575. if ok_transform
  576. and transform
  577. then
  578.  
  579. local ok_game_object,
  580. game_object =
  581. pcall(
  582. function()
  583.  
  584. return transform:call(
  585. "get_GameObject"
  586. )
  587.  
  588. end
  589. )
  590.  
  591. if ok_game_object
  592. and game_object
  593. then
  594.  
  595. local ok_name,
  596. object_name =
  597. pcall(
  598. function()
  599.  
  600. return game_object:call(
  601. "get_Name"
  602. )
  603.  
  604. end
  605. )
  606.  
  607. if ok_name
  608. and object_name
  609. then
  610.  
  611. object_name =
  612. tostring(
  613. object_name
  614. )
  615.  
  616. end
  617.  
  618. local ok_guid,
  619. object_guid =
  620. pcall(
  621. function()
  622.  
  623. return game_object:call(
  624. "get_GUID"
  625. )
  626.  
  627. end
  628. )
  629.  
  630. if ok_guid
  631. and object_guid
  632. then
  633.  
  634. object_guid =
  635. tostring(
  636. object_guid
  637. )
  638.  
  639. local database_index =
  640. guid_to_index[
  641. object_guid
  642. ]
  643.  
  644. if database_index
  645. then
  646.  
  647. test_log(
  648. "GUID MATCH = " ..
  649. object_guid ..
  650. " | NAME = " ..
  651. tostring(
  652. object_name
  653. )
  654. )
  655.  
  656. local ok_components_go,
  657. components =
  658. pcall(
  659. function()
  660.  
  661. return game_object:call(
  662. "get_Components"
  663. )
  664.  
  665. end
  666. )
  667.  
  668. if ok_components_go
  669. and components
  670. then
  671.  
  672. local ok_component_count,
  673. component_count =
  674. pcall(
  675. function()
  676.  
  677. return components:get_Count()
  678.  
  679. end
  680. )
  681.  
  682. if ok_component_count
  683. and component_count
  684. then
  685.  
  686. for c = 0,
  687. component_count - 1
  688. do
  689.  
  690. local ok_component,
  691. component =
  692. pcall(
  693. function()
  694.  
  695. return components:get_Item(
  696. c
  697. )
  698.  
  699. end
  700. )
  701.  
  702. if ok_component
  703. and component
  704. then
  705.  
  706. local ok_type,
  707. type_definition =
  708. pcall(
  709. function()
  710.  
  711. return component:get_type_definition()
  712.  
  713. end
  714. )
  715.  
  716. if ok_type
  717. and type_definition
  718. then
  719.  
  720. local ok_full_name,
  721. full_name =
  722. pcall(
  723. function()
  724.  
  725. return type_definition:get_full_name()
  726.  
  727. end
  728. )
  729.  
  730. if ok_full_name
  731. and full_name
  732. and tostring(
  733. full_name
  734. ) ==
  735. "via.render.LightProbes"
  736. then
  737.  
  738. resolved_lightprobes[
  739. database_index
  740. ] =
  741. component
  742.  
  743. test_log(
  744. "LIGHTPROBE RESOLVED = " ..
  745. tostring(
  746. object_name
  747. ) ..
  748. " | GUID = " ..
  749. object_guid
  750. )
  751.  
  752. break
  753.  
  754. end
  755.  
  756. end
  757.  
  758. end
  759.  
  760. end
  761.  
  762. end
  763.  
  764. end
  765.  
  766. end
  767.  
  768. end
  769.  
  770. end
  771.  
  772. end
  773.  
  774. end
  775.  
  776. local resolved_count =
  777. 0
  778.  
  779. for i = 1,
  780. #LIGHTPROBES_LIST
  781. do
  782.  
  783. if resolved_lightprobes[i]
  784. then
  785.  
  786. resolved_count =
  787. resolved_count + 1
  788.  
  789. end
  790.  
  791. end
  792.  
  793. test_log(
  794. "RESOLVED = " ..
  795. tostring(
  796. resolved_count
  797. ) ..
  798. " / " ..
  799. tostring(
  800. #LIGHTPROBES_LIST
  801. )
  802. )
  803.  
  804. return true
  805.  
  806. end
  807.  
  808. --------------------------------------------------------------------------------
  809. -- GET TARGET
  810. --------------------------------------------------------------------------------
  811.  
  812. local function get_target(index)
  813.  
  814. if resolved_lightprobes[index]
  815. then
  816.  
  817. return resolved_lightprobes[index]
  818.  
  819. end
  820.  
  821.  
  822. resolve_all_lightprobes()
  823.  
  824.  
  825. return resolved_lightprobes[index]
  826.  
  827. end
  828.  
  829.  
  830. --------------------------------------------------------------------------------
  831. -- COLOR CACHE
  832. --------------------------------------------------------------------------------
  833.  
  834. local original_color =
  835. {
  836. }
  837.  
  838.  
  839. --------------------------------------------------------------------------------
  840. -- READ COLOR
  841. --------------------------------------------------------------------------------
  842.  
  843. local function read_selected_color()
  844.  
  845. test_log(
  846. "================================================"
  847. )
  848.  
  849. test_log(
  850. "READ COLOR"
  851. )
  852.  
  853.  
  854. for i = 1,
  855. #LIGHTPROBES_LIST
  856. do
  857.  
  858. local entry =
  859. LIGHTPROBES_LIST[i]
  860.  
  861.  
  862. if entry.selected
  863. then
  864.  
  865. local lightprobes =
  866. get_target(
  867. i
  868. )
  869.  
  870.  
  871. if lightprobes
  872. then
  873.  
  874. local ok,
  875. color =
  876. pcall(
  877. function()
  878.  
  879. return lightprobes:get_AmbientColor()
  880.  
  881. end
  882. )
  883.  
  884.  
  885. if ok
  886. and color
  887. then
  888.  
  889. local ok_x,
  890. r =
  891. pcall(
  892. function()
  893.  
  894. return color.x
  895.  
  896. end
  897. )
  898.  
  899.  
  900. local ok_y,
  901. g =
  902. pcall(
  903. function()
  904.  
  905. return color.y
  906.  
  907. end
  908. )
  909.  
  910.  
  911. local ok_z,
  912. b =
  913. pcall(
  914. function()
  915.  
  916. return color.z
  917.  
  918. end
  919. )
  920.  
  921.  
  922. if ok_x
  923. and ok_y
  924. and ok_z
  925. then
  926.  
  927. original_color[i] =
  928. {
  929. x = r,
  930. y = g,
  931. z = b
  932. }
  933.  
  934.  
  935. test_log(
  936. entry.name ..
  937. " | COLOR = " ..
  938. tostring(r) ..
  939. " / " ..
  940. tostring(g) ..
  941. " / " ..
  942. tostring(b)
  943. )
  944.  
  945. else
  946.  
  947. test_log(
  948. entry.name ..
  949. " | COLOR COMPONENT READ FAILED"
  950. )
  951.  
  952. end
  953.  
  954. else
  955.  
  956. test_log(
  957. entry.name ..
  958. " | get_AmbientColor FAILED"
  959. )
  960.  
  961. end
  962.  
  963. else
  964.  
  965. test_log(
  966. entry.name ..
  967. " | TARGET NOT FOUND"
  968. )
  969.  
  970. end
  971.  
  972. end
  973.  
  974. end
  975.  
  976.  
  977. test_log(
  978. "================================================"
  979. )
  980.  
  981. end
  982.  
  983.  
  984.  
  985. --------------------------------------------------------------------------------
  986. -- RESTORE COLOR
  987. --------------------------------------------------------------------------------
  988.  
  989. local function restore_selected_color()
  990.  
  991. test_log(
  992. "================================================"
  993. )
  994.  
  995. test_log(
  996. "RESTORE COLOR"
  997. )
  998.  
  999.  
  1000. for i = 1,
  1001. #LIGHTPROBES_LIST
  1002. do
  1003.  
  1004. local entry =
  1005. LIGHTPROBES_LIST[i]
  1006.  
  1007.  
  1008. if entry.selected
  1009. then
  1010.  
  1011. local lightprobes =
  1012. get_target(
  1013. i
  1014. )
  1015.  
  1016.  
  1017. local original =
  1018. original_color[i]
  1019.  
  1020.  
  1021. if lightprobes
  1022. and original
  1023. then
  1024.  
  1025. local ok_color,
  1026. color =
  1027. pcall(
  1028. function()
  1029.  
  1030. return lightprobes:get_AmbientColor()
  1031.  
  1032. end
  1033. )
  1034.  
  1035.  
  1036. if ok_color
  1037. and color
  1038. then
  1039.  
  1040. color.x =
  1041. original.x
  1042.  
  1043. color.y =
  1044. original.y
  1045.  
  1046. color.z =
  1047. original.z
  1048.  
  1049.  
  1050. local ok_set =
  1051. pcall(
  1052. function()
  1053.  
  1054. lightprobes:set_AmbientColor(
  1055. color
  1056. )
  1057.  
  1058. end
  1059. )
  1060.  
  1061.  
  1062. if ok_set
  1063. then
  1064.  
  1065. test_log(
  1066. entry.name ..
  1067. " | COLOR RESTORED = " ..
  1068. tostring(original.x) ..
  1069. " / " ..
  1070. tostring(original.y) ..
  1071. " / " ..
  1072. tostring(original.z)
  1073. )
  1074.  
  1075. else
  1076.  
  1077. test_log(
  1078. entry.name ..
  1079. " | COLOR RESTORE FAILED"
  1080. )
  1081.  
  1082. end
  1083.  
  1084. else
  1085.  
  1086. test_log(
  1087. entry.name ..
  1088. " | get_AmbientColor FAILED"
  1089. )
  1090.  
  1091. end
  1092.  
  1093. else
  1094.  
  1095. test_log(
  1096. entry.name ..
  1097. " | NOTHING TO RESTORE"
  1098. )
  1099.  
  1100. end
  1101.  
  1102. end
  1103.  
  1104. end
  1105.  
  1106.  
  1107. test_log(
  1108. "================================================"
  1109. )
  1110.  
  1111. end
  1112.  
  1113. --------------------------------------------------------------------------------
  1114. -- APPLY x2
  1115. --------------------------------------------------------------------------------
  1116.  
  1117. local function apply_selected_intensity_x2()
  1118.  
  1119. test_log(
  1120. "================================================"
  1121. )
  1122.  
  1123. test_log(
  1124. "INTENSITY x2 SELECTED"
  1125. )
  1126.  
  1127.  
  1128. for i = 1,
  1129. #LIGHTPROBES_LIST
  1130. do
  1131.  
  1132. local entry =
  1133. LIGHTPROBES_LIST[i]
  1134.  
  1135.  
  1136. if entry.selected
  1137. then
  1138.  
  1139. local lightprobes =
  1140. get_target(
  1141. i
  1142. )
  1143.  
  1144.  
  1145. if lightprobes
  1146. then
  1147.  
  1148. local ok_read,
  1149. current =
  1150. pcall(
  1151. function()
  1152.  
  1153. return lightprobes:get_Intensity()
  1154.  
  1155. end
  1156. )
  1157.  
  1158.  
  1159. if ok_read
  1160. then
  1161.  
  1162. if original_intensity[i] == nil
  1163. then
  1164.  
  1165. original_intensity[i] =
  1166. current
  1167.  
  1168. end
  1169.  
  1170.  
  1171. local new_value =
  1172. current * 2.0
  1173.  
  1174.  
  1175. local ok_set =
  1176. pcall(
  1177. function()
  1178.  
  1179. lightprobes:set_Intensity(
  1180. new_value
  1181. )
  1182.  
  1183. end
  1184. )
  1185.  
  1186.  
  1187. if ok_set
  1188. then
  1189.  
  1190. test_log(
  1191. entry.name ..
  1192. " | OLD = " ..
  1193. tostring(
  1194. current
  1195. ) ..
  1196. " | NEW = " ..
  1197. tostring(
  1198. new_value
  1199. )
  1200. )
  1201.  
  1202. else
  1203.  
  1204. test_log(
  1205. entry.name ..
  1206. " | SET INTENSITY FAILED"
  1207. )
  1208.  
  1209. end
  1210.  
  1211. else
  1212.  
  1213. test_log(
  1214. entry.name ..
  1215. " | get_Intensity FAILED"
  1216. )
  1217.  
  1218. end
  1219.  
  1220. else
  1221.  
  1222. test_log(
  1223. entry.name ..
  1224. " | TARGET NOT FOUND"
  1225. )
  1226.  
  1227. end
  1228.  
  1229. end
  1230.  
  1231. end
  1232.  
  1233.  
  1234. test_log(
  1235. "================================================"
  1236. )
  1237.  
  1238. end
  1239.  
  1240.  
  1241. --------------------------------------------------------------------------------
  1242. -- RESTORE
  1243. --------------------------------------------------------------------------------
  1244.  
  1245. local function restore_selected_intensity()
  1246.  
  1247. test_log(
  1248. "================================================"
  1249. )
  1250.  
  1251. test_log(
  1252. "RESTORE SELECTED"
  1253. )
  1254.  
  1255.  
  1256. for i = 1,
  1257. #LIGHTPROBES_LIST
  1258. do
  1259.  
  1260. local entry =
  1261. LIGHTPROBES_LIST[i]
  1262.  
  1263.  
  1264. if entry.selected
  1265. then
  1266.  
  1267. local lightprobes =
  1268. get_target(
  1269. i
  1270. )
  1271.  
  1272.  
  1273. local original =
  1274. original_intensity[i]
  1275.  
  1276.  
  1277. if lightprobes
  1278. and original ~= nil
  1279. then
  1280.  
  1281. local ok_set =
  1282. pcall(
  1283. function()
  1284.  
  1285. lightprobes:set_Intensity(
  1286. original
  1287. )
  1288.  
  1289. end
  1290. )
  1291.  
  1292.  
  1293. if ok_set
  1294. then
  1295.  
  1296. test_log(
  1297. entry.name ..
  1298. " | RESTORED = " ..
  1299. tostring(
  1300. original
  1301. )
  1302. )
  1303.  
  1304. else
  1305.  
  1306. test_log(
  1307. entry.name ..
  1308. " | RESTORE FAILED"
  1309. )
  1310.  
  1311. end
  1312.  
  1313. else
  1314.  
  1315. test_log(
  1316. entry.name ..
  1317. " | NOTHING TO RESTORE"
  1318. )
  1319.  
  1320. end
  1321.  
  1322. end
  1323.  
  1324. end
  1325.  
  1326.  
  1327. test_log(
  1328. "================================================"
  1329. )
  1330.  
  1331. end
  1332.  
  1333. --------------------------------------------------------------------------------
  1334. -- READ CURRENT CONTROLS
  1335. --------------------------------------------------------------------------------
  1336.  
  1337. local function read_current_controls()
  1338.  
  1339. for i = 1,
  1340. #LIGHTPROBES_LIST
  1341. do
  1342.  
  1343. if LIGHTPROBES_LIST[i].selected
  1344. then
  1345.  
  1346. local lightprobes =
  1347. get_target(
  1348. i
  1349. )
  1350.  
  1351.  
  1352. if lightprobes
  1353. then
  1354.  
  1355. ----------------------------------------------------------------
  1356. -- INTENSITY
  1357. ----------------------------------------------------------------
  1358.  
  1359. local ok_intensity,
  1360. intensity =
  1361. pcall(
  1362. function()
  1363.  
  1364. return lightprobes:get_Intensity()
  1365.  
  1366. end
  1367. )
  1368.  
  1369.  
  1370. if ok_intensity
  1371. and intensity ~= nil
  1372. then
  1373.  
  1374. control_intensity =
  1375. intensity
  1376.  
  1377. end
  1378.  
  1379.  
  1380. ----------------------------------------------------------------
  1381. -- COLOR
  1382. ----------------------------------------------------------------
  1383.  
  1384. local ok_color,
  1385. color =
  1386. pcall(
  1387. function()
  1388.  
  1389. return lightprobes:get_AmbientColor()
  1390.  
  1391. end
  1392. )
  1393.  
  1394.  
  1395. if ok_color
  1396. and color
  1397. then
  1398.  
  1399. local ok_r,
  1400. r =
  1401. pcall(
  1402. function()
  1403.  
  1404. return color.x
  1405.  
  1406. end
  1407. )
  1408.  
  1409.  
  1410. local ok_g,
  1411. g =
  1412. pcall(
  1413. function()
  1414.  
  1415. return color.y
  1416.  
  1417. end
  1418. )
  1419.  
  1420.  
  1421. local ok_b,
  1422. b =
  1423. pcall(
  1424. function()
  1425.  
  1426. return color.z
  1427.  
  1428. end
  1429. )
  1430.  
  1431.  
  1432. if ok_r
  1433. and ok_g
  1434. and ok_b
  1435. then
  1436.  
  1437. control_red =
  1438. r
  1439.  
  1440. control_green =
  1441. g
  1442.  
  1443. control_blue =
  1444. b
  1445.  
  1446. end
  1447.  
  1448. end
  1449.  
  1450.  
  1451. break
  1452.  
  1453. end
  1454.  
  1455. end
  1456.  
  1457. end
  1458.  
  1459.  
  1460. test_log(
  1461. "CONTROL VALUES READ"
  1462. )
  1463.  
  1464. test_log(
  1465. "INTENSITY = " ..
  1466. tostring(
  1467. control_intensity
  1468. )
  1469. )
  1470.  
  1471. test_log(
  1472. "COLOR = " ..
  1473. tostring(
  1474. control_red
  1475. ) ..
  1476. " / " ..
  1477. tostring(
  1478. control_green
  1479. ) ..
  1480. " / " ..
  1481. tostring(
  1482. control_blue
  1483. )
  1484. )
  1485.  
  1486. end
  1487.  
  1488. --------------------------------------------------------------------------------
  1489. -- SELECT ALL
  1490. --------------------------------------------------------------------------------
  1491.  
  1492. local function select_all()
  1493.  
  1494. for i = 1,
  1495. #LIGHTPROBES_LIST
  1496. do
  1497.  
  1498. LIGHTPROBES_LIST[i].selected =
  1499. true
  1500.  
  1501. end
  1502.  
  1503. end
  1504.  
  1505.  
  1506. --------------------------------------------------------------------------------
  1507. -- DESELECT ALL
  1508. --------------------------------------------------------------------------------
  1509.  
  1510. local function deselect_all()
  1511.  
  1512. for i = 1,
  1513. #LIGHTPROBES_LIST
  1514. do
  1515.  
  1516. LIGHTPROBES_LIST[i].selected =
  1517. false
  1518.  
  1519. end
  1520.  
  1521. end
  1522.  
  1523.  
  1524. --------------------------------------------------------------------------------
  1525. -- COUNT SELECTED
  1526. --------------------------------------------------------------------------------
  1527.  
  1528. local function count_selected()
  1529.  
  1530. local count =
  1531. 0
  1532.  
  1533.  
  1534. for i = 1,
  1535. #LIGHTPROBES_LIST
  1536. do
  1537.  
  1538. if LIGHTPROBES_LIST[i].selected
  1539. then
  1540.  
  1541. count =
  1542. count + 1
  1543.  
  1544. end
  1545.  
  1546. end
  1547.  
  1548.  
  1549. return count
  1550.  
  1551. end
  1552.  
  1553.  
  1554. ----------------------------------------------------------------------------
  1555. -- SELECTION
  1556. ----------------------------------------------------------------------------
  1557.  
  1558. local function draw_selection_buttons()
  1559.  
  1560. if imgui.button(
  1561. "TOUT"
  1562. )
  1563. then
  1564.  
  1565. select_all()
  1566.  
  1567. end
  1568.  
  1569. imgui.same_line()
  1570.  
  1571. if imgui.button(
  1572. "RIEN"
  1573. )
  1574. then
  1575.  
  1576. deselect_all()
  1577.  
  1578. end
  1579.  
  1580. end
  1581. ----------------------------------------------------------------------------
  1582. -- RESOLVE
  1583. ----------------------------------------------------------------------------
  1584.  
  1585. local function draw_resolve_button()
  1586.  
  1587. if imgui.button(
  1588. "RESOLVE 16 LIGHTPROBES"
  1589. )
  1590. then
  1591.  
  1592. resolve_all_lightprobes()
  1593.  
  1594. end
  1595.  
  1596. end
  1597. ----------------------------------------------------------------------------
  1598. -- INTENSITY
  1599. ----------------------------------------------------------------------------
  1600.  
  1601. local function draw_intensity_control()
  1602.  
  1603. local intensity_changed,
  1604. new_intensity =
  1605. imgui.slider_float(
  1606. "Intensity",
  1607. control_intensity,
  1608. 0.0,
  1609. 1.0
  1610. )
  1611.  
  1612. if intensity_changed
  1613. then
  1614.  
  1615. control_intensity =
  1616. new_intensity
  1617.  
  1618. for i = 1,
  1619. #LIGHTPROBES_LIST
  1620. do
  1621.  
  1622. local entry =
  1623. LIGHTPROBES_LIST[i]
  1624.  
  1625. if entry
  1626. and entry.selected
  1627. then
  1628.  
  1629. local lightprobes =
  1630. get_target(i)
  1631.  
  1632. if lightprobes
  1633. then
  1634.  
  1635. pcall(
  1636. function()
  1637.  
  1638. lightprobes:set_Intensity(
  1639. control_intensity
  1640. )
  1641.  
  1642. end
  1643. )
  1644.  
  1645. end
  1646.  
  1647. end
  1648.  
  1649. end
  1650.  
  1651. end
  1652.  
  1653. end
  1654.  
  1655. ----------------------------------------------------------------------------
  1656. -- RED
  1657. ----------------------------------------------------------------------------
  1658.  
  1659. local function draw_red_control()
  1660.  
  1661. local red_changed,
  1662. new_red =
  1663. imgui.slider_float(
  1664. "Red",
  1665. control_red,
  1666. 0.0,
  1667. 1.0
  1668. )
  1669.  
  1670. if red_changed
  1671. then
  1672.  
  1673. control_red =
  1674. new_red
  1675.  
  1676. for i = 1,
  1677. #LIGHTPROBES_LIST
  1678. do
  1679.  
  1680. local entry =
  1681. LIGHTPROBES_LIST[i]
  1682.  
  1683. if entry
  1684. and entry.selected
  1685. then
  1686.  
  1687. local lightprobes =
  1688. get_target(i)
  1689.  
  1690. if lightprobes
  1691. then
  1692.  
  1693. local ok,
  1694. color =
  1695. pcall(
  1696. function()
  1697.  
  1698. return lightprobes:get_AmbientColor()
  1699.  
  1700. end
  1701. )
  1702.  
  1703. if ok
  1704. and color
  1705. then
  1706.  
  1707. color.x =
  1708. control_red
  1709.  
  1710. pcall(
  1711. function()
  1712.  
  1713. lightprobes:set_AmbientColor(
  1714. color
  1715. )
  1716.  
  1717. end
  1718. )
  1719.  
  1720. end
  1721.  
  1722. end
  1723.  
  1724. end
  1725.  
  1726. end
  1727.  
  1728. end
  1729.  
  1730. end
  1731. ----------------------------------------------------------------------------
  1732. -- GREEN
  1733. ----------------------------------------------------------------------------
  1734.  
  1735. local function draw_green_control()
  1736.  
  1737. local green_changed,
  1738. new_green =
  1739. imgui.slider_float(
  1740. "Green",
  1741. control_green,
  1742. 0.0,
  1743. 1.0
  1744. )
  1745.  
  1746. if green_changed
  1747. then
  1748.  
  1749. control_green =
  1750. new_green
  1751.  
  1752. for i = 1,
  1753. #LIGHTPROBES_LIST
  1754. do
  1755.  
  1756. local entry =
  1757. LIGHTPROBES_LIST[i]
  1758.  
  1759. if entry
  1760. and entry.selected
  1761. then
  1762.  
  1763. local lightprobes =
  1764. get_target(i)
  1765.  
  1766. if lightprobes
  1767. then
  1768.  
  1769. local ok,
  1770. color =
  1771. pcall(
  1772. function()
  1773.  
  1774. return lightprobes:get_AmbientColor()
  1775.  
  1776. end
  1777. )
  1778.  
  1779. if ok
  1780. and color
  1781. then
  1782.  
  1783. color.y =
  1784. control_green
  1785.  
  1786. pcall(
  1787. function()
  1788.  
  1789. lightprobes:set_AmbientColor(
  1790. color
  1791. )
  1792.  
  1793. end
  1794. )
  1795.  
  1796. end
  1797.  
  1798. end
  1799.  
  1800. end
  1801.  
  1802. end
  1803.  
  1804. end
  1805.  
  1806. end
  1807. ----------------------------------------------------------------------------
  1808. -- BLUE
  1809. ----------------------------------------------------------------------------
  1810.  
  1811. local function draw_blue_control()
  1812.  
  1813. local blue_changed,
  1814. new_blue =
  1815. imgui.slider_float(
  1816. "Blue",
  1817. control_blue,
  1818. 0.0,
  1819. 1.0
  1820. )
  1821.  
  1822. if blue_changed
  1823. then
  1824.  
  1825. control_blue =
  1826. new_blue
  1827.  
  1828. for i = 1,
  1829. #LIGHTPROBES_LIST
  1830. do
  1831.  
  1832. local entry =
  1833. LIGHTPROBES_LIST[i]
  1834.  
  1835. if entry
  1836. and entry.selected
  1837. then
  1838.  
  1839. local lightprobes =
  1840. get_target(i)
  1841.  
  1842. if lightprobes
  1843. then
  1844.  
  1845. local ok,
  1846. color =
  1847. pcall(
  1848. function()
  1849.  
  1850. return lightprobes:get_AmbientColor()
  1851.  
  1852. end
  1853. )
  1854.  
  1855. if ok
  1856. and color
  1857. then
  1858.  
  1859. color.z =
  1860. control_blue
  1861.  
  1862. pcall(
  1863. function()
  1864.  
  1865. lightprobes:set_AmbientColor(
  1866. color
  1867. )
  1868.  
  1869. end
  1870. )
  1871.  
  1872. end
  1873.  
  1874. end
  1875.  
  1876. end
  1877.  
  1878. end
  1879.  
  1880. end
  1881.  
  1882. end
  1883. ----------------------------------------------------------------------------
  1884. -- VALUES
  1885. ----------------------------------------------------------------------------
  1886.  
  1887. local function draw_values()
  1888.  
  1889. imgui.text(
  1890. "Intensity = " ..
  1891. string.format(
  1892. "%.6f",
  1893. control_intensity
  1894. )
  1895. )
  1896.  
  1897. imgui.text(
  1898. "RGB = " ..
  1899. string.format(
  1900. "%.3f",
  1901. control_red
  1902. ) ..
  1903. " / " ..
  1904. string.format(
  1905. "%.3f",
  1906. control_green
  1907. ) ..
  1908. " / " ..
  1909. string.format(
  1910. "%.3f",
  1911. control_blue
  1912. )
  1913. )
  1914.  
  1915. imgui.text(
  1916. "Saturate = " ..
  1917. string.format(
  1918. "%.3f",
  1919. control_saturate
  1920. )
  1921. )
  1922.  
  1923. imgui.text(
  1924. "Ambient Color Intensity = " ..
  1925. string.format(
  1926. "%.3f",
  1927. control_ambient_color_intensity
  1928. )
  1929. )
  1930.  
  1931. end
  1932.  
  1933. ----------------------------------------------------------------------------
  1934. -- RESTORE
  1935. ----------------------------------------------------------------------------
  1936.  
  1937. local function draw_restore_button()
  1938.  
  1939. if imgui.button(
  1940. "RESTORE ORIGINAL"
  1941. )
  1942. then
  1943.  
  1944. restore_selected_intensity()
  1945.  
  1946. restore_selected_color()
  1947.  
  1948. end
  1949.  
  1950. end
  1951.  
  1952. ----------------------------------------------------------------------------
  1953. -- RESTORE COLOR
  1954. ----------------------------------------------------------------------------
  1955.  
  1956. local function draw_restore_color_button()
  1957.  
  1958. if imgui.button(
  1959. "RESTORE COLOR"
  1960. )
  1961. then
  1962.  
  1963. restore_selected_color()
  1964.  
  1965. end
  1966.  
  1967. end
  1968. ----------------------------------------------------------------------------
  1969. -- LIGHTPROBES LIST
  1970. ----------------------------------------------------------------------------
  1971.  
  1972. local function draw_lightprobes_list()
  1973.  
  1974. for i = 1,
  1975. #LIGHTPROBES_LIST
  1976. do
  1977.  
  1978. local entry =
  1979. LIGHTPROBES_LIST[i]
  1980.  
  1981. local changed,
  1982. selected =
  1983. imgui.checkbox(
  1984. entry.name,
  1985. entry.selected
  1986. )
  1987.  
  1988. if changed
  1989. then
  1990.  
  1991. entry.selected =
  1992. selected
  1993.  
  1994. end
  1995.  
  1996. imgui.same_line()
  1997.  
  1998. imgui.text(
  1999. entry.guid
  2000. )
  2001.  
  2002. end
  2003.  
  2004. end
  2005.  
  2006.  
  2007.  
  2008. ----------------------------------------------------------------------------
  2009. -- SATURATE CONTROL
  2010. ----------------------------------------------------------------------------
  2011.  
  2012. local function draw_saturate_control()
  2013.  
  2014. local saturate_changed,
  2015. new_saturate =
  2016. imgui.slider_float(
  2017. "Saturate",
  2018. control_saturate,
  2019. 0.0,
  2020. 1.0
  2021. )
  2022.  
  2023. if saturate_changed
  2024. then
  2025.  
  2026. control_saturate =
  2027. new_saturate
  2028.  
  2029. for i = 1,
  2030. #LIGHTPROBES_LIST
  2031. do
  2032.  
  2033. local entry =
  2034. LIGHTPROBES_LIST[i]
  2035.  
  2036. if entry
  2037. and entry.selected
  2038. then
  2039.  
  2040. local lightprobes =
  2041. get_target(i)
  2042.  
  2043. if lightprobes
  2044. then
  2045.  
  2046. pcall(
  2047. function()
  2048.  
  2049. lightprobes:set_Saturate(
  2050. control_saturate
  2051. )
  2052.  
  2053. end
  2054. )
  2055.  
  2056. end
  2057.  
  2058. end
  2059.  
  2060. end
  2061.  
  2062. end
  2063.  
  2064. end
  2065.  
  2066.  
  2067.  
  2068. ----------------------------------------------------------------------------
  2069. -- AMBIENT COLOR INTENSITY CONTROL
  2070. ----------------------------------------------------------------------------
  2071.  
  2072. local function draw_ambient_color_intensity_control()
  2073.  
  2074. local changed,
  2075. new_value =
  2076. imgui.slider_float(
  2077. "Ambient Color Intensity",
  2078. control_ambient_color_intensity,
  2079. 0.0,
  2080. 2.0
  2081. )
  2082.  
  2083. if changed
  2084. then
  2085.  
  2086. control_ambient_color_intensity =
  2087. new_value
  2088.  
  2089. for i = 1,
  2090. #LIGHTPROBES_LIST
  2091. do
  2092.  
  2093. local entry =
  2094. LIGHTPROBES_LIST[i]
  2095.  
  2096. if entry
  2097. and entry.selected
  2098. then
  2099.  
  2100. local lightprobes =
  2101. get_target(i)
  2102.  
  2103. if lightprobes
  2104. then
  2105.  
  2106. pcall(
  2107. function()
  2108.  
  2109. lightprobes:set_AmbientColorIntensity(
  2110. control_ambient_color_intensity
  2111. )
  2112.  
  2113. end
  2114. )
  2115.  
  2116. end
  2117.  
  2118. end
  2119.  
  2120. end
  2121.  
  2122. end
  2123.  
  2124. end
  2125.  
  2126. --------------------------------------------------------------------------------
  2127. -- AMBIENT COLOR PICKER
  2128. --------------------------------------------------------------------------------
  2129.  
  2130. local control_alpha = 1.0
  2131.  
  2132. local function draw_ambient_color_picker()
  2133.  
  2134. local color =
  2135. Vector4f.new(
  2136. control_red,
  2137. control_green,
  2138. control_blue,
  2139. control_alpha
  2140. )
  2141.  
  2142. local changed,
  2143. new_color =
  2144. imgui.color_edit4(
  2145. "Ambient Color",
  2146. color
  2147. )
  2148.  
  2149. if changed
  2150. and new_color
  2151. then
  2152.  
  2153. control_red =
  2154. new_color.x
  2155.  
  2156. control_green =
  2157. new_color.y
  2158.  
  2159. control_blue =
  2160. new_color.z
  2161.  
  2162. control_alpha =
  2163. new_color.w
  2164.  
  2165.  
  2166. for i = 1,
  2167. #LIGHTPROBES_LIST
  2168. do
  2169.  
  2170. local entry =
  2171. LIGHTPROBES_LIST[i]
  2172.  
  2173. if entry
  2174. and entry.selected
  2175. then
  2176.  
  2177. local lightprobes =
  2178. get_target(i)
  2179.  
  2180. if lightprobes
  2181. then
  2182.  
  2183. pcall(
  2184. function()
  2185.  
  2186. local ambient_color =
  2187. lightprobes:get_AmbientColor()
  2188.  
  2189. ambient_color.x =
  2190. control_red
  2191.  
  2192. ambient_color.y =
  2193. control_green
  2194.  
  2195. ambient_color.z =
  2196. control_blue
  2197.  
  2198. lightprobes:set_AmbientColor(
  2199. ambient_color
  2200. )
  2201.  
  2202. end
  2203. )
  2204.  
  2205. end
  2206.  
  2207. end
  2208.  
  2209. end
  2210.  
  2211. end
  2212.  
  2213. end
  2214.  
  2215.  
  2216.  
  2217. --------------------------------------------------------------------------------
  2218. -- COLOR TEMPERATURE CONTROL
  2219. --------------------------------------------------------------------------------
  2220.  
  2221. local control_black_body_radiation =
  2222. 0.0
  2223.  
  2224. local control_temperature =
  2225. 6500.0
  2226.  
  2227.  
  2228. local function draw_color_temperature_controls()
  2229.  
  2230. ----------------------------------------------------------------
  2231. -- BLACK BODY RADIATION
  2232. ----------------------------------------------------------------
  2233.  
  2234. local changed_blackbody,
  2235. new_blackbody =
  2236. imgui.slider_float(
  2237. "Black Body Radiation",
  2238. control_black_body_radiation,
  2239. 0.0,
  2240. 1.0,
  2241. "%.2f"
  2242. )
  2243.  
  2244.  
  2245. if changed_blackbody
  2246. then
  2247.  
  2248. control_black_body_radiation =
  2249. new_blackbody
  2250.  
  2251.  
  2252. test_log(
  2253. "BlackBodyRadiation CHANGE = " ..
  2254. tostring(
  2255. control_black_body_radiation
  2256. )
  2257. )
  2258.  
  2259.  
  2260. for i = 1,
  2261. #LIGHTPROBES_LIST
  2262. do
  2263.  
  2264. local entry =
  2265. LIGHTPROBES_LIST[i]
  2266.  
  2267.  
  2268. if entry
  2269. and entry.selected
  2270. then
  2271.  
  2272. local lightprobes =
  2273. get_target(i)
  2274.  
  2275.  
  2276. if lightprobes
  2277. then
  2278.  
  2279. local ok,
  2280. result =
  2281. pcall(
  2282. function()
  2283.  
  2284. return lightprobes:call(
  2285. "set_BlackBodyRadiation",
  2286. control_black_body_radiation
  2287. )
  2288.  
  2289. end
  2290. )
  2291.  
  2292.  
  2293. test_log(
  2294. entry.name ..
  2295. " | set_BlackBodyRadiation | OK = " ..
  2296. tostring(ok) ..
  2297. " | RESULT = " ..
  2298. tostring(result)
  2299. )
  2300.  
  2301. end
  2302.  
  2303. end
  2304.  
  2305. end
  2306.  
  2307. end
  2308.  
  2309.  
  2310. ----------------------------------------------------------------
  2311. -- TEMPERATURE
  2312. ----------------------------------------------------------------
  2313.  
  2314. local changed_temperature,
  2315. new_temperature =
  2316. imgui.slider_float(
  2317. "Temperature",
  2318. control_temperature,
  2319. 1000.0,
  2320. 20000.0,
  2321. "%.0f K"
  2322. )
  2323.  
  2324.  
  2325. if changed_temperature
  2326. then
  2327.  
  2328. control_temperature =
  2329. new_temperature
  2330.  
  2331.  
  2332. test_log(
  2333. "Temperature CHANGE = " ..
  2334. tostring(
  2335. control_temperature
  2336. )
  2337. )
  2338.  
  2339.  
  2340. for i = 1,
  2341. #LIGHTPROBES_LIST
  2342. do
  2343.  
  2344. local entry =
  2345. LIGHTPROBES_LIST[i]
  2346.  
  2347.  
  2348. if entry
  2349. and entry.selected
  2350. then
  2351.  
  2352. local lightprobes =
  2353. get_target(i)
  2354.  
  2355.  
  2356. if lightprobes
  2357. then
  2358.  
  2359. local ok,
  2360. result =
  2361. pcall(
  2362. function()
  2363.  
  2364. return lightprobes:call(
  2365. "set_Temperature",
  2366. control_temperature
  2367. )
  2368.  
  2369. end
  2370. )
  2371.  
  2372.  
  2373. test_log(
  2374. entry.name ..
  2375. " | set_Temperature | OK = " ..
  2376. tostring(ok) ..
  2377. " | RESULT = " ..
  2378. tostring(result)
  2379. )
  2380.  
  2381. end
  2382.  
  2383. end
  2384.  
  2385. end
  2386.  
  2387. end
  2388.  
  2389. end
  2390.  
  2391. --------------------------------------------------------------------------------
  2392. -- UI
  2393. --------------------------------------------------------------------------------
  2394.  
  2395. re.on_draw_ui(
  2396. function()
  2397.  
  2398. if imgui.tree_node(
  2399. "LightProbes Control Test"
  2400. )
  2401. then
  2402.  
  2403. --------------------------------------------------------------------------------
  2404. -- LIGHTPROBES ZONE SELECTOR
  2405. --------------------------------------------------------------------------------
  2406.  
  2407. if #LIGHTPROBES_ZONES > 0
  2408. then
  2409.  
  2410. local current_zone_index =
  2411. 1
  2412.  
  2413.  
  2414. for i = 1,
  2415. #LIGHTPROBES_ZONES
  2416. do
  2417.  
  2418. if LIGHTPROBES_ZONES[i]
  2419. == selected_lightprobes_zone
  2420. then
  2421.  
  2422. current_zone_index =
  2423. i
  2424.  
  2425. break
  2426.  
  2427. end
  2428.  
  2429. end
  2430.  
  2431.  
  2432. local changed_zone,
  2433. new_zone_index =
  2434. imgui.combo(
  2435. "Zone",
  2436. current_zone_index - 1,
  2437. LIGHTPROBES_ZONES
  2438. )
  2439.  
  2440.  
  2441. if changed_zone
  2442. then
  2443.  
  2444. local new_zone =
  2445. LIGHTPROBES_ZONES[
  2446. new_zone_index + 1
  2447. ]
  2448.  
  2449.  
  2450. if new_zone
  2451. and new_zone ~= selected_lightprobes_zone
  2452. then
  2453.  
  2454. selected_lightprobes_zone =
  2455. new_zone
  2456.  
  2457.  
  2458. test_log(
  2459. "ZONE CHANGED = " ..
  2460. tostring(
  2461. selected_lightprobes_zone
  2462. )
  2463. )
  2464.  
  2465.  
  2466. resolved_lightprobes =
  2467. {
  2468. }
  2469.  
  2470.  
  2471. original_intensity =
  2472. {
  2473. }
  2474.  
  2475.  
  2476. original_color =
  2477. {
  2478. }
  2479.  
  2480.  
  2481. build_lightprobes_list_for_zone(
  2482. selected_lightprobes_zone
  2483. )
  2484.  
  2485.  
  2486. test_log(
  2487. "PROBES IN NEW ZONE = " ..
  2488. tostring(
  2489. #LIGHTPROBES_LIST
  2490. )
  2491. )
  2492.  
  2493. end
  2494.  
  2495. end
  2496.  
  2497. end
  2498.  
  2499.  
  2500. imgui.text(
  2501. "LightProbes : " ..
  2502. tostring(
  2503. #LIGHTPROBES_LIST
  2504. )
  2505. )
  2506.  
  2507.  
  2508. imgui.text(
  2509. "Selected : " ..
  2510. tostring(
  2511. count_selected()
  2512. ) ..
  2513. " / " ..
  2514. tostring(
  2515. #LIGHTPROBES_LIST
  2516. )
  2517. )
  2518.  
  2519.  
  2520. imgui.separator()
  2521.  
  2522.  
  2523. draw_selection_buttons()
  2524.  
  2525.  
  2526. draw_resolve_button()
  2527.  
  2528.  
  2529. imgui.separator()
  2530.  
  2531.  
  2532. imgui.text(
  2533. "LIGHTPROBES CONTROL"
  2534. )
  2535.  
  2536.  
  2537. draw_intensity_control()
  2538.  
  2539. draw_red_control()
  2540.  
  2541. draw_green_control()
  2542.  
  2543. draw_blue_control()
  2544.  
  2545. draw_ambient_color_picker()
  2546.  
  2547. draw_saturate_control()
  2548.  
  2549. draw_ambient_color_intensity_control()
  2550.  
  2551. draw_color_temperature_controls()
  2552.  
  2553.  
  2554. draw_values()
  2555.  
  2556.  
  2557. imgui.separator()
  2558.  
  2559.  
  2560. draw_restore_button()
  2561.  
  2562.  
  2563. imgui.same_line()
  2564.  
  2565.  
  2566. draw_restore_color_button()
  2567.  
  2568.  
  2569. imgui.separator()
  2570.  
  2571.  
  2572. draw_lightprobes_list()
  2573.  
  2574.  
  2575. imgui.tree_pop()
  2576.  
  2577. end
  2578.  
  2579. end
  2580. )
  2581.  
  2582.  
  2583. --------------------------------------------------------------------------------
  2584. -- STARTUP
  2585. --------------------------------------------------------------------------------
  2586.  
  2587. test_log(
  2588. "SCRIPT LOADED"
  2589. )
  2590.  
  2591.  
  2592. if load_lightprobes_database()
  2593. then
  2594.  
  2595. test_log(
  2596. "LIGHTPROBES DATABASE LOADED"
  2597. )
  2598.  
  2599.  
  2600. if build_lightprobes_zones()
  2601. then
  2602.  
  2603. test_log(
  2604. "LIGHTPROBES ZONES = " ..
  2605. tostring(
  2606. #LIGHTPROBES_ZONES
  2607. )
  2608. )
  2609.  
  2610.  
  2611. for i = 1,
  2612. #LIGHTPROBES_ZONES
  2613. do
  2614.  
  2615. test_log(
  2616. "ZONE [" ..
  2617. tostring(i) ..
  2618. "] = " ..
  2619. tostring(
  2620. LIGHTPROBES_ZONES[i]
  2621. )
  2622. )
  2623.  
  2624. end
  2625.  
  2626.  
  2627. if selected_lightprobes_zone
  2628. then
  2629.  
  2630. test_log(
  2631. "SELECTED ZONE = " ..
  2632. tostring(
  2633. selected_lightprobes_zone
  2634. )
  2635. )
  2636.  
  2637.  
  2638. if build_lightprobes_list_for_zone(
  2639. selected_lightprobes_zone
  2640. )
  2641. then
  2642.  
  2643. test_log(
  2644. "PROBES IN ZONE = " ..
  2645. tostring(
  2646. #LIGHTPROBES_LIST
  2647. )
  2648. )
  2649.  
  2650.  
  2651. for i = 1,
  2652. #LIGHTPROBES_LIST
  2653. do
  2654.  
  2655. local entry =
  2656. LIGHTPROBES_LIST[i]
  2657.  
  2658.  
  2659. if entry
  2660. then
  2661.  
  2662. test_log(
  2663. tostring(i) ..
  2664. " | " ..
  2665. tostring(
  2666. entry.zone
  2667. ) ..
  2668. " | " ..
  2669. tostring(
  2670. entry.name
  2671. ) ..
  2672. " | " ..
  2673. tostring(
  2674. entry.guid
  2675. )
  2676. )
  2677.  
  2678. end
  2679.  
  2680. end
  2681.  
  2682. else
  2683.  
  2684. test_log(
  2685. "LIGHTPROBES ZONE LIST BUILD FAILED"
  2686. )
  2687.  
  2688. end
  2689.  
  2690. else
  2691.  
  2692. test_log(
  2693. "NO LIGHTPROBES ZONE SELECTED"
  2694. )
  2695.  
  2696. end
  2697.  
  2698. else
  2699.  
  2700. test_log(
  2701. "LIGHTPROBES ZONES BUILD FAILED"
  2702. )
  2703.  
  2704. end
  2705.  
  2706. else
  2707.  
  2708. test_log(
  2709. "LIGHTPROBES DATABASE LOAD FAILED"
  2710. )
  2711.  
  2712. end
RAW Paste Data Copied
Advertisement
Advertisement