diff --git a/Content/Common/Data/Images/Emoji/LICENSE.txt b/Content/Common/Data/Images/Emoji/LICENSE.txt new file mode 100644 index 0000000..d545811 --- /dev/null +++ b/Content/Common/Data/Images/Emoji/LICENSE.txt @@ -0,0 +1,3 @@ +Emoji images are under the Apache license, version 2.0. + +https://github.com/googlefonts/noto-emoji \ No newline at end of file diff --git a/Content/Common/Data/Images/Emoji/emoji_u1f431.png b/Content/Common/Data/Images/Emoji/emoji_u1f431.png new file mode 100644 index 0000000..4cc0b80 Binary files /dev/null and b/Content/Common/Data/Images/Emoji/emoji_u1f431.png differ diff --git a/Content/Common/Data/Images/Emoji/emoji_u1f436.png b/Content/Common/Data/Images/Emoji/emoji_u1f436.png new file mode 100644 index 0000000..287b540 Binary files /dev/null and b/Content/Common/Data/Images/Emoji/emoji_u1f436.png differ diff --git a/Content/Common/Data/Images/LICENSE b/Content/Common/Data/Images/LICENSE deleted file mode 100644 index 427dc77..0000000 --- a/Content/Common/Data/Images/LICENSE +++ /dev/null @@ -1 +0,0 @@ -https://github.com/googlefonts/noto-emoji/tree/main/png/512/emoji_u1f446.png image is under the Apache license, version 2.0. diff --git a/Content/Common/Data/Images/TouchCursor512.png b/Content/Common/Data/Images/TouchCursor512.png new file mode 100644 index 0000000..0f3b780 Binary files /dev/null and b/Content/Common/Data/Images/TouchCursor512.png differ diff --git a/Content/Common/Data/Images/emoji_u1f446.png b/Content/Common/Data/Images/emoji_u1f446.png deleted file mode 100644 index e6ef11e..0000000 Binary files a/Content/Common/Data/Images/emoji_u1f446.png and /dev/null differ diff --git a/Content/Common/Data/Materials/Emoji/emoji_u1f431.material b/Content/Common/Data/Materials/Emoji/emoji_u1f431.material new file mode 100644 index 0000000..cbffc44 --- /dev/null +++ b/Content/Common/Data/Materials/Emoji/emoji_u1f431.material @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Content/Common/Data/Materials/Emoji/emoji_u1f436.material b/Content/Common/Data/Materials/Emoji/emoji_u1f436.material new file mode 100644 index 0000000..a1f94af --- /dev/null +++ b/Content/Common/Data/Materials/Emoji/emoji_u1f436.material @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Content/Common/Data/Materials/White.material b/Content/Common/Data/Materials/White.material new file mode 100644 index 0000000..b66b4a7 --- /dev/null +++ b/Content/Common/Data/Materials/White.material @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Content/Common/Data/Models/Link.mdl b/Content/Common/Data/Models/Link.mdl new file mode 100644 index 0000000..56cd618 Binary files /dev/null and b/Content/Common/Data/Models/Link.mdl differ diff --git a/Content/Common/Data/Objects/Link.prefab b/Content/Common/Data/Objects/Link.prefab new file mode 100644 index 0000000..40ed6f6 --- /dev/null +++ b/Content/Common/Data/Objects/Link.prefab @@ -0,0 +1,144 @@ +{ + "components": [ + { + "_typeName": "Octree" + } + ], + "nodes": [ + { + "components": [ + { + "_typeName": "AnimatedModel", + "attributes": [ + { + "name": "Model", + "type": "ResourceRef", + "value": "Model;Models/Link.mdl" + }, + { + "name": "Material", + "type": "ResourceRefList", + "value": "Material;Materials/White.material" + }, + { + "name": "Bone Animation Enabled", + "type": "VariantVector", + "value": [ + { + "type": "Bool", + "value": true + }, + { + "type": "Bool", + "value": true + }, + { + "type": "Bool", + "value": true + } + ] + } + ] + } + ], + "nodes": [ + { + "attributes": [ + { + "name": "Name", + "type": "String", + "value": "Root" + } + ], + "nodes": [ + { + "attributes": [ + { + "name": "Name", + "type": "String", + "value": "A" + } + ] + }, + { + "attributes": [ + { + "name": "Name", + "type": "String", + "value": "B" + } + ] + } + ] + } + ] + }, + { + "attributes": [ + { + "name": "Name", + "type": "String", + "value": "Default Skybox" + } + ], + "components": [ + { + "_typeName": "Skybox", + "attributes": [ + { + "name": "Model", + "type": "ResourceRef", + "value": "Model;Models/Box.mdl" + }, + { + "name": "Material", + "type": "ResourceRefList", + "value": "Material;Materials/DefaultSkybox.xml" + } + ] + } + ] + }, + { + "attributes": [ + { + "name": "Name", + "type": "String", + "value": "Default Zone" + } + ], + "components": [ + { + "_typeName": "Zone", + "attributes": [ + { + "name": "Bounding Box Min", + "type": "Vector3", + "value": "-1000 -1000 -1000" + }, + { + "name": "Bounding Box Max", + "type": "Vector3", + "value": "1000 1000 1000" + }, + { + "name": "Ambient Color", + "type": "Color", + "value": "0 0 0 1" + }, + { + "name": "Background Brightness", + "type": "Float", + "value": 1.0 + }, + { + "name": "Zone Texture", + "type": "ResourceRef", + "value": "TextureCube;Textures/DefaultSkybox.xml" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Content/Common/Data/Objects/Tile.prefab b/Content/Common/Data/Objects/Tile.prefab new file mode 100644 index 0000000..e33f284 --- /dev/null +++ b/Content/Common/Data/Objects/Tile.prefab @@ -0,0 +1,124 @@ +{ + "components": [ + { + "_typeName": "Octree" + }, + { + "_typeName": "PhysicsWorld" + }, + { + "_typeName": "RenderPipeline" + }, + { + "_typeName": "ReflectionProbeManager" + } + ], + "nodes": [ + { + "attributes": [ + { + "name": "Name", + "type": "String", + "value": "Tile" + } + ], + "components": [ + { + "_typeName": "StaticModel", + "attributes": [ + { + "name": "Model", + "type": "ResourceRef", + "value": "Model;Models/Plane.mdl" + }, + { + "name": "Material", + "type": "ResourceRefList", + "value": "Material;Materials/Emoji/emoji_u1f431.material" + } + ] + }, + { + "_typeName": "CollisionShape", + "attributes": [ + { + "name": "Size", + "type": "Vector3", + "value": "1 0.1 1" + } + ] + }, + { + "_typeName": "RigidBody" + } + ] + }, + { + "attributes": [ + { + "name": "Name", + "type": "String", + "value": "Default Skybox" + } + ], + "components": [ + { + "_typeName": "Skybox", + "attributes": [ + { + "name": "Model", + "type": "ResourceRef", + "value": "Model;Models/Box.mdl" + }, + { + "name": "Material", + "type": "ResourceRefList", + "value": "Material;Materials/DefaultSkybox.xml" + } + ] + } + ] + }, + { + "attributes": [ + { + "name": "Name", + "type": "String", + "value": "Default Zone" + } + ], + "components": [ + { + "_typeName": "Zone", + "attributes": [ + { + "name": "Bounding Box Min", + "type": "Vector3", + "value": "-1000 -1000 -1000" + }, + { + "name": "Bounding Box Max", + "type": "Vector3", + "value": "1000 1000 1000" + }, + { + "name": "Ambient Color", + "type": "Color", + "value": "0 0 0 1" + }, + { + "name": "Background Brightness", + "type": "Float", + "value": 1.0 + }, + { + "name": "Zone Texture", + "type": "ResourceRef", + "value": "TextureCube;Textures/DefaultSkybox.xml" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Content/Common/Data/Scenes/Scene.scene b/Content/Common/Data/Scenes/Scene.scene index c107e89..1c4f362 100644 --- a/Content/Common/Data/Scenes/Scene.scene +++ b/Content/Common/Data/Scenes/Scene.scene @@ -1,8 +1,8 @@ - - + + @@ -14,6 +14,7 @@ + @@ -39,9 +40,8 @@ - + - @@ -64,12 +64,43 @@ + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RbfxTemplate/AcceptPrivacyPolicyState.cs b/RbfxTemplate/AcceptPrivacyPolicyState.cs index fed3efe..308ac1e 100644 --- a/RbfxTemplate/AcceptPrivacyPolicyState.cs +++ b/RbfxTemplate/AcceptPrivacyPolicyState.cs @@ -1,6 +1,4 @@ -using System.Diagnostics; -using System.Runtime.InteropServices; -using Urho3DNet; +using Urho3DNet; namespace RbfxTemplate { diff --git a/RbfxTemplate/GameState.cs b/RbfxTemplate/GameState.cs index ff2ec43..ea6f534 100644 --- a/RbfxTemplate/GameState.cs +++ b/RbfxTemplate/GameState.cs @@ -1,4 +1,6 @@ -using Urho3DNet; +using System.Collections.Generic; +using System.IO; +using Urho3DNet; namespace RbfxTemplate { @@ -11,6 +13,9 @@ public sealed class GameState : RmlUIStateBase private readonly Node _cameraNode; private readonly Viewport _viewport; + private Dictionary _tileMaterials = new Dictionary(); + private readonly Node _link; + public GameState(UrhoPluginApplication app) : base(app, "UI/GameScreen.rml") { MouseMode = MouseMode.MmFree; @@ -27,6 +32,30 @@ public GameState(UrhoPluginApplication app) : base(app, "UI/GameScreen.rml") SetViewport(0, _viewport); _scene.Ptr.IsUpdateEnabled = false; + StringList stringList = new StringList(); + Context.VirtualFileSystem.Scan(stringList, new FileIdentifier("","Materials/Emoji"), "*.material", ScanFlag.ScanFiles); + + foreach (var matName in stringList) + { + _tileMaterials[Path.GetFileNameWithoutExtension(matName)] = + Context.ResourceCache.GetResource("Materials/Emoji/" + matName); + } + + _link = _scene.Ptr.GetChild("Link", true); + + Vector3 pos = Vector3.Zero; + foreach (var tileMaterial in _tileMaterials) + { + var tile = _scene.Ptr.CreateChild(); + var prefabReference = tile.CreateComponent(); + prefabReference.SetPrefab(Context.ResourceCache.GetResource("Objects/Tile.prefab")); + prefabReference.Inline(PrefabInlineFlag.None); + var model = tile.GetComponent(true); + model.SetMaterial(tileMaterial.Value); + tile.Position = pos; + pos += Vector3.Forward; + } + Deactivate(); } @@ -39,11 +68,45 @@ public override void Activate(StringVariantMap bundle) { SubscribeToEvent(E.KeyUp, HandleKeyUp); + SubscribeToEvent(E.MouseButtonDown, HandleMouseDown); + SubscribeToEvent(E.MouseButtonUp, HandleMouseUp); + SubscribeToEvent(E.MouseMove, HandleMouseMove); + _scene.Ptr.IsUpdateEnabled = true; + + base.Activate(bundle); } + private void HandleMouseMove(StringHash arg1, VariantMap arg2) + { + if (!_link.IsEnabled) + return; + + var x = arg2[E.MouseMove.X].Int; + var y = arg2[E.MouseMove.Y].Int; + var ray = _viewport.GetScreenRay(x, y); + var normal = Vector3.Up; + var d = normal.DotProduct(ray.Direction); + float t = -(normal.DotProduct(ray.Origin) + 0.0f) / d; + var a = _link.GetChild("A", true); + var b = _link.GetChild("B", true); + b.Position = ray.Origin + ray.Direction * t; + a.LookAt(b.Position); + b.LookAt(a.Position); + } + + private void HandleMouseUp(StringHash arg1, VariantMap arg2) + { + _link.IsEnabled = false; + } + + private void HandleMouseDown(StringHash arg1, VariantMap arg2) + { + _link.IsEnabled = true; + } + public override void Deactivate() { _scene.Ptr.IsUpdateEnabled = false; diff --git a/RbfxTemplate/Tile.cs b/RbfxTemplate/Tile.cs new file mode 100644 index 0000000..0080c0e --- /dev/null +++ b/RbfxTemplate/Tile.cs @@ -0,0 +1,13 @@ +using Urho3DNet; + +namespace RbfxTemplate +{ + [ObjectFactory] + [Preserve(AllMembers = true)] + public sealed class Tile : Component + { + public Tile(Context context) : base(context) + { + } + } +} \ No newline at end of file