69 Commits

Author SHA1 Message Date
c18309614f Stubbed out files for networking 2020-03-26 14:25:55 -05:00
bb8e210362 Added canvas_size_changed 'event' to Renderer and OpenGLRenderer 2020-03-25 13:27:00 -05:00
15e5d0a5e1 Framebuffer rendering on quad is now working! 😂 2020-03-25 13:06:40 -05:00
87ae77a9cb Updates 2020-03-25 10:11:56 -05:00
d293772690 Initial work on using framebuffer from GBuffer 2020-03-25 09:18:06 -05:00
9a195fbf68 Updated deps 2020-03-24 10:36:29 -05:00
d839811cfd Fixed reloading shader which failed to compile at start up but succeeded at runtime caused crash due to Model expecting access to attribute location of shader inputs 2020-03-24 10:32:32 -05:00
578c00673d Added command to reload shaders at runtime, added support for shared scripts to Manifest, lights are now loadable from MapParser, misc changes. 2020-03-24 09:51:20 -05:00
2ad1385fb4 Fixed NVIDIA renderering errors, use 'flat in/out int integerValue' instead of 'in/out float integerValue' 2020-03-23 18:45:25 -05:00
cb7b3d4883 Added static, maps, and data folders to build files, fixed crash for AssetViewer tool 2020-03-23 17:32:16 -05:00
87fcc3a05c Fixed lighting artifacts caused by untransformed normals, added 'Scene' for holding objects for rendering, added turn table models to menus using a scene, misc other changes. 2020-03-23 11:48:44 -05:00
18a62b81cc Added Texture object for handling creating and caching textures, stubbed ParticleEmitter 2020-03-23 08:05:40 -05:00
45021a92aa Bump version 2020-03-22 18:16:17 -05:00
3d86661921 Added notice on main menu if opengl version < 3.3 2020-03-22 18:13:41 -05:00
f32dbfabeb Set shader lights once per frame instead of per entity 2020-03-22 17:46:50 -05:00
0d1d7ff6bc Fixed modern opengl renderer not renderering model textures, framebuffer can be used without crashing, model uv coordinates are now in buffer, minor rendering optimization 2020-03-22 17:22:10 -05:00
35d6061198 Setup GBuffer for future deferred rendering 2020-03-22 14:56:22 -05:00
fd228aa0c0 Added extras menu, stubbed map editor, made asset viewer and map editor accessible from extras menu 2020-03-22 12:17:28 -05:00
d6802c8756 Enabled wireframes for shader renderer 2020-01-30 22:54:59 -06:00
99ae19c34d Fixed bug that prevented Asset Viewer from using shader, manifests are now sorted by name, fixed sponza test model manifest 2020-01-30 22:31:49 -06:00
1b6019419b Fixed cursor not showing up in Asset Viewer main menu, fixed Camera free move not having :turn_left/right implemented 2020-01-30 19:53:42 -06:00
eb1bfe204b Added Asset Viewer 2020-01-30 15:30:58 -06:00
dbf4edbb93 Collada parser mostly works for single object/material models 2020-01-30 13:36:42 -06:00
b8e53c7a88 Oriented tree properly 2020-01-30 13:35:29 -06:00
8b35bf037e Added evergreen_tree model, added work-in-progress collada parser, renamed ModelLoader to ModelCache 2020-01-30 11:25:31 -06:00
31f0fa141b Restructured Model loading to enable easier implementation of other parsers 2020-01-30 08:50:05 -06:00
4f1b490600 Use persistent hash for config 2020-01-29 18:18:46 -06:00
201ddabbcc Added game version footer on MainMenu 2020-01-28 23:52:55 -06:00
ea68748234 Renamed MapLoader to MapParser, added level select menu 2020-01-28 23:41:44 -06:00
c1b5e72d7d Added a proper cursor, game pause menu now has a transparent background (Game is drawn behind menu) 2020-01-28 23:17:25 -06:00
46cffa293e Added more menus; stub for settings, basic pause menu, fixes for multiple Game inits 2020-01-28 19:59:42 -06:00
c25df59819 Use new @include preprocessor added to CyberarmEngin::Shader 2020-01-28 10:48:47 -06:00
e7b84bd123 Removed redundant glError? from Map class and renamed CommonMethods#glError? to #gl_error?, added debug settings for disabling shaders and whether to exit on opengl error 2020-01-27 22:19:07 -06:00
75f94963b2 DISABLED collision detection and physics 2019-12-09 16:37:50 -06:00
59334132c8 Updated gemfile to require head version of cyberarm_engine 2019-12-09 16:17:05 -06:00
e4333a82b8 Fixed immediate mode lighting, improved-ish modern gl lighting 2019-12-09 11:48:54 -06:00
ff1d34deec Initital shader lighting support 2019-12-08 20:05:48 -06:00
af19166af2 Modern 'GL now renders properly, camera works as expected, added fallback to immediate mode if shader fails to compile. 2019-12-08 17:50:20 -06:00
e076ce8612 Stubbed out VBOs for model 2019-12-05 20:43:54 -06:00
6aeee41a71 Progress towards modern gl made 2019-12-05 17:23:02 -06:00
93a9e2215c Add character model 2019-11-06 08:39:13 -06:00
18595bdf7f Supplanted biped with character 2019-11-05 11:23:14 -06:00
2ae97aa993 Fixed progressbar jumping back due to needing to load additional assets detected in manifests 2019-09-30 09:14:35 -05:00
c1ec292570 Fixed power plant inverted normals, moved purchase terminal origin to back edge of model, fixed door texture 2019-09-28 13:55:45 -05:00
40d1105fb8 Moved collision/physics information into manifest, made real mouse cursor always invisible and use 'virtual' cursor when needed. 2019-09-28 13:29:21 -05:00
e038dcbe24 Extracted Crosshair and Demo from Game 2019-09-27 22:46:32 -05:00
4af7f21a51 Make PhysicsManager use Map#gravity, defined EARTH and MOON gravity's 2019-09-27 14:41:50 -05:00
f3d3ceebb8 Fixed crash when jumping 2019-09-27 14:33:35 -05:00
b091a489af Removed entity management from Game, refactored Map to MapLoader and added Map to manage world 2019-09-27 14:30:23 -05:00
1bfc6e6929 Initial work on Scripting sandbox, no longer Entity's responsibility. 2019-09-27 12:37:16 -05:00
0b40e042bf Make wavefront material parser use relative path for textures 2019-09-27 10:08:57 -05:00
819b3989de Update assets readme 2019-09-26 16:33:36 -05:00
b559c7c383 Add assets readme 2019-09-26 16:32:23 -05:00
8df05eda13 Added event handler for :entity_moved, added door script, various tweaks 2019-09-26 16:19:01 -05:00
f7936b38bc Ripped IMICFPS::Wavefront::Model to IMICFPS::Model, more refactoring needed. 2019-09-26 14:29:42 -05:00
f72008369d Updated PowerPlant and Alternate Tank models to be correctly orientated (x side to side, y back to front) 2019-09-26 12:23:02 -05:00
b6d7a6ebdb Implemented event system, Implemented initial bit of scripting system, Stubbed component system. Entities can now use the scripting system to place their 'decorations' 2019-09-26 12:13:08 -05:00
e41a2b6524 Cleanup i-mic-fps.rb a bit 2019-09-26 08:24:32 -05:00
eb7a7fc6d6 Added protype scripts for Alternate Tank and Power Plant, changed naming convention of assets to: package -> name instead of: package -> model 2019-09-25 22:01:03 -05:00
19f5a0cd9c Added Alternate Tank, go back to using glScalef for scaling models until shader based rendering is implemented, improved Map handling of scaling. 2019-09-25 20:59:19 -05:00
ecee086590 Exported door model, added CollisionManager#on_ground?(entity), made gravity work in PhyisicsManager if Entity has physics enabled, updated test map 2019-09-25 18:17:18 -05:00
954c6899be Made model/entity manifest a first class object 2019-09-25 11:52:19 -05:00
f41078b14b Fixed player unable to rotate 2019-09-25 10:57:37 -05:00
a2089c0ae1 Fixed demo feature crashing game 2019-09-25 10:50:50 -05:00
93522703f9 Fixed terrain and skydome not loading in LoadingState 2019-09-25 10:18:16 -05:00
ee844f256f Renamed objects/ to game_objects/ removed redundant entities, added Map loader and test map, made LoadingState use Map for entity asset loading. 2019-09-25 10:09:05 -05:00
42191729ae Added models for: Power Plant, Information Panel, Purchase Terminal, and Door. Updated War Factory model. added .svg files. misc. 2019-09-24 15:34:09 -05:00
06502abe3e Added Rakefile for windows build 2019-08-19 03:02:20 -05:00
9cc97fd6ec Added ocra to gemfile 2019-08-19 03:01:11 -05:00
159 changed files with 11657 additions and 20628 deletions

5
.gitignore vendored
View File

@@ -1,2 +1,5 @@
*.dat
profile.*
profile.*
pkg/*
data/*
!data/.gitkeep

10
Gemfile
View File

@@ -1,3 +1,9 @@
source "https://rubygems.org"
gem "opengl-bindings"
gem "cyberarm_engine"
gem "opengl-bindings", require: "opengl"
gem "cyberarm_engine", git: "https://github.com/cyberarm/cyberarm_engine"
gem "nokogiri", ">= 1.11.0.rc1"
gem "async-websocket"
group(:packaging) do
gem "ocra"
end

View File

@@ -1,19 +1,32 @@
GIT
remote: https://github.com/cyberarm/cyberarm_engine
revision: d8551c7428da98bb7da76c138e5fbde50ef0137f
specs:
cyberarm_engine (0.13.1)
gosu (~> 0.15.0)
GEM
remote: https://rubygems.org/
specs:
cyberarm_engine (0.10.2)
gosu (~> 0.14.0)
gosu (0.14.5)
gosu (0.14.5-x86-mingw32)
gosu (0.15.1)
gosu (0.15.1-x64-mingw32)
mini_portile2 (2.4.0)
nokogiri (1.11.0.rc1)
mini_portile2 (~> 2.4.0)
nokogiri (1.11.0.rc1-x64-mingw32)
mini_portile2 (~> 2.4.0)
ocra (1.3.11)
opengl-bindings (1.6.9)
PLATFORMS
ruby
x86-mingw32
x64-mingw32
DEPENDENCIES
cyberarm_engine
cyberarm_engine!
nokogiri (>= 1.11.0.rc1)
ocra
opengl-bindings
BUNDLED WITH
1.17.3
2.1.4

View File

@@ -10,5 +10,6 @@ Requires a Ruby runtime that supports the gosu and opengl-bindings C-extensions
### Options
* `--native` - Launch in fullscreen using primary displays resolution
* `--profile` - Run ruby-prof profiler
* `--mesa-override` - (Linux) Force MESA to use OpenGL/GLSL version 3.30
* `--savedemo` - Record camera movement and key events to playback later *(alpha-quality feature)*
* `--playdemo` - Plays the previously recorded demo *(alpha-quality feature)*

19
Rakefile Normal file
View File

@@ -0,0 +1,19 @@
require "releasy"
require 'bundler/setup' # Releasy requires that your application uses bundler.
require_relative "lib/version"
Releasy::Project.new do
name "I-MIC FPS"
version "#{IMICFPS::VERSION}"
executable "i-mic-fps.rb"
files ["lib/**/*.*", "assets/**/*.*", "blends/**/*.*", "shaders/**/*.*", "static/**/*.*", "maps/**/*.*", "data/**/*.*"]
exclude_encoding # Applications that don't use advanced encoding (e.g. Japanese characters) can save build size with this.
verbose
add_build :windows_folder do
# icon "assets/icon.ico"
executable_type :console # Assuming you don't want it to run with a console window.
add_package :exe # Windows self-extracting archive.
end
end

35
assets/README.md Normal file
View File

@@ -0,0 +1,35 @@
# IMIC FPS Assets
## Directory Structure
* /__package__
* /__name__
* /model
* model.obj
* /scripts
* script.rb
* /textures
* texture.png
* manifest.yaml
## Manifest File
```yaml
name: "Friendly Name of Object"
model: "model.obj" # path to model relative to package/name/model/
# optional options:
# Type of collision detection to use: null, boundingbox, orientated_bb, mesh
collision: "mesh"
# Path to collision model or null to use `model`
collision_mesh: null
# Array of scripts to load, relative to package/name/scripts/
# Optionally shared scripts can be loaded from package/shared/scripts/ if prefixed with an exclaimation mark "!"
scripts: [
"script",
"!shared_script"
]
# Array of assets to preload that this asset uses/requires
uses: [
-
package: "base"
name: "door"
]
```

View File

@@ -0,0 +1,5 @@
name: "Alternate Tank"
model: "alternate_tank.obj"
scripts: [
"!vehicle"
]

View File

@@ -0,0 +1,42 @@
# Blender MTL File: 'alternate_tank.blend'
# Material Count: 4
newmtl Body
Ns 110.250015
Ka 0.900000 0.900000 0.900000
Kd 0.029064 0.018578 0.011797
Ks 0.883333 0.883333 0.883333
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 3
newmtl Material
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.527719 0.213857 0.101860
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
newmtl Material.001
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.029064 0.018578 0.011797
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
newmtl wheel
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.044455 0.044455 0.044455
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2

File diff suppressed because it is too large Load Diff

View File

@@ -1,2 +1,6 @@
name: "biped"
model: "biped.obj"
model: "biped.obj"
collision: "mesh"
collision_mesh: null
collision_resolution: "dynamic"
physics: true

View File

@@ -0,0 +1,6 @@
name: "character"
model: "character.obj"
collision: "mesh"
collision_mesh: null
collision_resolution: "dynamic"
physics: true

View File

@@ -0,0 +1,13 @@
# Blender MTL File: 'character.blend'
# Material Count: 1
newmtl Material
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
map_Kd /home/cyberarm/Code/i-mic-fps/assets/base/character/textures/Base.png

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

View File

@@ -0,0 +1,7 @@
---
name: "door"
model: "door.obj"
collision: "boundingbox"
scripts: [
"door"
]

View File

@@ -0,0 +1,13 @@
# Blender MTL File: 'door.blend'
# Material Count: 1
newmtl Material
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
map_Kd /home/cyberarm/Code/i-mic-fps/assets/base/door/textures/door.png

View File

@@ -0,0 +1,55 @@
# Blender v2.80 (sub 75) OBJ File: 'door.blend'
# www.blender.org
mtllib door.mtl
o Cube
v 1.250000 2.400000 -0.125000
v 1.250000 0.000000 -0.125000
v 1.250000 2.400000 0.125000
v 1.250000 0.000000 0.125000
v 0.000000 0.000000 -0.125000
v 0.000000 2.400000 0.125000
v 0.000000 0.000000 0.125000
v 0.000000 2.400000 -0.125000
vt 0.923077 0.000000
vt 1.000000 0.500000
vt 0.923077 0.500000
vt 0.923077 0.960000
vt 0.846154 0.000000
vt 0.000000 0.959961
vt 0.384766 -0.000000
vt 0.000000 0.000000
vt 0.384615 0.960000
vt 0.000000 0.000000
vt 0.384615 0.000000
vt 1.000000 1.000000
vt 0.923077 0.500000
vt 1.000000 0.500000
vt 0.769231 0.960000
vt 0.846154 0.000000
vt 0.846154 0.960000
vt 1.000000 0.000000
vt 0.846154 0.960000
vt 0.384766 0.959961
vt 0.000000 0.960000
vt 0.923077 1.000000
vt 0.769231 0.000000
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
usemtl Material
s off
f 2/1/1 7/2/1 5/3/1
f 1/4/2 4/5/2 2/1/2
f 8/6/3 2/7/3 5/8/3
f 3/9/4 7/10/4 4/11/4
f 8/12/5 3/13/5 1/14/5
f 7/15/6 8/16/6 5/17/6
f 2/1/1 4/18/1 7/2/1
f 1/4/2 3/19/2 4/5/2
f 8/6/3 1/20/3 2/7/3
f 3/9/4 6/21/4 7/10/4
f 8/12/5 6/22/5 3/13/5
f 7/15/6 6/23/6 8/16/6

View File

@@ -0,0 +1,9 @@
origin = entity.position
on.entity_moved do |event|
if origin.distance3d(event.entity.position) <= 3.0
entity.position = origin + Vector.up * 2.4
else
entity.position = origin
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@@ -0,0 +1,4 @@
---
name: "evergreen_tree"
model: "evergreen_tree.dae"
collision: "boundingbox"

View File

@@ -0,0 +1,303 @@
<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<asset>
<contributor>
<author>Blender User</author>
<authoring_tool>Blender 2.81.16 commit date:2019-12-04, commit time:11:32, hash:f1aa4d18d49d</authoring_tool>
</contributor>
<created>2020-01-30T13:33:36</created>
<modified>2020-01-30T13:33:36</modified>
<unit name="meter" meter="1"/>
<up_axis>Z_UP</up_axis>
</asset>
<library_effects>
<effect id="Material_002-effect">
<profile_COMMON>
<technique sid="common">
<lambert>
<emission>
<color sid="emission">0 0 0 1</color>
</emission>
<diffuse>
<color sid="diffuse">0 0.4868966 0.07537682 1</color>
</diffuse>
<index_of_refraction>
<float sid="ior">1.45</float>
</index_of_refraction>
</lambert>
</technique>
</profile_COMMON>
</effect>
<effect id="Material_003-effect">
<profile_COMMON>
<technique sid="common">
<lambert>
<emission>
<color sid="emission">0 0 0 1</color>
</emission>
<diffuse>
<color sid="diffuse">0 0.5173332 0.03164556 1</color>
</diffuse>
<index_of_refraction>
<float sid="ior">1.45</float>
</index_of_refraction>
</lambert>
</technique>
</profile_COMMON>
</effect>
<effect id="Material_001-effect">
<profile_COMMON>
<technique sid="common">
<lambert>
<emission>
<color sid="emission">0 0 0 1</color>
</emission>
<diffuse>
<color sid="diffuse">0.3031975 0.1076129 0.05296437 1</color>
</diffuse>
<index_of_refraction>
<float sid="ior">1.45</float>
</index_of_refraction>
</lambert>
</technique>
</profile_COMMON>
</effect>
</library_effects>
<library_images/>
<library_materials>
<material id="Material_002-material" name="Material.002">
<instance_effect url="#Material_002-effect"/>
</material>
<material id="Material_003-material" name="Material.003">
<instance_effect url="#Material_003-effect"/>
</material>
<material id="Material_001-material" name="Material.001">
<instance_effect url="#Material_001-effect"/>
</material>
</library_materials>
<library_geometries>
<geometry id="Plane_002-mesh" name="Plane.002">
<mesh>
<source id="Plane_002-mesh-positions">
<float_array id="Plane_002-mesh-positions-array" count="15">-0.7701593 0 0.7701593 0.7701593 0 0.7701593 -0.7701593 0 -0.7701593 0.7701593 0 -0.7701593 0 0.6063125 0</float_array>
<technique_common>
<accessor source="#Plane_002-mesh-positions-array" count="5" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Plane_002-mesh-normals">
<float_array id="Plane_002-mesh-normals-array" count="15">0 -1 0 0 0.7857296 0.6185703 0.6185703 0.7857295 0 -0.6185703 0.7857295 0 0 0.7857296 -0.6185703</float_array>
<technique_common>
<accessor source="#Plane_002-mesh-normals-array" count="5" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Plane_002-mesh-map-0">
<float_array id="Plane_002-mesh-map-0-array" count="36">0 1 1 0 0 0 0 0 1 0 0 0 1 0 1 1 1 0 0 1 0 0 0 1 1 1 0 1 1 1 0 1 1 1 1 0</float_array>
<technique_common>
<accessor source="#Plane_002-mesh-map-0-array" count="18" stride="2">
<param name="S" type="float"/>
<param name="T" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="Plane_002-mesh-vertices">
<input semantic="POSITION" source="#Plane_002-mesh-positions"/>
</vertices>
<triangles material="Material_002-material" count="6">
<input semantic="VERTEX" source="#Plane_002-mesh-vertices" offset="0"/>
<input semantic="NORMAL" source="#Plane_002-mesh-normals" offset="1"/>
<input semantic="TEXCOORD" source="#Plane_002-mesh-map-0" offset="2" set="0"/>
<p>2 0 0 1 0 1 0 0 2 0 1 3 1 1 4 4 1 5 1 2 6 3 2 7 4 2 8 2 3 9 0 3 10 4 3 11 3 4 12 2 4 13 4 4 14 2 0 15 3 0 16 1 0 17</p>
</triangles>
</mesh>
</geometry>
<geometry id="Plane_001-mesh" name="Plane.001">
<mesh>
<source id="Plane_001-mesh-positions">
<float_array id="Plane_001-mesh-positions-array" count="24">-1 0 1 1 0 1 -1 0 -1 1 0 -1 -0.4597772 0.5360521 0.4597772 0.4597772 0.5360521 0.4597772 -0.4597772 0.5360521 -0.4597772 0.4597772 0.5360521 -0.4597772</float_array>
<technique_common>
<accessor source="#Plane_001-mesh-positions-array" count="8" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Plane_001-mesh-normals">
<float_array id="Plane_001-mesh-normals-array" count="30">0 -1 0 0 1 0 0 0.7098416 0.7043614 0.7043614 0.7098416 0 -0.7043614 0.7098416 0 0 0.7098416 -0.7043614 0 0.7098415 0.7043614 0.7043614 0.7098416 0 -0.7043614 0.7098416 0 0 0.7098415 -0.7043614</float_array>
<technique_common>
<accessor source="#Plane_001-mesh-normals-array" count="10" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Plane_001-mesh-map-0">
<float_array id="Plane_001-mesh-map-0-array" count="72">0 1 1 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 1 1 1 0 1 0 0 0 0 1 0 1 0 1 1 1 1 1 0 1 1 1 1 0 1 0 1 1 0 1 1 0 1 0 0 0 1 1 1 1 1 0 0 0 0 0 0 1 0 1 0 1 1 1</float_array>
<technique_common>
<accessor source="#Plane_001-mesh-map-0-array" count="36" stride="2">
<param name="S" type="float"/>
<param name="T" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="Plane_001-mesh-vertices">
<input semantic="POSITION" source="#Plane_001-mesh-positions"/>
</vertices>
<triangles material="Material_003-material" count="12">
<input semantic="VERTEX" source="#Plane_001-mesh-vertices" offset="0"/>
<input semantic="NORMAL" source="#Plane_001-mesh-normals" offset="1"/>
<input semantic="TEXCOORD" source="#Plane_001-mesh-map-0" offset="2" set="0"/>
<p>2 0 0 1 0 1 0 0 2 5 1 3 6 1 4 4 1 5 1 2 6 4 2 7 0 2 8 3 3 9 5 3 10 1 3 11 0 4 12 6 4 13 2 4 14 2 5 15 7 5 16 3 5 17 2 0 18 3 0 19 1 0 20 5 1 21 7 1 22 6 1 23 1 6 24 5 6 25 4 6 26 3 7 27 7 7 28 5 7 29 0 8 30 4 8 31 6 8 32 2 9 33 6 9 34 7 9 35</p>
</triangles>
</mesh>
</geometry>
<geometry id="Plane-mesh" name="Plane">
<mesh>
<source id="Plane-mesh-positions">
<float_array id="Plane-mesh-positions-array" count="24">-1.366034 0 1.366034 1.366034 0 1.366034 -1.366034 0 -1.366034 1.366034 0 -1.366034 -0.7 0.5 0.7 0.7 0.5 0.7 -0.7 0.5 -0.7 0.7 0.5 -0.7</float_array>
<technique_common>
<accessor source="#Plane-mesh-positions-array" count="8" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Plane-mesh-normals">
<float_array id="Plane-mesh-normals-array" count="30">0 -1 0 0 1 0 0 0.7997263 0.6003649 0.6003648 0.7997263 0 -0.6003648 0.7997263 0 0 0.7997263 -0.6003649 0 0.7997263 0.6003648 0.6003648 0.7997263 0 -0.6003648 0.7997263 0 0 0.7997263 -0.6003648</float_array>
<technique_common>
<accessor source="#Plane-mesh-normals-array" count="10" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Plane-mesh-map-0">
<float_array id="Plane-mesh-map-0-array" count="72">0 1 1 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 1 1 1 0 1 0 0 0 0 1 0 1 0 1 1 1 1 1 0 1 1 1 1 0 1 0 1 1 0 1 1 0 1 0 0 0 1 1 1 1 1 0 0 0 0 0 0 1 0 1 0 1 1 1</float_array>
<technique_common>
<accessor source="#Plane-mesh-map-0-array" count="36" stride="2">
<param name="S" type="float"/>
<param name="T" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="Plane-mesh-vertices">
<input semantic="POSITION" source="#Plane-mesh-positions"/>
</vertices>
<triangles material="Material_002-material" count="12">
<input semantic="VERTEX" source="#Plane-mesh-vertices" offset="0"/>
<input semantic="NORMAL" source="#Plane-mesh-normals" offset="1"/>
<input semantic="TEXCOORD" source="#Plane-mesh-map-0" offset="2" set="0"/>
<p>2 0 0 1 0 1 0 0 2 5 1 3 6 1 4 4 1 5 1 2 6 4 2 7 0 2 8 3 3 9 5 3 10 1 3 11 0 4 12 6 4 13 2 4 14 2 5 15 7 5 16 3 5 17 2 0 18 3 0 19 1 0 20 5 1 21 7 1 22 6 1 23 1 6 24 5 6 25 4 6 26 3 7 27 7 7 28 5 7 29 0 8 30 4 8 31 6 8 32 2 9 33 6 9 34 7 9 35</p>
</triangles>
</mesh>
</geometry>
<geometry id="Circle-mesh" name="Circle">
<mesh>
<source id="Circle-mesh-positions">
<float_array id="Circle-mesh-positions-array" count="75">0 0 -0.5 -0.4755282 0 -0.1545085 -0.2938926 0 0.4045085 0.2938927 0 0.4045085 0.4755282 0 -0.1545085 0 2 -0.4 -0.3804226 2 -0.1236068 -0.235114 2 0.3236068 0.2351141 2 0.3236068 0.3804226 2 -0.1236068 3.64108e-7 4.3 -0.42 -0.3043377 4.3 -0.1988854 -0.1880909 4.3 0.1588854 0.1880916 4.3 0.1588854 0.3043384 4.3 -0.1988855 -8.83978e-7 6 -0.156 -0.2434713 6 0.0208916 -0.1504738 6 0.3071084 0.1504722 6 0.3071084 0.2434695 6 0.02089154 -1.64407e-6 7 -0.02799999 -0.1217368 7 0.06044578 -0.0752381 7 0.2035542 0.07523488 7 0.2035542 0.1217336 7 0.06044578</float_array>
<technique_common>
<accessor source="#Circle-mesh-positions-array" count="25" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Circle-mesh-normals">
<float_array id="Circle-mesh-normals-array" count="129">0 -1 0 0.5877706 -0.007034838 -0.8089972 -0.587305 0.04041773 -0.8083561 0.9502794 0.04041779 0.3087643 -0.9502794 0.04041779 0.3087645 0.5873049 0.04041779 -0.808356 0 0.04041779 0.9991829 0.95104 -0.005896985 0.3090115 0 0.07143497 0.9974453 -0.5877708 -0.007034659 -0.808997 0.9502357 0.04153919 0.3087501 -0.9502357 0.04153949 0.3087502 0.5846588 0.1030038 -0.8047139 -0.9510399 -0.005898416 0.3090118 0.5832006 0.124656 -0.8027067 0 -0.08686035 0.9962205 -0.5832004 0.1246552 -0.8027069 0 1 0 0 0.1030034 0.994681 -0.5846592 0.1030029 -0.8047137 0.9459978 0.1030041 0.3073732 -0.945998 0.1030026 0.3073735 0.5877708 -0.007034838 -0.808997 -0.587305 0.04041779 -0.808356 0.9502794 0.04041779 0.3087643 -0.9502794 0.04041779 0.3087646 0.587305 0.04041779 -0.808356 0 0.04041779 0.9991829 0.9510402 -0.005896985 0.3090113 0 0.07143497 0.9974453 -0.5877707 -0.007034659 -0.808997 0.9502358 0.04153919 0.3087501 -0.9502357 0.04153949 0.3087503 0.5846586 0.1030038 -0.804714 -0.9510401 -0.005898416 0.3090116 0.5832004 0.124656 -0.8027068 0 -0.08686041 0.9962205 -0.5832005 0.1246553 -0.802707 -1.10718e-5 1 0 0 0.1030033 0.994681 -0.5846592 0.1030029 -0.8047137 0.9459979 0.1030041 0.3073732 -0.9459978 0.1030027 0.3073736</float_array>
<technique_common>
<accessor source="#Circle-mesh-normals-array" count="43" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Circle-mesh-map-0">
<float_array id="Circle-mesh-map-0-array" count="276">0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</float_array>
<technique_common>
<accessor source="#Circle-mesh-map-0-array" count="138" stride="2">
<param name="S" type="float"/>
<param name="T" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="Circle-mesh-vertices">
<input semantic="POSITION" source="#Circle-mesh-positions"/>
</vertices>
<triangles material="Material_001-material" count="46">
<input semantic="VERTEX" source="#Circle-mesh-vertices" offset="0"/>
<input semantic="NORMAL" source="#Circle-mesh-normals" offset="1"/>
<input semantic="TEXCOORD" source="#Circle-mesh-map-0" offset="2" set="0"/>
<p>4 0 0 3 0 1 2 0 2 5 1 3 14 1 4 9 1 5 1 2 6 5 2 7 0 2 8 4 3 9 8 3 10 3 3 11 2 4 12 6 4 13 1 4 14 0 5 15 9 5 16 4 5 17 3 6 18 7 6 19 2 6 20 13 7 21 19 7 22 18 7 23 8 8 24 12 8 25 7 8 26 5 9 27 11 9 28 10 9 29 9 10 30 13 10 31 8 10 32 6 11 33 12 11 34 11 11 35 15 12 36 24 12 37 19 12 38 12 13 39 16 13 40 11 13 41 14 14 42 15 14 43 19 14 44 12 15 45 18 15 46 17 15 47 11 16 48 15 16 49 10 16 50 22 17 51 24 17 52 20 17 53 17 18 54 23 18 55 22 18 56 16 19 57 20 19 58 15 19 59 18 20 60 24 20 61 23 20 62 16 21 63 22 21 64 21 21 65 2 0 66 1 0 67 0 0 68 0 0 69 4 0 70 2 0 71 5 22 72 10 22 73 14 22 74 1 23 75 6 23 76 5 23 77 4 24 78 9 24 79 8 24 80 2 25 81 7 25 82 6 25 83 0 26 84 5 26 85 9 26 86 3 27 87 8 27 88 7 27 89 13 28 90 14 28 91 19 28 92 8 29 93 13 29 94 12 29 95 5 30 96 6 30 97 11 30 98 9 31 99 14 31 100 13 31 101 6 32 102 7 32 103 12 32 104 15 33 105 20 33 106 24 33 107 12 34 108 17 34 109 16 34 110 14 35 111 10 35 112 15 35 113 12 36 114 13 36 115 18 36 116 11 37 117 16 37 118 15 37 119 20 38 120 21 38 121 22 38 122 22 17 123 23 17 124 24 17 125 17 39 126 18 39 127 23 39 128 16 40 129 21 40 130 20 40 131 18 41 132 19 41 133 24 41 134 16 42 135 17 42 136 22 42 137</p>
</triangles>
</mesh>
</geometry>
</library_geometries>
<library_visual_scenes>
<visual_scene id="Scene" name="Scene">
<node id="Plane_002" name="Plane.002" type="NODE">
<matrix sid="transform">1.326094 0 -0.4826588 0 0 3.66912 0 5.393049 0.4826588 0 1.326094 0 0 0 0 1</matrix>
<instance_geometry url="#Plane_002-mesh" name="Plane.002">
<bind_material>
<technique_common>
<instance_material symbol="Material_002-material" target="#Material_002-material">
<bind_vertex_input semantic="UVMap" input_semantic="TEXCOORD" input_set="0"/>
</instance_material>
</technique_common>
</bind_material>
</instance_geometry>
</node>
<node id="Plane_001" name="Plane.001" type="NODE">
<matrix sid="transform">1.544178 0 -0.2722803 0 0 4.0768 0 3.677205 0.2722803 0 1.544178 0 0 0 0 1</matrix>
<instance_geometry url="#Plane_001-mesh" name="Plane.001">
<bind_material>
<technique_common>
<instance_material symbol="Material_003-material" target="#Material_003-material">
<bind_vertex_input semantic="UVMap" input_semantic="TEXCOORD" input_set="0"/>
</instance_material>
</technique_common>
</bind_material>
</instance_geometry>
</node>
<node id="Plane" name="Plane" type="NODE">
<matrix sid="transform">1.6 0 0 0 0 4.16 0 2 0 0 1.6 0 0 0 0 1</matrix>
<instance_geometry url="#Plane-mesh" name="Plane">
<bind_material>
<technique_common>
<instance_material symbol="Material_002-material" target="#Material_002-material">
<bind_vertex_input semantic="UVMap" input_semantic="TEXCOORD" input_set="0"/>
</instance_material>
</technique_common>
</bind_material>
</instance_geometry>
</node>
<node id="Circle" name="Circle" type="NODE">
<matrix sid="transform">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix>
<instance_geometry url="#Circle-mesh" name="Circle">
<bind_material>
<technique_common>
<instance_material symbol="Material_001-material" target="#Material_001-material">
<bind_vertex_input semantic="UVMap" input_semantic="TEXCOORD" input_set="0"/>
</instance_material>
</technique_common>
</bind_material>
</instance_geometry>
</node>
</visual_scene>
</library_visual_scenes>
<scene>
<instance_visual_scene url="#Scene"/>
</scene>
</COLLADA>

View File

@@ -0,0 +1,4 @@
name: "information_panel"
model: "information_panel.obj"
collision: "mesh"
collision_mesh: null

View File

@@ -0,0 +1,32 @@
# Blender MTL File: 'information_panel.blend'
# Material Count: 3
newmtl Material
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.310814 0.310814 0.310814
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
newmtl Material.001
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.000000 0.581504 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
newmtl Material.002
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.496923 0.455629 0.203897
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2

View File

@@ -0,0 +1,266 @@
# Blender v2.80 (sub 75) OBJ File: 'information_panel.blend'
# www.blender.org
mtllib information_panel.mtl
o Cube
v 0.892570 1.235657 -0.268793
v 0.900000 1.077635 -0.301229
v 0.900000 1.054090 0.375000
v 0.900000 0.875000 0.375000
v -0.907430 1.235657 -0.268793
v -0.900000 1.077635 -0.301229
v -1.000000 1.125000 0.375000
v -1.000000 0.875000 0.375000
v -0.900000 1.054090 0.375000
v -0.900000 0.875000 0.375000
v 0.970903 1.084925 0.196072
v 1.000000 0.898673 0.200000
v -0.970903 1.084925 0.196072
v -1.000000 0.898673 0.200000
v 1.000000 0.975000 -0.137500
v 0.970903 1.237112 0.019890
v -0.970903 1.237112 0.019890
v -1.000000 0.975000 -0.137500
v 1.000000 1.240505 0.015962
v 1.000000 1.081532 0.200000
v -1.000000 1.240505 0.015962
v -1.000000 1.081532 0.200000
v 0.970903 1.230140 0.013868
v 0.970903 1.077953 0.190049
v -0.970903 1.230140 0.013868
v -0.970903 1.077953 0.190049
vt 0.625000 0.250000
vt 0.375000 0.375000
vt 0.375000 0.250000
vt 0.625000 0.875000
vt 0.500000 1.000000
vt 0.437500 0.875000
vt 0.125000 0.625000
vt 0.375000 0.750000
vt 0.125000 0.750000
vt 0.625000 0.500000
vt 0.875000 0.750000
vt 0.625000 0.750000
vt 0.625000 0.375000
vt 0.625000 0.187500
vt 0.406250 0.812500
vt 0.625000 0.093750
vt 0.125000 0.562500
vt 0.375000 0.625000
vt 0.625000 0.812500
vt 0.377823 0.123666
vt 0.560344 0.123666
vt 0.560344 0.123666
vt 0.375000 0.750000
vt 0.125000 0.500000
vt 0.375000 0.562500
vt 0.625000 0.000000
vt 0.375000 0.125000
vt 0.378087 0.063834
vt 0.593750 0.062500
vt 0.589996 0.063834
vt 0.378087 0.063834
vt 0.377823 0.123666
vt 0.589996 0.063834
vt 0.625000 1.000000
vt 0.875000 0.500000
vt 0.375000 0.500000
vt 0.562500 0.125000
vt 0.375000 0.062500
vt 0.375000 0.250000
vt 0.375000 0.000000
vt 0.500000 0.250000
vn 0.0000 0.0000 1.0000
vn 0.0000 -0.9910 -0.1341
vn 0.8682 0.0000 0.4961
vn 0.0000 0.2011 -0.9796
vn -0.8682 0.0000 0.4961
vn -1.0000 0.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 -0.9754 -0.2206
vn 0.0000 0.6537 -0.7568
vn 0.0000 -0.8473 -0.5311
vn 0.8880 0.2301 -0.3981
vn -0.9507 0.0188 -0.3094
vn 0.0000 0.7568 0.6537
vn 0.0000 -0.6537 0.7568
vn 0.9287 0.1160 -0.3523
vn -0.8880 0.2301 -0.3981
vn 0.0000 0.9879 0.1549
vn 0.0000 0.9999 -0.0170
usemtl Material
s off
f 3/1/1 10/2/1 4/3/1
f 12/4/2 10/5/2 14/6/2
f 12/7/3 3/8/3 4/9/3
f 6/10/4 1/11/4 2/12/4
f 14/6/5 9/13/5 22/14/5
f 18/15/6 22/14/6 21/16/6
f 15/17/7 20/18/7 12/7/7
f 15/19/8 14/6/8 18/15/8
f 11/20/9 26/21/9 13/22/9
f 2/12/10 18/15/10 6/23/10
f 2/24/11 19/25/11 15/17/11
f 6/23/12 21/16/12 5/26/12
f 13/22/13 20/27/13 11/20/13
f 16/28/13 21/29/13 17/30/13
f 11/20/6 23/31/6 24/32/6
f 17/30/14 23/31/14 16/28/14
f 13/22/7 25/33/7 17/30/7
f 3/1/1 9/13/1 10/2/1
f 12/4/2 4/34/2 10/5/2
f 12/7/3 20/18/3 3/8/3
f 6/10/4 5/35/4 1/11/4
f 14/6/5 10/5/5 9/13/5
f 18/15/6 14/6/6 22/14/6
f 15/17/7 19/25/7 20/18/7
f 15/19/8 12/4/8 14/6/8
f 11/20/9 24/32/9 26/21/9
f 2/12/10 15/19/10 18/15/10
f 2/24/15 1/36/15 19/25/15
f 6/23/16 18/15/16 21/16/16
f 13/22/13 22/37/13 20/27/13
f 16/28/13 19/38/13 21/29/13
f 11/20/6 16/28/6 23/31/6
f 17/30/14 25/33/14 23/31/14
f 13/22/7 26/21/7 25/33/7
usemtl Material.001
f 25/33/13 24/32/13 23/31/13
f 25/33/13 26/21/13 24/32/13
usemtl Material.002
f 22/37/17 3/39/17 20/27/17
f 1/40/18 21/29/18 19/38/18
f 16/28/13 20/27/13 19/38/13
f 17/30/13 22/37/13 13/22/13
f 22/37/17 9/41/17 3/39/17
f 1/40/18 5/26/18 21/29/18
f 16/28/13 11/20/13 20/27/13
f 17/30/13 21/29/13 22/37/13
o Cube.001_Cube.002
v -0.030000 0.000000 -0.170000
v -0.030000 1.062657 -0.170000
v -0.030000 0.000000 -0.230000
v -0.030000 1.062657 -0.230000
v 0.030000 0.000000 -0.170000
v 0.030000 1.062657 -0.170000
v 0.030000 0.000000 -0.230000
v 0.030000 1.062657 -0.230000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.375000 0.000000
vt 0.625000 0.250000
vt 0.375000 0.500000
vt 0.625000 0.500000
vt 0.375000 0.750000
vt 0.625000 0.750000
vt 0.375000 1.000000
vt 0.125000 0.750000
vt 0.125000 0.500000
vt 0.875000 0.500000
vt 0.625000 1.000000
vt 0.875000 0.750000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
usemtl Material
s off
f 28/42/19 29/43/19 27/44/19
f 30/45/20 33/46/20 29/43/20
f 34/47/21 31/48/21 33/46/21
f 32/49/22 27/50/22 31/48/22
f 33/46/23 27/51/23 29/52/23
f 30/53/24 32/49/24 34/47/24
f 28/42/19 30/45/19 29/43/19
f 30/45/20 34/47/20 33/46/20
f 34/47/21 32/49/21 31/48/21
f 32/49/22 28/54/22 27/50/22
f 33/46/23 31/48/23 27/51/23
f 30/53/24 28/55/24 32/49/24
o Cube.002
v -0.930000 -0.000000 0.230000
v -0.930000 1.062657 0.230000
v -0.930000 -0.000000 0.170000
v -0.930000 1.062657 0.170000
v -0.870000 -0.000000 0.230000
v -0.870000 1.062657 0.230000
v -0.870000 -0.000000 0.170000
v -0.870000 1.062657 0.170000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.375000 0.000000
vt 0.625000 0.250000
vt 0.375000 0.500000
vt 0.625000 0.500000
vt 0.375000 0.750000
vt 0.625000 0.750000
vt 0.375000 1.000000
vt 0.125000 0.750000
vt 0.125000 0.500000
vt 0.875000 0.500000
vt 0.625000 1.000000
vt 0.875000 0.750000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
usemtl Material
s off
f 36/56/25 37/57/25 35/58/25
f 38/59/26 41/60/26 37/57/26
f 42/61/27 39/62/27 41/60/27
f 40/63/28 35/64/28 39/62/28
f 41/60/29 35/65/29 37/66/29
f 38/67/30 40/63/30 42/61/30
f 36/56/25 38/59/25 37/57/25
f 38/59/26 42/61/26 41/60/26
f 42/61/27 40/63/27 39/62/27
f 40/63/28 36/68/28 35/64/28
f 41/60/29 39/62/29 35/65/29
f 38/67/30 36/69/30 40/63/30
o Cube.003_Cube.002
v 0.870000 -0.000000 0.230000
v 0.870000 1.062657 0.230000
v 0.870000 -0.000000 0.170000
v 0.870000 1.062657 0.170000
v 0.930000 -0.000000 0.230000
v 0.930000 1.062657 0.230000
v 0.930000 -0.000000 0.170000
v 0.930000 1.062657 0.170000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.375000 0.000000
vt 0.625000 0.250000
vt 0.375000 0.500000
vt 0.625000 0.500000
vt 0.375000 0.750000
vt 0.625000 0.750000
vt 0.375000 1.000000
vt 0.125000 0.750000
vt 0.125000 0.500000
vt 0.875000 0.500000
vt 0.625000 1.000000
vt 0.875000 0.750000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
usemtl Material
s off
f 44/70/31 45/71/31 43/72/31
f 46/73/32 49/74/32 45/71/32
f 50/75/33 47/76/33 49/74/33
f 48/77/34 43/78/34 47/76/34
f 49/74/35 43/79/35 45/80/35
f 46/81/36 48/77/36 50/75/36
f 44/70/31 46/73/31 45/71/31
f 46/73/32 50/75/32 49/74/32
f 50/75/33 48/77/33 47/76/33
f 48/77/34 44/82/34 43/78/34
f 49/74/35 47/76/35 43/79/35
f 46/81/36 44/83/36 48/77/36

View File

@@ -0,0 +1,17 @@
name: "power_plant"
model: "power_plant.obj"
collision: "mesh"
collision_mesh: null # Use model mesh for collision detection
scripts: [
"power_plant"
]
uses:
-
package: "base"
name: "purchase_terminal"
-
package: "base"
name: "information_panel"
-
package: "base"
name: "door"

View File

@@ -0,0 +1,42 @@
# Blender MTL File: 'power_plant.blend'
# Material Count: 4
newmtl Material
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.142401 0.072932 0.051375
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
newmtl Material.002
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.057602 0.000000
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
newmtl Material.004
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.350556 0.350556 0.350556
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
newmtl pipes
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.420023 0.371232 0.326654
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.000000
d 1.000000
illum 2

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
component(:building)
on.create do |event|
map.insert_entity("base", "purchase_terminal", event.entity.position + Vector.new(-1.5, 1.5, -4.52), Vector.new(0, 20, 0), data: {team: nil})
map.insert_entity("base", "information_panel", event.entity.position + Vector.new(3, 0, 1), Vector.new(0, -90, 0))
map.insert_entity("base", "door", event.entity.position + Vector.new(0, 0, 6), Vector.new(0, 0, 0))
map.insert_entity("base", "door", event.entity.position + Vector.new(0, 0, 6), Vector.new(0, 180, 0))
end

View File

@@ -0,0 +1,3 @@
name: "purchase_terminal"
model: "purchase_terminal.obj"
collision: "boundingbox"

View File

@@ -0,0 +1,23 @@
# Blender MTL File: 'purchase_terminal.blend'
# Material Count: 2
newmtl Material
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.094626 0.094626 0.094626
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
newmtl Material.001
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
map_Kd /home/cyberarm/Code/i-mic-fps/assets/base/purchase_terminal/textures/purchase_terminal_screen.png

View File

@@ -0,0 +1,108 @@
# Blender v2.80 (sub 75) OBJ File: 'purchase_terminal.blend'
# www.blender.org
mtllib purchase_terminal.mtl
o Cube
v 0.750000 1.000000 0.000000
v 0.750000 0.000000 0.000000
v 0.721107 0.980738 0.250000
v 0.750000 0.000000 0.300000
v 0.721107 0.219262 0.250000
v 0.750000 0.200000 0.000000
v -0.750000 1.000000 0.000000
v -0.750000 0.000000 0.000000
v -0.721107 0.980738 0.250000
v -0.750000 0.000000 0.300000
v 0.000000 0.200000 0.250000
v 0.000000 0.200000 0.000000
v -0.721107 0.219262 0.250000
v -0.750000 0.200000 0.000000
v 0.000000 0.000000 0.000000
v 0.000000 1.000000 0.250000
v 0.000000 0.000000 0.250000
v 0.000000 1.000000 0.000000
v 0.750000 1.000000 0.250000
v 0.750000 0.200000 0.250000
v -0.750000 1.000000 0.250000
v -0.750000 0.200000 0.250000
v 0.721107 0.980738 0.224828
v 0.721107 0.219262 0.224828
v -0.721107 0.980738 0.224828
v -0.721107 0.219262 0.224828
v 0.750000 0.100000 0.300000
v -0.750000 0.100000 0.300000
vt 0.125000 0.500000
vt 0.250000 0.500000
vt 0.125000 0.500000
vt 0.250000 0.750000
vt 0.187500 0.750000
vt 0.125000 0.750000
vt 0.375000 0.500000
vt 0.375000 0.750000
vt 0.375000 0.750000
vt 0.125000 0.750000
vt 0.187500 0.750000
vt 0.250000 0.750000
vt 0.375000 0.500000
vt 0.250000 0.500000
vt 0.253010 0.750000
vt 0.371990 0.750000
vt 0.371990 0.750000
vt 0.253010 0.750000
vt 0.371990 0.750000
vt 0.371990 0.750000
vt 0.253010 0.750000
vt 0.253010 0.750000
vt 1.000000 1.000000
vt -0.000000 0.000000
vt 1.000000 -0.000000
vt -0.000000 1.000000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.4472 0.8944
vn 0.0000 0.0000 1.0000
usemtl Material
s off
f 8/1/1 6/2/1 2/3/1
f 20/4/2 27/5/2 4/6/2
f 4/6/3 8/1/3 2/3/3
f 1/7/2 20/4/2 6/2/2
f 1/7/4 21/8/4 19/9/4
f 10/10/5 28/11/5 22/12/5
f 20/4/6 28/11/6 27/5/6
f 22/12/5 7/13/5 14/14/5
f 13/15/2 25/16/2 9/17/2
f 7/13/1 6/2/1 14/14/1
f 5/18/7 19/9/7 3/19/7
f 3/19/7 21/8/7 9/17/7
f 13/15/7 20/4/7 5/18/7
f 9/17/7 22/12/7 13/15/7
f 9/17/3 23/20/3 3/19/3
f 5/18/4 26/21/4 13/15/4
f 3/19/5 24/22/5 5/18/5
f 27/5/7 10/10/7 4/6/7
f 8/1/1 14/14/1 6/2/1
f 4/6/2 2/3/2 20/4/2
f 2/3/2 6/2/2 20/4/2
f 4/6/3 10/10/3 8/1/3
f 1/7/2 19/9/2 20/4/2
f 1/7/4 7/13/4 21/8/4
f 14/14/5 8/1/5 22/12/5
f 8/1/5 10/10/5 22/12/5
f 20/4/6 22/12/6 28/11/6
f 22/12/5 21/8/5 7/13/5
f 13/15/2 26/21/2 25/16/2
f 7/13/1 1/7/1 6/2/1
f 5/18/7 20/4/7 19/9/7
f 3/19/7 19/9/7 21/8/7
f 13/15/7 22/12/7 20/4/7
f 9/17/7 21/8/7 22/12/7
f 9/17/3 25/16/3 23/20/3
f 5/18/4 24/22/4 26/21/4
f 3/19/5 23/20/5 24/22/5
f 27/5/7 28/11/7 10/10/7
usemtl Material.001
f 23/23/7 26/24/7 24/25/7
f 23/23/7 25/26/7 26/24/7

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -1,3 +1,3 @@
---
name: "randomish_terrain"
model: "randomish_terrain.obj"
model: "randomish_terrain.obj"
collision: "mesh"

View File

@@ -1,3 +1,3 @@
---
name: "river_terrain"
model: "river_terrain.obj"
collision: "mesh"

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -0,0 +1,10 @@
component(:vehicle) # Generic, Weapon
on.button_down(:interact) do |event|
$window.console.stdin("#{event.entity.name} handled button_down(:interact)")
# if event.player.touching?(event.entity)
# event.player.enter_vehicle
# elsif event.player.driving?(event.entity) or event.player.passenger?(event.entity)
# event.player.exit_vehicle
# end
end

View File

@@ -1,2 +1,3 @@
name: "skydome"
model: "skydome.obj"
model: "skydome.obj"
collision: null

View File

@@ -0,0 +1,2 @@
name: sponza_demo
model: sponza.obj

View File

@@ -1,2 +1,5 @@
name: "war_factory"
model: "war_factory.obj"
model: "war_factory.obj"
scripts: [
"war_factory"
]

View File

@@ -1,42 +1,32 @@
# Blender MTL File: 'war_factory.blend'
# Material Count: 4
# Material Count: 3
newmtl Material
Ns 96.078431
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.527055 0.242208
Kd 0.800000 0.658819 0.302760
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl door
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.000000 0.006044 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ke 0.0 0.0 0.0
Ni 1.000000
d 1.000000
illum 2
newmtl garage
Ns 96.078431
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.358382 0.358382 0.358382
Kd 0.447978 0.447978 0.447978
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ke 0.0 0.0 0.0
Ni 1.000000
d 1.000000
illum 2
newmtl pipes
Ns 96.078431
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.336018 0.296986 0.261323
Kd 0.420023 0.371232 0.326654
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ke 0.0 0.0 0.0
Ni 1.000000
d 1.000000
illum 2

View File

@@ -1,4 +1,4 @@
# Blender v2.79 (sub 6) OBJ File: 'war_factory.blend'
# Blender v2.80 (sub 75) OBJ File: 'war_factory.blend'
# www.blender.org
mtllib war_factory.mtl
o smoke_stacks_Cube.001
@@ -263,86 +263,86 @@ f 65//15 66//15 18//15
f 18//16 66//16 67//16
f 67//17 68//17 20//17
o outlets_pipes_Cube.002
v 3.358796 7.940995 0.866388
v 3.887199 7.940995 0.350280
v 3.895892 7.940995 -0.388300
v 3.358797 7.940995 0.866388
v 3.887200 7.940995 0.350280
v 3.895893 7.940995 -0.388300
v 3.379785 7.940995 -0.916703
v 2.641204 7.940995 -0.925396
v 2.112801 7.940995 -0.409289
v 2.104108 7.940995 0.329292
v 2.620216 7.940995 0.857695
v 5.358797 7.940995 0.866388
v 5.887199 7.940995 0.350280
v 5.895893 7.940995 -0.388300
v 5.887200 7.940995 0.350280
v 5.895893 7.940995 -0.388301
v 5.379785 7.940995 -0.916704
v 4.641204 7.940995 -0.925396
v 4.641205 7.940995 -0.925396
v 4.112801 7.940995 -0.409289
v 4.104108 7.940995 0.329292
v 4.620215 7.940995 0.857695
v 3.358796 15.179012 0.866388
v 3.887199 15.179012 0.350280
v 3.895892 15.179010 -0.388300
v 4.620216 7.940995 0.857695
v 3.358797 15.179012 0.866388
v 3.887200 15.179012 0.350280
v 3.895893 15.179010 -0.388300
v 3.379785 15.179012 -0.916703
v 2.641204 15.179010 -0.925396
v 2.112801 15.179012 -0.409289
v 2.104108 15.179010 0.329292
v 2.620216 15.179012 0.857695
v 5.358797 15.179012 0.866388
v 5.887199 15.179012 0.350280
v 5.895893 15.179010 -0.388300
v 5.887200 15.179012 0.350280
v 5.895893 15.179010 -0.388301
v 5.379785 15.179012 -0.916704
v 4.641204 15.179010 -0.925396
v 4.641205 15.179010 -0.925396
v 4.112801 15.179012 -0.409289
v 4.104108 15.179010 0.329292
v 4.620215 15.179012 0.857695
v 4.620216 15.179012 0.857695
v 3.394676 15.179012 0.955977
v 3.975919 15.179012 0.388259
v 3.985482 15.179010 -0.424180
v 3.417763 15.179012 -1.005423
v 2.605324 15.179010 -1.014985
v 2.605325 15.179010 -1.014985
v 2.024081 15.179012 -0.447267
v 2.014518 15.179010 0.365172
v 2.014519 15.179010 0.365172
v 2.582237 15.179012 0.946415
v 5.394676 15.179012 0.955977
v 5.975919 15.179012 0.388258
v 5.985482 15.179010 -0.424180
v 5.417763 15.179012 -1.005423
v 4.605325 15.179010 -1.014985
v 4.024081 15.179012 -0.447267
v 5.394677 15.179012 0.955977
v 5.975920 15.179012 0.388259
v 5.985483 15.179010 -0.424180
v 5.417764 15.179012 -1.005424
v 4.605325 15.179010 -1.014986
v 4.024081 15.179012 -0.447268
v 4.014519 15.179010 0.365172
v 4.582237 15.179012 0.946415
v 4.582238 15.179012 0.946415
v 3.394676 15.379012 0.955977
v 3.975919 15.379012 0.388259
v 3.985482 15.379010 -0.424180
v 3.417763 15.379012 -1.005423
v 2.605324 15.379010 -1.014985
v 2.605325 15.379010 -1.014985
v 2.024081 15.379012 -0.447267
v 2.014518 15.379010 0.365172
v 2.014519 15.379010 0.365172
v 2.582237 15.379012 0.946415
v 5.394676 15.379012 0.955977
v 5.975919 15.379012 0.388258
v 5.985482 15.379010 -0.424180
v 5.417763 15.379012 -1.005423
v 4.605325 15.379010 -1.014985
v 4.024081 15.379012 -0.447267
v 5.394677 15.379012 0.955977
v 5.975920 15.379012 0.388259
v 5.985483 15.379010 -0.424180
v 5.417764 15.379012 -1.005424
v 4.605325 15.379010 -1.014986
v 4.024081 15.379012 -0.447268
v 4.014519 15.379010 0.365172
v 4.582237 15.379012 0.946415
v 4.582238 15.379012 0.946415
v 3.355209 15.379012 0.857429
v 3.878327 15.379012 0.346483
v 3.878328 15.379012 0.346483
v 3.886934 15.379010 -0.384712
v 3.375987 15.379012 -0.907831
v 2.644792 15.379010 -0.916437
v 2.121673 15.379012 -0.405491
v 2.113067 15.379010 0.325705
v 2.624013 15.379012 0.848823
v 2.624014 15.379012 0.848823
v 5.355209 15.379012 0.857429
v 5.878327 15.379012 0.346482
v 5.886934 15.379010 -0.384713
v 5.878328 15.379012 0.346482
v 5.886935 15.379010 -0.384713
v 5.375987 15.379012 -0.907832
v 4.644792 15.379010 -0.916437
v 4.644793 15.379010 -0.916438
v 4.121673 15.379012 -0.405491
v 4.113067 15.379010 0.325704
v 4.624013 15.379012 0.848823
v 4.624014 15.379012 0.848823
v 3.000000 8.000000 -4.800000
v 3.000000 8.800000 -4.800000
v 3.565686 8.000000 -4.565685
@@ -504,29 +504,29 @@ v 4.434315 9.249737 -2.039999
v 4.200000 9.815423 -2.039998
v 4.434315 10.381108 -2.039999
v 2.200000 9.773436 -0.494458
v 5.379784 9.142219 -0.916704
v 5.379784 10.427595 -0.916704
v 3.379785 9.142219 -0.916703
v 5.379786 9.142220 -0.916704
v 5.379786 10.427595 -0.916704
v 3.379785 9.142220 -0.916704
v 3.379785 10.427595 -0.916703
v 4.200000 9.773436 -0.494459
v 2.641204 9.133761 -0.925396
v 2.641204 9.133760 -0.925396
v 2.434314 9.213968 -0.723321
v 2.641204 10.436524 -0.925396
v 2.434314 10.345339 -0.723321
v 2.434314 10.345339 -0.723320
v 5.000000 10.585028 -0.921174
v 5.000000 8.985029 -0.921174
v 4.641204 9.133760 -0.925396
v 4.641204 10.436524 -0.925396
v 4.434315 9.213968 -0.723321
v 4.434315 10.345339 -0.723321
v 4.641205 9.133760 -0.925396
v 4.641205 10.436525 -0.925396
v 4.434315 9.213968 -0.723320
v 4.434315 10.345339 -0.723320
v 3.565686 9.214050 -0.726374
v 3.800000 9.773219 -0.486477
v 3.800000 9.773219 -0.486478
v 3.565686 10.345422 -0.726374
v 3.000000 10.585028 -0.921173
v 3.000000 8.985029 -0.921173
v 5.800000 9.773219 -0.486478
v 5.565685 9.214050 -0.726374
v 5.565685 10.345422 -0.726374
v 5.565685 9.214050 -0.726375
v 5.565685 10.345422 -0.726375
vn 0.0118 0.0000 -0.9999
vn -0.6987 0.0000 -0.7154
vn -0.9999 0.0000 -0.0118
@@ -713,7 +713,7 @@ f 83//26 338//26 99//26
f 91//26 342//26 107//26
f 102//27 117//27 101//27
f 110//27 125//27 109//27
f 102//27 119//27 118//27
f 103//27 118//27 102//27
f 110//27 127//27 126//27
f 104//27 119//27 103//27
f 112//27 127//27 111//27
@@ -745,19 +745,19 @@ f 126//20 141//20 125//20
f 118//21 135//21 134//21
f 133//28 148//28 132//28
f 141//28 156//28 140//28
f 134//28 149//28 133//28
f 133//28 150//28 149//28
f 141//28 158//28 157//28
f 134//28 151//28 150//28
f 135//28 150//28 134//28
f 143//28 158//28 142//28
f 136//28 151//28 135//28
f 135//28 152//28 151//28
f 143//28 160//28 159//28
f 129//28 152//28 136//28
f 130//28 145//28 129//28
f 137//28 160//28 144//28
f 138//28 153//28 137//28
f 131//28 146//28 130//28
f 137//28 154//28 153//28
f 130//28 147//28 146//28
f 138//28 155//28 154//28
f 131//28 148//28 147//28
f 132//28 147//28 131//28
f 139//28 156//28 155//28
f 157//29 110//29 109//29
f 159//30 110//30 158//30
@@ -770,7 +770,7 @@ f 157//36 108//36 156//36
f 149//29 102//29 101//29
f 151//31 104//31 103//31
f 152//32 97//32 104//32
f 145//33 98//33 97//33
f 97//33 146//33 98//33
f 98//34 147//34 99//34
f 147//35 100//35 99//35
f 162//37 163//37 161//37
@@ -975,7 +975,7 @@ f 91//26 343//26 342//26
f 342//26 344//26 107//26
f 102//27 118//27 117//27
f 110//27 126//27 125//27
f 102//27 103//27 119//27
f 103//27 119//27 118//27
f 110//27 111//27 127//27
f 104//27 120//27 119//27
f 112//27 128//27 127//27
@@ -1007,19 +1007,19 @@ f 126//20 142//20 141//20
f 118//21 119//21 135//21
f 133//28 149//28 148//28
f 141//28 157//28 156//28
f 134//28 150//28 149//28
f 133//28 134//28 150//28
f 141//28 142//28 158//28
f 134//28 135//28 151//28
f 135//28 151//28 150//28
f 143//28 159//28 158//28
f 136//28 152//28 151//28
f 135//28 136//28 152//28
f 143//28 144//28 160//28
f 129//28 145//28 152//28
f 130//28 146//28 145//28
f 137//28 153//28 160//28
f 138//28 154//28 153//28
f 131//28 147//28 146//28
f 137//28 138//28 154//28
f 130//28 131//28 147//28
f 138//28 139//28 155//28
f 131//28 132//28 148//28
f 132//28 148//28 147//28
f 139//28 140//28 156//28
f 157//29 158//29 110//29
f 159//30 111//30 110//30
@@ -1036,7 +1036,7 @@ f 103//30 102//30 151//30
f 102//30 150//30 151//30
f 151//31 152//31 104//31
f 152//32 145//32 97//32
f 145//33 146//33 98//33
f 97//33 145//33 146//33
f 98//34 146//34 147//34
f 147//35 148//35 100//35
f 162//37 164//37 163//37
@@ -1216,46 +1216,35 @@ v 5.999997 0.000000 -5.999997
v 5.999997 0.000000 5.999997
v -5.999998 0.000000 5.999996
v -5.999995 0.000000 -5.999999
v -5.999999 12.000000 5.999995
v -5.999997 12.000000 -5.999997
v -5.999999 11.000000 5.999995
v -5.999997 10.000000 -5.999997
v 5.999997 0.000000 0.000000
v 2.000001 0.000000 -5.999998
v 5.999999 6.000000 -5.999995
v 2.000000 0.000000 5.999997
v 5.999995 6.000000 5.999999
v -5.999997 0.000000 -0.000002
v -5.999999 6.000000 5.999996
v -5.999996 6.000000 -5.999999
v 2.000001 12.000000 -5.999996
v 1.999997 12.000000 5.999998
v -5.999998 12.000000 -0.000001
v 2.000001 6.000000 -5.999997
v -5.999997 6.000000 -0.000001
v 1.999998 4.000000 5.999997
v 5.999997 6.000000 0.000002
v 1.999999 12.000000 0.000001
v 2.000001 10.000000 -5.999996
v 1.999997 11.000000 5.999998
v -5.999998 11.000000 -2.000001
v 1.999999 11.000000 -1.999999
v 2.000000 0.000000 -0.000001
v 3.999999 0.000000 -5.999997
v 3.999999 0.000000 5.999997
v 4.000000 6.000000 -5.999997
v 3.999996 4.000000 5.999998
v 3.999999 0.000000 -0.000000
v 0.000003 0.000000 -5.999999
v 0.000001 0.000000 5.999997
v 0.000002 12.000000 -5.999997
v -0.000001 12.000000 5.999997
v 0.000003 6.000000 -5.999998
v -0.000000 8.000000 5.999997
v 0.000001 12.000000 0.000000
v 1.000001 0.000000 5.999997
v 0.000002 10.000000 -5.999997
v -0.000001 11.000000 5.999997
v 1.000000 8.000000 5.999997
v 0.000001 12.000000 -2.000000
v 0.000002 0.000000 -0.000001
v -3.999996 0.000000 -5.999999
v -3.999999 0.000000 5.999997
v -3.999997 12.000000 -5.999997
v -4.000000 12.000000 5.999996
v -3.999996 6.000000 -5.999999
v -3.999999 8.000000 5.999996
v -4.999999 0.000000 5.999997
v -3.999997 10.000000 -5.999997
v -4.000000 11.000000 5.999996
v -4.999999 8.000000 5.999996
v -3.999997 0.000000 -0.000002
v -3.999999 12.000000 -0.000001
v -3.999999 12.000000 -2.000001
v 6.000000 8.000000 -5.999994
v 5.999993 8.000000 6.000000
v 5.999997 8.000000 0.000003
@@ -1265,183 +1254,157 @@ v 1.999999 8.000000 0.000001
v 4.000000 8.000000 -5.999995
v 3.999995 8.000000 5.999999
v 3.999998 8.000000 0.000002
v 0.000001 0.000000 6.199996
v -0.000000 8.000000 6.199996
v -3.999999 0.000000 6.199996
v -3.999999 8.000000 6.199996
v -0.400000 0.000000 6.200000
v -0.400000 7.606016 6.200000
v -3.600000 0.000000 6.200000
v -3.600000 7.606016 6.200000
v -0.400000 7.606016 6.000000
v -0.400000 0.000000 6.000000
v -3.600000 0.000000 6.000000
v -3.600000 7.606016 6.000000
v 2.000000 0.000000 6.199996
v 1.999998 4.000000 6.199997
v 3.999999 0.000000 6.199997
v 3.999996 4.000000 6.199997
v 2.200000 0.000000 6.200000
v 2.200000 3.800000 6.200000
v 3.800000 0.000000 6.200000
v 3.800000 3.800000 6.200000
v 3.800000 0.000000 6.000000
v 2.200000 0.000000 6.000000
v 3.800000 3.800000 6.000000
v 2.200000 3.800000 6.000000
v 1.000001 0.000000 6.199996
v 1.000000 8.000000 6.199996
v -4.999999 0.000000 6.199996
v -4.999999 8.000000 6.199996
v 0.600000 0.000000 6.200000
v 0.600000 7.606016 6.200000
v -4.600000 0.000000 6.200000
v -4.600000 7.606016 6.200000
v 0.600000 7.606016 6.000000
v 0.600000 0.000000 6.000000
v -4.600000 0.000000 6.000000
v -4.600000 7.606016 6.000000
v 4.550002 0.000000 5.999997
v 2.049999 0.000000 5.999997
v 3.999998 2.400000 5.999998
v 4.550001 2.400000 5.999998
v 2.049999 2.400000 5.999997
v -5.999999 11.000000 2.999997
v -0.000000 12.000000 2.999998
v 1.999998 11.000000 2.999999
v -3.999999 12.000000 2.999998
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
vn -0.4472 0.8944 -0.0000
vn -0.0000 0.0000 1.0000
vn -1.0000 0.0000 -0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn -0.4082 0.8165 -0.4082
vn 0.0000 0.9701 -0.2425
vn 0.4472 0.8944 0.0000
vn 0.0000 0.8944 -0.4472
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn -0.0000 0.9487 0.3162
vn -0.4286 0.8571 0.2857
vn 0.4082 0.8165 -0.4082
vn 0.4286 0.8571 0.2857
usemtl Material
s off
f 382//185 356//185 387//185
f 361//186 384//186 388//186
f 386//187 349//187 357//187
f 361//188 358//188 363//188
f 381//189 358//189 385//189
f 385//189 350//189 383//189
f 368//189 362//189 370//189
f 363//188 348//188 356//188
f 357//188 356//188 347//188
f 349//188 363//188 357//188
f 382//187 357//187 347//187
f 419//185 410//185 354//185
f 365//190 346//190 351//190
f 353//190 351//190 345//190
f 350//186 388//186 383//186
f 387//185 348//185 381//185
f 368//185 367//185 352//185
f 372//185 354//185 367//185
f 351//185 369//185 372//185
f 345//185 372//185 368//185
f 346//187 371//187 369//187
f 345//189 370//189 353//189
f 352//185 380//185 373//185
f 375//186 366//186 359//186
f 364//187 374//187 354//187
f 352//189 377//189 362//189
f 379//186 360//186 366//186
f 354//185 380//185 367//185
f 380//185 381//185 373//185
f 383//186 379//186 375//186
f 378//190 398//190 374//190
f 377//189 383//189 375//189
f 377//189 381//189 385//189
f 376//187 386//187 378//187
f 388//186 376//186 379//186
f 374//185 387//185 380//185
f 392//186 397//186 395//186
f 395//186 391//186 389//186
f 397//186 390//186 391//186
f 395//189 353//189 370//189
f 355//190 391//190 390//190
f 365//190 389//190 391//190
f 400//187 405//187 401//187
f 386//186 399//186 378//186
f 382//188 401//188 386//188
f 405//185 406//185 403//185
f 401//187 403//187 399//187
f 398//187 403//187 402//187
f 403//188 407//188 402//188
f 404//190 409//190 405//190
f 398//185 407//185 374//185
f 408//185 400//185 382//185
f 410//187 415//187 411//187
f 354//188 411//188 364//188
f 371//190 412//190 369//190
f 414//190 421//190 415//190
f 418//185 412//185 416//185
f 412//187 417//187 416//187
f 413//187 415//187 417//187
f 417//188 418//188 416//188
f 415//185 420//185 417//185
f 362//189 395//189 370//189
f 394//190 359//190 366//190
f 375//189 359//189 392//189
f 393//186 397//186 394//186
f 371//186 411//186 413//186
f 355//187 396//187 371//187
f 378//187 393//187 360//187
f 393//190 366//190 360//190
f 396//187 364//187 371//187
f 382//185 347//185 356//185
f 361//186 349//186 384//186
f 386//187 384//187 349//187
f 361//188 350//188 358//188
f 381//189 348//189 358//189
f 385//189 358//189 350//189
f 368//189 352//189 362//189
f 363//188 358//188 348//188
f 357//188 363//188 356//188
f 349//188 361//188 363//188
f 382//187 386//187 357//187
f 419//185 414//185 410//185
f 365//190 355//190 346//190
f 353//190 365//190 351//190
f 350//186 361//186 388//186
f 387//185 356//185 348//185
f 368//185 372//185 367//185
f 372//185 369//185 354//185
f 351//185 346//185 369//185
f 345//185 351//185 372//185
f 346//187 355//187 371//187
f 345//189 368//189 370//189
f 352//185 367//185 380//185
f 375//186 379//186 366//186
f 364//187 378//187 374//187
f 352//189 373//189 377//189
f 379//186 376//186 360//186
f 354//185 374//185 380//185
f 380//185 387//185 381//185
f 383//186 388//186 379//186
f 378//190 399//190 398//190
f 377//189 385//189 383//189
f 377//189 373//189 381//189
f 376//187 384//187 386//187
f 388//186 384//186 376//186
f 374//185 382//185 387//185
f 392//186 394//186 397//186
f 395//186 397//186 391//186
f 397//186 396//186 390//186
f 395//189 389//189 353//189
f 355//190 365//190 391//190
f 365//190 353//190 389//190
f 400//187 404//187 405//187
f 386//186 401//186 399//186
f 382//188 400//188 401//188
f 405//185 409//185 406//185
f 401//187 405//187 403//187
f 398//187 399//187 403//187
f 403//188 406//188 407//188
f 404//190 408//190 409//190
f 398//185 402//185 407//185
f 408//185 404//185 400//185
f 410//187 414//187 415//187
f 354//188 410//188 411//188
f 371//190 413//190 412//190
f 414//190 419//190 421//190
f 418//185 369//185 412//185
f 412//187 413//187 417//187
f 413//187 411//187 415//187
f 417//188 420//188 418//188
f 415//185 421//185 420//185
f 362//189 392//189 395//189
f 394//190 392//190 359//190
f 392//189 362//189 377//189
f 377//189 375//189 392//189
f 393//186 396//186 397//186
f 371//186 364//186 411//186
f 355//187 390//187 396//187
f 360//187 376//187 378//187
f 378//187 364//187 393//187
f 393//190 394//190 366//190
f 396//187 393//187 364//187
f 372//185 354//185 376//185
f 358//186 407//186 377//186
f 375//187 349//187 355//187
f 372//187 355//187 347//187
f 346//188 380//188 379//188
f 373//189 358//189 377//189
f 376//185 348//185 371//185
f 361//185 360//185 352//185
f 400//185 353//185 360//185
f 399//185 362//185 363//185
f 345//185 363//185 361//185
f 352//185 370//185 364//185
f 366//190 359//190 356//190
f 359//191 405//191 406//191
f 360//185 365//185 370//185
f 370//185 371//185 364//185
f 373//192 369//192 366//192
f 368//188 387//188 365//188
f 367//187 375//187 368//187
f 377//193 405//193 369//193
f 370//185 372//185 376//185
f 381//193 386//193 384//193
f 384//193 380//193 378//193
f 386//193 379//193 380//193
f 389//187 394//187 390//187
f 375//193 388//193 368//193
f 372//194 390//194 375//194
f 394//185 395//185 392//185
f 390//187 392//187 388//187
f 387//187 392//187 391//187
f 392//194 396//194 391//194
f 393//188 398//188 394//188
f 387//185 396//185 365//185
f 397//185 389//185 372//185
f 359//188 381//188 356//188
f 382//193 386//193 383//193
f 357//187 368//187 382//187
f 383//188 359//188 406//188
f 382//187 365//187 353//187
f 354//194 347//194 355//194
f 354//194 350//194 348//194
f 350//195 371//195 348//195
f 373//195 364//195 371//195
f 366//195 352//195 364//195
f 381//195 361//195 352//195
f 384//195 345//195 361//195
f 351//188 378//188 380//188
f 402//187 399//187 346//187
f 403//187 385//187 382//187
f 407//196 367//196 405//196
f 406//193 367//193 357//193
f 404//197 374//197 407//197
f 372//185 347//185 354//185
f 358//186 404//186 407//186
f 375//187 374//187 349//187
f 372//187 375//187 355//187
f 346//188 351//188 380//188
f 373//190 350//190 358//190
f 376//185 354//185 348//185
f 361//185 363//185 360//185
f 360//185 363//185 400//185
f 363//185 362//185 400//185
f 363//185 351//185 399//185
f 351//185 346//185 399//185
f 345//185 351//185 363//185
f 352//185 360//185 370//185
f 366//198 369//198 359//198
f 359//191 369//191 405//191
f 360//185 353//185 365//185
f 370//185 376//185 371//185
f 373//192 377//192 369//192
f 368//188 388//188 387//188
f 367//187 374//187 375//187
f 377//193 407//193 405//193
f 370//185 365//185 372//185
f 381//193 383//193 386//193
f 384//193 386//193 380//193
f 386//193 385//193 379//193
f 389//187 393//187 394//187
f 375//193 390//193 388//193
f 372//194 389//194 390//194
f 394//185 398//185 395//185
f 390//187 394//187 392//187
f 387//187 388//187 392//187
f 392//194 395//194 396//194
f 393//188 397//188 398//188
f 387//185 391//185 396//185
f 397//185 393//185 389//185
f 359//188 383//188 381//188
f 382//193 385//193 386//193
f 357//187 367//187 368//187
f 406//188 357//188 382//188
f 382//188 383//188 406//188
f 382//187 368//187 365//187
f 355//194 349//194 404//194
f 404//194 358//194 355//194
f 358//194 354//194 355//194
f 354//194 358//194 350//194
f 350//195 373//195 371//195
f 373//195 366//195 364//195
f 366//195 356//195 352//195
f 381//195 384//195 361//195
f 384//195 378//195 345//195
f 351//188 345//188 378//188
f 346//187 379//187 402//187
f 379//187 385//187 402//187
f 385//187 401//187 402//187
f 353//187 400//187 403//187
f 403//187 401//187 385//187
f 382//187 353//187 403//187
f 407//196 374//196 367//196
f 406//199 405//199 367//199
f 404//193 349//193 374//193
usemtl garage
f 406//187 408//187 407//187
f 406//187 409//187 408//187
usemtl door
f 420//187 419//187 418//187
f 420//187 421//187 419//187
f 395//187 397//187 396//187
f 395//187 398//187 397//187

View File

@@ -0,0 +1,11 @@
component(:building)
on.create do |event|
map.insert_entity("base", "purchase_terminal", event.entity.position + Vector.new(6, 1.5, 3), Vector.new(0, -90, 0), data: {team: nil})
map.insert_entity("base", "information_panel", event.entity.position + Vector.new(0.5, 0, 3), Vector.new(0, 90, 0))
map.insert_entity("base", "door", event.entity.position + Vector.new(3.3, 0, 6), Vector.new(0, 0, 0))
map.insert_entity("base", "door", event.entity.position + Vector.new(3.3, 0, 6), Vector.new(0, 180, 0))
map.insert_particle_emitter(Vector.new(3.0, 15.379, 0.029), Texture.new(path: ["base", "shared", "particles", "smoke", "smoke.png"]))
map.insert_particle_emitter(Vector.new(5.0, 15.379, 0.029), Texture.new(path: ["base", "shared", "particles", "smoke", "smoke.png"]))
end

BIN
blends/STD_cutters.blend Normal file

Binary file not shown.

BIN
blends/alternate_tank.blend Normal file

Binary file not shown.

Binary file not shown.

BIN
blends/character.blend Normal file

Binary file not shown.

BIN
blends/character.blend1 Normal file

Binary file not shown.

BIN
blends/door.blend Normal file

Binary file not shown.

BIN
blends/door.blend1 Normal file

Binary file not shown.

BIN
blends/evergreen_tree.blend Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
blends/power_plant.blend Normal file

Binary file not shown.

BIN
blends/power_plant.blend1 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,13 +0,0 @@
# Blender MTL File: 'randomish_terrain.blend'
# Material Count: 1
newmtl Material.001
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd randomish_terrain.png

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

Binary file not shown.

1
data/.gitkeep Normal file
View File

@@ -0,0 +1 @@

16
i-mic-fps-server.rb Normal file
View File

@@ -0,0 +1,16 @@
require "async/websocket"
require_relative "lib/networking/director"
require_relative "lib/networking/packet_handler"
require_relative "lib/networking/server"
require_relative "lib/networking/client"
require_relative "lib/networking/backends/memory_server"
require_relative "lib/networking/backends/memory_connection"
director = IMICFPS::Networking::Director.new(mode: :server, hostname: "0.0.0.0", port: 56789, interface: IMICFPS::Networking::MemoryServer)
director.define_singleton_method(:tick) do |dt|
puts "Ticked: #{dt}"
end
director.run.join

View File

@@ -1,72 +1,24 @@
require "fiddle"
require "yaml"
require "json"
require "abbrev"
require "time"
require "opengl"
require "glu"
require "nokogiri"
begin
require_relative "../cyberarm_engine/lib/cyberarm_engine"
rescue LoadError
require "cyberarm_engine"
rescue LoadError => e
pp e
require "cyberarm_engine"
end
Dir.chdir(File.dirname(__FILE__))
case OpenGL.get_platform
when :OPENGL_PLATFORM_WINDOWS
OpenGL.load_lib("opengl32.dll", "C:/Windows/System32")
GLU.load_lib("GLU32.dll", "C:/Windows/System32")
when :OPENGL_PLATFORM_MACOSX
OpenGL.load_lib("libGL.dylib", "/System/Library/Frameworks/OpenGL.framework/Libraries")
GLU.load_lib("libGLU.dylib", "/System/Library/Frameworks/OpenGL.framework/Libraries")
when :OPENGL_PLATFORM_LINUX
# Black magic to get GLSL 3.30 support on older Intel hardware
# if `glxinfo | egrep "OpenGL vendor|OpenGL renderer"`.include?("Intel")
# ENV["MESA_GL_VERSION_OVERRIDE"] = "3.3"
# ENV["MESA_GLSL_VERSION_OVERRIDE"] = "330"
# end
gl_library_path = nil
if File.exist?("/usr/lib/x86_64-linux-gnu/libGL.so") # Ubuntu (Debian)
gl_library_path = "/usr/lib/x86_64-linux-gnu"
elsif File.exist?("/usr/lib/libGL.so") # Manjaro (ARCH)
gl_library_path = "/usr/lib"
elsif File.exist?("/usr/lib/arm-linux-gnueabihf/libGL.so") # Raspbian (ARM/Raspberry Pi)
gl_library_path = "/usr/lib/arm-linux-gnueabihf"
end
if gl_library_path
OpenGL.load_lib("libGL.so", gl_library_path)
GLU.load_lib("libGLU.so", gl_library_path)
else
raise RuntimeError, "Couldn't find GL libraries"
end
else
raise RuntimeError, "Unsupported platform."
end
if RUBY_VERSION < "2.5.0"
puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
puts "|NOTICE| Ruby is #{RUBY_VERSION} not 2.5.0+..............................|Notice|"
puts "|NOTICE| Monkey Patching Float to add required '.clamp' method.|Notice|"
puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
puts
class Float
def clamp(min, max)
if self < min
min
elsif self > max
max
else
return self
end
end
end
end
require_relative "lib/ext/numeric"
require_relative "lib/ext/load_opengl"
include CyberarmEngine
include OpenGL
@@ -88,6 +40,7 @@ require_relative "lib/managers/collision_manager"
require_relative "lib/managers/physics_manager"
require_relative "lib/renderer/renderer"
require_relative "lib/renderer/g_buffer"
require_relative "lib/renderer/opengl_renderer"
require_relative "lib/renderer/bounding_box_renderer"
@@ -101,25 +54,72 @@ Dir.glob("#{IMICFPS::GAME_ROOT_PATH}/lib/ui/commands/*.rb").each do |cmd|
end
require_relative "lib/ui/console"
require_relative "lib/ui/menus/main_menu"
require_relative "lib/ui/menus/settings_menu"
require_relative "lib/ui/menus/extras_menu"
require_relative "lib/ui/menus/level_select_menu"
require_relative "lib/ui/menus/game_pause_menu"
require_relative "lib/states/game_states/game"
require_relative "lib/states/game_states/loading_state"
require_relative "lib/objects/entity"
require_relative "lib/objects/model_loader"
require_relative "lib/objects/light"
require_relative "lib/subscription"
require_relative "lib/publisher"
require_relative "lib/event"
require_relative "lib/event_handler"
require_relative "lib/event_handlers/input"
require_relative "lib/event_handlers/entity_moved"
require_relative "lib/event_handlers/entity_lifecycle"
require_relative "lib/objects/camera"
require_relative "lib/objects/entities/player"
require_relative "lib/objects/entities/tree"
require_relative "lib/objects/entities/skydome"
require_relative "lib/objects/entities/test_object"
require_relative "lib/objects/entities/terrain"
require_relative "lib/scripting"
require_relative "lib/scripting/sandbox"
require_relative "lib/scripting/whitelist"
require_relative "lib/wavefront/model"
require_relative "lib/component"
require_relative "lib/components/building"
require_relative "lib/game_objects/entity"
require_relative "lib/game_objects/light"
require_relative "lib/game_objects/particle_emitter"
require_relative "lib/game_objects/camera"
require_relative "lib/game_objects/entities/player"
require_relative "lib/game_objects/entities/skydome"
require_relative "lib/game_objects/entities/terrain"
require_relative "lib/texture"
require_relative "lib/model"
require_relative "lib/model_cache"
require_relative "lib/model/parser"
require_relative "lib/model/model_object"
require_relative "lib/model/material"
require_relative "lib/model/parsers/wavefront_parser"
require_relative "lib/model/parsers/collada_parser"
require_relative "lib/map_parser"
require_relative "lib/manifest"
require_relative "lib/map"
require_relative "lib/scene"
require_relative "lib/scenes/turn_table"
require_relative "lib/crosshair"
require_relative "lib/demo"
require_relative "lib/networking/director"
require_relative "lib/networking/packet_handler"
require_relative "lib/networking/client"
require_relative "lib/networking/server"
require_relative "lib/networking/connection"
require_relative "lib/networking/backends/memory_server"
require_relative "lib/networking/backends/memory_connection"
require_relative "lib/window"
require_relative "lib/tools/asset_viewer"
require_relative "lib/tools/map_editor"
if ARGV.join.include?("--profile")
begin
require "ruby-prof"

View File

@@ -7,7 +7,7 @@ class IMICFPS
def window; $window; end
def delta_time; (Gosu.milliseconds - @delta_time) / 1000.0; end
def delta_time; (Gosu.milliseconds - window.delta_time) / 1000.0; end
def button_down?(id); window.button_down?(id); end
def mouse_x; window.mouse_x; end
@@ -43,12 +43,12 @@ class IMICFPS
draw_rect(0, 0, window.width, window.height, color)
end
def handleGlError
def gl_error?
e = glGetError()
if e != GL_NO_ERROR
$stderr.puts "OpenGL error detected by handler at: #{caller[0]}"
$stderr.puts " #{gluErrorString(e)} (#{e})\n"
exit
exit if window.config.get(:debug_options, :opengl_error_panic)
end
end
end

41
lib/component.rb Normal file
View File

@@ -0,0 +1,41 @@
class IMICFPS
class Component
COMPONENTS = {}
def self.get(name)
COMPONENTS.dig(name)
end
def self.inherited(subclass)
COMPONENTS["__pending"] ||= []
COMPONENTS["__pending"] << subclass
end
def self.initiate
return unless COMPONENTS.dig("__pending") # Already setup
COMPONENTS["__pending"].each do |klass|
component = klass.new
COMPONENTS[component.name] = component
end
COMPONENTS.delete("__pending")
end
def initialize
setup
end
def name
string = self.class.name.split("::").last
split = string.scan(/[A-Z][a-z]*/)
component_name = "#{split.map { |s| s.downcase }.join("_")}".to_sym
return component_name
end
def setup
end
end
end

View File

@@ -0,0 +1,6 @@
class IMICFPS
class Components
class Building < Component
end
end
end

View File

@@ -10,7 +10,7 @@ class IMICFPS
MODEL_METER_SCALE = 1.0
# Earth
GRAVITY = 9.8 # m/s
EARTH_GRAVITY = 9.8 # m/s
# Moon
# GRAVITY = 1.625 # m/s
MOON_GRAVITY = 1.625 # m/s
end

16
lib/crosshair.rb Normal file
View File

@@ -0,0 +1,16 @@
class IMICFPS
class Crosshair
include CommonMethods
def initialize(color: Gosu::Color.rgb(255,127,0), size: 10, thickness: 3)
@color = color
@size = size
@thickness = thickness
end
def draw
draw_rect(window.width/2-@size, (window.height/2-@size)-@thickness/2, @size*2, @thickness, @color, 0, :default)
draw_rect((window.width/2)-@thickness/2, window.height/2-(@size*2), @thickness, @size*2, @color, 0, :default)
end
end
end

108
lib/demo.rb Normal file
View File

@@ -0,0 +1,108 @@
class IMICFPS
class Demo
def initialize(camera:, player:, demo:, mode:)
@camera = camera
@player = player
@demo = demo
@mode = mode
@index= 0
@tick = 0
@changed = false
if ARGV.join.include?("--playdemo")
@data = File.exist?(demo) ? File.read("./demo.dat").lines : ""
elsif ARGV.join.include?("--savedemo")
@file = File.open(demo, "w")
@last_pitch = @camera.orientation.z
@last_yaw = @camera.orientation.y
at_exit { @file.close }
end
end
def button_down(id)
if recording?
unless @last_written_index == @index
@last_written_index = @index
@file.puts("tick #{@index}")
end
@file.puts("down #{InputMapper.action(id)}")
@changed = true
end
end
def button_up(id)
if recording?
unless @last_written_index == @index
@last_written_index = @index
@file.puts("tick #{@index}")
end
@file.puts("up #{InputMapper.action(id)}")
@changed = true
end
end
def update
play if playing?
record if recording?
@tick += 1
end
def playing?; @mode == :play; end
def recording?; !playing?; end
def play
if @data[@index]&.start_with?("tick")
if @tick == @data[@index].split(" ").last.to_i
@index+=1
until(@data[@index]&.start_with?("tick"))
break unless @data[@index]
data = @data[@index].split(" ")
if data.first == "up"
input = InputMapper.get(data.last.to_sym)
key = input.is_a?(Array) ? input.first : input
$window.current_state.button_up(key) if key
elsif data.first == "down"
input = InputMapper.get(data.last.to_sym)
key = input.is_a?(Array) ? input.first : input
$window.current_state.button_down(key) if key
elsif data.first == "mouse"
@camera.orientation.z = data[1].to_f
@player.orientation.y = (data[2].to_f * -1) - 180
else
# hmm
end
@index += 1
end
end
end
end
def record
if @camera.orientation.z != @last_pitch || @camera.orientation.y != @last_yaw
unless @last_written_index == @index
@last_written_index = @index
@file.puts("tick #{@index}")
end
@file.puts("mouse #{@camera.orientation.z} #{@camera.orientation.y}")
@last_pitch = @camera.orientation.z
@last_yaw = @camera.orientation.y
end
@changed = false
@index += 1
end
end
end

10
lib/event.rb Normal file
View File

@@ -0,0 +1,10 @@
class IMICFPS
class EventHandler
class Event
attr_reader :entity, :context
def initialize(entity:, context: nil)
@entity, @context = entity, context
end
end
end
end

39
lib/event_handler.rb Normal file
View File

@@ -0,0 +1,39 @@
class IMICFPS
class EventHandler
@@handlers = {}
def self.inherited(subclass)
@@handlers["__pending"] ||= []
@@handlers["__pending"] << subclass
end
def self.initiate
preserve = @@handlers["__pending"]
@@handlers.clear
@@handlers["__pending"] = preserve
@@handlers["__pending"].each do |handler|
instance = handler.new
instance.handles.each do |event|
@@handlers[event] = instance
end
end
end
def self.get(event)
@@handlers.dig(event)
end
def initialize
end
def handlers
raise NotImplementedError
end
def handle(subscriber, context, *args)
raise NotImplementedError
end
end
end

View File

@@ -0,0 +1,16 @@
class IMICFPS
class EventHandler
class EntityLifeCycle < EventHandler
def handles
[:create, :move, :destroy]
end
def handle(subscriber, context, *args)
return unless subscriber.entity == args.first.first
event = EventHandler::Event.new(entity: subscriber.entity, context: context)
subscriber.trigger(event)
end
end
end
end

View File

@@ -0,0 +1,15 @@
class IMICFPS
class EventHandler
class EntityMoved < EventHandler
def handles
[:entity_moved]
end
def handle(subscriber, context, *args)
event = EventHandler::Event.new(entity: args.first.first)
subscriber.trigger(event)
end
end
end
end

View File

@@ -0,0 +1,24 @@
class IMICFPS
class EventHandler
class Input < EventHandler
def handles
[:button_down, :button_up]
end
def handle(subscriber, context, *args)
action = subscriber.args.flatten.first
key = args.flatten.first
event = EventHandler::Event.new(entity: subscriber.entity, context: context)
if action.is_a?(Numeric) && action == key
subscriber.trigger(event)
else
if InputMapper.get(action) == key
subscriber.trigger(event)
end
end
end
end
end
end

35
lib/ext/load_opengl.rb Normal file
View File

@@ -0,0 +1,35 @@
case OpenGL.get_platform
when :OPENGL_PLATFORM_WINDOWS
OpenGL.load_lib("opengl32.dll", "C:/Windows/System32")
GLU.load_lib("GLU32.dll", "C:/Windows/System32")
when :OPENGL_PLATFORM_MACOSX
OpenGL.load_lib("libGL.dylib", "/System/Library/Frameworks/OpenGL.framework/Libraries")
GLU.load_lib("libGLU.dylib", "/System/Library/Frameworks/OpenGL.framework/Libraries")
when :OPENGL_PLATFORM_LINUX
# Black magic to get GLSL 3.30 support on older Intel hardware
if ARGV.join.include?("--mesa-override") && `glxinfo | egrep "OpenGL vendor|OpenGL renderer"`.include?("Intel")
ENV["MESA_GL_VERSION_OVERRIDE"] = "3.3"
ENV["MESA_GLSL_VERSION_OVERRIDE"] = "330"
end
gl_library_path = nil
if File.exist?("/usr/lib/x86_64-linux-gnu/libGL.so") # Ubuntu (Debian)
gl_library_path = "/usr/lib/x86_64-linux-gnu"
elsif File.exist?("/usr/lib/libGL.so") # Manjaro (ARCH)
gl_library_path = "/usr/lib"
elsif File.exist?("/usr/lib/arm-linux-gnueabihf/libGL.so") # Raspbian (ARM/Raspberry Pi)
gl_library_path = "/usr/lib/arm-linux-gnueabihf"
end
if gl_library_path
OpenGL.load_lib("libGL.so", gl_library_path)
GLU.load_lib("libGLU.so", gl_library_path)
else
raise RuntimeError, "Couldn't find GL libraries"
end
else
raise RuntimeError, "Unsupported platform."
end

18
lib/ext/numeric.rb Normal file
View File

@@ -0,0 +1,18 @@
if RUBY_VERSION < "2.5.0"
puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
puts "|NOTICE| Ruby is #{RUBY_VERSION} not 2.5.0+..............................|Notice|"
puts "|NOTICE| Monkey Patching Numeric to add required '.clamp' method.|Notice|"
puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
puts
class Numeric
def clamp(min, max)
if self < min
min
elsif self > max
max
else
return self
end
end
end
end

View File

@@ -4,11 +4,12 @@ class IMICFPS
attr_accessor :field_of_view, :mouse_sensitivity
attr_reader :entity, :position, :orientation, :mouse_captured
def initialize(x: 0, y: 0, z: 0, fov: 70.0, view_distance: 155.0)
@position = Vector.new(x,y,z)
@orientation = Vector.new(0, 0, 0)
def initialize(position:, orientation: Vector.new(0, 0, 0), fov: 70.0, min_view_distance: 0.1, max_view_distance: 155.0)
@position = position
@orientation = orientation
@field_of_view = fov
@view_distance = view_distance
@min_view_distance = min_view_distance
@max_view_distance = max_view_distance
@constant_pitch = 20.0
@entity = nil
@@ -54,14 +55,14 @@ class IMICFPS
end
end
x_offset = horizontal_distance_from_object * Math.sin(@entity.rotation.y.degrees_to_radians)
z_offset = horizontal_distance_from_object * Math.cos(@entity.rotation.y.degrees_to_radians)
# p @entity.x, @entity.z;exit
x_offset = horizontal_distance_from_object * Math.sin(@entity.orientation.y.degrees_to_radians)
z_offset = horizontal_distance_from_object * Math.cos(@entity.orientation.y.degrees_to_radians)
@position.x = @entity.position.x - x_offset
@position.y = @entity.position.y + 2
@position.z = @entity.position.z - z_offset
@orientation.y = 180 - @entity.rotation.y
@orientation.y = 180 - @entity.orientation.y
end
def draw
@@ -69,9 +70,9 @@ class IMICFPS
glMatrixMode(GL_PROJECTION) # The projection matrix is responsible for adding perspective to our scene.
glLoadIdentity # Resets current modelview matrix
# Calculates aspect ratio of the window. Gets perspective view. 45 is degree viewing angle, (0.1, 100) are ranges how deep can we draw into the screen
gluPerspective(@field_of_view, window.width / window.height, 0.1, @view_distance)
gluPerspective(@field_of_view, window.width / window.height, 0.1, @max_view_distance)
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
glRotatef(@orientation.z, 1, 0, 0)
glRotatef(@orientation.x, 1, 0, 0)
glRotatef(@orientation.y, 0, 1, 0)
glTranslatef(-@position.x, -@position.y, -@position.z)
glMatrixMode(GL_MODELVIEW) # The modelview matrix is where object information is stored.
@@ -86,12 +87,16 @@ class IMICFPS
@orientation.y -= delta
@orientation.y %= 360.0
@orientation.z -= Float(@true_mouse.y - self.mouse_y) / (@mouse_sensitivity * @field_of_view) * 70
@orientation.z = @orientation.z.clamp(-90.0, 90.0)
@orientation.x -= Float(@true_mouse.y - self.mouse_y) / (@mouse_sensitivity * @field_of_view) * 70
@orientation.x = @orientation.x.clamp(-90.0, 90.0)
@entity.rotation.y += delta if @entity
free_move unless @entity
position_camera if @entity
if @entity
@entity.orientation.y += delta
@entity.orientation.y %= 360.0
position_camera
else
free_move
end
self.mouse_x = window.width / 2 if self.mouse_x <= 1 || window.mouse_x >= window.width-1
self.mouse_y = window.height / 2 if self.mouse_y <= 1 || window.mouse_y >= window.height-1
@@ -106,26 +111,39 @@ class IMICFPS
def free_move
relative_y_rotation = (@orientation.y + 180)
relative_speed = 0.25
relative_speed = 2.5
relative_speed = 1.5 if InputMapper.down?(:sneak)
relative_speed = 10.0 if InputMapper.down?(:sprint)
relative_speed *= window.dt
turn_speed = 50.0 * window.dt
if InputMapper.down?( :forward)
@position.z+=Math.cos(relative_y_rotation * Math::PI / 180)*relative_speed
@position.x-=Math.sin(relative_y_rotation * Math::PI / 180)*relative_speed
@position.z+=Math.cos(relative_y_rotation * Math::PI / 180) * relative_speed
@position.x-=Math.sin(relative_y_rotation * Math::PI / 180) * relative_speed
end
if InputMapper.down?(:backward)
@position.z-=Math.cos(relative_y_rotation * Math::PI / 180)*relative_speed
@position.x+=Math.sin(relative_y_rotation * Math::PI / 180)*relative_speed
@position.z-=Math.cos(relative_y_rotation * Math::PI / 180) * relative_speed
@position.x+=Math.sin(relative_y_rotation * Math::PI / 180) * relative_speed
end
if InputMapper.down?(:strife_left)
@position.z+=Math.sin(relative_y_rotation * Math::PI / 180)*relative_speed
@position.x+=Math.cos(relative_y_rotation * Math::PI / 180)*relative_speed
@position.z+=Math.sin(relative_y_rotation * Math::PI / 180) * relative_speed
@position.x+=Math.cos(relative_y_rotation * Math::PI / 180) * relative_speed
end
if InputMapper.down?(:strife_right)
@position.z-=Math.sin(relative_y_rotation * Math::PI / 180)*relative_speed
@position.x-=Math.cos(relative_y_rotation * Math::PI / 180)*relative_speed
@position.z-=Math.sin(relative_y_rotation * Math::PI / 180) * relative_speed
@position.x-=Math.cos(relative_y_rotation * Math::PI / 180) * relative_speed
end
if InputMapper.down?(:turn_left)
@orientation.y -= turn_speed
end
if InputMapper.down?(:turn_right)
@orientation.y += turn_speed
end
if InputMapper.down?(:ascend)
@@ -154,14 +172,26 @@ class IMICFPS
elsif InputMapper.is?(:increase_view_distance, id)
# @field_of_view += 1
# @field_of_view = @field_of_view.clamp(1, 100)
@view_distance += 1
@view_distance = @view_distance.clamp(1, 1000)
@max_view_distance += 1
@max_view_distance = @max_view_distance.clamp(1, 1000)
elsif InputMapper.is?(:decrease_view_distance, id)
# @field_of_view -= 1
# @field_of_view = @field_of_view.clamp(1, 100)
@view_distance -= 1
@view_distance = @view_distance.clamp(1, 1000)
@max_view_distance -= 1
@max_view_distance = @max_view_distance.clamp(1, 1000)
end
end
def aspect_ratio
window.width / window.height.to_f
end
def projection_matrix
Transform.perspective(@field_of_view, aspect_ratio, @min_view_distance, @max_view_distance)
end
def view_matrix
Transform.translate_3d(@position * -1) * Transform.rotate_3d(@orientation)
end
end
end

View File

@@ -7,9 +7,7 @@ class IMICFPS
attr_reader :name, :bound_model, :first_person_view
def setup
bind_model("base", "biped")
@collision = :dynamic
bind_model
@speed = 2.5 # meter's per second
@running_speed = 5.0 # meter's per second
@turn_speed = 50.0
@@ -21,21 +19,7 @@ class IMICFPS
@devisor = 500.0
@name_image = Gosu::Image.from_text("#{Etc.getlogin}", 100, font: "Consolas", align: :center)
# @name_image.save("temp.png")
@name_tex = @name_image.gl_tex_info
array_of_pixels = @name_image.to_blob
tex_names_buf = ' ' * 8
glGenTextures(1, tex_names_buf)
@name_texture_id = tex_names_buf.unpack('L2').first
glBindTexture(GL_TEXTURE_2D, @name_texture_id)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, @name_image.width, @name_image.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, array_of_pixels)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR)
glGenerateMipmap(GL_TEXTURE_2D)
@name_texture_id = Texture.new(image: @name_image).id
end
def draw_nameplate
@@ -93,11 +77,6 @@ class IMICFPS
# Do not handle movement if mouse is not captured
return if @camera && !@camera.mouse_captured
if @_time_in_air
air_time = (Gosu.milliseconds - @_time_in_air) / 1000.0
@velocity.y -= IMICFPS::GRAVITY * air_time * delta_time
end
super
end
@@ -106,7 +85,7 @@ class IMICFPS
end
def relative_y_rotation
@rotation.y * -1
@orientation.y * -1
end
def forward
@@ -130,33 +109,16 @@ class IMICFPS
end
def turn_left
@rotation.y += @turn_speed * delta_time
@orientation.y += @turn_speed * delta_time
end
def turn_right
@rotation.y -= @turn_speed * delta_time
@orientation.y -= @turn_speed * delta_time
end
def jump
if InputMapper.down?(:jump) && !@jumping
@jumping = true
@_time_in_air = Gosu.milliseconds
elsif !@jumping
@falling = true
@_time_in_air ||= Gosu.milliseconds # FIXME
else
if @jumping && @velocity.y <= 0
@falling = false
@jumping = false
end
end
if @jumping && !@falling
if InputMapper.down?(:jump)
@velocity.y = 1.5
@falling = true
end
if InputMapper.down?(:jump) && window.current_state.map.collision_manager.on_ground?(self)
@velocity.y = 1.5
end
end
@@ -166,8 +128,8 @@ class IMICFPS
end
def turn_180
@rotation.y = @rotation.y + 180
@rotation.y %= 360
@orientation.y = @orientation.y + 180
@orientation.y %= 360
end
end
end

View File

@@ -1,7 +1,6 @@
class IMICFPS
class Skydome < Entity
def setup
bind_model("base", "skydome")
@collision = :none
end
@@ -12,8 +11,8 @@ class IMICFPS
end
def update
@rotation.y += 0.01
@rotation.y %= 360
@orientation.y += 0.01
@orientation.y %= 360
super
end
end

View File

@@ -0,0 +1,4 @@
class IMICFPS
class Terrain < Entity
end
end

View File

@@ -5,39 +5,48 @@ class IMICFPS
class Entity
include CommonMethods
attr_accessor :scale, :visible, :renderable, :backface_culling
attr_accessor :position, :rotation, :velocity
attr_reader :name, :debug_color, :bounding_box, :collision, :physics, :mass, :drag, :camera
attr_accessor :visible, :renderable, :backface_culling
attr_accessor :position, :orientation, :scale, :velocity
attr_reader :name, :debug_color, :bounding_box, :drag, :camera, :manifest
def initialize(manifest:, map_entity: nil, spawnpoint: nil, backface_culling: true, run_scripts: true)
@manifest = manifest
if map_entity
@position = map_entity.position.clone
@orientation = map_entity.orientation.clone
@scale = map_entity.scale.clone
@bound_model = bind_model
elsif spawnpoint
@position = spawnpoint.position.clone
@orientation = spawnpoint.orientation.clone
@scale = Vector.new(1, 1, 1)
else
@position = Vector.new
@orientation = Vector.up
@scale = Vector.new(1, 1, 1)
end
def initialize(x: 0, y: 0, z: 0, bound_model: nil, scale: MODEL_METER_SCALE, backface_culling: true, auto_manage: true, manifest_file: nil)
@position = Vector.new(x, y, z)
@scale = scale
@bound_model = bound_model
@backface_culling = backface_culling
@name = @manifest.name
@visible = true
@renderable = true
@rotation = Vector.new(0, 0, 0)
@velocity = Vector.new(0, 0, 0)
@drag = 1.0
@debug_color = Color.new(0.0, 1.0, 0.0)
@collidable = [:static, :dynamic]
# :dynamic => moves in response,
# :static => does not move ever,
# :none => no collision check, entities can pass through
@collision = :static
@physics = false # Entity affected by gravity and what not
@mass = 100 # kg
@delta_time = Gosu.milliseconds
@last_position = Vector.new(@position.x, @position.y, @position.z)
@sandboxes = []
load_scripts if run_scripts
setup
if @bound_model
@bound_model.model.entity = self
@bound_model.model.objects.each { |o| o.scale = self.scale }
@normalized_bounding_box = normalize_bounding_box_with_offset
normalize_bounding_box
@@ -48,20 +57,25 @@ class IMICFPS
return self
end
def collidable?
@collidable.include?(@collision)
def load_scripts
@manifest.scripts.each do |script|
@sandboxes << Scripting::SandBox.new(entity: self, script: script)
end
end
def bind_model(package, name)
model = ModelLoader.new(manifest_file: IMICFPS.assets_path + "/#{package}/#{name}/manifest.yaml", entity: @dummy_entity)
def collidable?
@manifest.collision
end
raise "model isn't a model!" unless model.is_a?(ModelLoader)
def bind_model
model = ModelCache.new(manifest: @manifest)
raise "model isn't a model!" unless model.is_a?(ModelCache)
@bound_model = model
@bound_model.model.entity = self
@bound_model.model.objects.each { |o| o.scale = self.scale }
@bounding_box = normalize_bounding_box_with_offset
# box = normalize_bounding_box
return model
end
def model
@@ -90,11 +104,13 @@ class IMICFPS
def update
model.update
@delta_time = Gosu.milliseconds
unless at_same_position?
Publisher.instance.publish(:entity_moved, nil, self)
@bounding_box = normalize_bounding_box_with_offset if model
end
@last_position = Vector.new(@position.x, @position.y, @position.z)
end
def debug_color=(color)
@@ -112,5 +128,9 @@ class IMICFPS
def normalize_bounding_box
@bound_model.model.bounding_box.normalize(self)
end
def model_matrix
Transform.rotate_3d(@orientation) * Transform.scale_3d(@scale) * Transform.translate_3d(@position)
end
end
end

46
lib/game_objects/light.rb Normal file
View File

@@ -0,0 +1,46 @@
class IMICFPS
class Light
DIRECTIONAL = 0
POINT = 1
attr_reader :light_id
attr_accessor :type, :ambient, :diffuse, :specular, :position, :intensity
def initialize(
id:,
type: Light::POINT,
ambient: Vector.new(0.5, 0.5, 0.5),
diffuse: Vector.new(1, 1, 1),
specular: Vector.new(0.2, 0.2, 0.2),
position: Vector.new(0, 0, 0),
intensity: 1
)
@light_id = id
@type = type
@ambient = ambient
@diffuse = diffuse
@specular = specular
@position = position
@intensity = intensity
end
def draw
glLightfv(@light_id, GL_AMBIENT, convert(@ambient).pack("f*"))
glLightfv(@light_id, GL_DIFFUSE, convert(@diffuse, true).pack("f*"))
glLightfv(@light_id, GL_SPECULAR, convert(@specular, true).pack("f*"))
glLightfv(@light_id, GL_POSITION, convert(@position).pack("f*"))
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1)
glEnable(GL_LIGHTING)
glEnable(@light_id)
end
def convert(struct, apply_intensity = false)
if apply_intensity
return struct.to_a.compact.map{ |i| i * @intensity }
else
return struct.to_a.compact
end
end
end
end

View File

@@ -0,0 +1,10 @@
class IMICFPS
def initialize(position:, image:, interval: 1_500, time_to_live: 3_000, max_particles: 500)
end
def draw
end
def update
end
end

View File

@@ -1,8 +1,8 @@
class IMICFPS
class CollisionManager
attr_reader :game_state, :collisions
def initialize(game_state:)
@game_state = game_state
attr_reader :map, :collisions
def initialize(map:)
@map = map
@collisions = {}
@aabb_tree = AABBTree.new
@@ -14,7 +14,7 @@ class IMICFPS
end
def update
@game_state.entities.each do |entity|
@map.entities.each do |entity|
next unless entity.is_a?(Entity)
next unless node = @aabb_tree.objects[entity]
@@ -42,9 +42,9 @@ class IMICFPS
@collisions.clear
broadphase = {}
@game_state.entities.each do |entity|
@map.entities.each do |entity|
next unless entity.collidable?
next if entity.collision == :static # Only dynamic entities can be resolved
next if entity.manifest.collision_resolution == :static # Only dynamic entities can be resolved
search = @aabb_tree.search(entity.bounding_box)
if search.size > 0
@@ -56,23 +56,23 @@ class IMICFPS
broadphase.each do |entity, _collisions|
_collisions.each do |ent|
# aabb vs aabb
next unless entity.bounding_box.intersect?(ent.bounding_box)
# next unless entity.bounding_box.intersect?(ent.bounding_box)
# entity model aabb tree vs ent model aabb tree
ent_tree_search = ent.model.aabb_tree.search(localize_entity_bounding_box(entity, ent), true)
next if ent_tree_search.size == 0
# ent_tree_search = ent.model.aabb_tree.search(localize_entity_bounding_box(entity, ent), true)
# next if ent_tree_search.size == 0
# puts "#{ent.class} -> #{ent_tree_search.size} (#{Gosu.milliseconds})"
entity.position.y = ent_tree_search.first.object.vertices.first.y if entity.is_a?(Player) && ent.is_a?(Terrain)
# entity.position.y = ent_tree_search.first.object.vertices.first.y if entity.is_a?(Player) && ent.is_a?(Terrain)
@collisions[entity] = _collisions
# @collisions[entity] = _collisions
end
end
end
# AABBTree on entities is relative to model origin of 0,0,0
def localize_entity_bounding_box(entity, target)
return entity.bounding_box if target.position == 0 && target.rotation == 0
return entity.bounding_box if target.position == 0 && target.orientation == 0
# "tranform" entity bounding box into target's space
local = (target.position) # needs tweaking, works well enough for now
@@ -82,5 +82,29 @@ class IMICFPS
return box
end
def on_ground?(entity) # TODO: Use some form of caching to speed this up
on_ground = false
@collisions.detect do |a, b|
next unless entity == a || entity == b
vs = a
vs = b if a == entity
broadphase = search(Ray.new(entity.position, Vector.down, entity.velocity.y.abs))
broadphase.detect do |ent|
ray = Ray.new(entity.position - ent.position, Vector.down)
if ent.model.aabb_tree.search(ray).size > 0
on_ground = true
return true
end
end
break if on_ground
end
return on_ground
end
end
end

View File

@@ -1,18 +1,29 @@
class IMICFPS
module EntityManager # Get included into GameState context
def add_entity(entity)
@collision_manager.add(entity)# Add every entity to collision manager
@collision_manager.add(entity) if @collision_manager && entity.manifest.collision# Add every entity to collision manager
Publisher.instance.publish(:create, nil, entity)
@entities << entity
end
def insert_entity(package, name, position, orientation, data = {})
ent = MapParser::Entity.new(package, name, position, orientation, Vector.new(1,1,1))
add_entity(IMICFPS::Entity.new(map_entity: ent, manifest: Manifest.new(package: package, name: name)))
end
def find_entity(entity)
@entities.detect {|entity| entity == entity}
end
def find_entity_by(name:)
@entities.detect { |entity| entity.name == name}
end
def remove_entity(entity)
ent = @entities.detect {|entity| entity == entity}
if ent
@collision_manager.remove(entity)
@collision_manager.remove(entity) if @collision_manager && entity.manifest.collision
@publisher.publish(:destroy, nil, entity)
@entities.delete(ent)
end
end
@@ -20,5 +31,8 @@ class IMICFPS
def entities
@entities
end
def insert_particle_emitter(position, texture)
end
end
end

View File

@@ -112,9 +112,12 @@ IMICFPS::InputMapper.set(:strife_right, Gosu::KbD)
IMICFPS::InputMapper.set(:turn_left, Gosu::KbLeft)
IMICFPS::InputMapper.set(:turn_right, Gosu::KbRight)
IMICFPS::InputMapper.set(:jump, Gosu::KbSpace)
IMICFPS::InputMapper.set(:sneak, [Gosu::KbLeftShift])
IMICFPS::InputMapper.set(:sprint, [Gosu::KbLeftControl])
IMICFPS::InputMapper.set(:turn_180, Gosu::KbX)
IMICFPS::InputMapper.set(:interact, Gosu::KbE)
IMICFPS::InputMapper.set(:ascend, Gosu::KbSpace)
IMICFPS::InputMapper.set(:descend, Gosu::KbC)
IMICFPS::InputMapper.set(:toggle_first_person_view, Gosu::KbF)

View File

@@ -20,5 +20,11 @@ class IMICFPS
def clear_lights
@lights.clear
end
def available_light
raise "Using to many lights, #{light_count}/#{LightManager::MAX_LIGHTS}" if light_count > LightManager::MAX_LIGHTS
puts "OpenGL::GL_LIGHT#{light_count}" if $window.config.get(:debug_options, :stats)
Object.const_get "OpenGL::GL_LIGHT#{light_count}"
end
end
end

View File

@@ -15,21 +15,25 @@ class IMICFPS
end
def resolve(entity, other)
if other.is_a?(Terrain)
entity.velocity.y = 0 if entity.velocity.y < 0
else
entity.velocity.y = other.velocity.y if other.velocity.y < entity.velocity.y && entity.velocity.y < 0
end
entity.velocity.y = other.velocity.y if other.velocity.y < entity.velocity.y && entity.velocity.y < 0
end
def simulate
@collision_manager.game_state.entities.each do |entity|
entity.velocity.x *= entity.drag
entity.velocity.z *= entity.drag
@collision_manager.map.entities.each do |entity|
entity.position.x += entity.velocity.x * entity.delta_time
entity.position.y += entity.velocity.y * entity.delta_time
entity.position.z += entity.velocity.z * entity.delta_time
on_ground = @collision_manager.on_ground?(entity)
entity.velocity.x *= entity.drag
entity.velocity.z *= entity.drag
if on_ground
entity.velocity.y = 0
else
entity.velocity.y -= @collision_manager.map.gravity * entity.delta_time if entity.manifest.physics
entity.velocity.y = 0 if entity.velocity.y < 0
end
end
end
end

69
lib/manifest.rb Normal file
View File

@@ -0,0 +1,69 @@
class IMICFPS
class Manifest
attr_reader :name, :model, :collision, :collision_mesh, :collision_resolution, :physics, :scripts, :uses
def initialize(manifest_file: nil, package: nil, name: nil)
unless manifest_file
raise "Entity package not specified!" unless package
raise "Entity name not specified!" unless name
manifest_file = "#{IMICFPS.assets_path}/#{package}/#{name}/manifest.yaml"
end
raise "No manifest found at: #{manifest_file}" unless File.exist?(manifest_file)
@file = manifest_file
parse(manifest_file)
end
def parse(file)
data = YAML.load(File.read(file))
# required
@name = data["name"]
@model = data["model"]
# optional
@collision = data["collision"] ? data["collision"] : nil
@collision_mesh = data["collision_mesh"] ? data["collision_mesh"] : nil
@collision_resolution = data["collision_resolution"] ? data["collision_resolution"].to_sym : :static
@physics = data["physics"] ? data["physics"] : false
@scripts = data["scripts"] ? parse_scripts(data["scripts"]) : []
@uses = data["uses"] ? parse_dependencies(data["uses"]) : [] # List of entities that this Entity uses
end
def parse_scripts(scripts)
list = []
scripts.each do |script|
path = ""
if script.start_with?("!")
script = script.sub("!", "")
path = File.expand_path("../shared/", file_path) + "/scripts/" + script
else
path = "#{file_path}/scripts/#{script}"
end
list << Script.new(script, File.read("#{path}.rb"))
end
return list
end
def parse_dependencies(list)
dependencies = []
list.each do |item|
dependencies << Dependency.new(item["package"], item["name"])
end
return dependencies
end
def file_path
File.expand_path("./../", @file)
end
Script = Struct.new(:name, :source)
Dependency = Struct.new(:package, :name)
end
end

61
lib/map.rb Normal file
View File

@@ -0,0 +1,61 @@
class IMICFPS
class Map
include EntityManager
include LightManager
include CommonMethods
attr_reader :collision_manager
attr_reader :gravity
def initialize(map_parser:, gravity: IMICFPS::EARTH_GRAVITY)
@map_parser = map_parser
@gravity = gravity
@entities = []
@lights = []
@collision_manager = CollisionManager.new(map: self)
@renderer = window.renderer
Publisher.new
end
def setup
add_entity(Terrain.new(map_entity: @map_parser.terrain, manifest: Manifest.new(package: @map_parser.terrain.package, name: @map_parser.terrain.name)))
add_entity(Skydome.new(map_entity: @map_parser.skydome, manifest: Manifest.new(package: @map_parser.skydome.package, name: @map_parser.skydome.name), backface_culling: false))
@map_parser.lights.each do |l|
add_light(Light.new(id: available_light, position: l.position, diffuse: l.diffuse, ambient: l.ambient, specular: l.specular, intensity: l.intensity))
end
@map_parser.entities.each do |ent|
add_entity(Entity.new(map_entity: ent, manifest: Manifest.new(package: ent.package, name: ent.name)))
end
add_entity(Player.new(spawnpoint: @map_parser.spawnpoints.sample, manifest: Manifest.new(package: "base", name: "character")))
end
def data
@map_parser
end
def render(camera)
gl_error?
Gosu.gl do
gl_error?
glClearColor(0,0.2,0.5,1) # skyish blue
gl_error?
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # clear the screen and the depth buffer
gl_error?
@renderer.draw(camera, @lights, @entities)
end
end
def update
@collision_manager.update
@entities.each(&:update)
end
end
end

170
lib/map_parser.rb Normal file
View File

@@ -0,0 +1,170 @@
class IMICFPS
class MapParser
attr_reader :metadata, :terrain, :skydome, :lights, :entities, :spawnpoints
attr_reader :assets, :missing_assets
def initialize(map_file:)
@metadata = MapParser::MetaData.new
@terrain = MapParser::Entity.new
@skydome = MapParser::Entity.new
@lights = []
@entities = []
@spawnpoints = []
@assets = []
@missing_assets = []
parse(map_file)
end
def parse(file)
data = JSON.parse(File.read(file))
if section = data["metadata"]
@metadata.name = section["name"]
@metadata.gamemode = section["gamemode"]
@metadata.authors = section["authors"]
@metadata.datetime = Time.parse(section["datetime"])
@metadata.thumbnail = section["thumbnail"] # TODO: convert thumbnail to Image
@metadata.description = section["description"]
else
raise "Map metadata is missing!"
end
if section = data["terrain"]
@terrain.package = section["package"]
@terrain.name = section["name"]
@terrain.position = Vector.new
@terrain.orientation = Vector.new
if section["scale"]
if section["scale"].is_a?(Hash)
@terrain.scale = Vector.new(
section["scale"]["x"],
section["scale"]["y"],
section["scale"]["z"]
)
else
scale = Float(section["scale"])
@terrain.scale = Vector.new(scale, scale, scale)
end
else
@terrain.scale = Vector.new(1, 1, 1)
end
@terrain.water_level = section["water_level"]
else
raise "Map terrain data is missing!"
end
if section = data["skydome"]
@skydome.package = section["package"]
@skydome.name = section["name"]
@skydome.position = Vector.new
@skydome.orientation = Vector.new
if section["scale"]
if section["scale"].is_a?(Hash)
@skydome.scale = Vector.new(
section["scale"]["x"],
section["scale"]["y"],
section["scale"]["z"]
)
else
scale = Float(section["scale"])
@skydome.scale = Vector.new(scale, scale, scale)
end
else
@skydome.scale = Vector.new(1, 1, 1)
end
else
raise "Map skydome data is missing!"
end
if section = data["lights"]
section.each do |l|
light = MapParser::Light.new
light.type = IMICFPS::Light::POINT # TODO: fix me
light.position = Vector.new(
l["position"]["x"],
l["position"]["y"],
l["position"]["z"]
)
light.diffuse = Color.new(
l["diffuse"]["red"],
l["diffuse"]["green"],
l["diffuse"]["blue"]
)
light.ambient = Color.new(
l["ambient"]["red"],
l["ambient"]["green"],
l["ambient"]["blue"]
)
light.specular = Color.new(
l["specular"]["red"],
l["specular"]["green"],
l["specular"]["blue"]
)
light.intensity = l["intensity"]
@lights << light
end
end
if section = data["entities"]
section.each do |ent|
entity = MapParser::Entity.new
entity.package = ent["package"]
entity.name = ent["name"]
entity.position = Vector.new(
ent["position"]["x"],
ent["position"]["y"],
ent["position"]["z"]
)
entity.orientation = Vector.new(
ent["orientation"]["x"],
ent["orientation"]["y"],
ent["orientation"]["z"]
)
if ent["scale"].is_a?(Hash)
entity.scale = Vector.new(
ent["scale"]["x"],
ent["scale"]["y"],
ent["scale"]["z"]
)
else
scale = Float(ent["scale"])
entity.scale = Vector.new(scale, scale, scale)
end
entity.scripts = ent["scripts"]
@entities << entity
end
else
raise "Map has no entities!"
end
if section = data["spawnpoints"]
section.each do |point|
spawnpoint = SpawnPoint.new
spawnpoint.team = point["team"]
spawnpoint.position = Vector.new(
point["position"]["x"],
point["position"]["y"],
point["position"]["z"]
)
spawnpoint.orientation = Vector.new(
point["orientation"]["x"],
point["orientation"]["y"],
point["orientation"]["z"]
)
@spawnpoints << spawnpoint
end
else
raise "Map has no spawnpoints!"
end
end
MetaData = Struct.new(:name, :gamemode, :authors, :datetime, :thumbnail, :description)
Light = Struct.new(:type, :position, :diffuse, :ambient, :specular, :intensity)
Entity = Struct.new(:package, :name, :position, :orientation, :scale, :water_level, :scripts)
SpawnPoint = Struct.new(:team, :position, :orientation)
end
end

250
lib/model.rb Normal file
View File

@@ -0,0 +1,250 @@
class IMICFPS
class Model
include CommonMethods
attr_accessor :objects, :materials, :vertices, :uvs, :texures, :normals, :faces, :colors, :bones
attr_accessor :scale, :entity, :material_file, :current_material, :current_object, :vertex_count, :smoothing
attr_reader :position, :bounding_box, :textured_material, :file_path
attr_reader :positions_buffer_id, :colors_buffer_id, :normals_buffer_id, :uvs_buffer_id, :textures_buffer_id
attr_reader :vertex_array_id
attr_reader :aabb_tree
def initialize(file_path:, entity: nil)
@file_path = file_path
@entity = entity
update if @entity
@material_file = nil
@current_object = nil
@current_material=nil
@vertex_count = 0
@objects = []
@materials= {}
@vertices = []
@colors = []
@uvs = []
@normals = []
@faces = []
@bones = []
@smoothing= 0
@bounding_box = BoundingBox.new
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)
type = File.basename(file_path).split(".").last.to_sym
parser = Model::Parser.find(type)
unless parser
raise "Unsupported model type '.#{type}', supported models are: #{Model::Parser.supported_formats}"
end
parse(parser)
puts "#{@file_path.split('/').last} took #{((Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)-start_time)/1000.0).round(2)} seconds to parse" if window.config.get(:debug_options, :stats)
@has_texture = false
@materials.each do |key, material|
if material.texture_id
@has_texture = true
@textured_material = key
end
end
allocate_gl_objects
populate_vertex_buffer
configure_vao
@objects.each {|o| @vertex_count+=o.vertices.size}
@objects.each_with_index do |o, i|
puts " Model::Object Name: #{o.name}, Vertices: #{o.vertices.size}" if window.config.get(:debug_options, :stats)
end
window.number_of_vertices+=@vertex_count
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)
# build_collision_tree
puts " Building mesh collision tree took #{((Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)-start_time)/1000.0).round(2)} seconds" if window.config.get(:debug_options, :stats)
end
def parse(parser)
parser.new(self).parse
end
def calculate_bounding_box(vertices, bounding_box)
unless bounding_box.min.x.is_a?(Float)
vertex = vertices.last
bounding_box.min.x = vertex.x
bounding_box.min.y = vertex.y
bounding_box.min.z = vertex.z
bounding_box.max.x = vertex.x
bounding_box.max.y = vertex.y
bounding_box.max.z = vertex.z
end
vertices.each do |vertex|
bounding_box.min.x = vertex.x if vertex.x <= bounding_box.min.x
bounding_box.min.y = vertex.y if vertex.y <= bounding_box.min.y
bounding_box.min.z = vertex.z if vertex.z <= bounding_box.min.z
bounding_box.max.x = vertex.x if vertex.x >= bounding_box.max.x
bounding_box.max.y = vertex.y if vertex.y >= bounding_box.max.y
bounding_box.max.z = vertex.z if vertex.z >= bounding_box.max.z
end
end
def allocate_gl_objects
# Allocate arrays for future use
@vertex_array_id = nil
buffer = " " * 4
glGenVertexArrays(1, buffer)
@vertex_array_id = buffer.unpack('L2').first
# Allocate buffers for future use
@positions_buffer_id = nil
buffer = " " * 4
glGenBuffers(1, buffer)
@positions_buffer_id = buffer.unpack('L2').first
@colors_buffer_id = nil
buffer = " " * 4
glGenBuffers(1, buffer)
@colors_buffer_id = buffer.unpack('L2').first
@normals_buffer_id = nil
buffer = " " * 4
glGenBuffers(1, buffer)
@normals_buffer_id = buffer.unpack('L2').first
@uvs_buffer_id = nil
buffer = " " * 4
glGenBuffers(1, buffer)
@uvs_buffer_id = buffer.unpack('L2').first
@textures_buffer_id = nil
buffer = " " * 4
glGenBuffers(1, buffer)
@textures_buffer_id = buffer.unpack('L2').first
end
def populate_vertex_buffer
pos = []
colors = []
norms = []
uvs = []
tex_ids = []
@faces.each do |face|
pos << face.vertices.map { |vert| [vert.x, vert.y, vert.z] }
colors << face.colors.map { |color| [color.red, color.green, color.blue] }
norms << face.normals.map { |vert| [vert.x, vert.y, vert.z, vert.weight] }
if has_texture?
uvs << face.uvs.map { |vert| [vert.x, vert.y, vert.z] }
tex_ids << face.material.texture_id ? face.material.texture_id.to_f : -1.0
end
end
glBindBuffer(GL_ARRAY_BUFFER, @positions_buffer_id)
glBufferData(GL_ARRAY_BUFFER, pos.flatten.size * Fiddle::SIZEOF_FLOAT, pos.flatten.pack("f*"), GL_STATIC_DRAW)
glBindBuffer(GL_ARRAY_BUFFER, @colors_buffer_id)
glBufferData(GL_ARRAY_BUFFER, colors.flatten.size * Fiddle::SIZEOF_FLOAT, colors.flatten.pack("f*"), GL_STATIC_DRAW)
glBindBuffer(GL_ARRAY_BUFFER, @normals_buffer_id)
glBufferData(GL_ARRAY_BUFFER, norms.flatten.size * Fiddle::SIZEOF_FLOAT, norms.flatten.pack("f*"), GL_STATIC_DRAW)
if has_texture?
glBindBuffer(GL_ARRAY_BUFFER, @uvs_buffer_id)
glBufferData(GL_ARRAY_BUFFER, uvs.flatten.size * Fiddle::SIZEOF_FLOAT, uvs.flatten.pack("f*"), GL_STATIC_DRAW)
# glBindBuffer(GL_ARRAY_BUFFER, @textures_buffer_id)
# glBufferData(GL_ARRAY_BUFFER, tex_ids.flatten.size * Fiddle::SIZEOF_FLOAT, tex_ids.flatten.pack("f*"), GL_STATIC_DRAW)
end
glBindBuffer(GL_ARRAY_BUFFER, 0)
end
def configure_vao
glBindVertexArray(@vertex_array_id)
gl_error?
# index, size, type, normalized, stride, pointer
# vertices (positions)
glBindBuffer(GL_ARRAY_BUFFER, @positions_buffer_id)
gl_error?
# inPosition
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nil)
gl_error?
# colors
glBindBuffer(GL_ARRAY_BUFFER, @colors_buffer_id)
# inColor
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, nil)
gl_error?
# normals
glBindBuffer(GL_ARRAY_BUFFER, @normals_buffer_id)
# inNormal
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, 0, nil)
gl_error?
if has_texture?
# uvs
glBindBuffer(GL_ARRAY_BUFFER, @uvs_buffer_id)
# inUV
glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, 0, nil)
gl_error?
# texture ids
glBindBuffer(GL_ARRAY_BUFFER, @textures_buffer_id)
# inTextureID
glVertexAttribPointer(4, 1, GL_FLOAT, GL_FALSE, 0, nil)
gl_error?
end
glBindBuffer(GL_ARRAY_BUFFER, 0)
glBindVertexArray(0)
end
def build_collision_tree
@aabb_tree = AABBTree.new
@faces.each do |face|
box = BoundingBox.new
box.min = face.vertices.first.dup
box.max = face.vertices.first.dup
face.vertices.each do |vertex|
if vertex.sum < box.min.sum
box.min = vertex.dup
elsif vertex.sum > box.max.sum
box.max = vertex.dup
end
end
# FIXME: Handle negatives
box.min *= 1.5
box.max *= 1.5
@aabb_tree.insert(face, box)
end
puts @aabb_tree.inspect if window.config.get(:debug_options, :stats)
end
def update
@position = @entity.position
@scale = @entity.scale
end
def has_texture?
@has_texture
end
def release_gl_resources
if @vertex_array_id
end
end
end
end

20
lib/model/material.rb Normal file
View File

@@ -0,0 +1,20 @@
class IMICFPS
class Model
class Material
attr_accessor :name, :ambient, :diffuse, :specular
attr_reader :texture_id
def initialize(name)
@name = name
@ambient = Color.new(1, 1, 1, 1)
@diffuse = Color.new(1, 1, 1, 1)
@specular= Color.new(1, 1, 1, 1)
@texture = nil
@texture_id = nil
end
def set_texture(texture_path)
@texture_id = Texture.new(path: texture_path).id
end
end
end
end

View File

@@ -1,10 +1,11 @@
class IMICFPS
class Wavefront
class Object
attr_reader :name, :vertices, :textures, :normals, :bounding_box, :debug_color
class Model
class ModelObject
attr_reader :id, :name, :vertices, :textures, :normals, :bounding_box, :debug_color
attr_accessor :faces, :scale
def initialize(name)
def initialize(id, name)
@id = id
@name = name
@vertices = []
@textures = []

69
lib/model/parser.rb Normal file
View File

@@ -0,0 +1,69 @@
class IMICFPS
class Model
class Parser
@@parsers = []
def self.handles
raise NotImplementedError, "Model::Parser#handles must return an array of file extensions that this parser supports"
end
def self.inherited(parser)
@@parsers << parser
end
def self.find(file_type)
found_parser = @@parsers.find do |parser|
parser.handles.include?(file_type)
end
return found_parser
end
def self.supported_formats
@@parsers.map { |parser| parser.handles }.flatten.map { |s| ".#{s}" }.join(", ")
end
def initialize(model)
@model = model
end
def parse
end
def set_object(id: nil, name: nil)
_model = nil
if id
_model = @model.objects.find { |o| o.id == id }
elsif name
_model = @model.objects.find { |o| o.name == name }
else
raise "Must provide either an id: or name:"
end
if _model
@model.current_object = _model
else
raise "Couldn't find ModelObject!"
end
end
def change_object(id, name)
@model.objects << Model::ModelObject.new(id, name)
@model.current_object = @model.objects.last
end
def set_material(name)
@model.current_material = name
end
def add_material(name, material)
@model.materials[name] = material
end
def current_material
@model.materials[@model.current_material]
end
end
end
end

View File

@@ -0,0 +1,119 @@
class IMICFPS
class ColladaParser < Model::Parser
def self.handles
[:dae]
end
def parse
@collada = Nokogiri::XML(File.read(@model.file_path))
@collada.css("library_materials material").each do |material|
parse_material(material)
end
@collada.css("library_geometries geometry").each do |geometry|
parse_geometry(geometry)
end
@model.calculate_bounding_box(@model.vertices, @model.bounding_box)
@model.objects.each do |o|
@model.calculate_bounding_box(o.vertices, o.bounding_box)
end
end
def parse_material(material)
name = material.attributes["id"].value
effect_id = material.at_css("instance_effect").attributes["url"].value
mat = Model::Material.new(name)
effect = @collada.at_css("[id=\"#{effect_id.sub('#', '')}\"]")
emission = effect.at_css("emission color")
diffuse = effect.at_css("diffuse color").children.first.to_s.split(" ").map { |c| Float(c) }
mat.diffuse = Color.new(*diffuse[0..2])
add_material(name, mat)
end
def parse_geometry(geometry)
geometry_id = geometry.attributes["id"].value
geometry_name = geometry.attributes["name"].value
change_object(geometry_id, geometry_name)
mesh = geometry.at_css("mesh")
get_positions(geometry_id, mesh)
get_normals(geometry_id, mesh)
get_texture_coordinates(geometry_id, mesh)
build_faces(geometry_id, mesh)
end
def get_positions(id, mesh)
positions = mesh.at_css("[id=\"#{id}-positions\"]")
array = positions.at_css("[id=\"#{id}-positions-array\"]")
stride = Integer(positions.at_css("[source=\"##{id}-positions-array\"]").attributes["stride"].value)
list = array.children.first.to_s.split(" ").map{ |f| Float(f) }.each_slice(stride).each do |slice|
position = Vector.new(*slice)
@model.current_object.vertices << position
@model.vertices << position
end
end
def get_normals(id, mesh)
normals = mesh.at_css("[id=\"#{id}-normals\"]")
array = normals.at_css("[id=\"#{id}-normals-array\"]")
stride = Integer(normals.at_css("[source=\"##{id}-normals-array\"]").attributes["stride"].value)
list = array.children.first.to_s.split(" ").map{ |f| Float(f) }.each_slice(stride).each do |slice|
normal = Vector.new(*slice)
@model.current_object.normals << normal
@model.normals << normal
end
end
def get_texture_coordinates(id, mesh)
end
def build_faces(id, mesh)
material_name = mesh.at_css("triangles").attributes["material"].value
set_material(material_name)
positions_index = []
normals_index = []
uvs_index = []
mesh.at_css("triangles p").children.first.to_s.split(" ").map { |i| Integer(i) }.each_slice(3).each do |slice|
positions_index << slice[0]
normals_index << slice[1]
uvs_index << slice[2]
end
norm_index = 0
positions_index.each_slice(3) do |slice|
face = Face.new
face.vertices = []
face.uvs = []
face.normals = []
face.colors = []
face.material = current_material
face.smoothing= @model.smoothing
slice.each do |index|
face.vertices << @model.vertices[index]
# face.uvs << @model.uvs[index]
face.normals << @model.normals[normals_index[norm_index]]
face.colors << current_material.diffuse
norm_index += 1
end
@model.current_object.faces << face
@model.faces << face
end
end
end
end

View File

@@ -0,0 +1,157 @@
class IMICFPS
class WavefrontParser < Model::Parser
def self.handles
[:obj]
end
def parse
lines = 0
list = File.read(@model.file_path).split("\n")
list.each do |line|
lines+=1
line = line.strip
array = line.split(' ')
case array[0]
when 'mtllib'
@model.material_file = array[1]
parse_mtllib
when 'usemtl'
set_material(array[1])
when 'o'
change_object(nil, array[1])
when 's'
set_smoothing(array[1])
when 'v'
add_vertex(array)
when 'vt'
add_texture_coordinate(array)
when 'vn'
add_normal(array)
when 'f'
verts = []
uvs = []
norms = []
array[1..3].each do |f|
verts << f.split("/")[0]
uvs << f.split("/")[1]
norms << f.split("/")[2]
end
face = Face.new
face.vertices = []
face.uvs = []
face.normals = []
face.colors = []
face.material = current_material
face.smoothing= @model.smoothing
mat = face.material.diffuse
color = mat
verts.each_with_index do |v, index|
if uvs.first != ""
face.vertices << @model.vertices[Integer(v)-1]
face.uvs << @model.uvs[Integer(uvs[index])-1]
face.normals << @model.normals[Integer(norms[index])-1]
face.colors << color
else
face.vertices << @model.vertices[Integer(v)-1]
face.uvs << nil
face.normals << @model.normals[Integer(norms[index])-1]
face.colors << color
end
end
@model.current_object.faces << face
@model.faces << face
end
end
puts "Total Lines: #{lines}" if $window.config.get(:debug_options, :stats)
@model.calculate_bounding_box(@model.vertices, @model.bounding_box)
@model.objects.each do |o|
@model.calculate_bounding_box(o.vertices, o.bounding_box)
end
end
def parse_mtllib
file = File.open(@model.file_path.sub(File.basename(@model.file_path), '')+@model.material_file, 'r')
file.readlines.each do |line|
array = line.strip.split(' ')
case array.first
when 'newmtl'
material = Model::Material.new(array.last)
@model.current_material = array.last
@model.materials[array.last] = material
when 'Ns' # Specular Exponent
when 'Ka' # Ambient color
@model.materials[@model.current_material].ambient = Color.new(Float(array[1]), Float(array[2]), Float(array[3]))
when 'Kd' # Diffuse color
@model.materials[@model.current_material].diffuse = Color.new(Float(array[1]), Float(array[2]), Float(array[3]))
when 'Ks' # Specular color
@model.materials[@model.current_material].specular = Color.new(Float(array[1]), Float(array[2]), Float(array[3]))
when 'Ke' # Emissive
when 'Ni' # Unknown (Blender Specific?)
when 'd' # Dissolved (Transparency)
when 'illum' # Illumination model
when 'map_Kd' # Diffuse texture
texture = File.basename(array[1])
texture_path = "#{File.expand_path("../../", @model.file_path)}/textures/#{texture}"
@model.materials[@model.current_material].set_texture(texture_path)
end
end
end
def set_smoothing(value)
if value == "1"
@model.smoothing = true
else
@model.smoothing = false
end
end
def add_vertex(array)
@model.vertex_count+=1
vert = nil
if array.size == 5
vert = Vector.new(Float(array[1]), Float(array[2]), Float(array[3]), Float(array[4]))
elsif array.size == 4
vert = Vector.new(Float(array[1]), Float(array[2]), Float(array[3]), 1.0)
else
raise
end
@model.current_object.vertices << vert
@model.vertices << vert
end
def add_normal(array)
vert = nil
if array.size == 5
vert = Vector.new(Float(array[1]), Float(array[2]), Float(array[3]), Float(array[4]))
elsif array.size == 4
vert = Vector.new(Float(array[1]), Float(array[2]), Float(array[3]), 1.0)
else
raise
end
@model.current_object.normals << vert
@model.normals << vert
end
def add_texture_coordinate(array)
texture = nil
if array.size == 4
texture = Vector.new(Float(array[1]), 1-Float(array[2]), Float(array[3]))
elsif array.size == 3
texture = Vector.new(Float(array[1]), 1-Float(array[2]), 1.0)
else
raise
end
@model.current_object.textures << texture
@model.uvs << texture
end
end
end

43
lib/model_cache.rb Normal file
View File

@@ -0,0 +1,43 @@
class IMICFPS
class ModelCache
CACHE = {}
attr_reader :model, :name, :debug_color
def initialize(manifest:, entity: nil)
@name = manifest.name
@model_file = model_file = manifest.file_path + "/model/#{manifest.model}"
@type = File.basename(@model_file).split(".").last.to_sym
@debug_color = Color.new(0.0, 1.0, 0.0)
@model = nil
unless load_model_from_cache
@model = IMICFPS::Model.new(file_path: @model_file)
cache_model
end
return self
end
def load_model_from_cache
found = false
if CACHE[@type].is_a?(Hash)
if CACHE[@type][@model_file]
@model = CACHE[@type][@model_file]#.dup # Don't know why, but adding .dup improves performance with Sponza (1 fps -> 20 fps)
puts "Used cached model for: #{@model_file.split('/').last}" if $window.config.get(:debug_options, :stats)
found = true
end
end
return found
end
def cache_model
CACHE[@type] = {} unless CACHE[@type].is_a?(Hash)
CACHE[@type][@model_file] = @model
end
end
end

Some files were not shown because too many files have changed in this diff Show More