├── .gitignore ├── LICENSE.md ├── README.md ├── _material_tesselation ├── README.md └── material_tessellation.blend ├── _vr_dino └── vr_dino.blend ├── animation_actions ├── README.md ├── Sources │ └── arm │ │ └── ActionPlayer.hx └── animation_actions.blend ├── animation_blend ├── Bundled │ └── canvas │ │ ├── MyCanvas.files │ │ ├── MyCanvas.json │ │ └── _themes.json ├── README.md ├── Sources │ └── arm │ │ └── MyTrait.hx └── animation_blend.blend ├── animation_bonechild ├── README.md ├── Sources │ └── arm │ │ └── SwapWeapon.hx └── animation_bonechild.blend ├── animation_instanced ├── README.md └── animation_instanced.blend ├── animation_movebone ├── README.md ├── Sources │ └── arm │ │ ├── MoveBoneFK.hx │ │ └── MoveBoneIK.hx └── animation_movebone.blend ├── animation_timeline └── animation_timeline.blend ├── animation_uv └── animation_uv.blend ├── call_hx ├── Bundled │ └── my_plugin.js ├── README.md ├── Sources │ └── arm │ │ ├── EvalJS.hx │ │ └── Plugin.hx └── call_hx.blend ├── call_js ├── README.md ├── Sources │ └── arm │ │ └── CallJS.hx └── call_js.blend ├── debug_draw ├── README.md ├── Sources │ └── arm │ │ └── MyTrait.hx └── debug_draw.blend ├── dev_logicnode ├── Libraries │ └── mynodes │ │ ├── Sources │ │ └── armory │ │ │ └── logicnode │ │ │ └── TestNode.hx │ │ └── blender.py └── dev_logicnode.blend ├── ease ├── README.md ├── Sources │ └── arm │ │ └── TweenTest.hx └── ease.blend ├── file_read ├── Bundled │ ├── canvas │ │ ├── MyCanvas.files │ │ ├── MyCanvas.json │ │ └── _themes.json │ └── my_file.json ├── README.md ├── Sources │ └── arm │ │ └── ReadFile.hx └── file_read.blend ├── file_storage ├── README.md ├── Sources │ └── arm │ │ └── StorageTest.hx └── file_storage.blend ├── file_write ├── README.md ├── Sources │ └── arm │ │ └── WriteFile.hx └── file_write.blend ├── game_bowling ├── Assets │ ├── floor_base.jpg │ ├── floor_nor.jpg │ ├── floor_occ.jpg │ ├── floor_rough.jpg │ ├── keys.png │ ├── menu.jpg │ ├── roll.wav │ ├── strike.wav │ ├── ui_exit.png │ ├── ui_play.png │ └── ui_refresh.png ├── Bundled │ └── canvas │ │ ├── GameCanvas.files │ │ ├── GameCanvas.json │ │ ├── MenuCanvas.files │ │ ├── MenuCanvas.json │ │ └── _themes.json ├── README.md ├── Sources │ └── arm │ │ ├── BallTrait.hx │ │ └── PinTrait.hx ├── game_bowling.blend ├── pin.blend └── textures │ └── bowling.jpg ├── game_endlessrun ├── Bundled │ └── canvas │ │ ├── MyCanvas.files │ │ └── MyCanvas.json ├── Sources │ └── arm │ │ ├── GemTrait.hx │ │ ├── PlayerController.hx │ │ └── SceneBuilder.hx ├── game_endless.blend └── grid.png ├── graphics_settings ├── Bundled │ ├── canvas │ │ ├── MyCanvas.files │ │ ├── MyCanvas.json │ │ └── _themes.json │ └── config.arm ├── README.md ├── Sources │ └── arm │ │ └── MyTrait.hx └── graphics_settings.blend ├── input_mouselock ├── README.md ├── Sources │ └── arm │ │ └── LockTrait.hx └── input_mouselock.blend ├── input_multitouch ├── Sources │ └── arm │ │ └── TouchTrait.hx └── input_multitouch.blend ├── input_sensor ├── Sources │ └── arm │ │ └── SensorTrait.hx └── input_sensor.blend ├── instancing ├── README.md └── instancing.blend ├── light_area ├── checker.png ├── checker_rough.png └── light_area.blend ├── light_ies ├── Bundled │ ├── iestexture.png │ ├── iestexture2.png │ └── iestexture3.png └── light_ies.blend ├── light_probes └── light_probes.blend ├── light_probes_cubemap └── light_probes_cubemap.blend ├── light_probes_plane └── light_probes_plane.blend ├── light_volumetric ├── README.md └── light_volumetric.blend ├── load_screen ├── Bundled │ └── bunny.png ├── Sources │ └── arm │ │ └── LoadingScreen.hx └── load_screen.blend ├── lod ├── README.md └── lod.blend ├── logic_Hello_World ├── logic_Hello_World.blend ├── logic_Hello_World_nodetree.png └── logic_Hello_World_output.png ├── logic_break └── logic_break.blend ├── logic_callgroup ├── Bundled │ └── canvas │ │ ├── MyCanvas.files │ │ └── MyCanvas.json ├── README.md └── logic_callgroup.blend ├── logic_camera_pan └── logic_camera_pan.blend ├── logic_camera_zoom └── logic_camera_zoom.blend ├── logic_canvas ├── Assets │ ├── background.png │ └── charactor.png ├── Bundled │ └── canvas │ │ ├── MyCanvas.files │ │ ├── MyCanvas.json │ │ └── _themes.json └── logic_canvas.blend ├── logic_event_fromhaxe ├── README.md ├── Sources │ └── arm │ │ └── SendEvent.hx └── logic_event_fromhaxe.blend ├── logic_event_global └── logic_event_global.blend ├── logic_event_object ├── README.md ├── Sources │ └── arm │ │ └── SendEvent.hx └── logic_event_object.blend ├── logic_gamepad ├── Bundled │ └── canvas │ │ ├── MyCanvas.files │ │ ├── MyCanvas.json │ │ └── _themes.json ├── Sources │ └── arm │ │ └── VirtualGamepad.hx └── logic_gamepad.blend ├── logic_gate ├── checker.png ├── checker_rough.png └── logic_gate.blend ├── logic_get_contacts └── logic_get_contacts.blend ├── logic_keyboard └── logic_keyboard.blend ├── logic_linked_variable └── logic_linked_variable.blend ├── logic_loadurl └── logic_loadurl.blend ├── logic_mouselock └── logic_mouselock.blend ├── logic_object_rotate ├── README.md └── logic_object_rotate.blend ├── logic_object_scale ├── README.md └── logic_object_scale.blend ├── logic_object_translate ├── README.md └── logic_object_translate.blend ├── logic_pause_trait ├── README.md └── logic_pause_trait.blend ├── logic_pong ├── checker.png ├── checker_rough.png └── logic_pong.blend ├── logic_scenes ├── README.md └── logic_scenes.blend ├── logic_scenetree ├── README.md └── logic_scenetree.blend ├── logic_script └── logic_script.blend ├── logic_set_property ├── README.md └── logic_set_property.blend ├── logic_toy_car ├── README.md └── logic_toy_car.blend ├── logic_transform └── logic_transform.blend ├── macro_armpack ├── README.md ├── Sources │ └── arm │ │ ├── Game.hx │ │ └── Macros.hx └── macro_armpack.blend ├── material_alpha ├── README.md ├── circle.png └── material_alpha.blend ├── material_bake └── material_bake.blend ├── material_batch └── material_batch.blend ├── material_billboard ├── bunny.png └── material_billboard.blend ├── material_bump ├── brick_bump.jpg └── material_bump.blend ├── material_decal ├── decal.png └── material_decal.blend ├── material_decal_colors ├── README.md └── material_decal_colors.blend ├── material_depth_texture ├── Assets │ ├── checker_rough.png │ └── grid.png ├── README.md └── material_depth_texture.blend ├── material_displace ├── README.md └── material_displace.blend ├── material_glossy_metallic └── material_glossy_metallic.blend ├── material_multiuvs └── multiuvs.blend ├── material_normalmap └── material_normalmap.blend ├── material_params ├── Bundled │ ├── tex1.png │ └── tex2.png ├── README.md ├── Sources │ └── arm │ │ └── MyTrait.hx └── material_params.blend ├── material_shadeless └── material_shadeless.blend ├── material_shaders ├── Bundled │ └── MyCustomMaterial │ │ └── MyCustomMaterial.json ├── Shaders │ ├── MyCustomMaterial.frag.glsl │ └── MyCustomMaterial.vert.glsl ├── Sources │ └── arm │ │ └── MyTrait.hx └── material_shaders.blend ├── material_sss └── material_sss.blend ├── material_translucent ├── circle.png └── material_translucent.blend ├── material_video ├── README.md ├── material_video.blend └── video.mp4 ├── mesh_generate ├── README.md ├── Sources │ └── arm │ │ └── BoxGenerator.hx └── mesh_generate.blend ├── mesh_import ├── Bundled │ └── cube.obj ├── Sources │ └── arm │ │ ├── ImportMesh.hx │ │ └── ObjParser.hx └── mesh_import.blend ├── mesh_terrain ├── Bundled │ └── heightmap_01.png ├── README.md ├── base.png └── mesh_terrain.blend ├── navmesh ├── README.md ├── gridbox.png ├── gridbox2.png └── navmesh.blend ├── navmesh_follow ├── README.md └── navmesh_follow.blend ├── network_zui_chat ├── Bundled │ └── canvas │ │ ├── MainCanvas.files │ │ ├── MainCanvas.json │ │ └── _themes.json ├── README.md └── network_zui_chat.blend ├── particle_bunny ├── bunny.png └── particle_bunny.blend ├── particle_hair └── particle_hair.blend ├── particle_hair_animated ├── README.md └── particle_hair_animated.blend ├── particle_info ├── part.png └── particle_info.blend ├── particle_mesh ├── README.md └── particle_mesh.blend ├── particle_smoke ├── particle_smoke.blend └── smoke.jpg ├── physics_break └── physics_break.blend ├── physics_collision_groups └── physics_collision_groups.blend ├── physics_constraints ├── README.md └── physics_constraints.blend ├── physics_drag ├── README.md └── physics_drag.blend ├── physics_pick ├── README.md ├── Sources │ └── arm │ │ ├── PickEvent.hx │ │ └── PickTrait.hx └── physics_pick.blend ├── physics_ragdoll ├── README.md ├── checker.png ├── checker_rough.png └── physics_ragdoll.blend ├── physics_raycast ├── README.md ├── Sources │ └── arm │ │ └── RayCastTrait.hx └── physics_raycast.blend ├── physics_softbody ├── README.md └── physics_softbody.blend ├── raycast_objects ├── Raycast_Objects.blend └── Sources │ ├── Main.hx │ └── arm │ └── MyTraitRaycastObjects.hx ├── render_bloom ├── README.md └── render_bloom.blend ├── render_colorgrading ├── Bundled │ └── luttexture.jpg ├── README.md ├── extras │ ├── LUT_Cold.jpg │ ├── LUT_Color_Neutral.jpg │ ├── LUT_Noir.jpg │ ├── LUT_Selective.jpg │ ├── LUT_Sepia.jpg │ └── LUT_Warm.jpg ├── img │ ├── calib_1.png │ ├── calib_2.png │ └── tex1.jpg └── render_colorgrading.blend ├── render_splitscreen ├── Sources │ └── arm │ │ └── SplitScreen.hx └── render_splitscreen.blend ├── render_to_texture ├── README.md ├── Sources │ └── arm │ │ └── MyTrait.hx └── render_to_texture.blend ├── render_voxelao_teapots ├── render_voxelao_teapots.blend └── shadows.blend ├── scene_stream ├── README.md └── scene_stream.blend ├── screentex ├── Sources │ └── arm │ │ └── MyTrait.hx └── screentex.blend ├── script_camera_lerp ├── README.md ├── Sources │ └── arm │ │ ├── CameraTrait.hx │ │ └── MyTrait.hx └── script_camera_lerp.blend ├── script_linkedgroup ├── README.md ├── Sources │ └── arm │ │ ├── PinSpawner.hx │ │ └── PinTrait.hx ├── pin.blend └── script_linkedgroup.blend ├── script_logic_talk └── property │ ├── Sources │ └── arm │ │ └── ReadConfig.hx │ └── property.blend ├── script_properties ├── Sources │ └── arm │ │ └── MyTrait.hx └── script_properties.blend ├── script_properties_global ├── Sources │ └── arm │ │ ├── Config.hx │ │ └── ReadConfig.hx └── script_properties_global.blend ├── script_rigidbody_trigger ├── README.md ├── Sources │ └── arm │ │ └── Trigger.hx └── script_rigidbody_trigger.blend ├── script_spawnobject ├── Sources │ └── arm │ │ └── SpawnTrait.hx └── script_spawnobject.blend ├── script_transform ├── README.md ├── Sources │ └── arm │ │ └── TransformTest.hx └── script_transform.blend ├── server_stream ├── README.md ├── Sources │ └── arm │ │ ├── ArcBall.hx │ │ ├── LoadTrait.hx │ │ └── ObjParser.hx └── server_stream.blend ├── sound ├── Bundled │ ├── hit0.wav │ ├── hit1.wav │ └── hit2.wav ├── README.md ├── Sources │ └── arm │ │ └── SoundControl.hx ├── drums.wav └── sound.blend ├── spawn_from_scene ├── README.md ├── Sources │ └── arm │ │ └── MyTrait.hx └── spawn_from_scene.blend ├── text_area_string └── text_area_string.blend ├── tilesheet ├── README.md ├── Sources │ └── arm │ │ └── AnimControl.hx ├── textures │ ├── dungeon tileset calciumtrice simple.png │ ├── minotaur spritesheet calciumtrice.png │ ├── orc spritesheet calciumtrice.png │ ├── ranger spritesheet calciumtrice.png │ ├── rogue spritesheet calciumtrice_0.png │ ├── warrior spritesheet calciumtrice.png │ └── wizard spritesheet calciumtrice.png └── tilesheet.blend ├── tilesheet_2d ├── README.md ├── Sources │ └── arm │ │ └── AnimControl.hx ├── textures │ ├── dungeon tileset calciumtrice simple.png │ ├── minotaur spritesheet calciumtrice.png │ ├── orc spritesheet calciumtrice.png │ ├── ranger spritesheet calciumtrice.png │ ├── rogue spritesheet calciumtrice_0.png │ ├── warrior spritesheet calciumtrice.png │ └── wizard spritesheet calciumtrice.png └── tilesheet_2d.blend ├── tilesheet_walkcycle ├── README.md ├── Sources │ └── arm │ │ └── AnimControl.hx ├── sprite_tux.png └── tilesheet_walkcycle.blend ├── tween ├── Sources │ └── arm │ │ └── MyTrait.hx └── tween.blend ├── ui_canvas ├── Assets │ ├── crate.png │ └── license.txt ├── Bundled │ └── canvas │ │ ├── MyCanvas.files │ │ └── MyCanvas.json ├── README.md ├── Sources │ └── arm │ │ └── CanvasTrait.hx └── ui_canvas.blend ├── ui_events ├── Bundled │ └── canvas │ │ ├── MyCanvas.files │ │ └── MyCanvas.json ├── README.md ├── Sources │ └── arm │ │ └── MyTrait.hx └── ui_events.blend ├── ui_script2d ├── README.md ├── Sources │ └── arm │ │ └── UITrait.hx └── ui_script2d.blend ├── ui_script3d ├── Assets │ └── dummy.jpg ├── README.md ├── Sources │ └── arm │ │ └── UITrait.hx ├── checker.png ├── checker_rough.png └── ui_script3d.blend ├── wasm_call ├── Bundled │ └── main.wasm ├── README.md ├── Sources │ └── arm │ │ └── MyTrait.hx ├── main.c ├── wasm.png └── wasm_call.blend ├── wasm_trait_c ├── Bundled │ └── main.wasm ├── README.md ├── main.c ├── wasm.png └── wasm_trait_c.blend ├── wasm_trait_rust ├── Bundled │ └── main.wasm ├── README.md ├── main.rs ├── wasm.png └── wasm_trait_rust.blend └── world_sun_direction ├── README.md ├── Sources └── arm │ └── MyTrait.hx └── world_sun_direction.blend /.gitignore: -------------------------------------------------------------------------------- 1 | */build* 2 | */*.blend? 3 | */Sources/Main.hx 4 | */Sources/arm/node/* 5 | *.pyc 6 | *.DS_Store 7 | khafile.js 8 | node_update_failure.* 9 | .vscode/ 10 | config.arm 11 | _*/ 12 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The zlib/libpng License 2 | 3 | This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. 4 | Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 5 | The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 6 | Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 7 | This notice may not be removed or altered from any source distribution. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Armory Example Projects 2 | 3 | Browse online: https://armory3d.github.io/armory_examples_browser/ 4 | 5 | Only use the latest revision of this repository if you are using [armory-git](https://github.com/armory3d/armory/wiki/gitversion). 6 | 7 | When adding a new project: 8 | 9 | - Demonstrate a single feature 10 | - Keep your assets as small as possible 11 | - Save the project into a directory with the same name as the main blend file (`/.blend`) 12 | - Prefix the name of the project with the category the of the showcase (`logic_`, `light_`, `render_`, `ui_`, ...) 13 | - Add a `/README.md` describing the project 14 | - If the `README.md` includes usage instructions (like: keybindings) link it as text file into blenders __Text Editor__. 15 | - Remove any orphaned data from your blend file 16 | 17 | --- 18 | 19 | [Download](https://armory3d.org/download) • [Manual](https://github.com/armory3d/armory/wiki) • [API](https://api.armory3d.org) • [Community](https://armory3d.org/community) 20 | -------------------------------------------------------------------------------- /_material_tesselation/README.md: -------------------------------------------------------------------------------- 1 | Note: Tessellation is only supported on OpenGL as of now. 2 | -------------------------------------------------------------------------------- /_material_tesselation/material_tessellation.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/_material_tesselation/material_tessellation.blend -------------------------------------------------------------------------------- /_vr_dino/vr_dino.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/_vr_dino/vr_dino.blend -------------------------------------------------------------------------------- /animation_actions/README.md: -------------------------------------------------------------------------------- 1 | Press keyboard `1`, `2`, `3` to change the animation action 2 | -------------------------------------------------------------------------------- /animation_actions/Sources/arm/ActionPlayer.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class ActionPlayer extends iron.Trait { 4 | 5 | function getAnim() { 6 | // Trait placed on mesh object 7 | var anim = object.animation; 8 | // Trait placed on armature object - retrieve animation from child mesh 9 | if (anim == null) anim = object.children[0].animation; 10 | return anim; 11 | } 12 | 13 | public function new() { 14 | super(); 15 | 16 | notifyOnInit(function() { 17 | var anim = getAnim(); 18 | anim.notifyOnMarker("my_marker", function() { 19 | trace("Marker!"); 20 | }); 21 | }); 22 | 23 | notifyOnUpdate(function() { 24 | var kb = iron.system.Input.getKeyboard(); 25 | 26 | var anim = getAnim(); 27 | 28 | if (kb.started("1")) anim.play("idle"); 29 | else if (kb.started("2")) anim.play("run"); 30 | else if (kb.started("3")) anim.play("slash", onSlash); 31 | else if (kb.started("6")) anim.pause(); 32 | else if (kb.started("7")) anim.resume(); 33 | }); 34 | } 35 | 36 | function onSlash() { 37 | trace("Slash animation played!"); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /animation_actions/animation_actions.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/animation_actions/animation_actions.blend -------------------------------------------------------------------------------- /animation_blend/Bundled/canvas/MyCanvas.files: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/animation_blend/Bundled/canvas/MyCanvas.files -------------------------------------------------------------------------------- /animation_blend/Bundled/canvas/MyCanvas.json: -------------------------------------------------------------------------------- 1 | {"name":"untitled","x":0,"y":0,"width":1280,"height":720,"elements":[{"id":0,"type":0,"name":"Text","event":"","x":0,"y":0,"width":383,"height":44,"rotation":0,"text":"Hold W/S to blend","asset":"","color":-1,"anchor":0,"parent":null,"children":[],"visible":true}],"assets":[],"theme":"Default Light"} -------------------------------------------------------------------------------- /animation_blend/Bundled/canvas/_themes.json: -------------------------------------------------------------------------------- 1 | [{"NAME":"Default Light","WINDOW_BG_COL":-1052689,"WINDOW_TINT_COL":-14540254,"ACCENT_COL":-1118482,"ACCENT_HOVER_COL":-4473925,"ACCENT_SELECT_COL":-5592406,"BUTTON_COL":-3355444,"BUTTON_TEXT_COL":-14540254,"BUTTON_HOVER_COL":-5000269,"BUTTON_PRESSED_COL":-5131855,"TEXT_COL":-14144472,"LABEL_COL":-5592406,"SEPARATOR_COL":-6710887,"HIGHLIGHT_COL":-14656100,"CONTEXT_COL":-5592406,"PANEL_BG_COL":-5592406,"FONT_SIZE":26,"ELEMENT_W":200,"ELEMENT_H":48,"ELEMENT_OFFSET":8,"ARROW_SIZE":10,"BUTTON_H":44,"CHECK_SIZE":30,"CHECK_SELECT_SIZE":16,"SCROLL_W":12,"TEXT_OFFSET":16,"TAB_W":24,"FILL_WINDOW_BG":false,"FILL_BUTTON_BG":true,"FILL_ACCENT_BG":false,"LINK_STYLE":0,"FULL_TABS":false}] -------------------------------------------------------------------------------- /animation_blend/README.md: -------------------------------------------------------------------------------- 1 | Hold keyboard `W`, `S` to blend between animations 2 | -------------------------------------------------------------------------------- /animation_blend/Sources/arm/MyTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class MyTrait extends iron.Trait { 4 | 5 | var factor = 0.0; 6 | 7 | public function new() { 8 | super(); 9 | 10 | notifyOnUpdate(function() { 11 | 12 | var anim:iron.object.BoneAnimation = cast object.children[0].animation; 13 | var kb = iron.system.Input.getKeyboard(); 14 | 15 | // Blend idle and run actions 16 | // factor 0.0 -> 100% idle 17 | // factor 0.5 -> 50% idle, 50% run 18 | // factor 1.0 -> 100% run 19 | if (kb.down("w")) { 20 | if (factor <= 0.99) factor += 0.01; 21 | anim.blend("idle", "run", factor); 22 | } 23 | 24 | if (kb.down("s")) { 25 | if (factor >= 0.01) factor -= 0.01; 26 | anim.blend("idle", "run", factor); 27 | } 28 | }); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /animation_blend/animation_blend.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/animation_blend/animation_blend.blend -------------------------------------------------------------------------------- /animation_bonechild/README.md: -------------------------------------------------------------------------------- 1 | - Hand object is parented to armature bone 2 | - Sword is parented to Hand object 3 | - Press `X` to swap weapons 4 | -------------------------------------------------------------------------------- /animation_bonechild/Sources/arm/SwapWeapon.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class SwapWeapon extends iron.Trait { 4 | 5 | var weapon = 0; 6 | var hand:iron.object.Object; 7 | var sword:iron.object.Object; 8 | var axe:iron.object.Object; 9 | 10 | public function new() { 11 | super(); 12 | 13 | notifyOnInit(function() { 14 | var sc = iron.Scene.active; 15 | hand = sc.getChild("Hand"); 16 | sword = sc.getChild("Sword"); 17 | axe = sc.getChild("Axe"); 18 | }); 19 | 20 | notifyOnUpdate(function() { 21 | var kb = iron.system.Input.getKeyboard(); 22 | if (kb.started("x")) { 23 | 24 | var a = weapon == 0 ? sword : axe; // Currently equipped weapon 25 | var b = weapon == 0 ? axe : sword; // The other weapon 26 | 27 | // Remove current weapon from hand 28 | hand.removeChild(a); 29 | a.visible = false; 30 | 31 | // Add the other weapon to hand 32 | hand.addChild(b); 33 | b.visible = true; 34 | 35 | // Swap weapon 36 | weapon = weapon == 0 ? 1 : 0; 37 | } 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /animation_bonechild/animation_bonechild.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/animation_bonechild/animation_bonechild.blend -------------------------------------------------------------------------------- /animation_instanced/README.md: -------------------------------------------------------------------------------- 1 | Use instancing for fast rendering of linked object duplicates. 2 | 3 | https://github.com/armory3d/armory/wiki/instancing 4 | -------------------------------------------------------------------------------- /animation_instanced/animation_instanced.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/animation_instanced/animation_instanced.blend -------------------------------------------------------------------------------- /animation_movebone/README.md: -------------------------------------------------------------------------------- 1 | The left arm is controlled by Inverse Kinematics with a finger following a ball movement. 2 | Use `W` `S` `A` and `D` keys to move the ball. 3 | The right arm is controlled by Forward Kinematics with a Haxe script. 4 | -------------------------------------------------------------------------------- /animation_movebone/Sources/arm/MoveBoneFK.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.math.Vec4; 4 | import iron.math.Quat; 5 | import iron.object.BoneAnimation; 6 | import iron.math.Mat4; 7 | 8 | // Moving a bone - forward kinematics 9 | class MoveBoneFK extends iron.Trait { 10 | 11 | public function new() { 12 | super(); 13 | 14 | notifyOnInit(function() { 15 | // Fetch armature animation 16 | var anim = cast(object.children[0].animation, BoneAnimation); 17 | // Fetch bone 18 | var bone = anim.getBone("mixamorig:RightArm"); 19 | 20 | // Manipulating bone in local space 21 | //var m = anim.getBoneMat(bone); 22 | // anim.notifyOnUpdate(function() { 23 | // var offset = new Quat().fromEuler(0, Math.sin(iron.system.Time.time()), 0); 24 | // m.applyQuat(offset); 25 | //}); 26 | 27 | // Manipulating bone in world space 28 | anim.notifyOnUpdate(function() { 29 | // Get bone mat in world space 30 | var m = anim.getAbsWorldMat(bone); 31 | // Decompose transform 32 | var loc = new Vec4(); 33 | var scl = new Vec4(); 34 | var rot = new Quat(); 35 | m.decompose(loc, rot, scl); 36 | // Apply rotation 37 | var offset = new Quat().fromEuler(Math.sin(iron.system.Time.time()), 0, 0); 38 | rot.multquats(offset, rot); 39 | // Compose world matrix 40 | m.compose(loc, rot, scl); 41 | // Set bone matrix from world matrix 42 | anim.setBoneMatFromWorldMat(m, bone); 43 | }); 44 | }); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /animation_movebone/Sources/arm/MoveBoneIK.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.object.BoneAnimation; 4 | 5 | // Moving a bone - inverse kinematics 6 | class MoveBoneIK extends iron.Trait { 7 | 8 | public function new() { 9 | super(); 10 | 11 | iron.Scene.active.notifyOnInit(function() { 12 | 13 | // Fetch armature animation 14 | var anim = cast(object.children[0].animation, BoneAnimation); 15 | // Fetch bone 16 | var bone = anim.getBone("mixamorig:LeftHandIndex4"); 17 | // Fetch goal 18 | var tr = iron.Scene.active.getChild("Goal").transform; 19 | var goal = new iron.math.Vec4(); 20 | 21 | anim.notifyOnUpdate(function() { 22 | goal.set(tr.worldx(), tr.worldy(), tr.worldz()); 23 | // Align skeleton to touch the goal 24 | anim.solveIK(bone, goal); 25 | }); 26 | }); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /animation_movebone/animation_movebone.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/animation_movebone/animation_movebone.blend -------------------------------------------------------------------------------- /animation_timeline/animation_timeline.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/animation_timeline/animation_timeline.blend -------------------------------------------------------------------------------- /animation_uv/animation_uv.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/animation_uv/animation_uv.blend -------------------------------------------------------------------------------- /call_hx/Bundled/my_plugin.js: -------------------------------------------------------------------------------- 1 | 2 | // Call Plugin class exposed from Haxe 3 | 4 | var plugin = new arm.Plugin(); 5 | plugin.hello(); 6 | 7 | var scene = plugin.scene(); 8 | var rot = 0.0; 9 | 10 | plugin.update = function() { 11 | rot += 0.01; 12 | var o = scene.getChild("Cube"); 13 | o.transform.setRotation(0, 0, rot); 14 | } 15 | -------------------------------------------------------------------------------- /call_hx/README.md: -------------------------------------------------------------------------------- 1 | Check console. 2 | https://github.com/armory3d/armory/wiki/js 3 | -------------------------------------------------------------------------------- /call_hx/Sources/arm/EvalJS.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class EvalJS { 4 | 5 | public function new() { 6 | // Evaluate bundled JS, usually you would embed JS into .html file instead 7 | iron.data.Data.getBlob("my_plugin.js", function(blob:kha.Blob) { 8 | js.Syntax.code("(1, eval)({0})", blob.toString()); 9 | }); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /call_hx/Sources/arm/Plugin.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | // Expose this class for easy access from JS 4 | 5 | @:expose 6 | class Plugin extends iron.Trait { 7 | 8 | var update:Void->Void = null; 9 | 10 | public function new() { 11 | super(); 12 | notifyOnUpdate(function() { 13 | if (update != null) update(); 14 | }); 15 | } 16 | 17 | public function hello() { 18 | trace("world"); 19 | } 20 | 21 | public function scene() { 22 | return iron.Scene.active; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /call_hx/call_hx.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/call_hx/call_hx.blend -------------------------------------------------------------------------------- /call_js/README.md: -------------------------------------------------------------------------------- 1 | Shows how to call js after clicking on a `Cube` object. 2 | 3 | - Requires html5 target and physics enabled. 4 | - Check devtools for output. 5 | 6 | https://github.com/armory3d/armory/wiki/js 7 | -------------------------------------------------------------------------------- /call_js/Sources/arm/CallJS.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import armory.trait.physics.PhysicsWorld; 4 | import iron.system.Input; 5 | 6 | // This example shows how to call JavaScript after clicking on a Cube object 7 | // Requires physics enabled and browser target 8 | 9 | class CallJS extends iron.Trait { 10 | 11 | public function new() { 12 | super(); 13 | var mouse = Input.getMouse(); 14 | notifyOnUpdate(function() { 15 | 16 | // Check mouse button 17 | if (!mouse.started()) return; 18 | 19 | // Pick object at mouse coords 20 | var rb = PhysicsWorld.active.pickClosest(mouse.x, mouse.y); 21 | 22 | // Check if picked object is our Cube 23 | if (rb != null && rb.object.name == 'Cube') { 24 | // Raw JS calls 25 | js.Syntax.code('console.log("Cube clicked");'); 26 | js.Syntax.code('document.title = "Cube clicked";'); 27 | js.Syntax.code('window.alert("Cube clicked");'); 28 | } else { 29 | js.Syntax.code('console.log("click");'); 30 | } 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /call_js/call_js.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/call_js/call_js.blend -------------------------------------------------------------------------------- /debug_draw/README.md: -------------------------------------------------------------------------------- 1 | To see debug drawing, `Armory Project - Debug Console` option has to be enabled. 2 | -------------------------------------------------------------------------------- /debug_draw/Sources/arm/MyTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | #if arm_debug 4 | import armory.trait.internal.DebugDraw; 5 | #end 6 | 7 | class MyTrait extends iron.Trait { 8 | 9 | public function new() { 10 | super(); 11 | notifyOnInit( () -> { 12 | var plane = iron.Scene.active.getChild("Plane"); 13 | var suzanne = iron.Scene.active.getChild("Suzanne"); 14 | // To see debug drawing, `Armory Project - Debug Console` option has to be enabled 15 | #if arm_debug 16 | DebugDraw.notifyOnRender( (draw:DebugDraw) -> { 17 | if(plane != null) draw.bounds(plane.transform); 18 | if(suzanne != null) draw.bounds(suzanne.transform); 19 | // draw.line(); 20 | }); 21 | #end 22 | }); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /debug_draw/debug_draw.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/debug_draw/debug_draw.blend -------------------------------------------------------------------------------- /dev_logicnode/Libraries/mynodes/Sources/armory/logicnode/TestNode.hx: -------------------------------------------------------------------------------- 1 | package armory.logicnode; 2 | 3 | class TestNode extends LogicNode { 4 | 5 | public function new(tree:LogicTree) { 6 | super(tree); 7 | } 8 | 9 | override function run(from:Int) { 10 | // Logic for this node 11 | trace("Hello, World!"); 12 | 13 | // Execute next action linked to this node 14 | runOutput(0); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /dev_logicnode/Libraries/mynodes/blender.py: -------------------------------------------------------------------------------- 1 | from bpy.types import Node 2 | from arm.logicnode.arm_nodes import * 3 | import arm.nodes_logic 4 | 5 | 6 | class TestNode(ArmLogicTreeNode): 7 | """Test node""" 8 | bl_idname = 'LNTestNode' 9 | bl_label = 'Test' 10 | 11 | # Use this as a tooltip in the add node menu. 12 | # If `bl_description` does not exist, the docstring of this node is used instead. 13 | bl_description = 'This is a test node' 14 | 15 | # The category in which this node is listed in the user interface 16 | arm_category = 'Custom Nodes' 17 | 18 | # Set the version of this node. If you update the node's Python 19 | # code later, increment this version so that older projects get 20 | # updated automatically. 21 | # See https://github.com/armory3d/armory/wiki/logicnodes#node-versioning 22 | arm_version = 0 23 | 24 | def init(self, context): 25 | self.add_input('ArmNodeSocketAction', 'In') 26 | self.add_output('ArmNodeSocketAction', 'Out') 27 | 28 | 29 | def register(): 30 | """This function is called when Armory loads this library.""" 31 | 32 | # Add a new category of nodes in which we will put the TestNode. 33 | # This step is optional, you can also add nodes to Armory's default 34 | # categories. 35 | add_category('Custom Nodes', icon='EVENT_C') 36 | 37 | # Register the TestNode 38 | TestNode.on_register() 39 | -------------------------------------------------------------------------------- /dev_logicnode/dev_logicnode.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/dev_logicnode/dev_logicnode.blend -------------------------------------------------------------------------------- /ease/README.md: -------------------------------------------------------------------------------- 1 | - https://api.armory3d.org/iron/system/Ease.html 2 | - https://api.armory3d.org/iron/system/Tween.html 3 | -------------------------------------------------------------------------------- /ease/Sources/arm/TweenTest.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.system.Tween; 4 | #if arm_debug 5 | import armory.trait.internal.DebugDraw; 6 | #end 7 | 8 | class TweenTest extends iron.Trait { 9 | 10 | @prop var ease : Int = 0; 11 | 12 | public function new() { 13 | super(); 14 | notifyOnInit(() -> { 15 | #if arm_debug 16 | //DebugDraw.notifyOnRender( draw -> draw.bounds( object.transform) ); 17 | #end 18 | doTween(10); 19 | }); 20 | } 21 | 22 | function doTween( v : Float ) { 23 | Tween.to({ 24 | target: object.transform.loc, 25 | props: { z: v }, 26 | delay: 0.5, 27 | duration: 2.0, 28 | ease: ease, 29 | tick: object.transform.buildMatrix, 30 | done: () -> doTween(-v) 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ease/ease.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/ease/ease.blend -------------------------------------------------------------------------------- /file_read/Bundled/canvas/MyCanvas.files: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/file_read/Bundled/canvas/MyCanvas.files -------------------------------------------------------------------------------- /file_read/Bundled/canvas/MyCanvas.json: -------------------------------------------------------------------------------- 1 | {"name":"untitled","x":0,"y":0,"width":1280,"height":720,"elements":[{"id":0,"type":0,"name":"Text","event":"","x":0,"y":0,"width":372,"height":44,"rotation":0,"text":"My Text","asset":"","color":-1,"anchor":0,"parent":null,"children":[],"visible":true,"color_text":-16744449}],"assets":[],"theme":"Default Light"} -------------------------------------------------------------------------------- /file_read/Bundled/canvas/_themes.json: -------------------------------------------------------------------------------- 1 | [{"NAME":"Default Light","WINDOW_BG_COL":-1052689,"WINDOW_TINT_COL":-14540254,"ACCENT_COL":-1118482,"ACCENT_HOVER_COL":-4473925,"ACCENT_SELECT_COL":-5592406,"BUTTON_COL":-3355444,"BUTTON_TEXT_COL":-14540254,"BUTTON_HOVER_COL":-5000269,"BUTTON_PRESSED_COL":-5131855,"TEXT_COL":-6710887,"LABEL_COL":-5592406,"SEPARATOR_COL":-6710887,"HIGHLIGHT_COL":-14656100,"CONTEXT_COL":-5592406,"PANEL_BG_COL":-5592406,"FONT_SIZE":26,"ELEMENT_W":200,"ELEMENT_H":48,"ELEMENT_OFFSET":8,"ARROW_SIZE":10,"BUTTON_H":44,"CHECK_SIZE":30,"CHECK_SELECT_SIZE":16,"SCROLL_W":12,"TEXT_OFFSET":16,"TAB_W":24,"FILL_WINDOW_BG":false,"FILL_BUTTON_BG":true,"FILL_ACCENT_BG":false,"LINK_STYLE":0}] -------------------------------------------------------------------------------- /file_read/Bundled/my_file.json: -------------------------------------------------------------------------------- 1 | { 2 | "my_text": "Hello from json!" 3 | } 4 | -------------------------------------------------------------------------------- /file_read/README.md: -------------------------------------------------------------------------------- 1 | Loads a json file from the `Bundled/` directory. 2 | -------------------------------------------------------------------------------- /file_read/Sources/arm/ReadFile.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import armory.trait.internal.CanvasScript; 4 | import iron.data.Data; 5 | import iron.Scene; 6 | 7 | class ReadFile extends iron.Trait { 8 | public function new() { 9 | super(); 10 | 11 | notifyOnInit(function() { 12 | 13 | // Relative or absolute path to file 14 | // In this case we load the file placed in the "Bundled/" directory 15 | var file = "my_file.json"; 16 | 17 | // Load the file asynchronously 18 | Data.getBlob(file, function(b:kha.Blob) { 19 | // File is now loaded 20 | // Get string from loaded bytes 21 | var string = b.toString(); 22 | 23 | // Get json from string 24 | var json = haxe.Json.parse(string); 25 | 26 | // Get canvas trait 27 | var canvas = Scene.active.getTrait(CanvasScript); 28 | 29 | // Display "my_text" entry found in the loaded json file 30 | canvas.getElement("Text").text = json.my_text; 31 | }); 32 | }); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /file_read/file_read.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/file_read/file_read.blend -------------------------------------------------------------------------------- /file_storage/README.md: -------------------------------------------------------------------------------- 1 | Increments a number every time you start the application. 2 | Check console. 3 | 4 | https://api.armory3d.org/kha/Storage.html 5 | -------------------------------------------------------------------------------- /file_storage/Sources/arm/StorageTest.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.system.Storage; 4 | 5 | class StorageTest extends iron.Trait { 6 | 7 | public function new() { 8 | super(); 9 | notifyOnInit(() -> { 10 | 11 | // Retrieve storage 12 | var data = Storage.data; 13 | if (data == null) 14 | return; 15 | 16 | // First run - init integer variable named 'count' 17 | var count: Dynamic = data.mycount; 18 | if (count == null) { 19 | data.mycount = 0; 20 | // Init more variables as needed 21 | // data.test1 = "String"; 22 | // data.test2 = 1.23; 23 | // data.test3 = true; 24 | // data.test4 = [3, 5, 7]; 25 | // data.test5 = {a: 3, b: "value"}; 26 | } 27 | 28 | trace("Count is " + data.mycount); 29 | 30 | // Increase count on every run 31 | data.mycount++; 32 | 33 | Storage.save(); 34 | 35 | var d = 10; 36 | var s = 1; 37 | var ox = 0; 38 | var oy = 0; 39 | notifyOnRender2D(g -> { 40 | g.end(); 41 | g.color = 0xff101010; 42 | ox = oy = 0; 43 | for(i in 0...data.mycount) { 44 | g.fillRect(d+ox, d+oy, d, d); 45 | ox += (d+1); 46 | if(ox+d > kha.System.windowWidth()) { 47 | ox = 0; 48 | oy += d+1; 49 | } 50 | } 51 | g.begin(false); 52 | }); 53 | }); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /file_storage/file_storage.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/file_storage/file_storage.blend -------------------------------------------------------------------------------- /file_write/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/armory/wiki/reference#write-json 2 | -------------------------------------------------------------------------------- /file_write/Sources/arm/WriteFile.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class WriteFile extends iron.Trait { 4 | public function new() { 5 | super(); 6 | 7 | notifyOnInit(function() { 8 | 9 | // File writing in Krom 10 | // To save data in HTML5, see file_storage example 11 | 12 | #if kha_krom 13 | // Data to save 14 | var o = { test: "Hello" }; 15 | var s = haxe.Json.stringify(o); 16 | 17 | // Save file into game build folder 18 | // Playing from Blender the file will be saved at 19 | // file_write/build_file/debug/krom/my_file.json 20 | var path = Krom.getFilesLocation() + "/my_file.json"; 21 | 22 | // Write file 23 | var bytes = haxe.io.Bytes.ofString(s); 24 | Krom.fileSaveBytes(path, bytes.getData()); 25 | #end 26 | }); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /file_write/file_write.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/file_write/file_write.blend -------------------------------------------------------------------------------- /game_bowling/Assets/floor_base.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_bowling/Assets/floor_base.jpg -------------------------------------------------------------------------------- /game_bowling/Assets/floor_nor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_bowling/Assets/floor_nor.jpg -------------------------------------------------------------------------------- /game_bowling/Assets/floor_occ.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_bowling/Assets/floor_occ.jpg -------------------------------------------------------------------------------- /game_bowling/Assets/floor_rough.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_bowling/Assets/floor_rough.jpg -------------------------------------------------------------------------------- /game_bowling/Assets/keys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_bowling/Assets/keys.png -------------------------------------------------------------------------------- /game_bowling/Assets/menu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_bowling/Assets/menu.jpg -------------------------------------------------------------------------------- /game_bowling/Assets/roll.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_bowling/Assets/roll.wav -------------------------------------------------------------------------------- /game_bowling/Assets/strike.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_bowling/Assets/strike.wav -------------------------------------------------------------------------------- /game_bowling/Assets/ui_exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_bowling/Assets/ui_exit.png -------------------------------------------------------------------------------- /game_bowling/Assets/ui_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_bowling/Assets/ui_play.png -------------------------------------------------------------------------------- /game_bowling/Assets/ui_refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_bowling/Assets/ui_refresh.png -------------------------------------------------------------------------------- /game_bowling/Bundled/canvas/GameCanvas.files: -------------------------------------------------------------------------------- 1 | ../../Assets/ui_exit.png 2 | ../../Assets/ui_refresh.png 3 | ../../Assets/keys.png 4 | -------------------------------------------------------------------------------- /game_bowling/Bundled/canvas/GameCanvas.json: -------------------------------------------------------------------------------- 1 | {"name":"untitled","x":0,"y":0,"width":1280,"height":720,"elements":[{"id":0,"type":1,"name":"Exit","event":"exit","x":15,"y":13,"width":64,"height":64,"text":"Image","asset":"ui_exit.png","color":-1,"anchor":0,"children":[],"visible":true,"rotation":0},{"id":1,"type":1,"name":"Refresh","event":"refresh","x":15,"y":91,"width":64,"height":64,"text":"Image","asset":"ui_refresh.png","color":-1,"anchor":0,"children":[],"visible":true,"rotation":0,"alignment":0},{"id":4,"type":1,"name":"Image","event":"","x":340,"y":620,"width":600,"height":70,"text":"Image","asset":"keys.png","color":-1,"anchor":0,"children":[],"visible":true,"rotation":0,"alignment":0}],"assets":[{"name":"ui_exit.png","file":"../../Assets/ui_exit.png","id":0},{"name":"ui_refresh.png","file":"../../Assets/ui_refresh.png","id":1},{"name":"keys.png","file":"../../Assets/keys.png","id":2}],"theme":"Default Light"} -------------------------------------------------------------------------------- /game_bowling/Bundled/canvas/MenuCanvas.files: -------------------------------------------------------------------------------- 1 | ../../Assets/ui_play.png 2 | ../../Assets/menu.jpg 3 | -------------------------------------------------------------------------------- /game_bowling/Bundled/canvas/MenuCanvas.json: -------------------------------------------------------------------------------- 1 | {"name":"untitled","x":0,"y":0,"width":1280,"height":720,"elements":[{"id":4,"type":1,"name":"Image","event":"","x":0,"y":0,"width":1280,"height":720,"rotation":0,"text":"My Image","asset":"menu.jpg","progress_at":0,"progress_total":100,"strength":1,"alignment":0,"anchor":0,"parent":null,"children":[],"visible":true},{"id":3,"type":1,"name":"Button","event":"play","x":580,"y":280,"width":160,"height":160,"rotation":0,"text":"My Image.002","asset":"ui_play.png","progress_at":0,"progress_total":100,"strength":1,"alignment":0,"anchor":0,"parent":null,"children":[],"visible":true}],"assets":[{"name":"ui_play.png","file":"../../Assets/ui_play.png","id":0},{"name":"menu.jpg","file":"../../Assets/menu.jpg","id":1}],"theme":"Default Light"} -------------------------------------------------------------------------------- /game_bowling/Bundled/canvas/_themes.json: -------------------------------------------------------------------------------- 1 | [{"NAME":"Default Light","WINDOW_BG_COL":-1052689,"WINDOW_TINT_COL":-14540254,"ACCENT_COL":-1118482,"ACCENT_HOVER_COL":-4473925,"ACCENT_SELECT_COL":-5592406,"BUTTON_COL":-3355444,"BUTTON_TEXT_COL":-14540254,"BUTTON_HOVER_COL":-5000269,"BUTTON_PRESSED_COL":-5131855,"TEXT_COL":-6710887,"LABEL_COL":-5592406,"SEPARATOR_COL":-6710887,"HIGHLIGHT_COL":-14656100,"CONTEXT_COL":-5592406,"PANEL_BG_COL":-5592406,"FONT_SIZE":26,"ELEMENT_W":200,"ELEMENT_H":48,"ELEMENT_OFFSET":8,"ARROW_SIZE":10,"BUTTON_H":44,"CHECK_SIZE":30,"CHECK_SELECT_SIZE":16,"SCROLL_W":12,"TEXT_OFFSET":16,"TAB_W":24,"FILL_WINDOW_BG":false,"FILL_BUTTON_BG":true,"FILL_ACCENT_BG":false,"LINK_STYLE":0,"FULL_TABS":false},{"NAME":"New Theme","WINDOW_BG_COL":-1052689,"WINDOW_TINT_COL":-14540254,"ACCENT_COL":-1118482,"ACCENT_HOVER_COL":-4473925,"ACCENT_SELECT_COL":-5592406,"BUTTON_COL":-3355444,"BUTTON_TEXT_COL":-14540254,"BUTTON_HOVER_COL":-5000269,"BUTTON_PRESSED_COL":-5131855,"TEXT_COL":-6710887,"LABEL_COL":-5592406,"SEPARATOR_COL":-6710887,"HIGHLIGHT_COL":-14656100,"CONTEXT_COL":-5592406,"PANEL_BG_COL":-5592406,"FONT_SIZE":26,"ELEMENT_W":200,"ELEMENT_H":48,"ELEMENT_OFFSET":8,"ARROW_SIZE":10,"BUTTON_H":44,"CHECK_SIZE":30,"CHECK_SELECT_SIZE":16,"SCROLL_W":12,"TEXT_OFFSET":16,"TAB_W":24,"FILL_WINDOW_BG":false,"FILL_BUTTON_BG":true,"FILL_ACCENT_BG":false,"LINK_STYLE":0,"FULL_TABS":false},{"NAME":"New Theme.001","WINDOW_BG_COL":-1052689,"WINDOW_TINT_COL":-14540254,"ACCENT_COL":-1118482,"ACCENT_HOVER_COL":-4473925,"ACCENT_SELECT_COL":-5592406,"BUTTON_COL":-3355444,"BUTTON_TEXT_COL":-14540254,"BUTTON_HOVER_COL":-5000269,"BUTTON_PRESSED_COL":-5131855,"TEXT_COL":-6710887,"LABEL_COL":-5592406,"SEPARATOR_COL":-6710887,"HIGHLIGHT_COL":-14656100,"CONTEXT_COL":-5592406,"PANEL_BG_COL":-5592406,"FONT_SIZE":26,"ELEMENT_W":200,"ELEMENT_H":48,"ELEMENT_OFFSET":8,"ARROW_SIZE":10,"BUTTON_H":44,"CHECK_SIZE":30,"CHECK_SELECT_SIZE":16,"SCROLL_W":12,"TEXT_OFFSET":16,"TAB_W":24,"FILL_WINDOW_BG":false,"FILL_BUTTON_BG":true,"FILL_ACCENT_BG":false,"LINK_STYLE":0,"FULL_TABS":false}] -------------------------------------------------------------------------------- /game_bowling/README.md: -------------------------------------------------------------------------------- 1 | Keyboard `space` to bowl 2 | -------------------------------------------------------------------------------- /game_bowling/Sources/arm/BallTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.math.Vec4; 4 | import armory.trait.physics.RigidBody; 5 | 6 | class BallTrait extends iron.Trait { 7 | 8 | @prop 9 | var impulse = 65.0; 10 | 11 | var fired = false; 12 | var rb:RigidBody; 13 | var start = new Vec4(); 14 | 15 | public function new() { 16 | super(); 17 | 18 | notifyOnInit(function() { 19 | rb = object.getTrait(RigidBody); 20 | start.setFrom(object.transform.loc); 21 | }); 22 | 23 | notifyOnUpdate(function() { 24 | 25 | var kb = iron.system.Input.getKeyboard(); 26 | var tr = object.transform; 27 | 28 | if (!fired) { 29 | if (kb.started("x") || kb.started("space")) { 30 | rb.applyImpulse(new Vec4(0, impulse, 0)); 31 | fired = true; 32 | } 33 | else if (kb.down("left") && tr.loc.x > -0.9) { 34 | tr.loc.x -= 0.02; 35 | tr.buildMatrix(); 36 | rb.syncTransform(); 37 | } 38 | else if (kb.down("right") && tr.loc.x < 0.9) { 39 | tr.loc.x += 0.02; 40 | tr.buildMatrix(); 41 | rb.syncTransform(); 42 | } 43 | } 44 | 45 | if (fired && tr.loc.z < -10) { 46 | tr.loc.setFrom(start); 47 | tr.buildMatrix(); 48 | rb.setLinearVelocity(0, 0, 0); 49 | rb.setAngularVelocity(0, 0, 0); 50 | rb.syncTransform(); 51 | fired = false; 52 | } 53 | }); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /game_bowling/Sources/arm/PinTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class PinTrait extends iron.Trait { 4 | 5 | public static var pinsRemoved = 0; 6 | 7 | public function new() { 8 | super(); 9 | 10 | pinsRemoved = 0; 11 | 12 | notifyOnUpdate(function() { 13 | 14 | if (object.transform.loc.z < - 20) { 15 | object.remove(); 16 | 17 | if (++pinsRemoved >= 10) { 18 | armory.system.Event.send("exit"); 19 | } 20 | } 21 | 22 | }); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /game_bowling/game_bowling.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_bowling/game_bowling.blend -------------------------------------------------------------------------------- /game_bowling/pin.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_bowling/pin.blend -------------------------------------------------------------------------------- /game_bowling/textures/bowling.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_bowling/textures/bowling.jpg -------------------------------------------------------------------------------- /game_endlessrun/Bundled/canvas/MyCanvas.files: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_endlessrun/Bundled/canvas/MyCanvas.files -------------------------------------------------------------------------------- /game_endlessrun/Bundled/canvas/MyCanvas.json: -------------------------------------------------------------------------------- 1 | {"name":"untitled","x":0,"y":0,"width":960,"height":540,"elements":[{"id":0,"type":0,"name":"Score","event":"","x":0,"y":0,"width":150,"height":48,"text":"0","asset":"","color":-16777216,"anchor":0,"children":[]}],"assets":[]} -------------------------------------------------------------------------------- /game_endlessrun/Sources/arm/GemTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class GemTrait extends iron.Trait { 4 | 5 | static var gemsCollected = 0; 6 | 7 | var player:iron.object.Object = null; 8 | 9 | public function new() { 10 | super(); 11 | 12 | notifyOnUpdate(function() { 13 | object.transform.rotate(iron.math.Vec4.zAxis(), 0.05); 14 | 15 | if (player == null) player = iron.Scene.active.getChild("Player"); 16 | var w1 = object.transform.world; 17 | var w2 = player.transform.world; 18 | var d = iron.math.Vec4.distance(w1.getLoc(), w2.getLoc()); 19 | 20 | // Collect gem 21 | if (d < 0.6) { 22 | gemsCollected++; 23 | object.remove(); 24 | 25 | // Update UI 26 | var canvas = iron.Scene.active.getTrait(armory.trait.internal.CanvasScript); 27 | canvas.getElement("Score").text = gemsCollected + ""; 28 | } 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /game_endlessrun/Sources/arm/PlayerController.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class PlayerController extends iron.Trait { 4 | public function new() { 5 | super(); 6 | 7 | notifyOnUpdate(function() { 8 | var kb = iron.system.Input.getKeyboard(); 9 | var x = object.transform.loc.x; 10 | 11 | // Move player 12 | if ((kb.down("left") || kb.down("a")) && x > -1.8) { 13 | object.transform.loc.x -= 0.06; 14 | object.transform.dirty = true; 15 | } 16 | if ((kb.down("right") || kb.down("d")) && x < 1.8) { 17 | object.transform.loc.x += 0.06; 18 | object.transform.dirty = true; 19 | } 20 | }); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /game_endlessrun/Sources/arm/SceneBuilder.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class SceneBuilder extends iron.Trait { 4 | 5 | var dist = 0.0; 6 | var tileNum = 0; 7 | var tilesVisible = 14; 8 | var tiles:Array = []; 9 | var empty:iron.object.Object; 10 | 11 | function spawnTile(num:Int) { 12 | iron.Scene.active.spawnObject("Tile" + Std.random(2), null, function(o) { 13 | 14 | // Remove old tile 15 | if (tiles[num % tilesVisible] != null) { 16 | tiles[num % tilesVisible].remove(); 17 | } 18 | 19 | // Spawn new tile 20 | tiles[num % tilesVisible] = o; 21 | o.transform.loc.x = 0; 22 | o.transform.loc.y = num * 4.0; 23 | o.transform.buildMatrix(); 24 | 25 | // Spawn gem 26 | if (Std.random(3) == 0) { 27 | iron.Scene.active.spawnObject("Gem", o, function(go) { 28 | go.transform.loc.x = (Math.random() - 0.5) * 1.8; 29 | go.transform.loc.z = 0.2; 30 | go.transform.buildMatrix(); 31 | }); 32 | } 33 | }); 34 | } 35 | 36 | public function new() { 37 | super(); 38 | 39 | notifyOnUpdate(function() { 40 | if (empty == null) empty = iron.Scene.active.getChild("Empty"); 41 | 42 | // Spawn new tiles 43 | while (tileNum < Std.int(dist / 4 + 13)) spawnTile(tileNum++); 44 | 45 | // Travel forward 46 | dist += 0.1; 47 | empty.transform.loc.y = dist; 48 | empty.transform.buildMatrix(); 49 | }); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /game_endlessrun/game_endless.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_endlessrun/game_endless.blend -------------------------------------------------------------------------------- /game_endlessrun/grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/game_endlessrun/grid.png -------------------------------------------------------------------------------- /graphics_settings/Bundled/canvas/MyCanvas.files: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/graphics_settings/Bundled/canvas/MyCanvas.files -------------------------------------------------------------------------------- /graphics_settings/Bundled/canvas/MyCanvas.json: -------------------------------------------------------------------------------- 1 | {"name":"untitled","x":0,"y":0,"width":1280,"height":720,"elements":[{"id":2,"type":6,"name":"SSR","event":"","x":20,"y":260,"width":150,"height":34,"rotation":0,"text":"SSR","asset":"","color":-1,"anchor":0,"parent":null,"children":[],"visible":true},{"id":3,"type":6,"name":"SSAO","event":"","x":20,"y":300,"width":150,"height":40,"rotation":0,"text":"SSAO","asset":"","color":-1,"anchor":0,"parent":null,"children":[],"visible":true},{"id":4,"type":6,"name":"Fullscreen","event":"","x":20,"y":80,"width":191,"height":14,"rotation":0,"text":"Fullscreen","asset":"","color":-1,"anchor":0,"parent":null,"children":[],"visible":true},{"id":6,"type":6,"name":"Bloom","event":"","x":20,"y":220,"width":150,"height":44,"rotation":0,"text":"Bloom","asset":"","color":-1,"anchor":0,"parent":null,"children":[],"visible":true},{"id":7,"type":6,"name":"MotionBlur","event":"","x":20,"y":180,"width":177,"height":44,"rotation":0,"text":"Motion Blur","asset":"","color":-1,"anchor":0,"parent":null,"children":[],"visible":true},{"id":8,"type":8,"name":"Shadows","event":"","x":20,"y":130,"width":160,"height":60,"rotation":0,"text":"High;Medium;Low","asset":"","color":-1,"anchor":0,"parent":null,"children":[],"visible":true},{"id":9,"type":10,"name":"ViewDistance","event":"","x":20,"y":360,"width":250,"height":44,"rotation":0,"text":"View Distance","asset":"","color":-1,"anchor":0,"parent":null,"children":[],"visible":true},{"id":11,"type":0,"name":"Title","event":"","x":10,"y":10,"width":540,"height":60,"rotation":0,"text":"Graphics Settings","asset":"","color":-1,"anchor":0,"parent":null,"children":[],"visible":true},{"id":12,"type":0,"name":"ShadowsTitle","event":"","x":185,"y":130,"width":184,"height":20,"rotation":0,"text":"Shadows","asset":"","color":-6381922,"anchor":0,"parent":null,"children":[],"visible":true},{"id":13,"type":2,"name":"Apply","event":"apply_settings","x":22,"y":479,"width":80,"height":50,"rotation":0,"text":"Apply","asset":"","color":-1,"anchor":0,"parent":null,"children":[],"visible":true},{"id":14,"type":9,"name":"FoV","event":"","x":20,"y":420,"width":249,"height":48,"rotation":0,"text":"FoV","asset":"","progress_at":0,"progress_total":100,"strength":1,"alignment":2,"anchor":0,"parent":null,"children":[],"visible":true,"color_text":null,"color":null,"color_hover":null}],"assets":[],"theme":"Default Light"} -------------------------------------------------------------------------------- /graphics_settings/Bundled/canvas/_themes.json: -------------------------------------------------------------------------------- 1 | [{"NAME":"Default Light","WINDOW_BG_COL":-1052689,"WINDOW_TINT_COL":-14540254,"ACCENT_COL":-1118482,"ACCENT_HOVER_COL":-4473925,"ACCENT_SELECT_COL":-5592406,"BUTTON_COL":-3355444,"BUTTON_TEXT_COL":-14540254,"BUTTON_HOVER_COL":-5000269,"BUTTON_PRESSED_COL":-5131855,"TEXT_COL":-16645630,"LABEL_COL":-5592406,"SEPARATOR_COL":-6710887,"HIGHLIGHT_COL":-14656100,"CONTEXT_COL":-5592406,"PANEL_BG_COL":-5592406,"FONT_SIZE":26,"ELEMENT_W":200,"ELEMENT_H":48,"ELEMENT_OFFSET":8,"ARROW_SIZE":10,"BUTTON_H":44,"CHECK_SIZE":30,"CHECK_SELECT_SIZE":16,"SCROLL_W":12,"TEXT_OFFSET":16,"TAB_W":24,"FILL_WINDOW_BG":false,"FILL_BUTTON_BG":true,"FILL_ACCENT_BG":false,"LINK_STYLE":0,"FULL_TABS":false}] -------------------------------------------------------------------------------- /graphics_settings/Bundled/config.arm: -------------------------------------------------------------------------------- 1 | { 2 | "rp_bloom": true, 3 | "rp_dynres": false, 4 | "rp_gi": false, 5 | "rp_motionblur": true, 6 | "rp_shadowmap_cascade": 1024, 7 | "rp_shadowmap_cube": 512, 8 | "rp_ssgi": true, 9 | "rp_ssr": true, 10 | "rp_supersample": 1.0, 11 | "window_h": 540, 12 | "window_maximizable": true, 13 | "window_minimizable": true, 14 | "window_mode": 0, 15 | "window_msaa": 1, 16 | "window_resizable": true, 17 | "window_scale": 1.0, 18 | "window_vsync": true, 19 | "window_w": 960 20 | } -------------------------------------------------------------------------------- /graphics_settings/README.md: -------------------------------------------------------------------------------- 1 | To generate config.arm file, enable `Armory Project - Write Config`. 2 | 3 | https://api.armory3d.org/armory/data/Config.html 4 | -------------------------------------------------------------------------------- /graphics_settings/Sources/arm/MyTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.Scene; 4 | import armory.system.Event; 5 | import armory.data.Config; 6 | import armory.trait.internal.CanvasScript; 7 | import armory.renderpath.RenderPathCreator; 8 | 9 | // WIP 10 | // To generate config.arm file, enable 'Armory Project - Write Config' 11 | // Fullscreen option will take effect on next game start up (will be resolved) 12 | class MyTrait extends iron.Trait { 13 | 14 | var canvas:CanvasScript; 15 | 16 | public function new() { 17 | super(); 18 | 19 | notifyOnInit(function() { 20 | canvas = Scene.active.getTrait(CanvasScript); 21 | 22 | // Init UI to values loaded from config.arm file 23 | canvas.notifyOnReady(function() { 24 | canvas.getHandle("Fullscreen").selected = Config.raw.window_mode == 1; 25 | canvas.getHandle("SSAO").selected = Config.raw.rp_ssgi; 26 | canvas.getHandle("SSR").selected = Config.raw.rp_ssr; 27 | canvas.getHandle("Bloom").selected = Config.raw.rp_bloom; 28 | canvas.getHandle("MotionBlur").selected = Config.raw.rp_motionblur; 29 | canvas.getHandle("Shadows").position = getShadowQuality(Config.raw.rp_shadowmap_cascade); 30 | var cam = Scene.active.camera; 31 | canvas.getHandle("ViewDistance").text = Std.string(Math.round(cam.data.raw.far_plane)); 32 | canvas.getHandle("FoV").value = cam.data.raw.fov; 33 | }); 34 | 35 | // Apply button clicked 36 | Event.add("apply_settings", applySettings); 37 | }); 38 | } 39 | 40 | function applySettings() { 41 | 42 | // Apply render path settings 43 | Config.raw.window_mode = canvas.getHandle("Fullscreen").selected ? 1 : 0; 44 | Config.raw.rp_ssgi = canvas.getHandle("SSAO").selected; 45 | Config.raw.rp_ssr = canvas.getHandle("SSR").selected; 46 | Config.raw.rp_bloom = canvas.getHandle("Bloom").selected; 47 | Config.raw.rp_motionblur = canvas.getHandle("MotionBlur").selected; 48 | Config.raw.rp_shadowmap_cascade = getShadowMapSize(canvas.getHandle("Shadows").position); 49 | Config.raw.rp_shadowmap_cube = getShadowMapSize(canvas.getHandle("Shadows").position); 50 | RenderPathCreator.applyConfig(); 51 | 52 | // Apply camera settings 53 | var cam = Scene.active.camera; 54 | cam.data.raw.far_plane = Std.parseFloat(canvas.getHandle("ViewDistance").text); 55 | cam.data.raw.fov = canvas.getHandle("FoV").value; 56 | cam.buildProjection(); 57 | 58 | // Save config.arm file 59 | Config.save(); 60 | } 61 | 62 | function getShadowQuality(i:Int):Int { 63 | // 0 - High, 1 - Medium, 2 - Low 64 | return i == 2048 ? 0 : i == 1024 ? 1 : 2; 65 | } 66 | 67 | function getShadowMapSize(i:Int):Int { 68 | // High - 2048, Medium - 1024, Low - 512 69 | return i == 0 ? 2048 : i == 1 ? 1024 : 512; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /graphics_settings/graphics_settings.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/graphics_settings/graphics_settings.blend -------------------------------------------------------------------------------- /input_mouselock/README.md: -------------------------------------------------------------------------------- 1 | Keyboard `Escape` to toggle mouse lock. 2 | 3 | https://api.armory3d.org/iron/system/Mouse.html 4 | -------------------------------------------------------------------------------- /input_mouselock/Sources/arm/LockTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.math.Vec4; 4 | import iron.system.Input; 5 | 6 | class LockTrait extends iron.Trait { 7 | 8 | public function new() { 9 | 10 | super(); 11 | 12 | var mouse = Input.getMouse(); 13 | var kb = Input.getKeyboard(); 14 | 15 | notifyOnUpdate(() -> { 16 | if (mouse.started("left")) { 17 | mouse.lock(); 18 | } else if (kb.started("escape")) { 19 | mouse.unlock(); 20 | } 21 | var cube = iron.Scene.active.getChild("Cube"); 22 | if (cube != null) { 23 | cube.transform.rotate(Vec4.zAxis(), mouse.movementX * 0.002); 24 | cube.transform.rotate(Vec4.xAxis(), mouse.movementY * 0.002); 25 | } 26 | }); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /input_mouselock/input_mouselock.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/input_mouselock/input_mouselock.blend -------------------------------------------------------------------------------- /input_multitouch/Sources/arm/TouchTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.system.Time; 4 | import iron.math.Vec4; 5 | 6 | class TouchTrait extends iron.Trait { 7 | 8 | var touches = [false, false, false]; 9 | 10 | public function new() { 11 | super(); 12 | 13 | notifyOnInit(function() { 14 | var surface = kha.input.Surface.get(); 15 | if (surface != null) surface.notify(touchStart, touchEnd, touchMove); 16 | notifyOnUpdate(update); 17 | }); 18 | } 19 | 20 | function update() { 21 | if (touches[0]) object.transform.rotate(Vec4.zAxis(), 0.05); 22 | if (touches[1]) object.transform.loc.x = Math.sin(Time.time()) * 3.0; 23 | if (touches[2]) object.transform.loc.z = Math.cos(Time.time()); 24 | object.transform.dirty = true; 25 | } 26 | 27 | function touchStart(index:Int, x:Int, y:Int) { 28 | if (index > 2) return; 29 | touches[index] = true; 30 | } 31 | 32 | function touchEnd(index:Int, x:Int, y:Int) { 33 | if (index > 2) return; 34 | touches[index] = false; 35 | } 36 | 37 | function touchMove(index:Int, x:Int, y:Int) {} 38 | } 39 | -------------------------------------------------------------------------------- /input_multitouch/input_multitouch.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/input_multitouch/input_multitouch.blend -------------------------------------------------------------------------------- /input_sensor/Sources/arm/SensorTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.math.Vec4; 4 | 5 | class SensorTrait extends iron.Trait { 6 | public function new() { 7 | super(); 8 | 9 | notifyOnInit(function() { 10 | var gyro = kha.input.Sensor.get(kha.input.SensorType.Gyroscope); 11 | if (gyro != null) gyro.notify(onGyroscope); 12 | }); 13 | } 14 | 15 | function onGyroscope(x:Float, y:Float, z:Float) { 16 | object.transform.rotate(Vec4.xAxis(), x / 20); 17 | object.transform.rotate(Vec4.yAxis(), y / 20); 18 | object.transform.rotate(Vec4.zAxis(), z / 20); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /input_sensor/input_sensor.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/input_sensor/input_sensor.blend -------------------------------------------------------------------------------- /instancing/README.md: -------------------------------------------------------------------------------- 1 | #### Enable instancing 2 | 3 | - Select object and set `Properties - Object - Armory Props - Instanced Children` property 4 | - Create linked duplicates and parent them to object being instanced 5 | 6 | https://github.com/armory3d/armory/wiki/instancing 7 | -------------------------------------------------------------------------------- /instancing/instancing.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/instancing/instancing.blend -------------------------------------------------------------------------------- /light_area/checker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/light_area/checker.png -------------------------------------------------------------------------------- /light_area/checker_rough.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/light_area/checker_rough.png -------------------------------------------------------------------------------- /light_area/light_area.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/light_area/light_area.blend -------------------------------------------------------------------------------- /light_ies/Bundled/iestexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/light_ies/Bundled/iestexture.png -------------------------------------------------------------------------------- /light_ies/Bundled/iestexture2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/light_ies/Bundled/iestexture2.png -------------------------------------------------------------------------------- /light_ies/Bundled/iestexture3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/light_ies/Bundled/iestexture3.png -------------------------------------------------------------------------------- /light_ies/light_ies.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/light_ies/light_ies.blend -------------------------------------------------------------------------------- /light_probes/light_probes.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/light_probes/light_probes.blend -------------------------------------------------------------------------------- /light_probes_cubemap/light_probes_cubemap.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/light_probes_cubemap/light_probes_cubemap.blend -------------------------------------------------------------------------------- /light_probes_plane/light_probes_plane.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/light_probes_plane/light_probes_plane.blend -------------------------------------------------------------------------------- /light_volumetric/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/armory/wiki/screen-effects#volumetric-fog 2 | -------------------------------------------------------------------------------- /light_volumetric/light_volumetric.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/light_volumetric/light_volumetric.blend -------------------------------------------------------------------------------- /load_screen/Bundled/bunny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/load_screen/Bundled/bunny.png -------------------------------------------------------------------------------- /load_screen/Sources/arm/LoadingScreen.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | // Custom loading screen, replaces the internal one 4 | 5 | class LoadingScreen { 6 | 7 | static inline var barColor = 0xff4c6ea5; 8 | static inline var barHeight = 20; 9 | 10 | static var first = true; 11 | static var bunny:kha.Image = null; 12 | 13 | public static function render(g:kha.graphics2.Graphics, assetsLoaded:Int, assetsTotal:Int) { 14 | 15 | // First run, load bundled image 16 | if (first) { 17 | first = false; 18 | iron.data.Data.getImage("bunny.png", function(img:kha.Image) { 19 | bunny = img; 20 | }); 21 | } 22 | 23 | // Draw loaded image 24 | if (bunny != null) { 25 | g.color = 0xffffffff; 26 | g.drawImage(bunny, iron.App.w() / 2 - bunny.width / 2, iron.App.h() / 2 - bunny.height / 2); 27 | } 28 | 29 | // Draw bar 30 | g.color = barColor; 31 | g.fillRect(0, 0, iron.App.w() / assetsTotal * assetsLoaded, barHeight); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /load_screen/load_screen.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/load_screen/load_screen.blend -------------------------------------------------------------------------------- /lod/README.md: -------------------------------------------------------------------------------- 1 | LOD (level of detail) can be decreased as the model moves away from the viewer. 2 | -------------------------------------------------------------------------------- /lod/lod.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/lod/lod.blend -------------------------------------------------------------------------------- /logic_Hello_World/logic_Hello_World.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_Hello_World/logic_Hello_World.blend -------------------------------------------------------------------------------- /logic_Hello_World/logic_Hello_World_nodetree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_Hello_World/logic_Hello_World_nodetree.png -------------------------------------------------------------------------------- /logic_Hello_World/logic_Hello_World_output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_Hello_World/logic_Hello_World_output.png -------------------------------------------------------------------------------- /logic_break/logic_break.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_break/logic_break.blend -------------------------------------------------------------------------------- /logic_callgroup/Bundled/canvas/MyCanvas.files: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_callgroup/Bundled/canvas/MyCanvas.files -------------------------------------------------------------------------------- /logic_callgroup/Bundled/canvas/MyCanvas.json: -------------------------------------------------------------------------------- 1 | {"name":"untitled","x":0,"y":0,"width":1280,"height":720,"theme":"New Theme","elements":[{"id":0,"type":0,"name":"Text","event":"","x":20,"y":20,"width":960,"height":20,"rotation":0,"text":"Press to call another logic group","asset":"","progress_at":0,"progress_total":100,"strength":1,"alignment":0,"anchor":0,"parent":null,"children":[],"visible":true,"color_text":null}],"assets":[]} -------------------------------------------------------------------------------- /logic_callgroup/README.md: -------------------------------------------------------------------------------- 1 | Keyboard `space`: 2 | - NodeTreeA calls NodeTreeB 3 | - NodeTreeB sets current time to global object property 4 | - NodeTreeA prints value of global object property 5 | -------------------------------------------------------------------------------- /logic_callgroup/logic_callgroup.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_callgroup/logic_callgroup.blend -------------------------------------------------------------------------------- /logic_camera_pan/logic_camera_pan.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_camera_pan/logic_camera_pan.blend -------------------------------------------------------------------------------- /logic_camera_zoom/logic_camera_zoom.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_camera_zoom/logic_camera_zoom.blend -------------------------------------------------------------------------------- /logic_canvas/Assets/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_canvas/Assets/background.png -------------------------------------------------------------------------------- /logic_canvas/Assets/charactor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_canvas/Assets/charactor.png -------------------------------------------------------------------------------- /logic_canvas/Bundled/canvas/MyCanvas.files: -------------------------------------------------------------------------------- 1 | ../../Assets/charactor.png 2 | ../../Assets/background.png 3 | -------------------------------------------------------------------------------- /logic_canvas/Bundled/canvas/MyCanvas.json: -------------------------------------------------------------------------------- 1 | {"name":"untitled","x":0,"y":0,"width":1024,"height":600,"elements":[{"id":1,"type":8,"name":"Combo","event":"","x":0,"y":200,"width":150,"height":44,"rotation":0,"text":"My Combo","asset":"","color":-1,"anchor":0,"parent":3,"children":[],"visible":false},{"id":0,"type":9,"name":"Shape","event":"","x":0,"y":50,"width":150,"height":100,"rotation":0,"text":"My Shape","asset":"","color":16777215,"anchor":0,"parent":3,"children":[],"visible":false},{"id":3,"type":3,"name":"EmptyB","event":"","x":0,"y":0,"width":0,"height":0,"rotation":0,"text":"My Empty","asset":"","color":-1,"anchor":0,"parent":null,"children":[0,1,11,12,14,15,16,19,18,9,21],"visible":false},{"id":2,"type":3,"name":"EmptyA","event":"","x":0,"y":0,"width":0,"height":0,"rotation":0,"text":"My Empty","asset":"","color":-1,"anchor":0,"parent":null,"children":[5,4,10,8,7,17,20],"visible":true},{"id":4,"type":1,"name":"Charactor","event":"","x":350,"y":300,"width":120,"height":200,"rotation":0,"text":"My Image","asset":"charactor.png","color":-1,"anchor":0,"parent":2,"children":[],"visible":true},{"id":5,"type":1,"name":"Background","event":"","x":0,"y":0,"width":1024,"height":600,"rotation":0,"text":"My Image","asset":"background.png","color":-1,"anchor":0,"parent":2,"children":[],"visible":true},{"id":19,"type":0,"name":"escInfo","event":"","x":640,"y":0,"width":430,"height":44,"rotation":0,"text":"ESC : Hide empty","asset":"","color":-1,"anchor":0,"parent":3,"children":[],"visible":true},{"id":8,"type":0,"name":"escInfo","event":"","x":640,"y":0,"width":430,"height":44,"rotation":0,"text":"ESC : Hide empty","asset":"","color":-1,"anchor":0,"parent":2,"children":[],"visible":true},{"id":18,"type":0,"name":"tabInfo","event":"","x":250,"y":0,"width":430,"height":44,"rotation":0,"text":"TAB : Change empty","asset":"","color":-1,"anchor":0,"parent":3,"children":[],"visible":true},{"id":7,"type":0,"name":"tabInfo","event":"","x":250,"y":0,"width":430,"height":44,"rotation":0,"text":"TAB : Change empty","asset":"","color":-1,"anchor":0,"parent":2,"children":[],"visible":true},{"id":9,"type":0,"name":"EmptyBInfo","event":"","x":0,"y":0,"width":200,"height":44,"rotation":0,"text":"EmptyB","asset":"","color":-1,"anchor":0,"parent":3,"children":[],"visible":true},{"id":10,"type":0,"name":"wasdInfo","event":"","x":20,"y":50,"width":600,"height":44,"rotation":0,"text":"WASD : Character operation","asset":"","color":-1,"anchor":0,"parent":2,"children":[],"visible":true},{"id":12,"type":6,"name":"Check","event":"","x":0,"y":100,"width":150,"height":44,"rotation":0,"text":"My Check","asset":"","color":-1,"anchor":0,"parent":3,"children":[],"visible":false},{"id":11,"type":2,"name":"Button","event":"","x":0,"y":50,"width":150,"height":44,"rotation":0,"text":"My Button","asset":"","color":-1,"anchor":0,"parent":3,"children":[],"visible":false},{"id":14,"type":10,"name":"Slider","event":"","x":0,"y":250,"width":150,"height":44,"rotation":0,"text":"My Slider","asset":"","color":-1,"anchor":0,"parent":3,"children":[22,25,26,27],"visible":true},{"id":15,"type":11,"name":"Input","event":"","x":0,"y":300,"width":150,"height":44,"rotation":0,"text":"","asset":"","color":-1,"anchor":0,"parent":3,"children":[],"visible":false},{"id":16,"type":7,"name":"Radio","event":"","x":0,"y":150,"width":150,"height":44,"rotation":0,"text":"My Radio","asset":"","color":-1,"anchor":0,"parent":3,"children":[],"visible":false},{"id":17,"type":0,"name":"EmptyAInfo","event":"","x":0,"y":0,"width":200,"height":44,"rotation":0,"text":"EmptyA","asset":"","color":-1,"anchor":0,"parent":2,"children":[],"visible":true},{"id":20,"type":0,"name":"AddInfo","event":"","x":670,"y":35,"width":150,"height":30,"rotation":0,"text":"or e","asset":"","color":-1,"anchor":0,"parent":2,"children":[],"visible":true},{"id":21,"type":0,"name":"AddInfo","event":"","x":670,"y":35,"width":150,"height":30,"rotation":0,"text":"or e","asset":"","color":-1,"anchor":0,"parent":3,"children":[],"visible":true},{"id":22,"type":0,"name":"TextSlider1","event":"","x":150,"y":-10,"width":330,"height":44,"rotation":0,"text":"Slider value is","asset":"","color":-1,"anchor":0,"parent":14,"children":[],"visible":true},{"id":25,"type":0,"name":"TextSlider2","event":"","x":400,"y":-10,"width":90,"height":44,"rotation":0,"text":"","asset":"","color":-1,"anchor":0,"parent":14,"children":[],"visible":true},{"id":26,"type":0,"name":"TextSlider3","event":"","x":0,"y":50,"width":950,"height":44,"rotation":0,"text":"Press 0 key to reset the slider value to 0.","asset":"","color":-1,"anchor":0,"parent":14,"children":[],"visible":true},{"id":27,"type":0,"name":"TextSlider4","event":"","x":20,"y":90,"width":560,"height":30,"rotation":0,"text":"Numeric keypad input is not accepted.","asset":"","color":-1,"anchor":0,"parent":14,"children":[],"visible":true}],"assets":[{"name":"charactor.png","file":"../../Assets/charactor.png","id":1},{"name":"background.png","file":"../../Assets/background.png","id":2}]} -------------------------------------------------------------------------------- /logic_canvas/Bundled/canvas/_themes.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_canvas/Bundled/canvas/_themes.json -------------------------------------------------------------------------------- /logic_canvas/logic_canvas.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_canvas/logic_canvas.blend -------------------------------------------------------------------------------- /logic_event_fromhaxe/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_event_fromhaxe/README.md -------------------------------------------------------------------------------- /logic_event_fromhaxe/Sources/arm/SendEvent.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import armory.system.Event; 4 | 5 | class SendEvent extends iron.Trait { 6 | 7 | public function new() { 8 | 9 | super(); 10 | 11 | var mouse = iron.system.Input.getMouse(); 12 | 13 | notifyOnUpdate(function() { 14 | if (mouse.started("left")) { 15 | Event.send("my_event"); 16 | } 17 | }); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /logic_event_fromhaxe/logic_event_fromhaxe.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_event_fromhaxe/logic_event_fromhaxe.blend -------------------------------------------------------------------------------- /logic_event_global/logic_event_global.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_event_global/logic_event_global.blend -------------------------------------------------------------------------------- /logic_event_object/README.md: -------------------------------------------------------------------------------- 1 | Keyboard left/right to send event. 2 | -------------------------------------------------------------------------------- /logic_event_object/Sources/arm/SendEvent.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import armory.system.Event; 4 | 5 | class SendEvent extends iron.Trait { 6 | public function new() { 7 | super(); 8 | 9 | notifyOnUpdate(function() { 10 | var mouse = iron.system.Input.getMouse(); 11 | if (mouse.started("left")) { 12 | Event.send("my_event"); 13 | } 14 | }); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /logic_event_object/logic_event_object.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_event_object/logic_event_object.blend -------------------------------------------------------------------------------- /logic_gamepad/Bundled/canvas/MyCanvas.files: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_gamepad/Bundled/canvas/MyCanvas.files -------------------------------------------------------------------------------- /logic_gamepad/Bundled/canvas/MyCanvas.json: -------------------------------------------------------------------------------- 1 | {"name":"untitled","x":0,"y":0,"width":1280,"height":720,"theme":"Default Light","elements":[{"id":2,"type":12,"name":"Filled_Rectangle","event":"","x":0,"y":0,"width":250,"height":50,"rotation":0,"text":"My Filled_Rectangle","asset":"","progress_at":0,"progress_total":100,"strength":1,"alignment":0,"anchor":0,"parent":null,"children":[],"visible":true,"color":null},{"id":1,"type":6,"name":"VGamepad","event":"","x":0,"y":0,"width":250,"height":50,"rotation":0,"text":"Virtual Gamepad","asset":"","progress_at":0,"progress_total":100,"strength":1,"alignment":0,"anchor":0,"parent":null,"children":[],"visible":true,"color_text":-6738141,"color":-3392436,"color_hover":-5726816}],"assets":[]} -------------------------------------------------------------------------------- /logic_gamepad/Bundled/canvas/_themes.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_gamepad/Bundled/canvas/_themes.json -------------------------------------------------------------------------------- /logic_gamepad/Sources/arm/VirtualGamepad.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.Trait; 4 | import iron.math.Vec2; 5 | import iron.system.Input; 6 | 7 | using kha.graphics2.GraphicsExtension; 8 | 9 | @:access(iron.system.Gamepad) 10 | class VirtualGamepad extends Trait { 11 | 12 | @prop public var gamepad : Int = 0; 13 | @prop public var radius : Int = 100; 14 | @prop public var offset : Int = 45; 15 | @prop public var sizeRatio : Float = 2.2; 16 | 17 | public var colorA : kha.Color = 0xff888888; 18 | public var colorB : kha.Color = 0xffcf2b43; 19 | 20 | var leftPadX = 0; 21 | var leftPadY = 0; 22 | var rightPadX = 0; 23 | var rightPadY = 0; 24 | var leftStickX = 0; 25 | var leftStickY = 0; 26 | var rightStickX = 0; 27 | var rightStickY = 0; 28 | // var leftStickXLast = 0; 29 | // var leftStickYLast = 0; 30 | // var rightStickXLast = 0; 31 | // var rightStickYLast = 0; 32 | var leftLocked = false; 33 | var rightLocked = false; 34 | var gamepad_ : Gamepad; 35 | 36 | public function new() { 37 | super(); 38 | notifyOnInit(function() { 39 | gamepad_ = Input.getGamepad( gamepad ); 40 | notifyOnUpdate(update); 41 | notifyOnRender2D(render2D); 42 | }); 43 | } 44 | 45 | function update() { 46 | 47 | var r = radius; 48 | var o = offset; 49 | 50 | leftPadX = r + o; 51 | rightPadX = iron.App.w() - r - o; 52 | leftPadY = rightPadY = iron.App.h() - r - o; 53 | 54 | final mouse = Input.getMouse(); 55 | if (mouse.started() ) { 56 | leftLocked = Vec2.distancef(mouse.x, mouse.y, leftPadX, leftPadY) <= r; 57 | } else if (mouse.released()) { 58 | leftLocked = false; 59 | } 60 | if (leftLocked) { 61 | leftStickX = Std.int(mouse.x - leftPadX); 62 | leftStickY = Std.int(mouse.y - leftPadY); 63 | if (Math.sqrt(leftStickX * leftStickX + leftStickY * leftStickY) > r) { 64 | leftStickX = Std.int(r * (leftStickX / Math.sqrt(leftStickX * leftStickX + leftStickY * leftStickY))); 65 | leftStickY = Std.int(r * (leftStickY / Math.sqrt(leftStickX * leftStickX + leftStickY * leftStickY))); 66 | } 67 | } else { 68 | leftStickX = leftStickY = 0; 69 | } 70 | 71 | if (mouse.started() ) { 72 | rightLocked = Vec2.distancef(mouse.x, mouse.y, rightPadX, rightPadY) <= r; 73 | } else if (mouse.released()) { 74 | rightLocked = false; 75 | } 76 | if (rightLocked) { 77 | rightStickX = Std.int(mouse.x - rightPadX); 78 | rightStickY = Std.int(mouse.y - rightPadY); 79 | if (Math.sqrt(rightStickX * rightStickX + rightStickY * rightStickY) > r) { 80 | rightStickX = Std.int(r * (rightStickX / Math.sqrt(rightStickX * rightStickX + rightStickY * rightStickY))); 81 | rightStickY = Std.int(r * (rightStickY / Math.sqrt(rightStickX * rightStickX + rightStickY * rightStickY))); 82 | } 83 | } 84 | else { 85 | rightStickX = rightStickY = 0; 86 | } 87 | 88 | gamepad_.axisListener(0, leftStickX / r); 89 | gamepad_.axisListener(1, leftStickY / r); 90 | gamepad_.axisListener(2, rightStickY / r); 91 | gamepad_.axisListener(3, rightStickX / r); 92 | 93 | // leftStickXLast = leftStickX; 94 | // leftStickYLast = leftStickY; 95 | // rightStickXLast = rightStickX; 96 | // rightStickYLast = rightStickY; 97 | } 98 | 99 | function render2D(g: kha.graphics2.Graphics) { 100 | 101 | var r = radius; 102 | var r2 = Std.int(r / sizeRatio); 103 | 104 | g.color = colorA; 105 | g.fillCircle(leftPadX, leftPadY, r); 106 | g.fillCircle(rightPadX, rightPadY, r); 107 | 108 | g.color = colorB; 109 | g.fillCircle(leftPadX + leftStickX, leftPadY + leftStickY, r2); 110 | g.fillCircle(rightPadX + rightStickX, rightPadY + rightStickY, r2); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /logic_gamepad/logic_gamepad.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_gamepad/logic_gamepad.blend -------------------------------------------------------------------------------- /logic_gate/checker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_gate/checker.png -------------------------------------------------------------------------------- /logic_gate/checker_rough.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_gate/checker_rough.png -------------------------------------------------------------------------------- /logic_gate/logic_gate.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_gate/logic_gate.blend -------------------------------------------------------------------------------- /logic_get_contacts/logic_get_contacts.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_get_contacts/logic_get_contacts.blend -------------------------------------------------------------------------------- /logic_keyboard/logic_keyboard.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_keyboard/logic_keyboard.blend -------------------------------------------------------------------------------- /logic_linked_variable/logic_linked_variable.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_linked_variable/logic_linked_variable.blend -------------------------------------------------------------------------------- /logic_loadurl/logic_loadurl.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_loadurl/logic_loadurl.blend -------------------------------------------------------------------------------- /logic_mouselock/logic_mouselock.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_mouselock/logic_mouselock.blend -------------------------------------------------------------------------------- /logic_object_rotate/README.md: -------------------------------------------------------------------------------- 1 | Press keyboard `A`, `D` to rotate object 2 | -------------------------------------------------------------------------------- /logic_object_rotate/logic_object_rotate.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_object_rotate/logic_object_rotate.blend -------------------------------------------------------------------------------- /logic_object_scale/README.md: -------------------------------------------------------------------------------- 1 | Press keyboard `↓` `↑` to scale object 2 | -------------------------------------------------------------------------------- /logic_object_scale/logic_object_scale.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_object_scale/logic_object_scale.blend -------------------------------------------------------------------------------- /logic_object_translate/README.md: -------------------------------------------------------------------------------- 1 | Keyboard `WASD` to translate object 2 | -------------------------------------------------------------------------------- /logic_object_translate/logic_object_translate.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_object_translate/logic_object_translate.blend -------------------------------------------------------------------------------- /logic_pause_trait/README.md: -------------------------------------------------------------------------------- 1 | #### Keyboard 2 | - `1` pause trait 3 | - `2` resume trait 4 | -------------------------------------------------------------------------------- /logic_pause_trait/logic_pause_trait.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_pause_trait/logic_pause_trait.blend -------------------------------------------------------------------------------- /logic_pong/checker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_pong/checker.png -------------------------------------------------------------------------------- /logic_pong/checker_rough.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_pong/checker_rough.png -------------------------------------------------------------------------------- /logic_pong/logic_pong.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_pong/logic_pong.blend -------------------------------------------------------------------------------- /logic_scenes/README.md: -------------------------------------------------------------------------------- 1 | #### Keyboard 2 | - `1` to drop all objects from other scene into current 3 | - `2` to remove current scene and switch to Scene3 4 | -------------------------------------------------------------------------------- /logic_scenes/logic_scenes.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_scenes/logic_scenes.blend -------------------------------------------------------------------------------- /logic_scenetree/README.md: -------------------------------------------------------------------------------- 1 | Check console -------------------------------------------------------------------------------- /logic_scenetree/logic_scenetree.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_scenetree/logic_scenetree.blend -------------------------------------------------------------------------------- /logic_script/logic_script.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_script/logic_script.blend -------------------------------------------------------------------------------- /logic_set_property/README.md: -------------------------------------------------------------------------------- 1 | - Press `1`, `2` or `3` 2 | -------------------------------------------------------------------------------- /logic_set_property/logic_set_property.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_set_property/logic_set_property.blend -------------------------------------------------------------------------------- /logic_toy_car/README.md: -------------------------------------------------------------------------------- 1 | Car control: `← ↓ ↑ →` 2 | -------------------------------------------------------------------------------- /logic_toy_car/logic_toy_car.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_toy_car/logic_toy_car.blend -------------------------------------------------------------------------------- /logic_transform/logic_transform.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/logic_transform/logic_transform.blend -------------------------------------------------------------------------------- /macro_armpack/README.md: -------------------------------------------------------------------------------- 1 | Use build macro to: 2 | - Create trait constructor 3 | - Create trait init function 4 | - Parse exported `Scene.arm` file and auto create references to objects in scene 5 | -------------------------------------------------------------------------------- /macro_armpack/Sources/arm/Game.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.math.Vec4; 4 | 5 | @:build(arm.Macros.build()) 6 | class Game extends iron.Trait { 7 | 8 | function update() { 9 | Cube.transform.rotate( Vec4.zAxis(), 0.01 ); 10 | Icosphere.transform.rotate( Vec4.yAxis(), 0.01 ); 11 | Torus.transform.rotate( Vec4.xAxis(), 0.01 ); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /macro_armpack/Sources/arm/Macros.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | #if macro 4 | 5 | import haxe.macro.Context; 6 | import haxe.macro.Expr; 7 | import iron.data.SceneFormat; 8 | import iron.system.ArmPack; 9 | import sys.FileSystem; 10 | import sys.io.File; 11 | 12 | using StringTools; 13 | using haxe.io.Path; 14 | 15 | class Macros { 16 | 17 | static function build() { 18 | var fields = Context.getBuildFields(); 19 | var pos = Context.currentPos(); 20 | var target = if( Context.defined('kha_krom') ) 'krom'; 21 | else if( Context.defined('kha_html5') ) 'html5'; 22 | else Context.fatalError('Only krom and html5 are supported targets for this project', pos ); 23 | var dir = Sys.getCwd() + target; 24 | var files = FileSystem.readDirectory(dir); 25 | var sceneData : TSceneFormat = null; 26 | var meshes = new Array(); 27 | for( file in files ) { 28 | if( file == 'Scene.arm' ) { 29 | var p = '$dir/$file'; 30 | sceneData = ArmPack.decode( File.getBytes(p) ); 31 | trace(sceneData); 32 | trace(sceneData.name); 33 | for( obj in sceneData.objects ) { 34 | if( obj.properties != null ) 35 | for( p in obj.properties ) trace(p.name +' = '+ p.value); 36 | if( obj.type == 'mesh_object' ) 37 | meshes.push(obj.name); 38 | } 39 | break; 40 | } 41 | } 42 | 43 | var constructorExprs = new Array(); 44 | constructorExprs.push(macro super() ); 45 | constructorExprs.push(macro notifyOnInit(init) ); 46 | fields.push({ 47 | access: [APublic,AInline], 48 | name: 'new', 49 | pos: pos, 50 | kind: FFun({ 51 | args: [], 52 | ret: macro: Void, 53 | expr: { expr: EBlock( constructorExprs ), pos: pos } 54 | }), 55 | }); 56 | 57 | var initExprs = new Array(); 58 | initExprs.push( macro trace("Init") ); 59 | for( mesh in meshes ) { 60 | fields.push({ 61 | name: mesh, 62 | access: [APublic], 63 | kind: FVar(macro: iron.object.MeshObject, macro null), 64 | pos: pos 65 | }); 66 | initExprs.push( macro this.$mesh = iron.Scene.active.getMesh($v{mesh}) ); 67 | } 68 | initExprs.push( macro notifyOnUpdate(update) ); 69 | 70 | fields.push({ 71 | name: 'init', 72 | access: [], 73 | kind: FFun({ 74 | args: [], 75 | ret: macro : Void, 76 | expr: { expr: EBlock( initExprs ), pos: Context.currentPos() } 77 | }), 78 | pos: pos 79 | }); 80 | 81 | return fields; 82 | } 83 | } 84 | 85 | #end 86 | -------------------------------------------------------------------------------- /macro_armpack/macro_armpack.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/macro_armpack/macro_armpack.blend -------------------------------------------------------------------------------- /material_alpha/README.md: -------------------------------------------------------------------------------- 1 | Transparency using `Properties - Material - Armory Props - Alpha Test` 2 | -------------------------------------------------------------------------------- /material_alpha/circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_alpha/circle.png -------------------------------------------------------------------------------- /material_alpha/material_alpha.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_alpha/material_alpha.blend -------------------------------------------------------------------------------- /material_bake/material_bake.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_bake/material_bake.blend -------------------------------------------------------------------------------- /material_batch/material_batch.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_batch/material_batch.blend -------------------------------------------------------------------------------- /material_billboard/bunny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_billboard/bunny.png -------------------------------------------------------------------------------- /material_billboard/material_billboard.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_billboard/material_billboard.blend -------------------------------------------------------------------------------- /material_bump/brick_bump.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_bump/brick_bump.jpg -------------------------------------------------------------------------------- /material_bump/material_bump.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_bump/material_bump.blend -------------------------------------------------------------------------------- /material_decal/decal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_decal/decal.png -------------------------------------------------------------------------------- /material_decal/material_decal.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_decal/material_decal.blend -------------------------------------------------------------------------------- /material_decal_colors/README.md: -------------------------------------------------------------------------------- 1 | - Left click and drag to rotate the monkey. 2 | - Left click to spawn decal with random color. 3 | - Scroll up or down to zoom in or out. 4 | - Right click to clear all decals 5 | -------------------------------------------------------------------------------- /material_decal_colors/material_decal_colors.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_decal_colors/material_decal_colors.blend -------------------------------------------------------------------------------- /material_depth_texture/Assets/checker_rough.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_depth_texture/Assets/checker_rough.png -------------------------------------------------------------------------------- /material_depth_texture/Assets/grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_depth_texture/Assets/grid.png -------------------------------------------------------------------------------- /material_depth_texture/README.md: -------------------------------------------------------------------------------- 1 | Wall with a material that's reading from a depth texture, which is copied from the depth buffer before drawing the wall as the last object in the scene. 2 | 3 | #### To use this in your own projects: 4 | 5 | 1. Enable `Material Properties > Armory Props > Read Depth` 6 | 2. Make sure `Render Properties > Armory Render Path > Renderer > Depth Texture` is set to `Auto` or `On` 7 | 3. Add a `Shader Data` node with a uniform sampler2D with the name `depthtex` and separate the x value from the color output 8 | 9 | Note that the depth values depend on the camera far/near values! Also the compositor needs to be enabled on forward render path in order to work. -------------------------------------------------------------------------------- /material_depth_texture/material_depth_texture.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_depth_texture/material_depth_texture.blend -------------------------------------------------------------------------------- /material_displace/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/armory/wiki/materials#displacement 2 | -------------------------------------------------------------------------------- /material_displace/material_displace.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_displace/material_displace.blend -------------------------------------------------------------------------------- /material_glossy_metallic/material_glossy_metallic.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_glossy_metallic/material_glossy_metallic.blend -------------------------------------------------------------------------------- /material_multiuvs/multiuvs.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_multiuvs/multiuvs.blend -------------------------------------------------------------------------------- /material_normalmap/material_normalmap.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_normalmap/material_normalmap.blend -------------------------------------------------------------------------------- /material_params/Bundled/tex1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_params/Bundled/tex1.png -------------------------------------------------------------------------------- /material_params/Bundled/tex2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_params/Bundled/tex2.png -------------------------------------------------------------------------------- /material_params/README.md: -------------------------------------------------------------------------------- 1 | Shows how to control material nodes at run-time. 2 | Press 1, 2, 3 to change parameters. 3 | 4 | - Enable `Parameter` property in `Logic Node Editor - Properties - Armory Material Node` 5 | - RGB, Value and Image Texture nodes are supported 6 | - See `MyTrait` script to set material parameters using Haxe 7 | - See `NodeTree` to set material parameters using logic nodes 8 | 9 | https://github.com/armory3d/armory/wiki/materials#material-parameters 10 | -------------------------------------------------------------------------------- /material_params/Sources/arm/MyTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.math.Vec4; 4 | import iron.object.Object; 5 | import iron.object.Uniforms; 6 | import iron.data.Data; 7 | import iron.data.MaterialData; 8 | import iron.system.Time; 9 | 10 | class MyTrait extends iron.Trait { 11 | 12 | var tex1:kha.Image = null; 13 | var tex2:kha.Image = null; 14 | 15 | public function new() { 16 | super(); 17 | notifyOnInit(() -> { 18 | // Register link callbacks 19 | Uniforms.externalVec3Links.push(vec3Link); 20 | Uniforms.externalFloatLinks.push(floatLink); 21 | Uniforms.externalTextureLinks.push(textureLink); 22 | }); 23 | Data.getImage("tex1.png", img -> tex1 = img ); 24 | Data.getImage("tex2.png", img -> tex2 = img ); 25 | } 26 | 27 | function vec3Link(object:Object, mat:MaterialData, link:String):Vec4 { 28 | // object - currently bound object 29 | // mat - currently bound material 30 | // link - material node name 31 | if (link == "RGB") { 32 | var t = Time.time(); 33 | return new Vec4(Math.sin(t) * 0.5 + 0.5, Math.cos(t) * 0.5 + 0.5, Math.sin(t + 0.5) * 0.5 + 0.5); 34 | } 35 | return null; 36 | } 37 | 38 | function floatLink(object:Object, mat:MaterialData, link:String):Null { 39 | if (link == "Value") { 40 | var t = Time.time(); 41 | return Math.floor(t); 42 | } 43 | return null; 44 | } 45 | 46 | function textureLink(object:Object, mat:MaterialData, link:String):kha.Image { 47 | if (link == "Image Texture") { 48 | var t = Time.time(); 49 | return Math.sin(t) > 0 ? tex1 : tex2; 50 | } 51 | return null; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /material_params/material_params.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_params/material_params.blend -------------------------------------------------------------------------------- /material_shadeless/material_shadeless.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_shadeless/material_shadeless.blend -------------------------------------------------------------------------------- /material_shaders/Bundled/MyCustomMaterial/MyCustomMaterial.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader_datas": [ 3 | { 4 | "contexts": [ 5 | { 6 | "color_attachments": [ 7 | "RGBA64" 8 | ], 9 | "compare_mode": "less", 10 | "constants": [ 11 | { 12 | "link": "_worldViewProjectionMatrix", 13 | "name": "WVP", 14 | "type": "mat4" 15 | }, 16 | { 17 | "link": "_normalMatrix", 18 | "name": "N", 19 | "type": "mat3" 20 | }, 21 | { 22 | "link": "_posUnpack", 23 | "name": "posUnpack", 24 | "type": "float" 25 | }, 26 | { 27 | "link": "_time", 28 | "name": "time", 29 | "type": "float" 30 | }, 31 | { 32 | "link": "myParam", 33 | "name": "myParam", 34 | "type": "float" 35 | } 36 | ], 37 | "cull_mode": "clockwise", 38 | "depth_write": true, 39 | "fragment_shader": "MyCustomMaterial.frag", 40 | "name": "mesh", 41 | "texture_units": [], 42 | "vertex_elements": [ 43 | { 44 | "name": "pos", 45 | "data": "short4norm" 46 | }, 47 | { 48 | "name": "nor", 49 | "data": "short2norm" 50 | } 51 | ], 52 | "vertex_shader": "MyCustomMaterial.vert" 53 | } 54 | ], 55 | "name": "MyCustomMaterial" 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /material_shaders/Shaders/MyCustomMaterial.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | in vec3 mpos; 4 | in vec3 normal; 5 | 6 | // Color of each fragment on the screen 7 | out vec4 fragColor; 8 | 9 | void main() { 10 | // Shadeless red color 11 | //fragColor = vec4(1.0,0.0,0.0,0.0); 12 | 13 | // Assuming forward rendering path for simplicity 14 | vec3 col = (mpos + vec3(1.0)) / 8.0; 15 | col += normal * 0.1; 16 | fragColor = vec4(col, 1.0); 17 | } 18 | -------------------------------------------------------------------------------- /material_shaders/Shaders/MyCustomMaterial.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | // Armory uses packed vertex data to preserve memory 4 | in vec4 pos; // pos.xyz, nor.z 5 | in vec2 nor; // nor.xy 6 | 7 | uniform mat4 WVP; 8 | uniform mat3 N; 9 | uniform float posUnpack; 10 | uniform float time; 11 | uniform float myParam; 12 | 13 | out vec3 mpos; 14 | out vec3 normal; 15 | 16 | void main() { 17 | vec4 p = vec4(pos.xyz, 1.0); 18 | 19 | // Position data is packed into (-1, 1) range 20 | // Retrieve model position 21 | mpos = pos.xyz * posUnpack; 22 | 23 | // Unpack normal.z component from pos.w 24 | normal = N * vec3(nor.xy, pos.w); 25 | 26 | p.z += sin((time + mpos.x + mpos.y) * 2.0) * 0.2 * myParam; 27 | gl_Position = WVP * p; 28 | } 29 | -------------------------------------------------------------------------------- /material_shaders/Sources/arm/MyTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.Scene; 4 | import iron.math.Vec4; 5 | import iron.data.MaterialData; 6 | import iron.object.MeshObject; 7 | import iron.object.Object; 8 | import iron.object.Uniforms; 9 | 10 | class MyTrait extends iron.Trait { 11 | 12 | public function new() { 13 | super(); 14 | notifyOnInit(() -> { 15 | Uniforms.externalFloatLinks.push(floatLink); 16 | }); 17 | } 18 | 19 | function floatLink(object:Object, mat:MaterialData, link:String):Null { 20 | if (link == "myParam") { 21 | var mouse = iron.system.Input.getMouse(); 22 | return (iron.App.h() - mouse.y) / 100; 23 | } 24 | return null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /material_shaders/material_shaders.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_shaders/material_shaders.blend -------------------------------------------------------------------------------- /material_sss/material_sss.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_sss/material_sss.blend -------------------------------------------------------------------------------- /material_translucent/circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_translucent/circle.png -------------------------------------------------------------------------------- /material_translucent/material_translucent.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_translucent/material_translucent.blend -------------------------------------------------------------------------------- /material_video/README.md: -------------------------------------------------------------------------------- 1 | - Krom is not yet supported, please use HTML5 or native targets for now. 2 | - ffmpeg is required to process video files. 3 | 4 | 1. Install [ffmpeg](https://ffmpeg.org) 5 | 2. Point `Edit - Preferences… - Add-ons - Armory - Advanced - FFMPEG Path` to ffmpeg binary 6 | 3. Play 7 | 4. During the first build, video processing may take some time 8 | -------------------------------------------------------------------------------- /material_video/material_video.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_video/material_video.blend -------------------------------------------------------------------------------- /material_video/video.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/material_video/video.mp4 -------------------------------------------------------------------------------- /mesh_generate/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/armory/wiki/generate_mesh 2 | 3 | #### Keyboard 4 | - `Up`, `W` Add cubes 5 | - `Down`, `S` Remove cubes 6 | -------------------------------------------------------------------------------- /mesh_generate/Sources/arm/BoxGenerator.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.data.Data; 4 | import iron.data.MaterialData; 5 | import iron.data.MeshData; 6 | import iron.data.SceneFormat; 7 | import iron.object.MeshObject; 8 | import iron.Scene; 9 | import iron.system.Input; 10 | import kha.arrays.Int16Array; 11 | import kha.arrays.Uint32Array; 12 | 13 | class BoxGenerator extends iron.Trait { 14 | 15 | var meshData:MeshData; 16 | var materials:haxe.ds.Vector; 17 | var cubes = new Array(); 18 | var font : kha.Font; 19 | 20 | function toI16(toPos:Int16Array, toNor:Int16Array, fromPos:Array, fromNor:Array) { 21 | var numVertices = Std.int(fromPos.length / 3); 22 | for (i in 0...numVertices) { 23 | // Values are scaled to the signed short (-32768, 32767) range 24 | // In the shader, vertex data is normalized into (-1, 1) range 25 | toPos[i * 4 ] = Std.int(fromPos[i * 3 ] * 32767); 26 | toPos[i * 4 + 1] = Std.int(fromPos[i * 3 + 1] * 32767); 27 | toPos[i * 4 + 2] = Std.int(fromPos[i * 3 + 2] * 32767); 28 | toNor[i * 2 ] = Std.int(fromNor[i * 3 ] * 32767); 29 | toNor[i * 2 + 1] = Std.int(fromNor[i * 3 + 1] * 32767); 30 | // normal.z component is packed into position.w component 31 | toPos[i * 4 + 3] = Std.int(fromNor[i * 3 + 2] * 32767); 32 | } 33 | } 34 | 35 | function toU32(to:Uint32Array, from:Array) { 36 | for (i in 0...to.length) to[i] = from[i]; 37 | } 38 | 39 | public function new() { 40 | super(); 41 | 42 | 43 | // Raw vertex data for our box 44 | var positions = [1.0,1.0,-1.0,1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,-1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0]; 45 | var normals = [0.0,0.0,-1.0,0.0,0.0,-1.0,0.0,0.0,-1.0,0.0,0.0,-1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,-1.0,-0.0,0.0,-1.0,-0.0,0.0,-1.0,-0.0,0.0,-1.0,-0.0,-1.0,0.0,-0.0,-1.0,0.0,-0.0,-1.0,0.0,-0.0,-1.0,0.0,-0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0]; 46 | var indices = [0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]; 47 | var numVertices = Std.int(positions.length / 3); 48 | 49 | // Armory uses packed 16-bit normalized vertex data to preserve memory 50 | // To prevent padding and ensure 32-bit align, 51 | // normal.z component is packed into position.w component 52 | var posI16 = new Int16Array(numVertices * 4); // pos.xyz, nor.z 53 | var norI16 = new Int16Array(numVertices * 2); // nor.xy 54 | toI16(posI16, norI16, positions, normals); 55 | 56 | var indU32 = new Uint32Array(indices.length); 57 | toU32(indU32, indices); 58 | 59 | var pos:TVertexArray = { attrib: "pos", values: posI16, data: "short4norm" }; 60 | var nor:TVertexArray = { attrib: "nor", values: norI16, data: "short2norm" }; 61 | var ind:TIndexArray = { material: 0, values: indU32 }; 62 | 63 | var rawmeshData:TMeshData = { 64 | name: "BoxMesh", 65 | vertex_arrays: [pos, nor], 66 | index_arrays: [ind], 67 | // Usable to scale positions over the (-1, 1) range 68 | scale_pos: 0.5 69 | }; 70 | 71 | new MeshData(rawmeshData, function(data:MeshData) { 72 | // Mesh data parsed 73 | meshData = data; 74 | meshData.geom.calculateAABB(); 75 | 76 | // Fetch material from scene data 77 | Data.getMaterial("Scene", "Material", function(data:MaterialData) { 78 | // Material loaded 79 | materials = haxe.ds.Vector.fromData([data]); 80 | notifyOnUpdate(update); 81 | }); 82 | }); 83 | 84 | Data.getFont('font_default.ttf', f -> { 85 | font = f; 86 | notifyOnRender2D( render2D ); 87 | }); 88 | } 89 | 90 | function update() { 91 | // Left mouse button was pressed / display touched 92 | final keyboard = Input.getKeyboard(); 93 | final mouse = Input.getMouse(); 94 | //if (mouse.down('left')) { 95 | if (keyboard.down('up') || keyboard.down('w') || mouse.down('left')) { 96 | final aabb = meshData.geom.aabb; 97 | for( i in 0...10) { 98 | // Create new object in active scene 99 | final object = Scene.active.addMeshObject(meshData, materials); 100 | 101 | // Just for testing, add rigid body trait 102 | object.transform.loc.set(Math.random() * 8- 4, Math.random() * 8 - 4, 5); 103 | object.transform.buildMatrix(); 104 | object.transform.dim.set(aabb.x, aabb.y, aabb.z); 105 | object.addTrait(new armory.trait.physics.RigidBody()); 106 | cubes.push(object); 107 | } 108 | trace(cubes.length); 109 | } else if (keyboard.down('down') || keyboard.down('s') || mouse.down('right')) { 110 | for( i in 0...10) { 111 | if( cubes.length == 0 ) break; 112 | cubes.shift().remove(); 113 | } 114 | trace(cubes.length); 115 | } 116 | } 117 | 118 | function render2D( g : kha.graphics2.Graphics ) { 119 | g.end(); 120 | g.font = font; 121 | final fontSize = 13; 122 | final text = 'CUBES: '+cubes.length; 123 | final w = font.width( g.fontSize, text ); 124 | g.fontSize = 13; 125 | g.drawString( text, 10, 10 ); 126 | g.begin( false ); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /mesh_generate/mesh_generate.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/mesh_generate/mesh_generate.blend -------------------------------------------------------------------------------- /mesh_import/Bundled/cube.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.80 (sub 41) OBJ File: '' 2 | # www.blender.org 3 | o Cube 4 | v 1.000000 1.000000 -1.000000 5 | v 1.000000 -1.000000 -1.000000 6 | v 1.000000 1.000000 1.000000 7 | v 1.000000 -1.000000 1.000000 8 | v -1.000000 1.000000 -1.000000 9 | v -1.000000 -1.000000 -1.000000 10 | v -1.000000 1.000000 1.000000 11 | v -1.000000 -1.000000 1.000000 12 | vt 0.375000 0.000000 13 | vt 0.625000 0.000000 14 | vt 0.625000 0.250000 15 | vt 0.375000 0.250000 16 | vt 0.375000 0.250000 17 | vt 0.625000 0.250000 18 | vt 0.625000 0.500000 19 | vt 0.375000 0.500000 20 | vt 0.625000 0.750000 21 | vt 0.375000 0.750000 22 | vt 0.625000 0.750000 23 | vt 0.625000 1.000000 24 | vt 0.375000 1.000000 25 | vt 0.125000 0.500000 26 | vt 0.375000 0.500000 27 | vt 0.375000 0.750000 28 | vt 0.125000 0.750000 29 | vt 0.625000 0.500000 30 | vt 0.875000 0.500000 31 | vt 0.875000 0.750000 32 | vn 0.0000 1.0000 0.0000 33 | vn 0.0000 0.0000 1.0000 34 | vn -1.0000 0.0000 0.0000 35 | vn 0.0000 -1.0000 0.0000 36 | vn 1.0000 0.0000 0.0000 37 | vn 0.0000 0.0000 -1.0000 38 | s off 39 | f 1/1/1 5/2/1 7/3/1 3/4/1 40 | f 4/5/2 3/6/2 7/7/2 8/8/2 41 | f 8/8/3 7/7/3 5/9/3 6/10/3 42 | f 6/10/4 2/11/4 4/12/4 8/13/4 43 | f 2/14/5 1/15/5 3/16/5 4/17/5 44 | f 6/18/6 5/19/6 1/20/6 2/11/6 45 | -------------------------------------------------------------------------------- /mesh_import/Sources/arm/ImportMesh.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.Scene; 4 | import iron.data.SceneFormat; 5 | import iron.data.Data; 6 | import iron.data.MeshData; 7 | import iron.data.MaterialData; 8 | import iron.system.Input; 9 | 10 | class ImportMesh extends iron.Trait { 11 | 12 | var meshData:MeshData; 13 | var materials:haxe.ds.Vector; 14 | 15 | public function new() { 16 | super(); 17 | 18 | // Get raw blob 19 | Data.getBlob("cube.obj", function(blob:kha.Blob) { 20 | 21 | // Parse obj file 22 | var mesh = new ObjParser(blob); 23 | 24 | // Positions, normals and indices 25 | var pos:TVertexArray = { attrib: "pos", values: mesh.posa, data: "short4norm" }; 26 | var nor:TVertexArray = { attrib: "nor", values: mesh.nora, data: "short2norm" }; 27 | var ind:TIndexArray = { material: 0, values: mesh.inda }; 28 | 29 | var rawmeshData:TMeshData = { 30 | name: "BoxMesh", 31 | vertex_arrays: [pos, nor], 32 | index_arrays: [ind], 33 | // Usable to scale positions over the (-1, 1) range 34 | scale_pos: mesh.scalePos 35 | }; 36 | 37 | // Construct new mesh 38 | new MeshData(rawmeshData, function(data:MeshData) { 39 | meshData = data; 40 | meshData.geom.calculateAABB(); 41 | 42 | // Fetch material from scene data 43 | Data.getMaterial("Scene", "Material", function(data:MaterialData) { 44 | // Material loaded 45 | materials = haxe.ds.Vector.fromData([data]); 46 | notifyOnUpdate(update); 47 | }); 48 | }); 49 | }); 50 | } 51 | 52 | function update() { 53 | // Left mouse button was pressed / display touched 54 | var mouse = Input.getMouse(); 55 | if (mouse.down()) { 56 | // Create new object in active scene 57 | var object = Scene.active.addMeshObject(meshData, materials); 58 | 59 | // Just for testing, add rigid body trait 60 | var aabb = meshData.geom.aabb; 61 | object.transform.loc.set(Math.random() * 8 - 4, Math.random() * 8 - 4, 5); 62 | object.transform.buildMatrix(); 63 | object.transform.dim.set(aabb.x, aabb.y, aabb.z); 64 | object.addTrait(new armory.trait.physics.RigidBody()); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /mesh_import/Sources/arm/ObjParser.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class ObjParser { 4 | 5 | public static var splitCode = "o".code; // Object split, "g" for groups, "u"semtl for materials 6 | public var posa: kha.arrays.Int16Array = null; 7 | public var nora: kha.arrays.Int16Array = null; 8 | public var texa: kha.arrays.Int16Array = null; 9 | public var inda: kha.arrays.Uint32Array = null; 10 | public var udims: Array = null; // Indices split per udim tile 11 | public var udimsU = 1; // Number of horizontal udim tiles 12 | public var scalePos = 1.0; 13 | public var scaleTex = 1.0; 14 | public var name = ""; 15 | public var hasNext = false; // File contains multiple objects 16 | public var pos = 0; 17 | var posTemp: Array; 18 | var uvTemp: Array; 19 | var norTemp: Array; 20 | var va: kha.arrays.Uint32Array; 21 | var ua: kha.arrays.Uint32Array; 22 | var na: kha.arrays.Uint32Array; 23 | var vi = 0; 24 | var ui = 0; 25 | var ni = 0; 26 | var buf: haxe.io.UInt8Array = null; 27 | 28 | static var vindOff = 0; 29 | static var tindOff = 0; 30 | static var nindOff = 0; 31 | static var bytes: haxe.io.Bytes = null; 32 | static var posFirst: Array; 33 | static var uvFirst: Array; 34 | static var norFirst: Array; 35 | 36 | public function new(blob: kha.Blob, startPos = 0, udim = false) { 37 | pos = startPos; 38 | var posIndices: Array = []; 39 | var uvIndices: Array = []; 40 | var norIndices: Array = []; 41 | var readingFaces = false; 42 | var readingObject = false; 43 | var fullAttrib = false; 44 | bytes = blob.bytes; 45 | 46 | posTemp = []; 47 | uvTemp = []; 48 | norTemp = []; 49 | va = new kha.arrays.Uint32Array(60); 50 | ua = new kha.arrays.Uint32Array(60); 51 | na = new kha.arrays.Uint32Array(60); 52 | buf = new haxe.io.UInt8Array(64); 53 | 54 | if (splitCode == "u".code && startPos > 0) { 55 | posTemp = posFirst; 56 | norTemp = norFirst; 57 | uvTemp = uvFirst; 58 | } 59 | 60 | while (true) { 61 | if (pos >= bytes.length) break; 62 | 63 | var c0 = bytes.get(pos++); 64 | if (readingObject && readingFaces && (c0 == "v".code || c0 == splitCode)) { 65 | pos--; 66 | hasNext = true; 67 | break; 68 | } 69 | 70 | if (c0 == "v".code) { 71 | var c1 = bytes.get(pos++); 72 | if (c1 == " ".code) { 73 | // Some exporters put additional space directly after "v" 74 | if (bytes.get(pos) == " ".code) pos++; 75 | posTemp.push(readFloat()); 76 | pos++; // Space 77 | posTemp.push(readFloat()); 78 | pos++; // Space 79 | posTemp.push(readFloat()); 80 | } 81 | else if (c1 == "t".code) { 82 | pos++; // Space 83 | uvTemp.push(readFloat()); 84 | pos++; // Space 85 | uvTemp.push(readFloat()); 86 | if (norTemp.length > 0) fullAttrib = true; 87 | } 88 | else if (c1 == "n".code) { 89 | pos++; // Space 90 | norTemp.push(readFloat()); 91 | pos++; // Space 92 | norTemp.push(readFloat()); 93 | pos++; // Space 94 | norTemp.push(readFloat()); 95 | if (uvTemp.length > 0) fullAttrib = true; 96 | } 97 | } 98 | else if (c0 == "f".code) { 99 | pos++; // Space 100 | readingFaces = true; 101 | vi = 0; 102 | ui = 0; 103 | ni = 0; 104 | fullAttrib ? readFaceFast() : readFace(); 105 | 106 | posIndices.push(va[0]); 107 | posIndices.push(va[1]); 108 | posIndices.push(va[2]); 109 | for (i in 3...vi) { 110 | posIndices.push(va[0]); 111 | posIndices.push(va[i - 1]); 112 | posIndices.push(va[i]); 113 | } 114 | if (uvTemp.length > 0) { 115 | uvIndices.push(ua[0]); 116 | uvIndices.push(ua[1]); 117 | uvIndices.push(ua[2]); 118 | for (i in 3...ui) { 119 | uvIndices.push(ua[0]); 120 | uvIndices.push(ua[i - 1]); 121 | uvIndices.push(ua[i]); 122 | } 123 | } 124 | if (norTemp.length > 0) { 125 | norIndices.push(na[0]); 126 | norIndices.push(na[1]); 127 | norIndices.push(na[2]); 128 | for (i in 3...ni) { 129 | norIndices.push(na[0]); 130 | norIndices.push(na[i - 1]); 131 | norIndices.push(na[i]); 132 | } 133 | } 134 | } 135 | else if (c0 == splitCode) { 136 | if (splitCode == "u".code) pos += 5; // "u"semtl 137 | pos++; // Space 138 | if (!udim) readingObject = true; 139 | name = readString(); 140 | } 141 | nextLine(); 142 | } 143 | 144 | if (startPos > 0) { 145 | if (splitCode != "u".code) { 146 | for (i in 0...posIndices.length) posIndices[i] -= vindOff; 147 | for (i in 0...uvIndices.length) uvIndices[i] -= tindOff; 148 | for (i in 0...norIndices.length) norIndices[i] -= nindOff; 149 | } 150 | } 151 | else { 152 | vindOff = tindOff = nindOff = 0; 153 | 154 | if (splitCode == "u".code) { 155 | posFirst = posTemp; 156 | norFirst = norTemp; 157 | uvFirst = uvTemp; 158 | } 159 | } 160 | vindOff += Std.int(posTemp.length / 3); // Assumes separate vertex data per object 161 | tindOff += Std.int(uvTemp.length / 2); 162 | nindOff += Std.int(norTemp.length / 3); 163 | 164 | // Pack positions to (-1, 1) range 165 | scalePos = 0.0; 166 | for (i in 0...posTemp.length) { 167 | var f = Math.abs(posTemp[i]); 168 | if (scalePos < f) scalePos = f; 169 | } 170 | var inv = 32767 * (1 / scalePos); 171 | 172 | posa = new kha.arrays.Int16Array(posIndices.length * 4); 173 | inda = new kha.arrays.Uint32Array(posIndices.length); 174 | for (i in 0...posIndices.length) { 175 | posa[i * 4 ] = Std.int( posTemp[posIndices[i] * 3 ] * inv); 176 | posa[i * 4 + 1] = Std.int(-posTemp[posIndices[i] * 3 + 2] * inv); 177 | posa[i * 4 + 2] = Std.int( posTemp[posIndices[i] * 3 + 1] * inv); 178 | inda[i] = i; 179 | } 180 | 181 | if (norIndices.length > 0) { 182 | nora = new kha.arrays.Int16Array(norIndices.length * 2); 183 | for (i in 0...posIndices.length) { 184 | nora[i * 2 ] = Std.int( norTemp[norIndices[i] * 3 ] * 32767); 185 | nora[i * 2 + 1] = Std.int(-norTemp[norIndices[i] * 3 + 2] * 32767); 186 | posa[i * 4 + 3] = Std.int( norTemp[norIndices[i] * 3 + 1] * 32767); 187 | } 188 | } 189 | else { 190 | // Calc normals 191 | nora = new kha.arrays.Int16Array(inda.length * 2); 192 | var va = new iron.math.Vec4(); 193 | var vb = new iron.math.Vec4(); 194 | var vc = new iron.math.Vec4(); 195 | var cb = new iron.math.Vec4(); 196 | var ab = new iron.math.Vec4(); 197 | for (i in 0...Std.int(inda.length / 3)) { 198 | var i1 = inda[i * 3 ]; 199 | var i2 = inda[i * 3 + 1]; 200 | var i3 = inda[i * 3 + 2]; 201 | va.set(posa[i1 * 4], posa[i1 * 4 + 1], posa[i1 * 4 + 2]); 202 | vb.set(posa[i2 * 4], posa[i2 * 4 + 1], posa[i2 * 4 + 2]); 203 | vc.set(posa[i3 * 4], posa[i3 * 4 + 1], posa[i3 * 4 + 2]); 204 | cb.subvecs(vc, vb); 205 | ab.subvecs(va, vb); 206 | cb.cross(ab); 207 | cb.normalize(); 208 | nora[i1 * 2 ] = Std.int(cb.x * 32767); 209 | nora[i1 * 2 + 1] = Std.int(cb.y * 32767); 210 | posa[i1 * 4 + 3] = Std.int(cb.z * 32767); 211 | nora[i2 * 2 ] = Std.int(cb.x * 32767); 212 | nora[i2 * 2 + 1] = Std.int(cb.y * 32767); 213 | posa[i2 * 4 + 3] = Std.int(cb.z * 32767); 214 | nora[i3 * 2 ] = Std.int(cb.x * 32767); 215 | nora[i3 * 2 + 1] = Std.int(cb.y * 32767); 216 | posa[i3 * 4 + 3] = Std.int(cb.z * 32767); 217 | } 218 | } 219 | 220 | if (uvIndices.length > 0) { 221 | if (udim) { 222 | // Find number of tiles 223 | var tilesU = 1; 224 | var tilesV = 1; 225 | for (i in 0...Std.int(uvTemp.length / 2)) { 226 | while (uvTemp[i * 2 ] > tilesU) tilesU++; 227 | while (uvTemp[i * 2 + 1] > tilesV) tilesV++; 228 | } 229 | 230 | function getTile(i1: Int, i2: Int, i3: Int): Int { 231 | var u1 = uvTemp[uvIndices[i1] * 2 ]; 232 | var v1 = uvTemp[uvIndices[i1] * 2 + 1]; 233 | var u2 = uvTemp[uvIndices[i2] * 2 ]; 234 | var v2 = uvTemp[uvIndices[i2] * 2 + 1]; 235 | var u3 = uvTemp[uvIndices[i3] * 2 ]; 236 | var v3 = uvTemp[uvIndices[i3] * 2 + 1]; 237 | var tileU = Std.int((u1 + u2 + u3) / 3); 238 | var tileV = Std.int((v1 + v2 + v3) / 3); 239 | return tileU + tileV * tilesU; 240 | } 241 | 242 | // Amount of indices pre tile 243 | var num = new kha.arrays.Uint32Array(tilesU * tilesV); 244 | for (i in 0...Std.int(inda.length / 3)) { 245 | var tile = getTile(inda[i * 3], inda[i * 3 + 1], inda[i * 3 + 2]); 246 | num[tile] += 3; 247 | } 248 | 249 | // Split indices per tile 250 | udims = []; 251 | udimsU = tilesU; 252 | for (i in 0...tilesU * tilesV) { udims.push(new kha.arrays.Uint32Array(num[i])); num[i] = 0; } 253 | 254 | for (i in 0...Std.int(inda.length / 3)) { 255 | var i1 = inda[i * 3 ]; 256 | var i2 = inda[i * 3 + 1]; 257 | var i3 = inda[i * 3 + 2]; 258 | var tile = getTile(i1, i2, i3); 259 | udims[tile][num[tile]++] = i1; 260 | udims[tile][num[tile]++] = i2; 261 | udims[tile][num[tile]++] = i3; 262 | } 263 | 264 | // Normalize uvs to 0-1 range 265 | var uvtiles = new kha.arrays.Int16Array(uvTemp.length); 266 | for (i in 0...Std.int(inda.length / 3)) { // TODO: merge loops 267 | var i1 = inda[i * 3 ]; 268 | var i2 = inda[i * 3 + 1]; 269 | var i3 = inda[i * 3 + 2]; 270 | var tile = getTile(i1, i2, i3); 271 | var tileU = tile % tilesU; 272 | var tileV = Std.int(tile / tilesU); 273 | uvtiles[uvIndices[i1] * 2 ] = tileU; 274 | uvtiles[uvIndices[i1] * 2 + 1] = tileV; 275 | uvtiles[uvIndices[i2] * 2 ] = tileU; 276 | uvtiles[uvIndices[i2] * 2 + 1] = tileV; 277 | uvtiles[uvIndices[i3] * 2 ] = tileU; 278 | uvtiles[uvIndices[i3] * 2 + 1] = tileV; 279 | } 280 | for (i in 0...uvtiles.length) uvTemp[i] -= uvtiles[i]; 281 | } 282 | 283 | texa = new kha.arrays.Int16Array(uvIndices.length * 2); 284 | for (i in 0...posIndices.length) { 285 | texa[i * 2 ] = Std.int( uvTemp[uvIndices[i] * 2 ] * 32767); 286 | texa[i * 2 + 1] = Std.int((1.0 - uvTemp[uvIndices[i] * 2 + 1]) * 32767); 287 | } 288 | } 289 | bytes = null; 290 | if (!hasNext) { posFirst = norFirst = uvFirst = null; } 291 | } 292 | 293 | function readFaceFast() { 294 | while (true) { 295 | va[vi++] = readInt() - 1; 296 | pos++; // "/" 297 | ua[ui++] = readInt() - 1; 298 | pos++; // "/" 299 | na[ni++] = readInt() - 1; 300 | if (bytes.get(pos) == "\n".code || bytes.get(pos) == "\r".code) break; 301 | pos++; // " " 302 | // Some exporters put space at the end of "f" line 303 | if (vi >= 3 && (bytes.get(pos) == "\n".code || bytes.get(pos) == "\r".code)) break; 304 | } 305 | } 306 | 307 | function readFace() { 308 | while (true) { 309 | va[vi++] = readInt() - 1; 310 | if (uvTemp.length > 0 || norTemp.length > 0) { 311 | pos++; // "/" 312 | } 313 | if (uvTemp.length > 0) { 314 | ua[ui++] = readInt() - 1; 315 | } 316 | if (norTemp.length > 0) { 317 | pos++; // "/" 318 | na[ni++] = readInt() - 1; 319 | } 320 | if (bytes.get(pos) == "\n".code || bytes.get(pos) == "\r".code) break; 321 | pos++; // " " 322 | // Some exporters put space at the end of "f" line 323 | if (vi >= 3 && (bytes.get(pos) == "\n".code || bytes.get(pos) == "\r".code)) break; 324 | } 325 | } 326 | 327 | function readFloat(): Float { 328 | var bi = 0; 329 | while (true) { // Read into buffer 330 | var c = bytes.get(pos); 331 | if (c == " ".code || c == "\n".code || c == "\r".code) break; 332 | if (c == "E".code || c == "e".code) { 333 | while (true) { 334 | pos++; 335 | c = bytes.get(pos); 336 | if (c == " ".code || c == "\n".code || c == "\r".code) break; 337 | } 338 | return 0.0; // Assume number close to zero for now 339 | } 340 | pos++; 341 | buf[bi++] = c; 342 | } 343 | var res = 0.0; // Parse buffer into float 344 | var dot = 1; 345 | var dec = 1; 346 | var off = buf[0] == "-".code ? 1 : 0; 347 | var len = bi - 1; 348 | for (i in 0...bi - off) { 349 | var c = buf[len - i]; 350 | if (c == ".".code) { dot = dec; continue; } 351 | res += (c - 48) * dec; 352 | dec *= 10; 353 | } 354 | off > 0 ? res /= -dot : res /= dot; 355 | return res; 356 | } 357 | 358 | function readInt(): Int { 359 | var bi = 0; 360 | while (true) { // Read into buffer 361 | var c = bytes.get(pos); 362 | if (c == "/".code || c == "\n".code || c == "\r".code || c == " ".code) break; 363 | pos++; 364 | buf[bi++] = c; 365 | } 366 | var res = 0; // Parse buffer into int 367 | var dec = 1; 368 | var off = buf[0] == "-".code ? 1 : 0; 369 | var len = bi - 1; 370 | for (i in 0...bi - off) { 371 | res += (buf[len - i] - 48) * dec; 372 | dec *= 10; 373 | } 374 | if (off > 0) res *= -1; 375 | return res; 376 | } 377 | 378 | function readString(): String { 379 | var s = ""; 380 | while (true) { 381 | var c = bytes.get(pos); 382 | if (c == "\n".code || c == "\r".code || c == " ".code) break; 383 | pos++; 384 | s += String.fromCharCode(c); 385 | } 386 | return s; 387 | } 388 | 389 | function nextLine() { 390 | while (true) { 391 | var c = bytes.get(pos++); 392 | if (c == "\n".code || pos >= bytes.length) break; // \n, \r\n 393 | } 394 | } 395 | } 396 | -------------------------------------------------------------------------------- /mesh_import/mesh_import.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/mesh_import/mesh_import.blend -------------------------------------------------------------------------------- /mesh_terrain/Bundled/heightmap_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/mesh_terrain/Bundled/heightmap_01.png -------------------------------------------------------------------------------- /mesh_terrain/README.md: -------------------------------------------------------------------------------- 1 | To generate terrain: 2 | 3 | - Place your heightmap as `Bundled/heightmap_01.png` 4 | - Navigate to `Properties - Scene - Armory Terrain` 5 | - Set terrain dimensions using `Sector Size` 6 | - Set terrain height using `Height Scale` 7 | - Click `Generate` 8 | - Adjust terrain material 9 | 10 | See 11 | -------------------------------------------------------------------------------- /mesh_terrain/base.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/mesh_terrain/base.png -------------------------------------------------------------------------------- /mesh_terrain/mesh_terrain.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/mesh_terrain/mesh_terrain.blend -------------------------------------------------------------------------------- /navmesh/README.md: -------------------------------------------------------------------------------- 1 | - https://github.com/armory3d/armory/wiki/navmesh 2 | --- 3 | - https://api.armory3d.org/armory/trait/NavMesh.html 4 | - https://api.armory3d.org/armory/trait/NavAgent.html 5 | - https://api.armory3d.org/armory/trait/NavCrowd.html 6 | -------------------------------------------------------------------------------- /navmesh/gridbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/navmesh/gridbox.png -------------------------------------------------------------------------------- /navmesh/gridbox2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/navmesh/gridbox2.png -------------------------------------------------------------------------------- /navmesh/navmesh.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/navmesh/navmesh.blend -------------------------------------------------------------------------------- /navmesh_follow/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/armory/wiki/navmesh 2 | -------------------------------------------------------------------------------- /navmesh_follow/navmesh_follow.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/navmesh_follow/navmesh_follow.blend -------------------------------------------------------------------------------- /network_zui_chat/Bundled/canvas/MainCanvas.files: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/network_zui_chat/Bundled/canvas/MainCanvas.files -------------------------------------------------------------------------------- /network_zui_chat/Bundled/canvas/MainCanvas.json: -------------------------------------------------------------------------------- 1 | {"name":"untitled","x":0,"y":0,"width":1280,"height":720,"theme":"Default Light","elements":[{"id":4,"type":12,"name":"chatBackground","event":"","x":0,"y":-160,"width":420,"height":60,"rotation":0,"text":"","asset":"","progress_at":0,"progress_total":100,"strength":1,"alignment":0,"anchor":4,"parent":null,"children":[],"visible":true,"color":-14145496},{"id":0,"type":0,"name":"chatStatus","event":"","x":-20,"y":-220,"width":420,"height":30,"rotation":0,"text":"CHAT: Disconnected","asset":"","progress_at":0,"progress_total":100,"strength":1,"alignment":0,"anchor":4,"parent":null,"children":[],"visible":true,"color_text":null},{"id":1,"type":0,"name":"chatMsg","event":"","x":0,"y":-180,"width":420,"height":20,"rotation":0,"text":"...","asset":"","progress_at":0,"progress_total":100,"strength":1,"alignment":0,"anchor":4,"parent":null,"children":[],"visible":true,"color_text":null},{"id":2,"type":2,"name":"chatSend","event":"","x":160,"y":-100,"width":104,"height":44,"rotation":0,"text":"SEND","asset":"","progress_at":0,"progress_total":100,"strength":1,"alignment":1,"anchor":4,"parent":null,"children":[],"visible":true,"color_text":null,"color":null,"color_hover":null,"color_press":null},{"id":3,"type":10,"name":"chatInput","event":"","x":-60,"y":-100,"width":300,"height":48,"rotation":0,"text":"","asset":"","progress_at":0,"progress_total":100,"strength":1,"alignment":0,"anchor":4,"parent":null,"children":[],"visible":true,"color_text":null,"color":null,"color_hover":null}],"assets":[]} -------------------------------------------------------------------------------- /network_zui_chat/Bundled/canvas/_themes.json: -------------------------------------------------------------------------------- 1 | [{"NAME":"Default Light","WINDOW_BG_COL":-1052689,"WINDOW_TINT_COL":-14540254,"ACCENT_COL":-1118482,"ACCENT_HOVER_COL":-4473925,"ACCENT_SELECT_COL":-5592406,"BUTTON_COL":-3355444,"BUTTON_TEXT_COL":-14540254,"BUTTON_HOVER_COL":-5000269,"BUTTON_PRESSED_COL":-5131855,"TEXT_COL":-6710887,"LABEL_COL":-5592406,"SEPARATOR_COL":-6710887,"HIGHLIGHT_COL":-14656100,"CONTEXT_COL":-5592406,"PANEL_BG_COL":-5592406,"FONT_SIZE":26,"ELEMENT_W":200,"ELEMENT_H":48,"ELEMENT_OFFSET":8,"ARROW_SIZE":10,"BUTTON_H":44,"CHECK_SIZE":30,"CHECK_SELECT_SIZE":16,"SCROLL_W":12,"TEXT_OFFSET":16,"TAB_W":24,"FILL_WINDOW_BG":false,"FILL_BUTTON_BG":true,"FILL_ACCENT_BG":false,"LINK_STYLE":0,"FULL_TABS":false}] -------------------------------------------------------------------------------- /network_zui_chat/README.md: -------------------------------------------------------------------------------- 1 | Simple Network Zui Chat Example: 2 | 3 | - Red nodes are for system host targets 4 | - Teal nodes are for system and html browser client targets 5 | 6 | ** If you plan on using 3rd party server / client configuration please keep in mind our nodes use bytes and buffers even for regular strings 7 | 8 | ** Once a buffer is read it is not accessible any more, meaning if a msg parser node matches the same API field the buffer will be read and converted back into its data type 9 | 10 | ** Both host nodes and client nodes are allowed on the same node tree however browser html targets are not capable of being hosts. A browser cannot create/listen to TCP/UDP ports) so any host related nodes will be ignored when targeting html browsers 11 | 12 | ** System server *targets (like hashlink C for desktop/mobile) are intended to basically turn your desktop/mobile device into a server to which you can connect to with either another client instance on desktop/mobile or with a browser instance only as a client. 13 | 14 | ``` 15 | C targets = host / client 16 | Browser = only client 17 | Krom = N/A (for now) 18 | ``` 19 | 20 | Introduction to Networking in Armory 3D | Overview of all nodes 21 | https://www.youtube.com/watch?t=135&v=ZmaG_JFmn0Q&feature=youtu.be 22 | -------------------------------------------------------------------------------- /network_zui_chat/network_zui_chat.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/network_zui_chat/network_zui_chat.blend -------------------------------------------------------------------------------- /particle_bunny/bunny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/particle_bunny/bunny.png -------------------------------------------------------------------------------- /particle_bunny/particle_bunny.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/particle_bunny/particle_bunny.blend -------------------------------------------------------------------------------- /particle_hair/particle_hair.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/particle_hair/particle_hair.blend -------------------------------------------------------------------------------- /particle_hair_animated/README.md: -------------------------------------------------------------------------------- 1 | You can watch the video explaining this set up here: 2 | https://youtu.be/6HqsRFteGKo 3 | 4 | 5 | The particule Number is set to 100 but it 6 | is multiplied by 5 in the Armory Props setion 7 | of the particlue system (right at the bottom) 8 | 9 | Textures are CC0: 10 | https://opengameart.org/content/foliage1 11 | -------------------------------------------------------------------------------- /particle_hair_animated/particle_hair_animated.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/particle_hair_animated/particle_hair_animated.blend -------------------------------------------------------------------------------- /particle_info/part.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/particle_info/part.png -------------------------------------------------------------------------------- /particle_info/particle_info.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/particle_info/particle_info.blend -------------------------------------------------------------------------------- /particle_mesh/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/armory/wiki/supported_particles 2 | 3 | #### Keyboard 4 | - `1` Particle speed = 1 5 | - `2` Particle speed = 0 6 | -------------------------------------------------------------------------------- /particle_mesh/particle_mesh.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/particle_mesh/particle_mesh.blend -------------------------------------------------------------------------------- /particle_smoke/particle_smoke.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/particle_smoke/particle_smoke.blend -------------------------------------------------------------------------------- /particle_smoke/smoke.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/particle_smoke/smoke.jpg -------------------------------------------------------------------------------- /physics_break/physics_break.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/physics_break/physics_break.blend -------------------------------------------------------------------------------- /physics_collision_groups/physics_collision_groups.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/physics_collision_groups/physics_collision_groups.blend -------------------------------------------------------------------------------- /physics_constraints/README.md: -------------------------------------------------------------------------------- 1 | - https://github.com/armory3d/armory/wiki/physics#rigid-body-constraints 2 | - https://api.armory3d.org/armory/trait/physics/PhysicsConstraint.html 3 | -------------------------------------------------------------------------------- /physics_constraints/physics_constraints.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/physics_constraints/physics_constraints.blend -------------------------------------------------------------------------------- /physics_drag/README.md: -------------------------------------------------------------------------------- 1 | https://api.armory3d.org/armory/trait/PhysicsDrag.html 2 | -------------------------------------------------------------------------------- /physics_drag/physics_drag.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/physics_drag/physics_drag.blend -------------------------------------------------------------------------------- /physics_pick/README.md: -------------------------------------------------------------------------------- 1 | Example on physics-based picking. 2 | Object to be picked is required to have rigid body enabled. 3 | Click on a cube to make it jump. 4 | Select Camera object, go to `Properties - Object - Armory Traits` and enable one of the traits you wish to test: 5 | - PickTrait - using scripting 6 | - PickEvent - using scripting with mouse event 7 | - PickTree - using logic nodes 8 | 9 | -------------------------------------------------------------------------------- /physics_pick/Sources/arm/PickEvent.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import kha.input.Mouse; 4 | import armory.trait.physics.PhysicsWorld; 5 | 6 | // Using mouse events 7 | class PickEvent extends iron.Trait { 8 | 9 | public function new() { 10 | super(); 11 | 12 | notifyOnInit(function() { 13 | Mouse.get().notify(onMouseDown, onMouseUp, onMouseMove, onMouseWheel); 14 | }); 15 | 16 | notifyOnRemove(function() { 17 | // Trait or its object is removed, remove event listeners 18 | Mouse.get().remove(onMouseDown, onMouseUp, onMouseMove, onMouseWheel); 19 | }); 20 | } 21 | 22 | function onMouseDown(button: Int, x: Int, y: Int) { 23 | // Pick object at mouse coords 24 | var rb = PhysicsWorld.active.pickClosest(x, y); 25 | 26 | // Check if picked object is our Cube 27 | if (rb != null && rb.object.name == 'Cube') { 28 | rb.object.transform.translate(0, 0, 1); 29 | rb.syncTransform(); 30 | } 31 | } 32 | 33 | function onMouseUp(button: Int, x: Int, y: Int) { } 34 | function onMouseMove(x: Int, y: Int, movementX: Int, movementY: Int) { } 35 | function onMouseWheel(delta: Int) { } 36 | } 37 | -------------------------------------------------------------------------------- /physics_pick/Sources/arm/PickTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.system.Input; 4 | import armory.trait.physics.PhysicsWorld; 5 | 6 | class PickTrait extends iron.Trait { 7 | 8 | public function new() { 9 | super(); 10 | 11 | notifyOnUpdate(function() { 12 | // Check mouse button 13 | var mouse = Input.getMouse(); 14 | if (!mouse.started()) return; 15 | 16 | // Pick object at mouse coords 17 | var rb = PhysicsWorld.active.pickClosest(mouse.x, mouse.y); 18 | 19 | // Check if picked object is our Cube 20 | if (rb != null && rb.object.name == 'Cube') { 21 | rb.object.transform.translate(0, 0, 1); 22 | rb.syncTransform(); 23 | } 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /physics_pick/physics_pick.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/physics_pick/physics_pick.blend -------------------------------------------------------------------------------- /physics_ragdoll/README.md: -------------------------------------------------------------------------------- 1 | Drag ragdoll with mouse, legs and arms are destructible. 2 | 3 | ### Building a ragdoll 4 | 5 | 1. Build approx rig from hitboxes 6 | 2. Connect hitboxes using rigid body constraints 7 | 3. Clear bone parents 8 | 4. Attach bones to hitboxes using bone constraints - type 'Child Of'. 9 | 5. Press 'Clear Inverse' and 'Set Inverse' once target is set. 10 | 11 | 12 | -------------------------------------------------------------------------------- /physics_ragdoll/checker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/physics_ragdoll/checker.png -------------------------------------------------------------------------------- /physics_ragdoll/checker_rough.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/physics_ragdoll/checker_rough.png -------------------------------------------------------------------------------- /physics_ragdoll/physics_ragdoll.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/physics_ragdoll/physics_ragdoll.blend -------------------------------------------------------------------------------- /physics_raycast/README.md: -------------------------------------------------------------------------------- 1 | - Keyboard `L/R` Rotate cone 2 | - Mouse `L` Raycast in cone direction 3 | 4 | https://github.com/armory3d/armory/wiki/physics#raycast 5 | -------------------------------------------------------------------------------- /physics_raycast/Sources/arm/RayCastTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import armory.trait.physics.PhysicsWorld; 4 | 5 | class RayCastTrait extends iron.Trait { 6 | 7 | var q = new iron.math.Quat(); 8 | 9 | public function new() { 10 | super(); 11 | 12 | var mouse = iron.system.Input.getMouse(); 13 | var keyboard = iron.system.Input.getKeyboard(); 14 | 15 | notifyOnUpdate(function() { 16 | 17 | if (mouse.down()) { 18 | var physics = PhysicsWorld.active; 19 | 20 | // Start from cone location 21 | var from = object.transform.world.getLoc(); 22 | 23 | // Cast ray in the direction cone points to 24 | var to = object.transform.look(); 25 | 26 | // 1000 units long 27 | to.mult(1000); 28 | 29 | // End position 30 | to.add(from); 31 | 32 | var hit = physics.rayCast(from, to); 33 | var rb = (hit != null) ? hit.rb : null; 34 | var info = ''; 35 | if( rb != null ) info += ' ${rb.object.name}'; 36 | trace(info); 37 | } 38 | 39 | if (keyboard.down("left")) { 40 | q.fromEuler(0, 0, 0.1); 41 | object.transform.rot.mult(q); 42 | object.transform.buildMatrix(); 43 | } 44 | 45 | if (keyboard.down("right")) { 46 | q.fromEuler(0, 0, -0.1); 47 | object.transform.rot.mult(q); 48 | object.transform.buildMatrix(); 49 | } 50 | }); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /physics_raycast/physics_raycast.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/physics_raycast/physics_raycast.blend -------------------------------------------------------------------------------- /physics_softbody/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/armory/wiki/physics#soft-bodies 2 | -------------------------------------------------------------------------------- /physics_softbody/physics_softbody.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/physics_softbody/physics_softbody.blend -------------------------------------------------------------------------------- /raycast_objects/Raycast_Objects.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/raycast_objects/Raycast_Objects.blend -------------------------------------------------------------------------------- /raycast_objects/Sources/Main.hx: -------------------------------------------------------------------------------- 1 | // Auto-generated 2 | package ; 3 | class Main { 4 | public static inline var projectName = 'Raycast_Objects'; 5 | public static inline var projectVersion = '1.0.0'; 6 | public static inline var projectPackage = 'arm'; 7 | public static function main() { 8 | iron.object.BoneAnimation.skinMaxBones = 8; 9 | iron.object.LightObject.cascadeCount = 4; 10 | iron.object.LightObject.cascadeSplitFactor = 0.800000011920929; 11 | armory.system.Starter.main( 12 | 'Scene', 13 | 0, 14 | false, 15 | true, 16 | false, 17 | 1920, 18 | 1080, 19 | 1, 20 | true, 21 | armory.renderpath.RenderPathCreator.get 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /raycast_objects/Sources/arm/MyTraitRaycastObjects.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.system.Input; 4 | import iron.math.Vec4; 5 | import iron.math.RayCaster; 6 | import iron.object.Object; 7 | import iron.object.CameraObject; 8 | 9 | class MyTraitRaycastObjects extends iron.Trait { 10 | 11 | var v = new Vec4(); 12 | var mouse = Input.getMouse(); 13 | var objects: Array; 14 | var o: Object; 15 | 16 | public function new() { 17 | super(); 18 | 19 | notifyOnInit(function() { 20 | 21 | objects = [object, iron.Scene.active.getChild('Sphere'), iron.Scene.active.getChild('Suzanne')]; 22 | 23 | }); 24 | 25 | notifyOnUpdate(function() { 26 | 27 | 28 | if(mouse.started('left')){ 29 | v = RayCaster.boxIntersectObject(object, mouse.x, mouse.y, iron.Scene.active.camera); 30 | if(v != null) 31 | trace('Raycast object at position: '+v); 32 | 33 | o = RayCaster.closestBoxIntersectObject(objects, mouse.x, mouse.y, iron.Scene.active.camera); 34 | if (o != null){ 35 | v = RayCaster.boxIntersectObject(o, mouse.x, mouse.y, iron.Scene.active.camera); 36 | trace('Raycast object: '+o.name+' at position: '+v); 37 | } 38 | } 39 | 40 | }); 41 | 42 | // notifyOnRemove(function() { 43 | // }); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /render_bloom/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/armory/wiki/screen-effects#bloom 2 | -------------------------------------------------------------------------------- /render_bloom/render_bloom.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/render_bloom/render_bloom.blend -------------------------------------------------------------------------------- /render_colorgrading/Bundled/luttexture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/render_colorgrading/Bundled/luttexture.jpg -------------------------------------------------------------------------------- /render_colorgrading/README.md: -------------------------------------------------------------------------------- 1 | ### LUT Textures 2 | 3 | 1. Create a `Bundled` folder in project root 4 | 2. Put a 512x512 LUT jpg in there 5 | 3. Armory Render Path - Post Process panel: write `luttexture.jpg` 6 | 7 | You might need to clean your project for it to show. 8 | 9 | A color neutral LUT file have been included in `extras` folder. 10 | Simply tweak the colors inside a photo-editing application and call it `luttexture.jpg` 11 | 12 | Other LUT files have also been included. 13 | Use them as you wish. 14 | 15 | Includes pictures are public domain provided by National Gallery of Arts. 16 | -------------------------------------------------------------------------------- /render_colorgrading/extras/LUT_Cold.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/render_colorgrading/extras/LUT_Cold.jpg -------------------------------------------------------------------------------- /render_colorgrading/extras/LUT_Color_Neutral.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/render_colorgrading/extras/LUT_Color_Neutral.jpg -------------------------------------------------------------------------------- /render_colorgrading/extras/LUT_Noir.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/render_colorgrading/extras/LUT_Noir.jpg -------------------------------------------------------------------------------- /render_colorgrading/extras/LUT_Selective.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/render_colorgrading/extras/LUT_Selective.jpg -------------------------------------------------------------------------------- /render_colorgrading/extras/LUT_Sepia.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/render_colorgrading/extras/LUT_Sepia.jpg -------------------------------------------------------------------------------- /render_colorgrading/extras/LUT_Warm.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/render_colorgrading/extras/LUT_Warm.jpg -------------------------------------------------------------------------------- /render_colorgrading/img/calib_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/render_colorgrading/img/calib_1.png -------------------------------------------------------------------------------- /render_colorgrading/img/calib_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/render_colorgrading/img/calib_2.png -------------------------------------------------------------------------------- /render_colorgrading/img/tex1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/render_colorgrading/img/tex1.jpg -------------------------------------------------------------------------------- /render_colorgrading/render_colorgrading.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/render_colorgrading/render_colorgrading.blend -------------------------------------------------------------------------------- /render_splitscreen/Sources/arm/SplitScreen.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.Scene; 4 | import iron.object.CameraObject; 5 | import armory.renderpath.RenderPathCreator; 6 | 7 | class SplitScreen extends iron.Trait { 8 | public function new() { 9 | super(); 10 | 11 | notifyOnInit(function() { 12 | 13 | var drawMeshes = RenderPathCreator.drawMeshes; 14 | 15 | // Single viewport size 16 | var w = Std.int(iron.App.w() / 2); 17 | var h = iron.App.h(); 18 | 19 | // Retrieve cameras 20 | var cam1:CameraObject = cast Scene.active.getChild("Camera"); 21 | var cam2:CameraObject = cast Scene.active.getChild("Camera.001"); 22 | cam1.buildProjection(w / h); 23 | cam2.buildProjection(w / h); 24 | 25 | // Override draw method to draw split screen 26 | RenderPathCreator.drawMeshes = function() { 27 | 28 | var g = RenderPathCreator.path.currentG; 29 | 30 | // Left viewport 31 | RenderPathCreator.setTargetMeshes(); 32 | Scene.active.camera = cam1; 33 | g.viewport(0, 0, w, h); 34 | drawMeshes(); 35 | 36 | // Right viewport 37 | RenderPathCreator.setTargetMeshes(); 38 | Scene.active.camera = cam2; 39 | g.viewport(w, 0, w, h); 40 | drawMeshes(); 41 | } 42 | }); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /render_splitscreen/render_splitscreen.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/render_splitscreen/render_splitscreen.blend -------------------------------------------------------------------------------- /render_to_texture/README.md: -------------------------------------------------------------------------------- 1 | #### Keyboard 2 | `R T F G V B` to rotate suzanne 3 | -------------------------------------------------------------------------------- /render_to_texture/Sources/arm/MyTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class MyTrait extends iron.Trait { 4 | public function new() { 5 | super(); 6 | 7 | notifyOnInit(function() { 8 | // Retrieve camera object 9 | var cam = cast(iron.Scene.active.getChild("Camera.001"), iron.object.CameraObject); 10 | 11 | // Create render target for camera 12 | cam.renderTarget = kha.Image.createRenderTarget( 13 | 640, 14 | 360, 15 | kha.graphics4.TextureFormat.RGBA32, 16 | kha.graphics4.DepthStencilFormat.NoDepthAndStencil 17 | ); 18 | 19 | // Display camera output on this plane 20 | var o = cast(object, iron.object.MeshObject); 21 | o.materials[0].contexts[0].textures[0] = cam.renderTarget; // Override base color texture 22 | 23 | notifyOnRender(function(g:kha.graphics4.Graphics) { 24 | // Set as scene camera 25 | var activeCamera = iron.Scene.active.camera; 26 | iron.Scene.active.camera = cam; 27 | 28 | // Update camera output 29 | cam.renderFrame(g); 30 | 31 | // Restore original camera 32 | iron.Scene.active.camera = activeCamera; 33 | }); 34 | }); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /render_to_texture/render_to_texture.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/render_to_texture/render_to_texture.blend -------------------------------------------------------------------------------- /render_voxelao_teapots/render_voxelao_teapots.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/render_voxelao_teapots/render_voxelao_teapots.blend -------------------------------------------------------------------------------- /render_voxelao_teapots/shadows.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/render_voxelao_teapots/shadows.blend -------------------------------------------------------------------------------- /scene_stream/README.md: -------------------------------------------------------------------------------- 1 | - Scene contains 3000+ unique, non-linked meshes, first build may take over 30 sec 2 | - Far plane is set to 100 to visualize streaming 3 | - Object is streamed at camera distance less than (far_plane * 1.1), and unloaded at distance over (far_plane * 1.5) 4 | - Check debug console to see amount of objects loaded 5 | - Mobile render path is set to focus on stream performance 6 | 7 | - Only HTML5 streaming is multi-threaded currently 8 | - Materials (and associated textures) are preloaded at scene startup 9 | -------------------------------------------------------------------------------- /scene_stream/scene_stream.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/scene_stream/scene_stream.blend -------------------------------------------------------------------------------- /screentex/Sources/arm/MyTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import armory.renderpath.RenderPathCreator; 4 | 5 | class MyTrait extends iron.Trait { 6 | public function new() { 7 | super(); 8 | 9 | notifyOnRender2D(function(g:kha.graphics2.Graphics) { 10 | if (RenderPathCreator.finalTarget == null) return; 11 | 12 | // Access final composited image that is afterwards drawn to the screen 13 | var image = RenderPathCreator.finalTarget.image; 14 | 15 | g.color = 0xffffffff; 16 | if (kha.Image.renderTargetsInvertedY()) { 17 | g.drawScaledImage(image, 0, image.height / 5, image.width / 5, -image.height / 5); 18 | } 19 | else { 20 | g.drawScaledImage(image, 0, 0, image.width / 5, image.height / 5); 21 | } 22 | }); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /screentex/screentex.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/screentex/screentex.blend -------------------------------------------------------------------------------- /script_camera_lerp/README.md: -------------------------------------------------------------------------------- 1 | Use keys `A` and `D` to rotate the cube. 2 | The camera follows the cube smoothly with interpolation. 3 | -------------------------------------------------------------------------------- /script_camera_lerp/Sources/arm/CameraTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.object.Object; 4 | import iron.Scene; 5 | import iron.math.Quat; 6 | 7 | class CameraTrait extends iron.Trait { 8 | 9 | var cube:Object; 10 | 11 | public function new() { 12 | super(); 13 | 14 | notifyOnInit(function() { 15 | cube = Scene.active.getChild("Cube"); 16 | }); 17 | 18 | notifyOnUpdate(function() { 19 | if(cube.transform.rot != object.transform.rot){ 20 | var newRot = new Quat().lerp(cube.transform.rot, object.transform.rot, 0.9); 21 | object.transform.rot.setFrom(newRot); 22 | object.transform.buildMatrix(); 23 | } 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /script_camera_lerp/Sources/arm/MyTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.system.Input; 4 | import iron.math.Vec4; 5 | import iron.system.Time; 6 | 7 | class MyTrait extends iron.Trait { 8 | public function new() { 9 | super(); 10 | 11 | notifyOnUpdate(function() { 12 | 13 | var kb = Input.getKeyboard(); 14 | 15 | if(kb.down("a") || kb.down("left")){ 16 | object.transform.rotate(new Vec4(0,0,1), -3 * Time.delta); 17 | } else if(kb.down("d") || kb.down("right")){ 18 | object.transform.rotate(new Vec4(0,0,1), 3 * Time.delta); 19 | } 20 | 21 | }); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /script_camera_lerp/script_camera_lerp.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/script_camera_lerp/script_camera_lerp.blend -------------------------------------------------------------------------------- /script_linkedgroup/README.md: -------------------------------------------------------------------------------- 1 | Click to spawn pin -------------------------------------------------------------------------------- /script_linkedgroup/Sources/arm/PinSpawner.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class PinSpawner extends iron.Trait { 4 | public function new() { 5 | super(); 6 | 7 | notifyOnUpdate(function() { 8 | var mouse = iron.system.Input.getMouse(); 9 | if (mouse.started()) { 10 | iron.Scene.active.spawnObject("PinGroup", null, null); 11 | } 12 | }); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /script_linkedgroup/Sources/arm/PinTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class PinTrait extends iron.Trait { 4 | 5 | public function new() { 6 | super(); 7 | 8 | notifyOnInit(function() { 9 | trace("Pin spawned!"); 10 | }); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /script_linkedgroup/pin.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/script_linkedgroup/pin.blend -------------------------------------------------------------------------------- /script_linkedgroup/script_linkedgroup.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/script_linkedgroup/script_linkedgroup.blend -------------------------------------------------------------------------------- /script_logic_talk/property/Sources/arm/ReadConfig.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class ReadConfig extends iron.Trait { 4 | public function new() { 5 | super(); 6 | 7 | notifyOnInit(function() { 8 | // Retrieve property set from logic nodes 9 | var prop = iron.Scene.global.properties.get("test"); 10 | trace(prop); 11 | }); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /script_logic_talk/property/property.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/script_logic_talk/property/property.blend -------------------------------------------------------------------------------- /script_properties/Sources/arm/MyTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.math.Vec4; 4 | 5 | class MyTrait extends iron.Trait { 6 | 7 | // Property marked with @prop gets exposed in 8 | // Blender - Properties - Object - Armory Traits panel 9 | @prop 10 | var speed:Float = 0.1; 11 | 12 | public function new() { 13 | super(); 14 | 15 | notifyOnUpdate(function() { 16 | object.transform.rotate(Vec4.zAxis(), speed); 17 | }); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /script_properties/script_properties.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/script_properties/script_properties.blend -------------------------------------------------------------------------------- /script_properties_global/Sources/arm/Config.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class Config extends iron.Trait { 4 | 5 | @prop public var speed:Float = 0.1; 6 | @prop public var text:String; 7 | 8 | public static var inst:Config = null; 9 | 10 | public function new() { 11 | super(); 12 | inst = this; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /script_properties_global/Sources/arm/ReadConfig.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class ReadConfig extends iron.Trait { 4 | public function new() { 5 | super(); 6 | 7 | notifyOnInit(function() { 8 | var c = Config.inst; 9 | trace("Text is: " + c.text + ", speed is: " + c.speed); 10 | }); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /script_properties_global/script_properties_global.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/script_properties_global/script_properties_global.blend -------------------------------------------------------------------------------- /script_rigidbody_trigger/README.md: -------------------------------------------------------------------------------- 1 | Rigid body set to: 2 | - Active dynamic 3 | - Axis and rotation locked (linear and angular factor) 4 | - Trigger/Ghost checked making this a trigger instead of a collision object 5 | - Force deactivation unchecked to make sure physics engine keep the rigid body active 6 | - Trigger script checks for overlapping rigid bodies on each update 7 | 8 | ## How to test 9 | Move the box around using WASD+QE. 10 | When box is overlapping sphere the icoshpere object is visible, otherwise it's hidden. 11 | -------------------------------------------------------------------------------- /script_rigidbody_trigger/Sources/arm/Trigger.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.object.Object; 4 | import iron.Scene; 5 | import armory.trait.physics.PhysicsWorld; 6 | import armory.trait.physics.RigidBody; 7 | 8 | class Trigger extends iron.Trait { 9 | 10 | var rb:RigidBody; 11 | var physics:armory.trait.physics.PhysicsWorld; 12 | var obj:Object; 13 | 14 | public function new() { 15 | super(); 16 | 17 | notifyOnInit(function() { 18 | rb = object.getTrait(RigidBody); 19 | physics = armory.trait.physics.PhysicsWorld.active; 20 | obj = Scene.active.getChild("Icosphere"); 21 | }); 22 | 23 | notifyOnUpdate(function() { 24 | // TODO: replace with notifyOnCollisionEnter or notifyOnTriggerEnter once implemented 25 | // ref: https://github.com/armory3d/armory/issues/331 26 | var rbs = physics.getContacts(object.getTrait(RigidBody)); 27 | var visible = false; 28 | 29 | if (rbs != null) { 30 | for (rb in rbs){ 31 | if(rb.object.name == "Cube"){ 32 | visible = true; 33 | } 34 | } 35 | } 36 | 37 | obj.visible = visible; 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /script_rigidbody_trigger/script_rigidbody_trigger.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/script_rigidbody_trigger/script_rigidbody_trigger.blend -------------------------------------------------------------------------------- /script_spawnobject/Sources/arm/SpawnTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class SpawnTrait extends iron.Trait { 4 | public function new() { 5 | super(); 6 | 7 | notifyOnInit(function() { 8 | 9 | // Spawn object from scene hierarchy, including children 10 | iron.Scene.active.spawnObject("Cube", null, function(object:iron.object.Object) { 11 | object.transform.loc.set(0, 4, 0); 12 | object.transform.buildMatrix(); 13 | }); 14 | 15 | // Spawn single object from scene hierarchy 16 | var spawnChildren = false; 17 | iron.Scene.active.spawnObject("Cube", null, function(object:iron.object.Object) { 18 | object.transform.loc.set(-4, 0, 0); 19 | object.transform.buildMatrix(); 20 | }, spawnChildren); 21 | }); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /script_spawnobject/script_spawnobject.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/script_spawnobject/script_spawnobject.blend -------------------------------------------------------------------------------- /script_transform/README.md: -------------------------------------------------------------------------------- 1 | Check console -------------------------------------------------------------------------------- /script_transform/Sources/arm/TransformTest.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class TransformTest extends iron.Trait { 4 | public function new() { 5 | super(); 6 | 7 | notifyOnInit(function() { 8 | 9 | trace('Testing 2 cubes, parent cube at (1, 0, 0), child cube at (5, 0, 0)'); 10 | 11 | trace('Parent location: ' + object.parent.transform.loc); 12 | // (1, 0, 0) 13 | 14 | trace('Child location: ' + object.transform.loc); 15 | // (5, 0, 0) 16 | 17 | trace('Child location in world space: ' + object.transform.world.getLoc()); 18 | // (6, 0, 0) 19 | 20 | trace('Setting child to parent location …'); 21 | object.transform.loc.set(0, 0, 0); 22 | object.transform.buildMatrix(); 23 | 24 | trace('Child location: ' + object.transform.loc); 25 | // (0, 0, 0) 26 | 27 | trace('Child location in world space: ' + object.transform.world.getLoc()); 28 | // (1, 0, 0) 29 | 30 | trace('Moving parent …'); 31 | object.parent.transform.loc.set(0, 3, 0); 32 | object.parent.transform.buildMatrix(); 33 | 34 | trace('Child location: ' + object.transform.loc); 35 | // (0, 0, 0) 36 | 37 | trace('Child location in world space: ' + object.transform.world.getLoc()); 38 | // (0, 3, 0) 39 | 40 | // Note: In Blender, you may need to: 41 | // - Clear Parent - Clear Parent Inverse 42 | // - To get local transform 43 | }); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /script_transform/script_transform.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/script_transform/script_transform.blend -------------------------------------------------------------------------------- /server_stream/README.md: -------------------------------------------------------------------------------- 1 | Press keyboard space to play speaker sound -------------------------------------------------------------------------------- /server_stream/Sources/arm/ArcBall.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.Trait; 4 | import iron.system.Input; 5 | import iron.math.Vec4; 6 | 7 | class ArcBall extends Trait { 8 | 9 | public function new() { 10 | super(); 11 | notifyOnUpdate(update); 12 | } 13 | 14 | function update() { 15 | var mouse = Input.getMouse(); 16 | if (mouse.down()) { 17 | object.transform.rotate(new Vec4(0, 0, 1), mouse.movementX / 100); 18 | object.transform.buildMatrix(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /server_stream/Sources/arm/LoadTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import haxe.io.Bytes; 4 | import iron.object.MeshObject; 5 | import iron.data.MeshData; 6 | import iron.data.SceneFormat; 7 | import iron.Scene; 8 | 9 | class LoadTrait extends iron.Trait { 10 | 11 | function getFormat(asset:Dynamic, format:String):Dynamic { 12 | var fs:Array = asset.formats; 13 | for (i in 0...fs.length) if (fs[i].formatType == format) return fs[i]; 14 | return null; 15 | } 16 | 17 | public function new() { 18 | super(); 19 | 20 | notifyOnInit(function() { 21 | // Load Future Car mesh by Dennis Haupt from poly.google.com 22 | // See https://developers.google.com/poly/develop/web 23 | var url = "https://poly.googleapis.com/v1/assets/0XrQdpjc4Vk/?key=AIzaSyAME8tuXn8gIaPcxmVaz0qbar0DkR4Kw6Q"; 24 | var http = new haxe.Http(url); 25 | http.onData = function(data:String) { 26 | var format = getFormat(haxe.Json.parse(data), "OBJ"); 27 | if (format != null) { 28 | var root = format.root; 29 | http = new haxe.Http(root.url); 30 | http.onData = makeMesh; 31 | http.request(); 32 | } 33 | } 34 | http.request(); 35 | }); 36 | } 37 | 38 | function makeMesh(data:String) { 39 | // Parse received .obj data 40 | var mesh = new ObjParser(kha.Blob.fromBytes(Bytes.ofString(data))); 41 | var posaAr: TVertexArray = { attrib: "pos", values: mesh.posa, data: "short4norm"}; 42 | var noraAr: TVertexArray = { attrib: "nor", values: mesh.nora, data: "short2norm"}; 43 | var raw:TMeshData = { 44 | name: "Mesh", 45 | vertex_arrays: [posaAr, noraAr], 46 | index_arrays: [ 47 | { values: mesh.inda, material: 0 } 48 | ], 49 | scale_pos: mesh.scalePos 50 | }; 51 | 52 | // Set as a new mesh for cube object 53 | new MeshData(raw, function(md:MeshData) { 54 | var cube = cast(Scene.active.getChild("Cube"), MeshObject); 55 | cube.data.delete(); 56 | cube.setData(md); 57 | }); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /server_stream/server_stream.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/server_stream/server_stream.blend -------------------------------------------------------------------------------- /sound/Bundled/hit0.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/sound/Bundled/hit0.wav -------------------------------------------------------------------------------- /sound/Bundled/hit1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/sound/Bundled/hit1.wav -------------------------------------------------------------------------------- /sound/Bundled/hit2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/sound/Bundled/hit2.wav -------------------------------------------------------------------------------- /sound/README.md: -------------------------------------------------------------------------------- 1 | - Keyboard `Space`: load/play bundled sound 2 | - Keyboard `A`: toggle play/pause positional speaker 3 | 4 | - https://github.com/armory3d/armory/wiki/sound 5 | - https://api.armory3d.org/iron/object/SpeakerObject.html 6 | - https://api.armory3d.org/kha/Sound.html 7 | -------------------------------------------------------------------------------- /sound/Sources/arm/SoundControl.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.object.SpeakerObject; 4 | import iron.system.Input; 5 | 6 | class SoundControl extends iron.Trait { 7 | 8 | public function new() { 9 | super(); 10 | notifyOnInit(() -> { 11 | final mouse = Input.getMouse(); 12 | final keyboard = Input.getKeyboard(); 13 | final speaker = iron.Scene.active.getSpeaker('Speaker'); 14 | trace(speaker.data); 15 | notifyOnUpdate( () -> { 16 | if(keyboard.started('a')) { 17 | trace('Toggle speaker (${!speaker.paused})'); 18 | speaker.paused ? speaker.play() : speaker.pause(); 19 | } 20 | if(keyboard.started('space')) { 21 | // Randomly play one of the three hit sounds 22 | final sound = 'hit${Std.random(3)}.wav'; 23 | trace('Play $sound'); 24 | iron.data.Data.getSound(sound, (s:kha.Sound) -> { 25 | var channel = iron.system.Audio.play(s); 26 | channel.volume = 0.4; 27 | }); 28 | } 29 | }); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sound/drums.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/sound/drums.wav -------------------------------------------------------------------------------- /sound/sound.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/sound/sound.blend -------------------------------------------------------------------------------- /spawn_from_scene/README.md: -------------------------------------------------------------------------------- 1 | Spawns an object from another scene. 2 | 3 | https://api.armory3d.org/iron/Scene.html#spawnObject 4 | -------------------------------------------------------------------------------- /spawn_from_scene/Sources/arm/MyTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.Scene; 4 | import iron.object.Object; 5 | import iron.data.Data; 6 | import iron.data.SceneFormat; 7 | 8 | class MyTrait extends iron.Trait { 9 | public function new() { 10 | super(); 11 | notifyOnInit(init); 12 | } 13 | 14 | function init() { 15 | Data.getSceneRaw("Scene.001", function (raw:TSceneFormat) { 16 | var obj = Scene.getRawObjectByName(raw, "Suzanne"); 17 | Scene.active.createObject(obj, raw, null, null, function(o:Object) { 18 | trace("Suzanne spawned!"); 19 | }); 20 | }); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spawn_from_scene/spawn_from_scene.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/spawn_from_scene/spawn_from_scene.blend -------------------------------------------------------------------------------- /text_area_string/text_area_string.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/text_area_string/text_area_string.blend -------------------------------------------------------------------------------- /tilesheet/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/armory/wiki/Tilesheets 2 | -------------------------------------------------------------------------------- /tilesheet/Sources/arm/AnimControl.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class AnimControl extends iron.Trait { 4 | 5 | var tilesheet:iron.object.Tilesheet; 6 | 7 | public function new() { 8 | super(); 9 | 10 | notifyOnInit(function() { 11 | tilesheet = cast(object, iron.object.MeshObject).tilesheet; 12 | iron.system.Tween.timer(Std.random(8), playAnim); 13 | }); 14 | } 15 | 16 | function playAnim() { 17 | tilesheet.play("rest", function() { 18 | tilesheet.play("idle"); 19 | iron.system.Tween.timer(Std.random(8), playAnim); 20 | }); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tilesheet/textures/dungeon tileset calciumtrice simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet/textures/dungeon tileset calciumtrice simple.png -------------------------------------------------------------------------------- /tilesheet/textures/minotaur spritesheet calciumtrice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet/textures/minotaur spritesheet calciumtrice.png -------------------------------------------------------------------------------- /tilesheet/textures/orc spritesheet calciumtrice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet/textures/orc spritesheet calciumtrice.png -------------------------------------------------------------------------------- /tilesheet/textures/ranger spritesheet calciumtrice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet/textures/ranger spritesheet calciumtrice.png -------------------------------------------------------------------------------- /tilesheet/textures/rogue spritesheet calciumtrice_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet/textures/rogue spritesheet calciumtrice_0.png -------------------------------------------------------------------------------- /tilesheet/textures/warrior spritesheet calciumtrice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet/textures/warrior spritesheet calciumtrice.png -------------------------------------------------------------------------------- /tilesheet/textures/wizard spritesheet calciumtrice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet/textures/wizard spritesheet calciumtrice.png -------------------------------------------------------------------------------- /tilesheet/tilesheet.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet/tilesheet.blend -------------------------------------------------------------------------------- /tilesheet_2d/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/armory/wiki/Tilesheets 2 | -------------------------------------------------------------------------------- /tilesheet_2d/Sources/arm/AnimControl.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class AnimControl extends iron.Trait { 4 | 5 | var tilesheet:iron.object.Tilesheet; 6 | 7 | public function new() { 8 | super(); 9 | 10 | notifyOnInit(function() { 11 | tilesheet = cast(object, iron.object.MeshObject).tilesheet; 12 | iron.system.Tween.timer(Std.random(8), playAnim); 13 | }); 14 | } 15 | 16 | function playAnim() { 17 | tilesheet.play("rest", function() { 18 | tilesheet.play("idle"); 19 | iron.system.Tween.timer(Std.random(8), playAnim); 20 | }); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tilesheet_2d/textures/dungeon tileset calciumtrice simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet_2d/textures/dungeon tileset calciumtrice simple.png -------------------------------------------------------------------------------- /tilesheet_2d/textures/minotaur spritesheet calciumtrice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet_2d/textures/minotaur spritesheet calciumtrice.png -------------------------------------------------------------------------------- /tilesheet_2d/textures/orc spritesheet calciumtrice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet_2d/textures/orc spritesheet calciumtrice.png -------------------------------------------------------------------------------- /tilesheet_2d/textures/ranger spritesheet calciumtrice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet_2d/textures/ranger spritesheet calciumtrice.png -------------------------------------------------------------------------------- /tilesheet_2d/textures/rogue spritesheet calciumtrice_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet_2d/textures/rogue spritesheet calciumtrice_0.png -------------------------------------------------------------------------------- /tilesheet_2d/textures/warrior spritesheet calciumtrice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet_2d/textures/warrior spritesheet calciumtrice.png -------------------------------------------------------------------------------- /tilesheet_2d/textures/wizard spritesheet calciumtrice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet_2d/textures/wizard spritesheet calciumtrice.png -------------------------------------------------------------------------------- /tilesheet_2d/tilesheet_2d.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet_2d/tilesheet_2d.blend -------------------------------------------------------------------------------- /tilesheet_walkcycle/README.md: -------------------------------------------------------------------------------- 1 | The level is built using [SpryTile blender add-on](https://chemikhazi.itch.io/sprytile). 2 | https://github.com/armory3d/armory/wiki/Tilesheets 3 | -------------------------------------------------------------------------------- /tilesheet_walkcycle/Sources/arm/AnimControl.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class AnimControl extends iron.Trait { 4 | 5 | var tilesheet:iron.object.Tilesheet; 6 | 7 | public function new() { 8 | super(); 9 | 10 | notifyOnInit(function() { 11 | tilesheet = cast(object, iron.object.MeshObject).tilesheet; 12 | iron.system.Tween.timer(Std.random(8), playAnim); 13 | }); 14 | } 15 | 16 | function playAnim() { 17 | tilesheet.play("rest", function() { 18 | tilesheet.play("idle"); 19 | iron.system.Tween.timer(Std.random(8), playAnim); 20 | }); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tilesheet_walkcycle/sprite_tux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet_walkcycle/sprite_tux.png -------------------------------------------------------------------------------- /tilesheet_walkcycle/tilesheet_walkcycle.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tilesheet_walkcycle/tilesheet_walkcycle.blend -------------------------------------------------------------------------------- /tween/Sources/arm/MyTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.system.Tween; 4 | import iron.math.Vec4; 5 | import iron.math.Quat; 6 | 7 | class MyTrait extends iron.Trait { 8 | 9 | public function new() { 10 | super(); 11 | 12 | notifyOnInit(function() { 13 | scaleUp(); 14 | }); 15 | } 16 | 17 | var q = new Quat(); 18 | 19 | function scaleUp() { 20 | // Begin tween 21 | iron.system.Tween.to({ 22 | target: object.transform, 23 | props: { // Target values to tween 24 | loc: new Vec4(0, 0, 1), 25 | scale: new Vec4(1.5, 1.5, 1.5), 26 | rot: q.fromEuler(0, 0, Math.PI / 2), // Radians 27 | }, 28 | duration: 1.0, 29 | // Optional 30 | delay: 0, // Wait before tweening starts 31 | tick: function() { trace("Scaling up"); }, // Tweening in progress 32 | done: scaleDown, // Tweening finished 33 | ease: Ease.ExpoOut 34 | }); 35 | 36 | // Single vector component 37 | // iron.system.Tween.to({ 38 | // target: object.transform.loc, 39 | // props: { z: 1.0 }, 40 | // duration: 1.0, 41 | // done: scaleDown, 42 | // // Make sure transform matrix gets updated 43 | // tick: function() { object.transform.dirty = true; } 44 | // }); 45 | } 46 | 47 | function scaleDown() { 48 | iron.system.Tween.to({ 49 | target: object.transform, 50 | props: { 51 | loc: new Vec4(0, 0, 0), 52 | scale: new Vec4(1, 1, 1), 53 | rot: q.fromEuler(0, 0, 0) 54 | }, 55 | duration: 1.0, 56 | delay: 0, 57 | tick: function() { trace("Scaling down"); }, 58 | done: scaleUp, 59 | ease: Ease.Linear 60 | }); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /tween/tween.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/tween/tween.blend -------------------------------------------------------------------------------- /ui_canvas/Assets/crate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/ui_canvas/Assets/crate.png -------------------------------------------------------------------------------- /ui_canvas/Assets/license.txt: -------------------------------------------------------------------------------- 1 | Crate by Cpt_flash - CC0 2 | https://opengameart.org/content/2d-wooden-box -------------------------------------------------------------------------------- /ui_canvas/Bundled/canvas/MyCanvas.files: -------------------------------------------------------------------------------- 1 | ../../Assets/crate.png 2 | -------------------------------------------------------------------------------- /ui_canvas/Bundled/canvas/MyCanvas.json: -------------------------------------------------------------------------------- 1 | {"name":"untitled","x":0,"y":0,"width":960,"height":540,"elements":[{"id":0,"type":0,"name":"MyText","event":"","x":0,"y":0,"width":364,"height":48,"text":"Text","asset":"crate.png","color":-1,"anchor":3,"children":[],"visible":true,"rotation":0,"color_text":-1},{"id":1,"type":1,"name":"MyImage","event":"","x":352,"y":120,"width":256,"height":256,"text":"Image","asset":"crate.png","color":-1,"anchor":0,"children":[],"visible":true,"rotation":0,"color_text":-1,"color_hover":-1},{"id":2,"type":2,"name":"MyButton","event":"buttonEvent","x":5,"y":60,"width":150,"height":34,"text":"0","asset":"crate.png","color":-1,"anchor":0,"children":[],"visible":true,"rotation":0,"color_text":-13290187,"color_hover":-5066062,"color_press":-10921639},{"id":3,"type":9,"name":"Shape","event":"","x":742,"y":66,"width":190,"height":145,"rotation":0,"text":"My Shape","asset":"","color":16777215,"anchor":0,"parent":null,"children":[7,8,10],"visible":true},{"id":4,"type":2,"name":"MenuButton","event":"toggleMenu","x":779,"y":7,"width":150,"height":44,"rotation":0,"text":"Menu","asset":"","color":-1,"anchor":0,"parent":null,"children":[],"visible":true,"color_text":-12763843,"color_hover":-5066062,"color_press":-8421505},{"id":7,"type":8,"name":"Combo","event":"","x":0,"y":4,"width":190,"height":44,"rotation":0,"text":"Combo 1;Combo 2","asset":"","color":-1,"anchor":0,"parent":3,"children":[],"visible":true,"color_text":-1,"color_hover":-5066062},{"id":8,"type":7,"name":"Radio","event":"","x":0,"y":49,"width":190,"height":44,"rotation":0,"text":"Radio 1;Radio 2","asset":"","color":-1,"anchor":0,"parent":3,"children":[],"visible":true,"color_text":-1,"color_hover":-5066062},{"id":9,"type":6,"name":"Check","event":"","x":5,"y":112,"width":150,"height":44,"rotation":0,"text":"Rotate","asset":"","color":-1,"anchor":0,"parent":null,"children":[],"visible":true,"color_text":-1,"color_hover":-5066062},{"id":10,"type":9,"name":"Slider","event":"","x":2,"y":98,"width":187,"height":48,"rotation":0,"text":"My Slider","asset":"","color":-1,"color_text":-8226182,"color_hover":-1,"color_press":-15000805,"anchor":0,"parent":3,"children":[],"visible":true}],"assets":[{"name":"crate.png","file":"../../Assets/crate.png","id":0}]} -------------------------------------------------------------------------------- /ui_canvas/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/armory/wiki/ui_editor 2 | -------------------------------------------------------------------------------- /ui_canvas/Sources/arm/CanvasTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.Scene; 4 | import iron.App; 5 | import iron.system.Time; 6 | import armory.system.Event; 7 | import armory.trait.internal.CanvasScript; 8 | 9 | class CanvasTrait extends iron.Trait { 10 | 11 | var canvas:CanvasScript; 12 | var clicks = 0; 13 | 14 | public function new() { 15 | super(); 16 | 17 | notifyOnInit(function() { 18 | // Get canvas attached to scene 19 | canvas = Scene.active.getTrait(CanvasScript); 20 | 21 | // Notify on button click 22 | Event.add("buttonEvent", onEvent); 23 | Event.add("toggleMenu", onToggleMenu); 24 | 25 | canvas.notifyOnReady(function() { 26 | notifyOnUpdate(update); 27 | }); 28 | }); 29 | } 30 | 31 | function onEvent() { 32 | // Set butotn text 33 | canvas.getElement("MyButton").text = Std.string(++clicks); 34 | } 35 | 36 | function onToggleMenu() { 37 | var shape = canvas.getElement("Shape"); 38 | shape.visible = !shape.visible; 39 | } 40 | 41 | function update() { 42 | // Canvas may be still being loaded 43 | if (!canvas.ready) return; 44 | 45 | // Set text 46 | canvas.getElement("MyText").text = "Hello world"; 47 | 48 | // Move image 49 | var img = canvas.getElement("MyImage"); 50 | var center = App.w() / 2 - img.width / 2; 51 | img.x = center + Math.sin(Time.time()) * 100; 52 | img.rotation = canvas.getHandle("Check").selected ? Math.PI / 4 : 0; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ui_canvas/ui_canvas.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/ui_canvas/ui_canvas.blend -------------------------------------------------------------------------------- /ui_events/Bundled/canvas/MyCanvas.files: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/ui_events/Bundled/canvas/MyCanvas.files -------------------------------------------------------------------------------- /ui_events/Bundled/canvas/MyCanvas.json: -------------------------------------------------------------------------------- 1 | {"name":"untitled","x":0,"y":0,"width":960,"height":540,"elements":[{"id":1,"type":2,"name":"Button","event":"move_box","x":20,"y":20,"width":201,"height":57,"text":"Move Box","asset":"","color":-1,"anchor":0,"children":[],"visible":true,"rotation":0}],"assets":[],"theme":"Default Light"} -------------------------------------------------------------------------------- /ui_events/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/armory/wiki/ui_editor 2 | -------------------------------------------------------------------------------- /ui_events/Sources/arm/MyTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | class MyTrait extends iron.Trait { 4 | public function new() { 5 | super(); 6 | armory.system.Event.add("move_box", onEvent); 7 | } 8 | 9 | function onEvent() { 10 | trace("move_box"); 11 | var loc = object.transform.loc; 12 | loc.y += 1; 13 | if (loc.y > 4) loc.y -= 8; 14 | object.transform.buildMatrix(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ui_events/ui_events.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/ui_events/ui_events.blend -------------------------------------------------------------------------------- /ui_script2d/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/zui 2 | -------------------------------------------------------------------------------- /ui_script2d/Sources/arm/UITrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.object.Object; 4 | import zui.*; 5 | 6 | class UITrait extends iron.Trait { 7 | 8 | var ui:Zui; 9 | var cube:Object; 10 | var plane:Object; 11 | var move = true; 12 | 13 | public function new() { 14 | super(); 15 | 16 | // Load font for UI labels 17 | iron.data.Data.getFont("font_default.ttf", function(f:kha.Font) { 18 | ui = new Zui({font: f}); 19 | iron.Scene.active.notifyOnInit(sceneInit); 20 | }); 21 | } 22 | 23 | function sceneInit() { 24 | // Store references to cube and plane objects 25 | cube = iron.Scene.active.getChild("Cube"); 26 | plane = iron.Scene.active.getChild("Plane"); 27 | notifyOnRender2D(render2D); 28 | notifyOnUpdate(update); 29 | } 30 | 31 | function render2D(g:kha.graphics2.Graphics) { 32 | g.end(); 33 | 34 | // Start with UI 35 | ui.begin(g); 36 | // Make window 37 | if (ui.window(Id.handle(), 20, 20, 230, 600, true)) { 38 | // Make panel in this window 39 | if (ui.panel(Id.handle({selected: true}), "Menu")) { 40 | ui.indent(); 41 | 42 | // Scale sliders 43 | ui.text("Scale"); 44 | var sx = ui.slider(Id.handle({value: 1.0}), "X", 0, 2, true); 45 | var sy = ui.slider(Id.handle({value: 1.0}), "Y", 0, 2, true); 46 | var sz = ui.slider(Id.handle({value: 1.0}), "Z", 0, 2, true); 47 | 48 | // Rotation sliders 49 | ui.text("Rotation"); 50 | var rx = ui.slider(Id.handle(), "X", 0, 3.14); 51 | var ry = ui.slider(Id.handle(), "Y", 0, 3.14); 52 | var rz = ui.slider(Id.handle(), "Z", 0, 3.14); 53 | 54 | // Move checkbox 55 | move = ui.check(Id.handle({selected: move}), "Move"); 56 | 57 | // Toggle buttons 58 | if (ui.button("Toggle Cube")) { 59 | cube.visible = !cube.visible; 60 | } 61 | 62 | ui.row([1/2, 1/2]); 63 | if (ui.button("Toggle Plane")) { 64 | plane.visible = !plane.visible; 65 | } 66 | if (ui.button("Rotate Plane")) { 67 | plane.transform.rotate(iron.math.Vec4.zAxis(), Math.random() * 3.14); 68 | } 69 | 70 | ui.unindent(); 71 | 72 | // Set cube transform using values set in UI 73 | cube.transform.setRotation(rx, ry, rz); 74 | cube.transform.scale.set(sx, sy, sz); 75 | } 76 | } 77 | ui.end(); 78 | 79 | g.begin(false); 80 | } 81 | 82 | function update() { 83 | // Translate cube location over time 84 | if (move) { 85 | cube.transform.loc.x = Math.sin(iron.system.Time.time() * 2); 86 | cube.transform.dirty = true; 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /ui_script2d/ui_script2d.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/ui_script2d/ui_script2d.blend -------------------------------------------------------------------------------- /ui_script3d/Assets/dummy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/ui_script3d/Assets/dummy.jpg -------------------------------------------------------------------------------- /ui_script3d/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/zui 2 | -------------------------------------------------------------------------------- /ui_script3d/Sources/arm/UITrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.object.Object; 4 | import iron.system.Input; 5 | import zui.*; 6 | 7 | class UITrait extends iron.Trait { 8 | 9 | var ui:Zui; 10 | var rt:kha.Image; // Render target for UI 11 | var uiWidth = 512; 12 | var uiHeight = 512; 13 | var gate:Object; 14 | var opened = false; 15 | 16 | public function new() { 17 | super(); 18 | 19 | // Load font for UI labels 20 | iron.data.Data.getFont("font_default.ttf", function(f:kha.Font) { 21 | ui = new Zui({font: f, autoNotifyInput: false}); 22 | iron.Scene.active.notifyOnInit(sceneInit); 23 | }); 24 | } 25 | 26 | function sceneInit() { 27 | // Reference to gate object 28 | gate = iron.Scene.active.getChild('Gate'); 29 | gate.animation.pause(); 30 | 31 | rt = kha.Image.createRenderTarget(uiWidth, uiHeight); 32 | 33 | // We will use empty texture slot in attached material to render UI 34 | var mat:iron.data.MaterialData = cast(object, iron.object.MeshObject).materials[0]; 35 | mat.contexts[0].textures[0] = rt; // Override diffuse texture 36 | 37 | notifyOnRender(render); 38 | notifyOnUpdate(update); 39 | } 40 | 41 | function render(g:kha.graphics4.Graphics) { 42 | // Begin drawing UI 43 | ui.begin(rt.g2); 44 | // Make new window 45 | if (ui.window(Id.handle(), 0, 0, uiWidth, uiHeight, true)) { 46 | // Gate controll buttons 47 | if (ui.button("Open") && !opened) { 48 | // Gate object is animated in Blender 49 | // Play GateOpen animation 50 | gate.animation.play('GateOpen', function() { gate.animation.pause(); }); 51 | opened = true; 52 | } 53 | if (ui.button("Close") && opened) { 54 | // And close.. 55 | gate.animation.play('GateClose', function() { gate.animation.pause(); }); 56 | opened = false; 57 | } 58 | } 59 | ui.end(); 60 | } 61 | 62 | function update() { 63 | // Get plane UV 64 | var mouse = Input.getMouse(); 65 | var uv = iron.math.RayCaster.boxIntersect(cast object.transform, mouse.x, mouse.y, iron.Scene.active.camera); 66 | if (uv == null) return; 67 | 68 | // Pixel coords 69 | var d1 = object.transform.dim; 70 | var px = Std.int(((uv.x-(-d1.x/2)) / ((d1.x/2)-(-d1.x/2)) - object.transform.worldx()) * uiWidth); 71 | var py = Std.int(((uv.z-(d1.z/2)) / ((d1.z/2)-(-d1.z/2)) - object.transform.worldz()) * -uiHeight) ; 72 | 73 | 74 | // Send input events 75 | if (mouse.started()) ui.onMouseDown(0, px, py); 76 | else if (mouse.released()) ui.onMouseUp(0, px, py); 77 | if (mouse.movementX != 0 || mouse.movementY != 0) ui.onMouseMove(px, py, 0, 0); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /ui_script3d/checker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/ui_script3d/checker.png -------------------------------------------------------------------------------- /ui_script3d/checker_rough.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/ui_script3d/checker_rough.png -------------------------------------------------------------------------------- /ui_script3d/ui_script3d.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/ui_script3d/ui_script3d.blend -------------------------------------------------------------------------------- /wasm_call/Bundled/main.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/wasm_call/Bundled/main.wasm -------------------------------------------------------------------------------- /wasm_call/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/armory/wiki/wasm 2 | -------------------------------------------------------------------------------- /wasm_call/Sources/arm/MyTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import iron.data.Data; 4 | import iron.data.Wasm; 5 | 6 | class MyTrait extends iron.Trait { 7 | 8 | public function new() { 9 | super(); 10 | notifyOnInit(init); 11 | } 12 | 13 | function init() { 14 | // Load wasm blob 15 | Data.getBlob("main.wasm", blob -> { 16 | // Create wasm module 17 | var wasm = Wasm.instance(blob); 18 | var rot = 0.0; 19 | notifyOnUpdate(function() { 20 | // Call function from wasm module 21 | rot += wasm.exports.test(); 22 | object.transform.setRotation(0, 0, rot); 23 | }); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /wasm_call/main.c: -------------------------------------------------------------------------------- 1 | #define WASM_EXPORT __attribute__((visibility("default"))) 2 | 3 | WASM_EXPORT 4 | float test() { 5 | return 0.01f; 6 | } 7 | -------------------------------------------------------------------------------- /wasm_call/wasm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/wasm_call/wasm.png -------------------------------------------------------------------------------- /wasm_call/wasm_call.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/wasm_call/wasm_call.blend -------------------------------------------------------------------------------- /wasm_trait_c/Bundled/main.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/wasm_trait_c/Bundled/main.wasm -------------------------------------------------------------------------------- /wasm_trait_c/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/armory/wiki/wasm -------------------------------------------------------------------------------- /wasm_trait_c/main.c: -------------------------------------------------------------------------------- 1 | #define WASM_EXPORT __attribute__((visibility("default"))) 2 | 3 | void notify_on_update(void* f); 4 | int get_object(const char* name); 5 | void set_transform(int object, float x, float y, float z, float rx, float ry, float rz, float sx, float sy, float sz); 6 | 7 | WASM_EXPORT void update() { 8 | static float rot = 0.0f; 9 | rot += 0.01f; 10 | set_transform(get_object("Cube"), 0, 0, 0, 0, 0, rot, 1, 1, 1); 11 | } 12 | 13 | // Include main function, Armory calls it when trait is instantiated 14 | WASM_EXPORT int main() { 15 | notify_on_update(update); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /wasm_trait_c/wasm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/wasm_trait_c/wasm.png -------------------------------------------------------------------------------- /wasm_trait_c/wasm_trait_c.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/wasm_trait_c/wasm_trait_c.blend -------------------------------------------------------------------------------- /wasm_trait_rust/Bundled/main.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/wasm_trait_rust/Bundled/main.wasm -------------------------------------------------------------------------------- /wasm_trait_rust/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/armory3d/armory/wiki/wasm 2 | -------------------------------------------------------------------------------- /wasm_trait_rust/main.rs: -------------------------------------------------------------------------------- 1 | extern { 2 | fn notify_on_update(f: extern fn() -> ()) -> (); 3 | fn get_object(name: *const i8) -> i32; 4 | fn set_transform(object: i32, x: f32, y: f32, z: f32, rx: f32, ry: f32, rz: f32, sx: f32, sy: f32, sz: f32) -> (); 5 | } 6 | 7 | #[no_mangle] 8 | pub extern "C" fn update() -> () { 9 | unsafe { 10 | let name = std::ffi::CString::new("Cube").unwrap(); 11 | let object = get_object(name.as_ptr()); 12 | static mut rot: f32 = 0.1; 13 | rot += 0.01; 14 | set_transform(object, 0.0, 0.0, 0.0, 0.0, 0.0, rot, 1.0, 1.0, 1.0); 15 | } 16 | } 17 | 18 | #[no_mangle] 19 | pub extern "C" fn main() -> i32 { 20 | unsafe { 21 | notify_on_update(update); 22 | } 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /wasm_trait_rust/wasm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/wasm_trait_rust/wasm.png -------------------------------------------------------------------------------- /wasm_trait_rust/wasm_trait_rust.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/wasm_trait_rust/wasm_trait_rust.blend -------------------------------------------------------------------------------- /world_sun_direction/README.md: -------------------------------------------------------------------------------- 1 | Sky Texture synchronized with light direction. 2 | 3 | ### Keyboard 4 | 5 | - `1` HosekWilkie 6 | - `2` Nishita 7 | -------------------------------------------------------------------------------- /world_sun_direction/Sources/arm/MyTrait.hx: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | import armory.renderpath.HosekWilkie; 4 | import armory.renderpath.Nishita; 5 | import iron.Scene; 6 | import iron.math.Vec4; 7 | import iron.system.Input; 8 | 9 | class MyTrait extends iron.Trait { 10 | public function new() { 11 | super(); 12 | notifyOnInit(function() { 13 | 14 | var world = Scene.active.world; 15 | var center = Scene.active.getEmpty('Center'); 16 | var light = Scene.active.lights[0]; 17 | var keyboard = Input.getKeyboard(); 18 | var model = 'hosekwilkie'; 19 | notifyOnUpdate(function() { 20 | 21 | if (keyboard.started("1")) Scene.setActive('Scene_'+(model = 'hosekwilkie')); 22 | if (keyboard.started("2")) Scene.setActive('Scene_'+(model = 'nishita')); 23 | 24 | center.transform.rotate(Vec4.xAxis(),0.02); 25 | 26 | // Sync sun direction 27 | var v = light.look(); 28 | world.raw.sun_direction[0] = v.x; 29 | world.raw.sun_direction[1] = v.y; 30 | world.raw.sun_direction[2] = v.z; 31 | 32 | switch model { 33 | case 'hosekwilkie': HosekWilkie.recompute(world); 34 | case 'nishita': Nishita.recompute(world); 35 | } 36 | 37 | // Set world strength 38 | // world.getGlobalProbe().raw.strength = 1.0; 39 | }); 40 | }); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /world_sun_direction/world_sun_direction.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armory_examples/4c03d7335d7fe64f54d3ad3ab687638354c46e88/world_sun_direction/world_sun_direction.blend --------------------------------------------------------------------------------