Skip to content

Commit

Permalink
Merge pull request #29 from tong/improve-projects
Browse files Browse the repository at this point in the history
Misc improvements
  • Loading branch information
luboslenco authored Aug 16, 2021
2 parents dcc2bc2 + 2e2bb1c commit cfd15c4
Show file tree
Hide file tree
Showing 31 changed files with 45 additions and 29 deletions.
Binary file modified call_hx/call_hx.blend
Binary file not shown.
6 changes: 5 additions & 1 deletion call_js/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
Check console.
Shows how to call js after clicking on a `Cube` object.

- Requires html5 target and physics enabled.
- Check devtools for output.

https://github.com/armory3d/armory/wiki/js
9 changes: 6 additions & 3 deletions call_js/Sources/arm/CallJS.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package arm;

import iron.system.Input;
import armory.trait.physics.PhysicsWorld;
import iron.system.Input;

// This example shows how to call JavaScript after clicking on a Cube object
// Requires physics enabled and browser target
Expand All @@ -22,8 +22,11 @@ class CallJS extends iron.Trait {
// Check if picked object is our Cube
if (rb != null && rb.object.name == 'Cube') {
// Raw JS calls
js.Syntax.code('document.title = "Cube clicked!"');
js.Syntax.code('console.log("Testing..");');
js.Syntax.code('console.log("Cube clicked");');
js.Syntax.code('document.title = "Cube clicked";');
js.Syntax.code('window.alert("Cube clicked");');
} else {
js.Syntax.code('console.log("click");');
}
});
}
Expand Down
Binary file modified call_js/call_js.blend
Binary file not shown.
2 changes: 1 addition & 1 deletion game_bowling/Bundled/canvas/MenuCanvas.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"untitled","x":0,"y":0,"width":960,"height":540,"elements":[{"id":1,"type":1,"name":"Image","event":"","x":0,"y":0,"width":1280,"height":720,"text":"Image","asset":"menu.jpg","color":-1,"anchor":0,"children":[]},{"id":0,"type":1,"name":"Image","event":"play","x":404,"y":197,"width":160,"height":160,"text":"Image","asset":"ui_play.png","color":-1,"anchor":4,"children":[]}],"assets":[{"name":"ui_play.png","file":"../../Assets/ui_play.png","id":0},{"name":"menu.jpg","file":"../../Assets/menu.jpg","id":1}]}
{"name":"untitled","x":0,"y":0,"width":960,"height":540,"elements":[{"id":3,"type":1,"name":"Button","event":"play","x":400,"y":260,"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},{"id":4,"type":1,"name":"Image","event":"","x":0,"y":0,"width":960,"height":540,"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}],"assets":[{"name":"ui_play.png","file":"../../Assets/ui_play.png","id":0},{"name":"menu.jpg","file":"../../Assets/menu.jpg","id":1}],"theme":"Default Light"}
Binary file modified game_bowling/game_bowling.blend
Binary file not shown.
3 changes: 2 additions & 1 deletion input_mouselock/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Click to lock mouse, press ESC to unlock mouse.
Keyboard `Escape` to toggle mouse lock.

https://armory3d.org/api/iron/system/Mouse.html
Binary file modified input_mouselock/input_mouselock.blend
Binary file not shown.
Binary file modified instancing/instancing.blend
Binary file not shown.
Binary file modified logic_break/logic_break.blend
Binary file not shown.
Binary file modified logic_event_object/logic_event_object.blend
Binary file not shown.
Binary file removed logic_hello_world/logic_hello_world.blend
Binary file not shown.
Binary file modified logic_script/logic_script.blend
Binary file not shown.
Binary file added logic_toy_car/logic_toy_car.blend
Binary file not shown.
Binary file modified material_billboard/material_billboard.blend
Binary file not shown.
Binary file modified material_decal/material_decal.blend
Binary file not shown.
7 changes: 7 additions & 0 deletions material_params/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
Shows how to control material nodes at run-time.

- Enable 'Parameter' property in 'Logic Node Editor - Properties - Armory Material Node'
- RGB, Value and Image Texture nodes are supported
- See 'MyTrait' script to set material parameters using Haxe
- See 'NodeTree' to set material parameters using logic nodes

https://github.com/armory3d/armory/wiki/materials#material-parameters
17 changes: 6 additions & 11 deletions material_params/Sources/arm/MyTrait.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package arm;
import iron.math.Vec4;
import iron.object.Object;
import iron.object.Uniforms;
import iron.data.Data;
import iron.data.MaterialData;
import iron.system.Time;

Expand All @@ -13,23 +14,17 @@ class MyTrait extends iron.Trait {

public function new() {
super();

notifyOnInit(function() {
notifyOnInit(() -> {
// Register link callbacks
Uniforms.externalVec3Links.push(vec3Link);
Uniforms.externalFloatLinks.push(floatLink);
Uniforms.externalTextureLinks.push(textureLink);
});

iron.data.Data.getImage("tex1.png", function(image:kha.Image) {
tex1 = image;
});
iron.data.Data.getImage("tex2.png", function(image:kha.Image) {
tex2 = image;
});
Data.getImage("tex1.png", img -> tex1 = img );
Data.getImage("tex2.png", img -> tex2 = img );
}

function vec3Link(object:Object, mat:MaterialData, link:String):iron.math.Vec4 {
function vec3Link(object:Object, mat:MaterialData, link:String):Vec4 {
// object - currently bound object
// mat - currently bound material
// link - material node name
Expand All @@ -43,7 +38,7 @@ class MyTrait extends iron.Trait {
function floatLink(object:Object, mat:MaterialData, link:String):Null<kha.FastFloat> {
if (link == "Value") {
var t = Time.time();
return Math.sin(t) * 0.5 + 0.5;
return Math.floor(t);
}
return null;
}
Expand Down
Binary file modified material_params/material_params.blend
Binary file not shown.
10 changes: 5 additions & 5 deletions material_video/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Note: Krom is not yet supported, please use HTML5 or native targets for now.
ffmpeg is required to process video files.
- Krom is not yet supported, please use HTML5 or native targets for now.
- ffmpeg is required to process video files.

1. Install ffmpeg binaries from https://ffmpeg.org
2. Point 'Edit - Preferences... - Add-ons - Armory - Advanced - FFMPEG Path' to ffmpeg binary
3. Play!
1. Install [ffmpeg](https://ffmpeg.org)
2. Point `Edit - Preferences - Add-ons - Armory - Advanced - FFMPEG Path` to ffmpeg binary
3. Play
4. During the first build, video processing may take some time
Binary file modified material_video/material_video.blend
Binary file not shown.
3 changes: 2 additions & 1 deletion mesh_terrain/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
To generate terrain:

- Place your heightmap as `Bundled/heightmap_01.png`
- Navigate to `Properties - Scene - Armory Terrain`
- Set terrain dimensions using `Sector Size`
- Set terrain height using `Height Scale`
- Click `Generate`
- Adjust terrain material

Check terrain template: <https://github.com/tong/armory_templates/tree/master/third_person_terrain>
See <https://github.com/tong/armory_templates/tree/master/third_person_terrain>
3 changes: 3 additions & 0 deletions physics_raycast/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
- Keyboard `L/R` Rotate cone
- Mouse `L` Raycast in cone direction

https://github.com/armory3d/armory/wiki/physics#raycast
11 changes: 6 additions & 5 deletions physics_raycast/Sources/arm/RayCastTrait.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ class RayCastTrait extends iron.Trait {
public function new() {
super();

var mouse = iron.system.Input.getMouse();
var keyboard = iron.system.Input.getKeyboard();

notifyOnUpdate(function() {
var mouse = iron.system.Input.getMouse();
var keyboard = iron.system.Input.getKeyboard();

if (mouse.down()) {
var physics = PhysicsWorld.active;
Expand All @@ -30,9 +31,9 @@ class RayCastTrait extends iron.Trait {

var hit = physics.rayCast(from, to);
var rb = (hit != null) ? hit.rb : null;
if (rb != null) {
trace(rb.object.name);
}
var info = '';
if( rb != null ) info += ' ${rb.object.name}';
trace(info);
}

if (keyboard.down("left")) {
Expand Down
Binary file modified physics_raycast/physics_raycast.blend
Binary file not shown.
3 changes: 2 additions & 1 deletion render_to_texture/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Press keyboard r, t, f, g, v, b to rotate suzanne
#### Keyboard
`R T F G V B` to rotate suzanne
Binary file modified render_to_texture/render_to_texture.blend
Binary file not shown.
Binary file modified render_voxelao_teapots/render_voxelao_teapots.blend
Binary file not shown.
Binary file added sound/ambient.wav
Binary file not shown.
Binary file modified sound/sound.blend
Binary file not shown.
Binary file modified world_sun_direction/world_sun_direction.blend
Binary file not shown.

0 comments on commit cfd15c4

Please sign in to comment.