arcanoae 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +12 -0
- data/LICENSE.txt +21 -0
- data/README.md +128 -0
- data/arcanoae.gemspec +31 -0
- data/examples/01_hello_world.rb +47 -0
- data/examples/02_basic_shapes.rb +58 -0
- data/examples/03_materials.rb +69 -0
- data/examples/04_textures.rb +48 -0
- data/examples/05_lighting.rb +66 -0
- data/examples/06_camera_controls.rb +49 -0
- data/examples/07_animation.rb +83 -0
- data/examples/08_particles.rb +86 -0
- data/examples/09_physics.rb +66 -0
- data/examples/10_post_processing.rb +60 -0
- data/examples/11_gui.rb +85 -0
- data/examples/12_load_model.rb +73 -0
- data/examples/13_pbr_demo.rb +98 -0
- data/examples/14_complete_game.rb +159 -0
- data/examples/15_spectral_cornell_box.rb +350 -0
- data/examples/16_ward_brdf_teapot.rb +321 -0
- data/examples/17_terrain_flight.rb +263 -0
- data/examples/18_cellular_automata.rb +417 -0
- data/lib/arcanoae/animation/animatable.rb +108 -0
- data/lib/arcanoae/animation/animation.rb +110 -0
- data/lib/arcanoae/animation/animation_group.rb +159 -0
- data/lib/arcanoae/animation/easing_functions.rb +214 -0
- data/lib/arcanoae/audio/audio_engine.rb +85 -0
- data/lib/arcanoae/audio/sound.rb +135 -0
- data/lib/arcanoae/audio/sound_track.rb +53 -0
- data/lib/arcanoae/backends/glfw_bindings.rb +99 -0
- data/lib/arcanoae/backends/opengl_bindings.rb +240 -0
- data/lib/arcanoae/cameras/arc_rotate_camera.rb +134 -0
- data/lib/arcanoae/cameras/camera.rb +52 -0
- data/lib/arcanoae/cameras/perspective_camera.rb +35 -0
- data/lib/arcanoae/core/disposable.rb +25 -0
- data/lib/arcanoae/core/engine.rb +163 -0
- data/lib/arcanoae/core/logger.rb +51 -0
- data/lib/arcanoae/dsl/scene_builder.rb +238 -0
- data/lib/arcanoae/gui/container.rb +50 -0
- data/lib/arcanoae/gui/control.rb +91 -0
- data/lib/arcanoae/gui/controls.rb +195 -0
- data/lib/arcanoae/input/input_manager.rb +172 -0
- data/lib/arcanoae/lights/directional_light.rb +24 -0
- data/lib/arcanoae/lights/hemispheric_light.rb +26 -0
- data/lib/arcanoae/lights/light.rb +30 -0
- data/lib/arcanoae/lights/point_light.rb +23 -0
- data/lib/arcanoae/lights/shadow_generator.rb +151 -0
- data/lib/arcanoae/loaders/gltf_loader.rb +223 -0
- data/lib/arcanoae/loaders/obj_loader.rb +179 -0
- data/lib/arcanoae/materials/material.rb +67 -0
- data/lib/arcanoae/materials/pbr_material.rb +75 -0
- data/lib/arcanoae/materials/standard_material.rb +38 -0
- data/lib/arcanoae/math/bounding_box.rb +98 -0
- data/lib/arcanoae/math/bounding_sphere.rb +52 -0
- data/lib/arcanoae/math/color3.rb +183 -0
- data/lib/arcanoae/math/color4.rb +143 -0
- data/lib/arcanoae/math/frustum.rb +101 -0
- data/lib/arcanoae/math/matrix4.rb +357 -0
- data/lib/arcanoae/math/plane.rb +51 -0
- data/lib/arcanoae/math/quaternion.rb +247 -0
- data/lib/arcanoae/math/ray.rb +78 -0
- data/lib/arcanoae/math/vector2.rb +159 -0
- data/lib/arcanoae/math/vector3.rb +173 -0
- data/lib/arcanoae/math/vector4.rb +132 -0
- data/lib/arcanoae/math.rb +45 -0
- data/lib/arcanoae/meshes/mesh.rb +101 -0
- data/lib/arcanoae/meshes/mesh_builder.rb +286 -0
- data/lib/arcanoae/meshes/vertex_data.rb +166 -0
- data/lib/arcanoae/physics/physics_engine.rb +145 -0
- data/lib/arcanoae/physics/physics_impostor.rb +84 -0
- data/lib/arcanoae/post_process/effects/fxaa_post_process.rb +112 -0
- data/lib/arcanoae/post_process/post_process.rb +68 -0
- data/lib/arcanoae/post_process/post_process_manager.rb +62 -0
- data/lib/arcanoae/rendering/gpu_buffer.rb +70 -0
- data/lib/arcanoae/rendering/mesh_renderer.rb +144 -0
- data/lib/arcanoae/rendering/render_pipeline.rb +98 -0
- data/lib/arcanoae/rendering/shader_program.rb +114 -0
- data/lib/arcanoae/rendering/shader_store.rb +226 -0
- data/lib/arcanoae/scene/scene.rb +131 -0
- data/lib/arcanoae/scene/transform_node.rb +185 -0
- data/lib/arcanoae/textures/base_texture.rb +48 -0
- data/lib/arcanoae/textures/render_target_texture.rb +73 -0
- data/lib/arcanoae/textures/texture.rb +90 -0
- data/lib/arcanoae/version.rb +5 -0
- data/lib/arcanoae.rb +89 -0
- data/shaders/blur.frag +29 -0
- data/shaders/default.frag +30 -0
- data/shaders/default.vert +23 -0
- data/shaders/fxaa.frag +55 -0
- data/shaders/particles.frag +25 -0
- data/shaders/particles.vert +33 -0
- data/shaders/pbr.frag +176 -0
- data/shaders/pbr.vert +31 -0
- data/shaders/post_process.vert +11 -0
- data/shaders/shadow_map.frag +4 -0
- data/shaders/shadow_map.vert +10 -0
- data/shaders/standard.frag +99 -0
- data/shaders/standard.vert +29 -0
- metadata +184 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 40ce75e91b0d590d01a6943c1ae4a2a45bd464226efb829342f7c629f1457093
|
|
4
|
+
data.tar.gz: 11e2c068f79fab39aefa4afc39dabe8fc9fc9b38702361b399c892596683ca8b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 2e25835485b38ad8aeacb4d27aafe9817975fa880df95fb40dc866183a93ed6969c2b1ce23c7e8d99b34367abc875ea8dea9263a80d2527b28b46c263c08a61f
|
|
7
|
+
data.tar.gz: dce34d4f77614ab207bb6d6009b080f6bf001f920b558f3c39c9a60c87d8f26db304725f42b9a852625c8edfa33699183cc68b8a5bebcb1b79936cacf2eacc45
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## Unreleased
|
|
9
|
+
|
|
10
|
+
## 0.1.0 - 2026-01-01
|
|
11
|
+
|
|
12
|
+
- Initial release
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Yudai Takada
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Arcanoae
|
|
2
|
+
|
|
3
|
+
A 3D graphics library for Ruby with Babylon.js-like API.
|
|
4
|
+
|
|
5
|
+
Arcanoae provides Babylon.js-equivalent functionality using OpenGL backend.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'arcanoae'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
bundle install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or install it yourself as:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
gem install arcanoae
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
require "arcanoae"
|
|
31
|
+
|
|
32
|
+
engine = Arcanoae::Core::Engine.new(
|
|
33
|
+
width: 800,
|
|
34
|
+
height: 600,
|
|
35
|
+
title: "Arcanoae - Hello World"
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
scene = Arcanoae::Scene::Scene.new(engine)
|
|
39
|
+
engine.add_scene(scene)
|
|
40
|
+
|
|
41
|
+
camera = Arcanoae::Cameras::ArcRotateCamera.new(
|
|
42
|
+
"MainCamera",
|
|
43
|
+
Math::PI / 4,
|
|
44
|
+
Math::PI / 3,
|
|
45
|
+
10,
|
|
46
|
+
Arcanoae::Math::Vector3.zero,
|
|
47
|
+
scene
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
light = Arcanoae::Lights::HemisphericLight.new(
|
|
51
|
+
"Light",
|
|
52
|
+
Arcanoae::Math::Vector3.up,
|
|
53
|
+
scene
|
|
54
|
+
)
|
|
55
|
+
light.intensity = 1.0
|
|
56
|
+
|
|
57
|
+
sphere = Arcanoae::Meshes::MeshBuilder.create_sphere("Sphere", { diameter: 2 }, scene)
|
|
58
|
+
sphere.position = Arcanoae::Math::Vector3.new(0, 1, 0)
|
|
59
|
+
|
|
60
|
+
mat = Arcanoae::Materials::StandardMaterial.new("SphereMat", scene)
|
|
61
|
+
mat.diffuse_color = Arcanoae::Math::Color3.new(0.4, 0.4, 1.0)
|
|
62
|
+
sphere.material = mat
|
|
63
|
+
|
|
64
|
+
engine.run_render_loop do
|
|
65
|
+
end
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Features
|
|
69
|
+
|
|
70
|
+
### Core
|
|
71
|
+
- Scene graph with transform nodes
|
|
72
|
+
- Cameras (Perspective, ArcRotate)
|
|
73
|
+
- Lights (Point, Directional, Hemispheric)
|
|
74
|
+
- Shadow mapping
|
|
75
|
+
|
|
76
|
+
### Rendering
|
|
77
|
+
- Materials (Standard, PBR)
|
|
78
|
+
- Mesh primitives (Box, Sphere, Plane, Cylinder, Torus, etc.)
|
|
79
|
+
- Textures (PNG, JPEG)
|
|
80
|
+
- Post-processing effects (FXAA, Blur)
|
|
81
|
+
|
|
82
|
+
### Animation
|
|
83
|
+
- Keyframe animations
|
|
84
|
+
- Animation groups
|
|
85
|
+
- Easing functions (Bounce, Elastic, Cubic, etc.)
|
|
86
|
+
|
|
87
|
+
### Additional
|
|
88
|
+
- Physics engine
|
|
89
|
+
- Particle systems
|
|
90
|
+
- GUI controls
|
|
91
|
+
- Audio system (3D spatial sound)
|
|
92
|
+
- Model loaders (glTF, OBJ)
|
|
93
|
+
- Input management (Keyboard, Mouse, Gamepad)
|
|
94
|
+
|
|
95
|
+
## Examples
|
|
96
|
+
|
|
97
|
+
See the `examples/` directory for usage examples.
|
|
98
|
+
|
|
99
|
+
## Documentation
|
|
100
|
+
|
|
101
|
+
- [Getting Started](docs/getting_started.md)
|
|
102
|
+
- [Tutorial 01: First Scene](docs/tutorials/01_first_scene.md)
|
|
103
|
+
- [Tutorial 02: Materials](docs/tutorials/02_materials.md)
|
|
104
|
+
- [Tutorial 03: Animation](docs/tutorials/03_animation.md)
|
|
105
|
+
|
|
106
|
+
Generate API documentation:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
bundle exec rake yard
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Development
|
|
113
|
+
|
|
114
|
+
After checking out the repo:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
bundle install
|
|
118
|
+
bundle exec rspec # Run tests
|
|
119
|
+
bundle exec rake yard # Generate documentation
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Acknowledgments
|
|
123
|
+
|
|
124
|
+
This project is inspired by [Babylon.js](https://www.babylonjs.com/), a powerful, beautiful, simple, and open game and rendering engine. We are grateful to the Babylon.js team for their excellent work and API design.
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
The gem is available as open source under the terms of the [MIT License](LICENSE.txt).
|
data/arcanoae.gemspec
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/arcanoae/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "arcanoae"
|
|
7
|
+
spec.version = Arcanoae::VERSION
|
|
8
|
+
spec.authors = ["Yudai Takada"]
|
|
9
|
+
spec.email = ["t.yudai92@gmail.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "A 3D graphics library for Ruby with Babylon.js-like API"
|
|
12
|
+
spec.description = "Arcanoae is a 3D graphics library for Ruby that provides " \
|
|
13
|
+
"Babylon.js-equivalent functionality using OpenGL/Vulkan backends."
|
|
14
|
+
spec.homepage = "https://github.com/ydah/arcanoae"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
spec.required_ruby_version = ">= 3.0.0"
|
|
17
|
+
|
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
19
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
20
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
|
21
|
+
|
|
22
|
+
spec.files = Dir.glob("{lib,shaders,examples}/**/*", File::FNM_DOTMATCH, base: __dir__).reject { |f| File.directory?(f) } +
|
|
23
|
+
%w[LICENSE.txt README.md CHANGELOG.md arcanoae.gemspec].select { |f| File.exist?(File.join(__dir__, f)) }
|
|
24
|
+
spec.bindir = "exe"
|
|
25
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
26
|
+
spec.require_paths = ["lib"]
|
|
27
|
+
|
|
28
|
+
spec.add_dependency "base64"
|
|
29
|
+
spec.add_dependency "json"
|
|
30
|
+
spec.add_dependency "ffi"
|
|
31
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../lib/arcanoae"
|
|
5
|
+
|
|
6
|
+
engine = Arcanoae::Core::Engine.new(
|
|
7
|
+
width: 800,
|
|
8
|
+
height: 600,
|
|
9
|
+
title: "Arcanoae - Hello World"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
scene = Arcanoae::Scene::Scene.new(engine)
|
|
13
|
+
engine.add_scene(scene)
|
|
14
|
+
|
|
15
|
+
camera = Arcanoae::Cameras::ArcRotateCamera.new(
|
|
16
|
+
"MainCamera",
|
|
17
|
+
::Math::PI / 4,
|
|
18
|
+
::Math::PI / 3,
|
|
19
|
+
10,
|
|
20
|
+
Arcanoae::Math::Vector3.zero,
|
|
21
|
+
scene
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
light = Arcanoae::Lights::HemisphericLight.new(
|
|
25
|
+
"Light",
|
|
26
|
+
Arcanoae::Math::Vector3.up,
|
|
27
|
+
scene
|
|
28
|
+
)
|
|
29
|
+
light.intensity = 1.0
|
|
30
|
+
|
|
31
|
+
sphere = Arcanoae::Meshes::MeshBuilder.create_sphere("Sphere", { diameter: 2 }, scene)
|
|
32
|
+
sphere.position = Arcanoae::Math::Vector3.new(0, 1, 0)
|
|
33
|
+
|
|
34
|
+
mat = Arcanoae::Materials::StandardMaterial.new("SphereMat", scene)
|
|
35
|
+
mat.diffuse_color = Arcanoae::Math::Color3.new(0.4, 0.4, 1.0)
|
|
36
|
+
sphere.material = mat
|
|
37
|
+
|
|
38
|
+
ground = Arcanoae::Meshes::MeshBuilder.create_ground("Ground", { width: 10, height: 10 }, scene)
|
|
39
|
+
ground_mat = Arcanoae::Materials::StandardMaterial.new("GroundMat", scene)
|
|
40
|
+
ground_mat.diffuse_color = Arcanoae::Math::Color3.new(0.5, 0.5, 0.5)
|
|
41
|
+
ground.material = ground_mat
|
|
42
|
+
|
|
43
|
+
puts "Arcanoae - Hello World"
|
|
44
|
+
puts "Press ESC or close window to exit"
|
|
45
|
+
|
|
46
|
+
engine.run_render_loop do
|
|
47
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../lib/arcanoae"
|
|
5
|
+
|
|
6
|
+
engine = Arcanoae::Core::Engine.new(
|
|
7
|
+
width: 1024,
|
|
8
|
+
height: 768,
|
|
9
|
+
title: "Arcanoae - Basic Shapes"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
scene = Arcanoae.scene(engine) do
|
|
13
|
+
camera :arc_rotate, "Camera" do
|
|
14
|
+
alpha ::Math::PI / 4
|
|
15
|
+
beta ::Math::PI / 3
|
|
16
|
+
radius 15
|
|
17
|
+
target 0, 0, 0
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
light :hemispheric, "Light" do
|
|
21
|
+
intensity 0.8
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
mesh :box, "Box" do
|
|
25
|
+
position -4, 1, 0
|
|
26
|
+
material { diffuse_color 1, 0, 0 }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
mesh :sphere, "Sphere", diameter: 2 do
|
|
30
|
+
position -1.5, 1, 0
|
|
31
|
+
material { diffuse_color 0, 1, 0 }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
mesh :cylinder, "Cylinder", diameter: 1, height: 2 do
|
|
35
|
+
position 1.5, 1, 0
|
|
36
|
+
material { diffuse_color 0, 0, 1 }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
mesh :torus, "Torus", diameter: 1.5, thickness: 0.5 do
|
|
40
|
+
position 4, 1, 0
|
|
41
|
+
material { diffuse_color 1, 1, 0 }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
mesh :ground, "Ground", width: 15, height: 15 do
|
|
45
|
+
material { diffuse_color 0.5, 0.5, 0.5 }
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
engine.add_scene(scene)
|
|
50
|
+
|
|
51
|
+
puts "Arcanoae - Basic Shapes"
|
|
52
|
+
puts "Created #{scene.meshes.count} meshes:"
|
|
53
|
+
scene.meshes.each do |mesh|
|
|
54
|
+
puts " - #{mesh.name} at #{mesh.position}"
|
|
55
|
+
end
|
|
56
|
+
puts "Press ESC or close window to exit"
|
|
57
|
+
|
|
58
|
+
engine.run_render_loop
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../lib/arcanoae"
|
|
5
|
+
|
|
6
|
+
engine = Arcanoae::Core::Engine.new(
|
|
7
|
+
width: 1024,
|
|
8
|
+
height: 768,
|
|
9
|
+
title: "Arcanoae - Materials"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
scene = Arcanoae.scene(engine) do
|
|
13
|
+
camera :arc_rotate, "Camera" do
|
|
14
|
+
alpha ::Math::PI / 4
|
|
15
|
+
beta ::Math::PI / 4
|
|
16
|
+
radius 12
|
|
17
|
+
target 0, 0, 0
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
light :hemispheric, "HemiLight" do
|
|
21
|
+
direction 0, 1, 0
|
|
22
|
+
intensity 0.7
|
|
23
|
+
ground_color 0.2, 0.2, 0.3
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
light :point, "PointLight" do
|
|
27
|
+
position 3, 5, 3
|
|
28
|
+
intensity 0.5
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
mesh :sphere, "Matte", diameter: 2 do
|
|
32
|
+
position -3, 1, 0
|
|
33
|
+
material do
|
|
34
|
+
diffuse_color 1, 0.3, 0.3
|
|
35
|
+
specular_power 4
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
mesh :sphere, "Shiny", diameter: 2 do
|
|
40
|
+
position 0, 1, 0
|
|
41
|
+
material do
|
|
42
|
+
diffuse_color 0.3, 1, 0.3
|
|
43
|
+
specular_color 1, 1, 1
|
|
44
|
+
specular_power 128
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
mesh :sphere, "Emissive", diameter: 2 do
|
|
49
|
+
position 3, 1, 0
|
|
50
|
+
material do
|
|
51
|
+
diffuse_color 0.3, 0.3, 1
|
|
52
|
+
emissive_color 0.2, 0.2, 0.5
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
mesh :ground, "Ground", width: 12, height: 12 do
|
|
57
|
+
material { diffuse_color 0.4, 0.4, 0.4 }
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
engine.add_scene(scene)
|
|
62
|
+
|
|
63
|
+
puts "Arcanoae - Material Comparison"
|
|
64
|
+
puts "Left: Matte (low specular power)"
|
|
65
|
+
puts "Center: Shiny (high specular power)"
|
|
66
|
+
puts "Right: Emissive (self-illuminating)"
|
|
67
|
+
puts "Press ESC or close window to exit"
|
|
68
|
+
|
|
69
|
+
engine.run_render_loop
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../lib/arcanoae"
|
|
5
|
+
|
|
6
|
+
engine = Arcanoae::Core::Engine.new(
|
|
7
|
+
width: 1024,
|
|
8
|
+
height: 768,
|
|
9
|
+
title: "Arcanoae - Textures"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
scene = Arcanoae::Scene::Scene.new(engine)
|
|
13
|
+
engine.add_scene(scene)
|
|
14
|
+
|
|
15
|
+
camera = Arcanoae::Cameras::ArcRotateCamera.new(
|
|
16
|
+
"Camera", ::Math::PI / 4, ::Math::PI / 3, 10,
|
|
17
|
+
Arcanoae::Math::Vector3.zero, scene
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
Arcanoae::Lights::HemisphericLight.new("Light", Arcanoae::Math::Vector3.up, scene)
|
|
21
|
+
|
|
22
|
+
box = Arcanoae::Meshes::MeshBuilder.create_box("TexturedBox", { size: 2 }, scene)
|
|
23
|
+
box.position = Arcanoae::Math::Vector3.new(-2, 1, 0)
|
|
24
|
+
|
|
25
|
+
box_mat = Arcanoae::Materials::StandardMaterial.new("BoxMat", scene)
|
|
26
|
+
box_mat.diffuse_color = Arcanoae::Math::Color3.new(1, 1, 1)
|
|
27
|
+
box.material = box_mat
|
|
28
|
+
|
|
29
|
+
sphere = Arcanoae::Meshes::MeshBuilder.create_sphere("TexturedSphere", { diameter: 2 }, scene)
|
|
30
|
+
sphere.position = Arcanoae::Math::Vector3.new(2, 1, 0)
|
|
31
|
+
|
|
32
|
+
sphere_mat = Arcanoae::Materials::StandardMaterial.new("SphereMat", scene)
|
|
33
|
+
sphere_mat.diffuse_color = Arcanoae::Math::Color3.new(0.8, 0.8, 1.0)
|
|
34
|
+
sphere.material = sphere_mat
|
|
35
|
+
|
|
36
|
+
ground = Arcanoae::Meshes::MeshBuilder.create_ground("Ground", { width: 10, height: 10 }, scene)
|
|
37
|
+
ground_mat = Arcanoae::Materials::StandardMaterial.new("GroundMat", scene)
|
|
38
|
+
ground_mat.diffuse_color = Arcanoae::Math::Color3.new(0.4, 0.4, 0.4)
|
|
39
|
+
ground.material = ground_mat
|
|
40
|
+
|
|
41
|
+
puts "Arcanoae - Textures Example"
|
|
42
|
+
puts "Materials with texture support:"
|
|
43
|
+
scene.materials.each do |mat|
|
|
44
|
+
puts " - #{mat.name}: diffuse_color=#{mat.diffuse_color}"
|
|
45
|
+
end
|
|
46
|
+
puts "Press ESC or close window to exit"
|
|
47
|
+
|
|
48
|
+
engine.run_render_loop
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../lib/arcanoae"
|
|
5
|
+
|
|
6
|
+
engine = Arcanoae::Core::Engine.new(
|
|
7
|
+
width: 1024,
|
|
8
|
+
height: 768,
|
|
9
|
+
title: "Arcanoae - Lighting"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
scene = Arcanoae::Scene::Scene.new(engine)
|
|
13
|
+
engine.add_scene(scene)
|
|
14
|
+
|
|
15
|
+
camera = Arcanoae::Cameras::ArcRotateCamera.new(
|
|
16
|
+
"Camera",
|
|
17
|
+
::Math::PI / 4,
|
|
18
|
+
::Math::PI / 3,
|
|
19
|
+
15,
|
|
20
|
+
Arcanoae::Math::Vector3.zero,
|
|
21
|
+
scene
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
hemi = Arcanoae::Lights::HemisphericLight.new(
|
|
25
|
+
"HemiLight",
|
|
26
|
+
Arcanoae::Math::Vector3.up,
|
|
27
|
+
scene
|
|
28
|
+
)
|
|
29
|
+
hemi.intensity = 0.3
|
|
30
|
+
hemi.diffuse = Arcanoae::Math::Color3.new(0.8, 0.8, 1.0)
|
|
31
|
+
hemi.ground_color = Arcanoae::Math::Color3.new(0.2, 0.1, 0.1)
|
|
32
|
+
|
|
33
|
+
point = Arcanoae::Lights::PointLight.new(
|
|
34
|
+
"PointLight",
|
|
35
|
+
Arcanoae::Math::Vector3.new(3, 5, 3),
|
|
36
|
+
scene
|
|
37
|
+
)
|
|
38
|
+
point.intensity = 0.8
|
|
39
|
+
point.diffuse = Arcanoae::Math::Color3.new(1, 0.9, 0.7)
|
|
40
|
+
|
|
41
|
+
directional = Arcanoae::Lights::DirectionalLight.new(
|
|
42
|
+
"DirLight",
|
|
43
|
+
Arcanoae::Math::Vector3.new(-1, -2, -1),
|
|
44
|
+
scene
|
|
45
|
+
)
|
|
46
|
+
directional.intensity = 0.4
|
|
47
|
+
directional.diffuse = Arcanoae::Math::Color3.new(0.7, 0.7, 1)
|
|
48
|
+
|
|
49
|
+
sphere = Arcanoae::Meshes::MeshBuilder.create_sphere("Sphere", { diameter: 2 }, scene)
|
|
50
|
+
sphere.position = Arcanoae::Math::Vector3.new(0, 1, 0)
|
|
51
|
+
|
|
52
|
+
mat = Arcanoae::Materials::StandardMaterial.new("SphereMat", scene)
|
|
53
|
+
mat.diffuse_color = Arcanoae::Math::Color3.new(1, 1, 1)
|
|
54
|
+
sphere.material = mat
|
|
55
|
+
|
|
56
|
+
ground = Arcanoae::Meshes::MeshBuilder.create_ground("Ground", { width: 10, height: 10 }, scene)
|
|
57
|
+
ground_mat = Arcanoae::Materials::StandardMaterial.new("GroundMat", scene)
|
|
58
|
+
ground_mat.diffuse_color = Arcanoae::Math::Color3.new(0.5, 0.5, 0.5)
|
|
59
|
+
ground.material = ground_mat
|
|
60
|
+
|
|
61
|
+
puts "Arcanoae - Lighting Demo"
|
|
62
|
+
puts "Lights in scene: #{scene.lights.count}"
|
|
63
|
+
scene.lights.each { |l| puts " - #{l.class.name.split('::').last}: #{l.name}" }
|
|
64
|
+
puts "Press ESC or close window to exit"
|
|
65
|
+
|
|
66
|
+
engine.run_render_loop
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../lib/arcanoae"
|
|
5
|
+
|
|
6
|
+
engine = Arcanoae::Core::Engine.new(
|
|
7
|
+
width: 1024,
|
|
8
|
+
height: 768,
|
|
9
|
+
title: "Arcanoae - Camera Controls"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
scene = Arcanoae::Scene::Scene.new(engine)
|
|
13
|
+
engine.add_scene(scene)
|
|
14
|
+
|
|
15
|
+
arc_camera = Arcanoae::Cameras::ArcRotateCamera.new(
|
|
16
|
+
"ArcRotate",
|
|
17
|
+
::Math::PI / 4,
|
|
18
|
+
::Math::PI / 3,
|
|
19
|
+
10,
|
|
20
|
+
Arcanoae::Math::Vector3.zero,
|
|
21
|
+
scene
|
|
22
|
+
)
|
|
23
|
+
arc_camera.lower_radius_limit = 5
|
|
24
|
+
arc_camera.upper_radius_limit = 20
|
|
25
|
+
arc_camera.lower_beta_limit = 0.1
|
|
26
|
+
arc_camera.upper_beta_limit = ::Math::PI / 2
|
|
27
|
+
|
|
28
|
+
Arcanoae::Lights::HemisphericLight.new("Light", Arcanoae::Math::Vector3.up, scene)
|
|
29
|
+
|
|
30
|
+
box = Arcanoae::Meshes::MeshBuilder.create_box("Box", { size: 2 }, scene)
|
|
31
|
+
box.position = Arcanoae::Math::Vector3.new(0, 1, 0)
|
|
32
|
+
box_mat = Arcanoae::Materials::StandardMaterial.new("BoxMat", scene)
|
|
33
|
+
box_mat.diffuse_color = Arcanoae::Math::Color3.new(0.4, 0.6, 0.9)
|
|
34
|
+
box.material = box_mat
|
|
35
|
+
|
|
36
|
+
ground = Arcanoae::Meshes::MeshBuilder.create_ground("Ground", { width: 10, height: 10 }, scene)
|
|
37
|
+
ground_mat = Arcanoae::Materials::StandardMaterial.new("GroundMat", scene)
|
|
38
|
+
ground_mat.diffuse_color = Arcanoae::Math::Color3.new(0.5, 0.5, 0.5)
|
|
39
|
+
ground.material = ground_mat
|
|
40
|
+
|
|
41
|
+
puts "Arcanoae - Camera Controls"
|
|
42
|
+
puts "ArcRotateCamera settings:"
|
|
43
|
+
puts " Alpha: #{arc_camera.alpha.round(2)} rad"
|
|
44
|
+
puts " Beta: #{arc_camera.beta.round(2)} rad"
|
|
45
|
+
puts " Radius: #{arc_camera.radius}"
|
|
46
|
+
puts " Radius limits: #{arc_camera.lower_radius_limit} - #{arc_camera.upper_radius_limit}"
|
|
47
|
+
puts "Press ESC or close window to exit"
|
|
48
|
+
|
|
49
|
+
engine.run_render_loop
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../lib/arcanoae"
|
|
5
|
+
|
|
6
|
+
engine = Arcanoae::Core::Engine.new(
|
|
7
|
+
width: 1024,
|
|
8
|
+
height: 768,
|
|
9
|
+
title: "Arcanoae - Animation"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
scene = Arcanoae::Scene::Scene.new(engine)
|
|
13
|
+
engine.add_scene(scene)
|
|
14
|
+
|
|
15
|
+
camera = Arcanoae::Cameras::ArcRotateCamera.new(
|
|
16
|
+
"Camera", ::Math::PI / 4, ::Math::PI / 3, 10,
|
|
17
|
+
Arcanoae::Math::Vector3.zero, scene
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
Arcanoae::Lights::HemisphericLight.new("Light", Arcanoae::Math::Vector3.up, scene)
|
|
21
|
+
|
|
22
|
+
box = Arcanoae::Meshes::MeshBuilder.create_box("Box", { size: 1 }, scene)
|
|
23
|
+
box.position = Arcanoae::Math::Vector3.new(0, 0.5, 0)
|
|
24
|
+
|
|
25
|
+
mat = Arcanoae::Materials::StandardMaterial.new("BoxMat", scene)
|
|
26
|
+
mat.diffuse_color = Arcanoae::Math::Color3.new(0.4, 0.6, 0.8)
|
|
27
|
+
box.material = mat
|
|
28
|
+
|
|
29
|
+
ground = Arcanoae::Meshes::MeshBuilder.create_ground("Ground", { width: 10, height: 10 }, scene)
|
|
30
|
+
ground_mat = Arcanoae::Materials::StandardMaterial.new("GroundMat", scene)
|
|
31
|
+
ground_mat.diffuse_color = Arcanoae::Math::Color3.new(0.5, 0.5, 0.5)
|
|
32
|
+
ground.material = ground_mat
|
|
33
|
+
|
|
34
|
+
position_anim = Arcanoae::Animation::Animation.new(
|
|
35
|
+
"positionY",
|
|
36
|
+
"position.y",
|
|
37
|
+
30,
|
|
38
|
+
Arcanoae::Animation::Animation::ANIMATIONTYPE_FLOAT,
|
|
39
|
+
Arcanoae::Animation::Animation::ANIMATIONLOOPMODE_CYCLE
|
|
40
|
+
)
|
|
41
|
+
position_anim.set_keys([
|
|
42
|
+
{ frame: 0, value: 0.5 },
|
|
43
|
+
{ frame: 30, value: 2.5 },
|
|
44
|
+
{ frame: 60, value: 0.5 }
|
|
45
|
+
])
|
|
46
|
+
|
|
47
|
+
rotation_anim = Arcanoae::Animation::Animation.new(
|
|
48
|
+
"rotationY",
|
|
49
|
+
"rotation.y",
|
|
50
|
+
30,
|
|
51
|
+
Arcanoae::Animation::Animation::ANIMATIONTYPE_FLOAT,
|
|
52
|
+
Arcanoae::Animation::Animation::ANIMATIONLOOPMODE_CYCLE
|
|
53
|
+
)
|
|
54
|
+
rotation_anim.set_keys([
|
|
55
|
+
{ frame: 0, value: 0 },
|
|
56
|
+
{ frame: 60, value: ::Math::PI * 2 }
|
|
57
|
+
])
|
|
58
|
+
|
|
59
|
+
ease = Arcanoae::Animation::EasingFunction::SineEase.new
|
|
60
|
+
ease.easing_mode = Arcanoae::Animation::EasingFunction::EASINGMODE_EASEINOUT
|
|
61
|
+
position_anim.easing_function = ease
|
|
62
|
+
|
|
63
|
+
box.animations = [position_anim, rotation_anim]
|
|
64
|
+
|
|
65
|
+
anim_group = Arcanoae::Animation::AnimationGroup.new("BoxAnimations", scene)
|
|
66
|
+
anim_group.add_targeted_animation(position_anim, box)
|
|
67
|
+
anim_group.add_targeted_animation(rotation_anim, box)
|
|
68
|
+
anim_group.start(loop: true)
|
|
69
|
+
|
|
70
|
+
puts "Arcanoae - Animation Example"
|
|
71
|
+
puts " - Position animation with SineEase"
|
|
72
|
+
puts " - Rotation animation (linear)"
|
|
73
|
+
puts "Animation group: #{anim_group.name}"
|
|
74
|
+
puts "Press ESC or close window to exit"
|
|
75
|
+
|
|
76
|
+
start_time = Time.now
|
|
77
|
+
scene.before_render do
|
|
78
|
+
elapsed = Time.now - start_time
|
|
79
|
+
frame = (elapsed * 30).to_i % 60
|
|
80
|
+
anim_group.update(frame)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
engine.run_render_loop
|