types.vala 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  1. /*
  2. * Copyright (c) 2012-2025 Daniele Bartolini et al.
  3. * SPDX-License-Identifier: GPL-3.0-or-later
  4. */
  5. namespace Crown
  6. {
  7. const string OBJECT_TYPE_ACTOR = "actor";
  8. const string OBJECT_TYPE_ANIMATION_FRAME = "animation_frame";
  9. const string OBJECT_TYPE_ANIMATION_STATE_MACHINE = "animation_state_machine";
  10. const string OBJECT_TYPE_BLOOM = "bloom";
  11. const string OBJECT_TYPE_CAMERA = "camera";
  12. const string OBJECT_TYPE_COLLIDER = "collider";
  13. const string OBJECT_TYPE_FILE = "file";
  14. const string OBJECT_TYPE_FOG = "fog";
  15. const string OBJECT_TYPE_FONT = "font";
  16. const string OBJECT_TYPE_GLOBAL_LIGHTING = "global_lighting";
  17. const string OBJECT_TYPE_LEVEL = "level";
  18. const string OBJECT_TYPE_LIGHT = "light";
  19. const string OBJECT_TYPE_MATERIAL = "material";
  20. const string OBJECT_TYPE_MESH = "mesh";
  21. const string OBJECT_TYPE_MESH_ANIMATION = "mesh_animation";
  22. const string OBJECT_TYPE_MESH_BONE = "mesh_bone";
  23. const string OBJECT_TYPE_MESH_RENDERER = "mesh_renderer";
  24. const string OBJECT_TYPE_MESH_SKELETON = "mesh_skeleton";
  25. const string OBJECT_TYPE_MOVER = "mover";
  26. const string OBJECT_TYPE_NODE_ANIMATION = "node_animation";
  27. const string OBJECT_TYPE_NODE_TRANSITION = "node_transition";
  28. const string OBJECT_TYPE_SCRIPT = "script";
  29. const string OBJECT_TYPE_SOUND = "sound";
  30. const string OBJECT_TYPE_SOUND_SOURCE = "sound_source";
  31. const string OBJECT_TYPE_SPRITE = "sprite";
  32. const string OBJECT_TYPE_SPRITE_ANIMATION = "sprite_animation";
  33. const string OBJECT_TYPE_SPRITE_RENDERER = "sprite_renderer";
  34. const string OBJECT_TYPE_STATE_MACHINE = "state_machine";
  35. const string OBJECT_TYPE_STATE_MACHINE_NODE = "state_machine_node";
  36. const string OBJECT_TYPE_STATE_MACHINE_VARIABLE = "state_machine_variable";
  37. const string OBJECT_TYPE_TEXTURE = "texture";
  38. const string OBJECT_TYPE_TONEMAP = "tonemap";
  39. const string OBJECT_TYPE_TRANSFORM = "transform";
  40. const string OBJECT_TYPE_UNIT = "unit";
  41. // UI order reference table:
  42. //
  43. // spatial 500
  44. // rendering 1000
  45. // global_lighti 1001
  46. // camera 1100
  47. // light 1101
  48. // mesh 1102
  49. // sprite 1103
  50. // fog 1104
  51. // physics 2000
  52. // collider 2100
  53. // actor 2101
  54. // mover 2102
  55. // animation 3000
  56. // state_machine 3100
  57. // scripting 7000
  58. // lua_script 7100
  59. // post-processing 9000
  60. // bloom 9100
  61. // tonemap 9900
  62. public static void node_name_enum_callback(InputField enum_property, InputEnum combo, Project project)
  63. {
  64. try {
  65. string path = ResourceId.path(OBJECT_TYPE_MESH, (string)enum_property.union_value());
  66. Mesh mesh = Mesh.load_from_path(project, path);
  67. combo.clear();
  68. foreach (var node in mesh._nodes)
  69. combo.append(node, node);
  70. combo.value = combo.any_valid_id();
  71. } catch (JsonSyntaxError e) {
  72. loge(e.message);
  73. }
  74. }
  75. public static void scene_resource_callback(InputField enum_property, InputResource chooser, Project project)
  76. {
  77. if (enum_property.union_value() == "mesh")
  78. chooser.set_union_value("core/units/primitives/cube");
  79. }
  80. public static void shape_resource_callback(InputField enum_property, InputEnum combo, Project project)
  81. {
  82. if (enum_property.union_value() == "inline")
  83. combo.set_union_value("box");
  84. }
  85. public static void class_enum_callback(InputField property_enum, InputEnum combo, Project project)
  86. {
  87. try {
  88. string path = ResourceId.path("physics_config", "global");
  89. Hashtable global = SJSON.load_from_path(project.absolute_path(path));
  90. string prev_enum = combo.value;
  91. combo.clear();
  92. if (global.has_key("actors")) {
  93. Hashtable obj = (Hashtable)global["actors"];
  94. foreach (var e in obj)
  95. combo.append(e.key, e.key);
  96. }
  97. combo.value = prev_enum;
  98. } catch (JsonSyntaxError e) {
  99. loge(e.message);
  100. }
  101. }
  102. public static void collision_filter_enum_callback(InputField property_enum, InputEnum combo, Project project)
  103. {
  104. try {
  105. string path = ResourceId.path("physics_config", "global");
  106. Hashtable global = SJSON.load_from_path(project.absolute_path(path));
  107. string prev_enum = combo.value;
  108. combo.clear();
  109. if (global.has_key("collision_filters")) {
  110. Hashtable obj = (Hashtable)global["collision_filters"];
  111. foreach (var e in obj)
  112. combo.append(e.key, e.key);
  113. }
  114. combo.value = prev_enum;
  115. } catch (JsonSyntaxError e) {
  116. loge(e.message);
  117. }
  118. }
  119. public static void material_enum_callback(InputField property_enum, InputEnum combo, Project project)
  120. {
  121. try {
  122. string path = ResourceId.path("physics_config", "global");
  123. Hashtable global = SJSON.load_from_path(project.absolute_path(path));
  124. string prev_enum = combo.value;
  125. combo.clear();
  126. if (global.has_key("materials")) {
  127. Hashtable obj = (Hashtable)global["materials"];
  128. foreach (var e in obj)
  129. combo.append(e.key, e.key);
  130. }
  131. combo.value = prev_enum;
  132. } catch (JsonSyntaxError e) {
  133. loge(e.message);
  134. }
  135. }
  136. public static void create_object_types(Database database)
  137. {
  138. PropertyDefinition[] properties;
  139. properties =
  140. {
  141. PropertyDefinition()
  142. {
  143. type = PropertyType.VECTOR3,
  144. name = "data.position",
  145. },
  146. PropertyDefinition()
  147. {
  148. type = PropertyType.QUATERNION,
  149. name = "data.rotation",
  150. },
  151. PropertyDefinition()
  152. {
  153. type = PropertyType.VECTOR3,
  154. name = "data.scale",
  155. min = VECTOR3_ZERO,
  156. deffault = VECTOR3_ONE,
  157. },
  158. };
  159. database.create_object_type(OBJECT_TYPE_TRANSFORM
  160. , properties
  161. , 500
  162. , ObjectTypeFlags.UNIT_COMPONENT
  163. );
  164. properties =
  165. {
  166. PropertyDefinition()
  167. {
  168. type = PropertyType.STRING,
  169. name = "data.mesh_resource",
  170. label = "Scene",
  171. editor = PropertyEditorType.RESOURCE,
  172. resource_type = OBJECT_TYPE_MESH,
  173. },
  174. PropertyDefinition()
  175. {
  176. type = PropertyType.STRING,
  177. name = "data.geometry_name",
  178. label = "Node",
  179. editor = PropertyEditorType.ENUM,
  180. enum_property = "data.mesh_resource",
  181. enum_callback = node_name_enum_callback,
  182. },
  183. PropertyDefinition()
  184. {
  185. type = PropertyType.STRING,
  186. name = "data.material",
  187. editor = PropertyEditorType.RESOURCE,
  188. resource_type = OBJECT_TYPE_MATERIAL,
  189. },
  190. PropertyDefinition()
  191. {
  192. type = PropertyType.BOOL,
  193. name = "data.visible",
  194. },
  195. PropertyDefinition()
  196. {
  197. type = PropertyType.BOOL,
  198. name = "data.cast_shadows",
  199. deffault = true
  200. },
  201. };
  202. database.create_object_type(OBJECT_TYPE_MESH_RENDERER
  203. , properties
  204. , 1102
  205. , ObjectTypeFlags.UNIT_COMPONENT
  206. , OBJECT_TYPE_TRANSFORM
  207. );
  208. properties =
  209. {
  210. PropertyDefinition()
  211. {
  212. type = PropertyType.STRING,
  213. name = "data.sprite_resource",
  214. label = "Sprite",
  215. editor = PropertyEditorType.RESOURCE,
  216. resource_type = OBJECT_TYPE_SPRITE,
  217. },
  218. PropertyDefinition()
  219. {
  220. type = PropertyType.STRING,
  221. name = "data.material",
  222. editor = PropertyEditorType.RESOURCE,
  223. resource_type = OBJECT_TYPE_MATERIAL,
  224. },
  225. PropertyDefinition()
  226. {
  227. type = PropertyType.DOUBLE,
  228. name = "data.layer",
  229. min = 0.0,
  230. max = 7.0,
  231. },
  232. PropertyDefinition()
  233. {
  234. type = PropertyType.DOUBLE,
  235. name = "data.depth",
  236. min = 0.0,
  237. max = (double)uint32.MAX,
  238. },
  239. PropertyDefinition()
  240. {
  241. type = PropertyType.BOOL,
  242. name = "data.visible",
  243. },
  244. PropertyDefinition()
  245. {
  246. type = PropertyType.BOOL,
  247. name = "data.flip_x",
  248. },
  249. PropertyDefinition()
  250. {
  251. type = PropertyType.BOOL,
  252. name = "data.flip_y",
  253. },
  254. };
  255. database.create_object_type(OBJECT_TYPE_SPRITE_RENDERER
  256. , properties
  257. , 1103
  258. , ObjectTypeFlags.UNIT_COMPONENT
  259. , OBJECT_TYPE_TRANSFORM
  260. );
  261. properties =
  262. {
  263. PropertyDefinition()
  264. {
  265. type = PropertyType.STRING,
  266. name = "data.type",
  267. editor = PropertyEditorType.ENUM,
  268. enum_values = { "directional", "omni", "spot" },
  269. },
  270. PropertyDefinition()
  271. {
  272. type = PropertyType.DOUBLE,
  273. name = "data.range",
  274. min = 0.0,
  275. },
  276. PropertyDefinition()
  277. {
  278. type = PropertyType.DOUBLE,
  279. name = "data.intensity",
  280. min = 0.0,
  281. },
  282. PropertyDefinition()
  283. {
  284. type = PropertyType.DOUBLE,
  285. name = "data.spot_angle",
  286. editor = PropertyEditorType.ANGLE,
  287. min = 0.0,
  288. max = 90.0,
  289. },
  290. PropertyDefinition()
  291. {
  292. type = PropertyType.VECTOR3,
  293. name = "data.color",
  294. editor = PropertyEditorType.COLOR,
  295. min = VECTOR3_ZERO,
  296. max = VECTOR3_ONE,
  297. },
  298. PropertyDefinition()
  299. {
  300. type = PropertyType.DOUBLE,
  301. name = "data.shadow_bias",
  302. min = 0.0,
  303. max = 1.0,
  304. deffault = 0.0001,
  305. },
  306. PropertyDefinition()
  307. {
  308. type = PropertyType.BOOL,
  309. name = "data.cast_shadows",
  310. deffault = true,
  311. },
  312. };
  313. database.create_object_type(OBJECT_TYPE_LIGHT
  314. , properties
  315. , 1101
  316. , ObjectTypeFlags.UNIT_COMPONENT
  317. , OBJECT_TYPE_TRANSFORM
  318. );
  319. properties =
  320. {
  321. PropertyDefinition()
  322. {
  323. type = PropertyType.STRING,
  324. name = "data.projection",
  325. editor = PropertyEditorType.ENUM,
  326. enum_values = { "orthographic", "perspective" },
  327. },
  328. PropertyDefinition()
  329. {
  330. type = PropertyType.DOUBLE,
  331. name = "data.fov",
  332. label = "FOV",
  333. editor = PropertyEditorType.ANGLE,
  334. min = 0.0,
  335. max = 90.0
  336. },
  337. PropertyDefinition()
  338. {
  339. type = PropertyType.DOUBLE,
  340. name = "data.near_range",
  341. deffault = 0.1,
  342. },
  343. PropertyDefinition()
  344. {
  345. type = PropertyType.DOUBLE,
  346. name = "data.far_range",
  347. deffault = 1000.0,
  348. },
  349. };
  350. database.create_object_type(OBJECT_TYPE_CAMERA
  351. , properties
  352. , 1100
  353. , ObjectTypeFlags.UNIT_COMPONENT
  354. , OBJECT_TYPE_TRANSFORM
  355. );
  356. properties =
  357. {
  358. PropertyDefinition()
  359. {
  360. type = PropertyType.STRING,
  361. name = "data.source",
  362. editor = PropertyEditorType.ENUM,
  363. enum_values = { "mesh", "inline" },
  364. },
  365. PropertyDefinition()
  366. {
  367. type = PropertyType.STRING,
  368. name = "data.scene",
  369. editor = PropertyEditorType.RESOURCE,
  370. resource_type = OBJECT_TYPE_MESH,
  371. enum_property = "data.source",
  372. resource_callback = scene_resource_callback
  373. },
  374. PropertyDefinition()
  375. {
  376. type = PropertyType.STRING,
  377. name = "data.name",
  378. label = "Node",
  379. editor = PropertyEditorType.ENUM,
  380. enum_property = "data.scene",
  381. enum_callback = node_name_enum_callback,
  382. },
  383. PropertyDefinition()
  384. {
  385. type = PropertyType.STRING,
  386. name = "data.shape",
  387. editor = PropertyEditorType.ENUM,
  388. enum_values = { "sphere", "capsule", "box", "convex_hull", "mesh" },
  389. enum_property = "data.source",
  390. enum_callback = shape_resource_callback,
  391. },
  392. PropertyDefinition()
  393. {
  394. type = PropertyType.VECTOR3,
  395. name = "data.collider_data.position",
  396. },
  397. PropertyDefinition()
  398. {
  399. type = PropertyType.QUATERNION,
  400. name = "data.collider_data.rotation",
  401. },
  402. PropertyDefinition()
  403. {
  404. type = PropertyType.VECTOR3,
  405. name = "data.collider_data.half_extents", // Box only.
  406. min = VECTOR3_ZERO,
  407. deffault = Vector3(0.5, 0.5, 0.5),
  408. },
  409. PropertyDefinition()
  410. {
  411. type = PropertyType.DOUBLE,
  412. name = "data.collider_data.radius", // Sphere and capsule only.
  413. min = 0.0,
  414. deffault = 0.5,
  415. },
  416. PropertyDefinition()
  417. {
  418. type = PropertyType.DOUBLE,
  419. name = "data.collider_data.height", // Capsule only.
  420. min = 0.0,
  421. deffault = 1.0,
  422. },
  423. };
  424. database.create_object_type(OBJECT_TYPE_COLLIDER
  425. , properties
  426. , 2100
  427. , ObjectTypeFlags.UNIT_COMPONENT
  428. , OBJECT_TYPE_TRANSFORM
  429. );
  430. properties =
  431. {
  432. PropertyDefinition()
  433. {
  434. type = PropertyType.STRING,
  435. name = "_global_physics_config",
  436. deffault = "global",
  437. editor = PropertyEditorType.RESOURCE,
  438. resource_type = "physics_config",
  439. hidden = true,
  440. },
  441. PropertyDefinition()
  442. {
  443. type = PropertyType.STRING,
  444. name = "data.class",
  445. editor = PropertyEditorType.ENUM,
  446. enum_property = "_global_physics_config",
  447. enum_callback = class_enum_callback
  448. },
  449. PropertyDefinition()
  450. {
  451. type = PropertyType.STRING,
  452. name = "data.collision_filter",
  453. editor = PropertyEditorType.ENUM,
  454. enum_property = "_global_physics_config",
  455. enum_callback = collision_filter_enum_callback
  456. },
  457. PropertyDefinition()
  458. {
  459. type = PropertyType.STRING,
  460. name = "data.material",
  461. editor = PropertyEditorType.ENUM,
  462. enum_property = "_global_physics_config",
  463. enum_callback = material_enum_callback
  464. },
  465. PropertyDefinition()
  466. {
  467. type = PropertyType.DOUBLE,
  468. name = "data.mass",
  469. min = 0.0,
  470. deffault = 1.0,
  471. },
  472. PropertyDefinition()
  473. {
  474. type = PropertyType.BOOL,
  475. name = "data.lock_translation_x",
  476. },
  477. PropertyDefinition()
  478. {
  479. type = PropertyType.BOOL,
  480. name = "data.lock_translation_y",
  481. },
  482. PropertyDefinition()
  483. {
  484. type = PropertyType.BOOL,
  485. name = "data.lock_translation_z",
  486. },
  487. PropertyDefinition()
  488. {
  489. type = PropertyType.BOOL,
  490. name = "data.lock_rotation_x",
  491. },
  492. PropertyDefinition()
  493. {
  494. type = PropertyType.BOOL,
  495. name = "data.lock_rotation_y",
  496. },
  497. PropertyDefinition()
  498. {
  499. type = PropertyType.BOOL,
  500. name = "data.lock_rotation_z",
  501. },
  502. };
  503. database.create_object_type(OBJECT_TYPE_ACTOR
  504. , properties
  505. , 2101
  506. , ObjectTypeFlags.UNIT_COMPONENT
  507. , OBJECT_TYPE_TRANSFORM
  508. );
  509. properties =
  510. {
  511. PropertyDefinition()
  512. {
  513. type = PropertyType.STRING,
  514. name = "data.script_resource",
  515. label = "Script",
  516. editor = PropertyEditorType.RESOURCE,
  517. resource_type = "lua"
  518. },
  519. };
  520. database.create_object_type(OBJECT_TYPE_SCRIPT
  521. , properties
  522. , 7100
  523. , ObjectTypeFlags.UNIT_COMPONENT
  524. );
  525. properties =
  526. {
  527. PropertyDefinition()
  528. {
  529. type = PropertyType.STRING,
  530. name = "data.state_machine_resource",
  531. label = "State Machine",
  532. editor = PropertyEditorType.RESOURCE,
  533. resource_type = OBJECT_TYPE_STATE_MACHINE
  534. },
  535. };
  536. database.create_object_type(OBJECT_TYPE_ANIMATION_STATE_MACHINE
  537. , properties
  538. , 3100
  539. , ObjectTypeFlags.UNIT_COMPONENT
  540. );
  541. properties =
  542. {
  543. PropertyDefinition()
  544. {
  545. type = PropertyType.VECTOR3,
  546. name = "position",
  547. },
  548. PropertyDefinition()
  549. {
  550. type = PropertyType.QUATERNION,
  551. name = "rotation",
  552. },
  553. PropertyDefinition()
  554. {
  555. type = PropertyType.STRING,
  556. name = "name",
  557. editor = PropertyEditorType.RESOURCE,
  558. resource_type = OBJECT_TYPE_SOUND,
  559. },
  560. PropertyDefinition()
  561. {
  562. type = PropertyType.DOUBLE,
  563. name = "range",
  564. min = 0.0,
  565. deffault = 10.0,
  566. },
  567. PropertyDefinition()
  568. {
  569. type = PropertyType.DOUBLE,
  570. name = "volume",
  571. min = 0.0,
  572. max = 1.0,
  573. deffault = 1.0,
  574. },
  575. PropertyDefinition()
  576. {
  577. type = PropertyType.BOOL,
  578. name = "loop",
  579. },
  580. PropertyDefinition()
  581. {
  582. type = PropertyType.STRING,
  583. name = "group",
  584. deffault = "music",
  585. },
  586. };
  587. database.create_object_type(OBJECT_TYPE_SOUND_SOURCE, properties, 3.0);
  588. properties =
  589. {
  590. PropertyDefinition()
  591. {
  592. type = PropertyType.VECTOR3,
  593. name = "data.color",
  594. editor = PropertyEditorType.COLOR,
  595. min = VECTOR3_ZERO,
  596. max = VECTOR3_ONE,
  597. deffault = VECTOR3_ONE,
  598. },
  599. PropertyDefinition()
  600. {
  601. type = PropertyType.DOUBLE,
  602. name = "data.density",
  603. min = 0.0,
  604. deffault = 0.02
  605. },
  606. PropertyDefinition()
  607. {
  608. type = PropertyType.DOUBLE,
  609. name = "data.range_min",
  610. min = 0.0,
  611. },
  612. PropertyDefinition()
  613. {
  614. type = PropertyType.DOUBLE,
  615. name = "data.range_max",
  616. min = 0.0,
  617. deffault = 1000.0
  618. },
  619. PropertyDefinition()
  620. {
  621. type = PropertyType.DOUBLE,
  622. name = "data.sun_blend",
  623. min = 0.0,
  624. max = 1.0,
  625. deffault = 0.0
  626. },
  627. PropertyDefinition()
  628. {
  629. type = PropertyType.BOOL,
  630. name = "data.enabled",
  631. deffault = true,
  632. },
  633. };
  634. database.create_object_type(OBJECT_TYPE_FOG
  635. , properties
  636. , 1104
  637. , ObjectTypeFlags.UNIT_COMPONENT
  638. );
  639. properties =
  640. {
  641. PropertyDefinition()
  642. {
  643. type = PropertyType.STRING,
  644. name = "_global_physics_config",
  645. deffault = "global",
  646. editor = PropertyEditorType.RESOURCE,
  647. resource_type = "physics_config",
  648. hidden = true,
  649. },
  650. PropertyDefinition()
  651. {
  652. type = PropertyType.DOUBLE,
  653. name = "data.height",
  654. min = 0.0,
  655. deffault = 1.80,
  656. },
  657. PropertyDefinition()
  658. {
  659. type = PropertyType.DOUBLE,
  660. name = "data.radius",
  661. min = 0.0,
  662. deffault = 0.50,
  663. },
  664. PropertyDefinition()
  665. {
  666. type = PropertyType.DOUBLE,
  667. name = "data.max_slope_angle",
  668. editor = PropertyEditorType.ANGLE,
  669. min = 0.0,
  670. max = 90.0,
  671. deffault = 45.0,
  672. },
  673. PropertyDefinition()
  674. {
  675. type = PropertyType.STRING,
  676. name = "data.collision_filter",
  677. editor = PropertyEditorType.ENUM,
  678. enum_property = "_global_physics_config",
  679. enum_callback = collision_filter_enum_callback
  680. },
  681. };
  682. database.create_object_type(OBJECT_TYPE_MOVER
  683. , properties
  684. , 2102
  685. , ObjectTypeFlags.UNIT_COMPONENT
  686. , OBJECT_TYPE_TRANSFORM
  687. );
  688. properties =
  689. {
  690. PropertyDefinition()
  691. {
  692. type = PropertyType.STRING,
  693. name = "data.skydome_map",
  694. label = "Skydome Map",
  695. editor = PropertyEditorType.RESOURCE,
  696. resource_type = OBJECT_TYPE_TEXTURE,
  697. deffault = "core/units/skydome/skydome"
  698. },
  699. PropertyDefinition()
  700. {
  701. type = PropertyType.DOUBLE,
  702. name = "data.skydome_intensity",
  703. min = 0.0,
  704. deffault = 1.0,
  705. },
  706. PropertyDefinition()
  707. {
  708. type = PropertyType.VECTOR3,
  709. name = "data.ambient_color",
  710. editor = PropertyEditorType.COLOR,
  711. min = VECTOR3_ZERO,
  712. max = VECTOR3_ONE,
  713. },
  714. };
  715. database.create_object_type(OBJECT_TYPE_GLOBAL_LIGHTING
  716. , properties
  717. , 1001
  718. , ObjectTypeFlags.UNIT_COMPONENT
  719. );
  720. properties =
  721. {
  722. PropertyDefinition()
  723. {
  724. type = PropertyType.BOOL,
  725. name = "data.enabled",
  726. deffault = true,
  727. },
  728. PropertyDefinition()
  729. {
  730. type = PropertyType.DOUBLE,
  731. name = "data.threshold",
  732. min = 0.0,
  733. hidden = true
  734. },
  735. PropertyDefinition()
  736. {
  737. type = PropertyType.DOUBLE,
  738. name = "data.weight",
  739. min = 0.0,
  740. max = 1.0,
  741. deffault = 0.05,
  742. },
  743. PropertyDefinition()
  744. {
  745. type = PropertyType.DOUBLE,
  746. name = "data.intensity",
  747. min = 0.0,
  748. max = 2.0,
  749. deffault = 0.8,
  750. },
  751. };
  752. database.create_object_type(OBJECT_TYPE_BLOOM
  753. , properties
  754. , 9100
  755. , ObjectTypeFlags.UNIT_COMPONENT
  756. );
  757. properties =
  758. {
  759. PropertyDefinition()
  760. {
  761. type = PropertyType.STRING,
  762. name = "data.type",
  763. editor = PropertyEditorType.ENUM,
  764. enum_values = { "gamma", "reinhard", "filmic", "aces" },
  765. },
  766. };
  767. database.create_object_type(OBJECT_TYPE_TONEMAP
  768. , properties
  769. , 9900
  770. , ObjectTypeFlags.UNIT_COMPONENT
  771. );
  772. properties =
  773. {
  774. PropertyDefinition()
  775. {
  776. type = PropertyType.STRING,
  777. name = "editor.name",
  778. },
  779. };
  780. database.create_object_type(OBJECT_TYPE_UNIT, properties);
  781. properties =
  782. {
  783. PropertyDefinition()
  784. {
  785. type = PropertyType.STRING,
  786. name = "name",
  787. editor = PropertyEditorType.RESOURCE,
  788. resource_type = OBJECT_TYPE_MESH_ANIMATION,
  789. },
  790. PropertyDefinition()
  791. {
  792. type = PropertyType.STRING,
  793. name = "weight",
  794. }
  795. };
  796. StringId64 node_animation_type = database.create_object_type(OBJECT_TYPE_NODE_ANIMATION, properties);
  797. properties =
  798. {
  799. PropertyDefinition()
  800. {
  801. type = PropertyType.STRING,
  802. name = "event",
  803. },
  804. PropertyDefinition()
  805. {
  806. type = PropertyType.STRING,
  807. name = "mode",
  808. editor = PropertyEditorType.ENUM,
  809. enum_values = { "immediate", "wait_until_end" },
  810. },
  811. PropertyDefinition()
  812. {
  813. type = PropertyType.GUID,
  814. object_type = StringId64(OBJECT_TYPE_STATE_MACHINE_NODE),
  815. name = "to",
  816. },
  817. };
  818. StringId64 node_transition_type = database.create_object_type(OBJECT_TYPE_NODE_TRANSITION, properties);
  819. properties =
  820. {
  821. PropertyDefinition()
  822. {
  823. type = PropertyType.STRING,
  824. name = "name",
  825. deffault = "New Node",
  826. },
  827. PropertyDefinition()
  828. {
  829. type = PropertyType.OBJECTS_SET,
  830. name = "animations",
  831. object_type = node_animation_type,
  832. },
  833. PropertyDefinition()
  834. {
  835. type = PropertyType.BOOL,
  836. name = "loop",
  837. },
  838. PropertyDefinition()
  839. {
  840. type = PropertyType.STRING,
  841. name = "speed",
  842. },
  843. PropertyDefinition()
  844. {
  845. type = PropertyType.OBJECTS_SET,
  846. name = "transitions",
  847. object_type = node_transition_type,
  848. },
  849. };
  850. StringId64 state_machine_node_type = database.create_object_type(OBJECT_TYPE_STATE_MACHINE_NODE, properties);
  851. properties =
  852. {
  853. PropertyDefinition()
  854. {
  855. type = PropertyType.STRING,
  856. name = "name",
  857. },
  858. PropertyDefinition()
  859. {
  860. type = PropertyType.DOUBLE,
  861. name = "value",
  862. },
  863. };
  864. StringId64 state_machine_variable_type = database.create_object_type(OBJECT_TYPE_STATE_MACHINE_VARIABLE, properties);
  865. properties =
  866. {
  867. PropertyDefinition()
  868. {
  869. type = PropertyType.GUID,
  870. object_type = StringId64(OBJECT_TYPE_STATE_MACHINE_NODE),
  871. name = "initial_state",
  872. },
  873. PropertyDefinition()
  874. {
  875. type = PropertyType.OBJECTS_SET,
  876. name = "states",
  877. object_type = state_machine_node_type,
  878. },
  879. PropertyDefinition()
  880. {
  881. type = PropertyType.OBJECTS_SET,
  882. name = "variables",
  883. object_type = state_machine_variable_type,
  884. },
  885. };
  886. database.create_object_type(OBJECT_TYPE_STATE_MACHINE, properties);
  887. }
  888. } /* namespace Crown */