mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-12 02:02:20 +00:00
fbx loader improvements
This commit is contained in:
Generated
+102
-102
@@ -6,13 +6,13 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="1932b2c4-d6ff-413c-9558-19959667326b" name="Default Changelist" comment="scene graph">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/engine/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/engine/mod.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/main.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/math/ray.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/math/ray.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/physics/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/physics/mod.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/renderer/surface.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/renderer/surface.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/resource/fbx/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/resource/fbx/mod.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/scene/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/scene/mod.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/scene/node.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/scene/node.rs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/utils/pool.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/utils/pool.rs" afterDir="false" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/target/" />
|
||||
<ignored path="$PROJECT_DIR$/out/" />
|
||||
@@ -27,8 +27,8 @@
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/physics/mod.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="527">
|
||||
<caret line="142" lean-forward="true" selection-start-line="142" selection-end-line="142" />
|
||||
<state relative-caret-position="395">
|
||||
<caret line="147" column="38" selection-start-line="147" selection-start-column="38" selection-end-line="147" selection-end-column="38" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@@ -36,8 +36,8 @@
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/scene/node.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="327">
|
||||
<caret line="106" column="11" selection-start-line="106" selection-start-column="11" selection-end-line="106" selection-end-column="11" />
|
||||
<state relative-caret-position="666">
|
||||
<caret line="291" column="35" selection-start-line="291" selection-start-column="35" selection-end-line="291" selection-end-column="35" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@@ -45,44 +45,35 @@
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/scene/mod.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="429">
|
||||
<caret line="107" column="23" selection-start-line="107" selection-start-column="23" selection-end-line="107" selection-end-column="23" />
|
||||
<state relative-caret-position="456">
|
||||
<caret line="127" column="46" selection-start-line="127" selection-start-column="46" selection-end-line="127" selection-end-column="46" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/src/rust/src/libcore/cmp.rs">
|
||||
<entry file="file://$PROJECT_DIR$/src/utils/pool.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="335">
|
||||
<caret line="1008" column="11" selection-start-line="1008" selection-start-column="11" selection-end-line="1008" selection-end-column="11" />
|
||||
<state relative-caret-position="68">
|
||||
<caret line="4" lean-forward="true" selection-start-line="4" selection-end-line="4" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/src/rust/src/libcore/ops/arith.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="930">
|
||||
<caret line="515" column="7" selection-start-line="515" selection-start-column="7" selection-end-line="515" selection-end-column="7" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/math/ray.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="527">
|
||||
<caret line="31" column="19" selection-start-line="31" selection-start-column="19" selection-end-line="31" selection-end-column="19" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/resource/fbx/mod.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1534">
|
||||
<caret line="1045" column="19" lean-forward="true" selection-start-line="1045" selection-start-column="19" selection-end-line="1045" selection-end-column="19" />
|
||||
<state relative-caret-position="286">
|
||||
<caret line="1118" column="13" lean-forward="true" selection-start-line="1118" selection-start-column="13" selection-end-line="1118" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/src/rust/src/libcore/time.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="335">
|
||||
<caret line="326" column="17" selection-start-line="326" selection-start-column="17" selection-end-line="326" selection-end-column="17" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@@ -90,17 +81,26 @@
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/renderer/renderer.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="335">
|
||||
<state relative-caret-position="3128">
|
||||
<caret line="184" column="31" selection-start-line="184" selection-start-column="31" selection-end-line="184" selection-end-column="31" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="408">
|
||||
<caret line="24" lean-forward="true" selection-start-line="24" selection-end-line="24" />
|
||||
<state relative-caret-position="2452">
|
||||
<caret line="260" column="17" lean-forward="true" selection-start-line="260" selection-start-column="17" selection-end-line="260" selection-end-column="17" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/engine/mod.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="599">
|
||||
<caret line="113" column="26" lean-forward="true" selection-start-line="113" selection-start-column="26" selection-end-line="113" selection-end-column="26" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@@ -108,8 +108,8 @@
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/renderer/surface.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="272">
|
||||
<caret line="51" column="13" selection-start-line="51" selection-start-column="13" selection-end-line="51" selection-end-column="13" />
|
||||
<state relative-caret-position="677">
|
||||
<caret line="332" column="51" lean-forward="true" selection-start-line="332" selection-start-column="51" selection-end-line="332" selection-end-column="51" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@@ -160,21 +160,21 @@
|
||||
<option value="$PROJECT_DIR$/src/math/quat.rs" />
|
||||
<option value="$PROJECT_DIR$/src/math/vec2.rs" />
|
||||
<option value="$PROJECT_DIR$/src/math/vec4.rs" />
|
||||
<option value="$PROJECT_DIR$/src/engine/mod.rs" />
|
||||
<option value="$PROJECT_DIR$/src/renderer/renderer.rs" />
|
||||
<option value="$PROJECT_DIR$/src/utils/pool.rs" />
|
||||
<option value="$PROJECT_DIR$/src/math/mod.rs" />
|
||||
<option value="$PROJECT_DIR$/src/math/vec3.rs" />
|
||||
<option value="$PROJECT_DIR$/src/math/mat4.rs" />
|
||||
<option value="$PROJECT_DIR$/src/math/plane.rs" />
|
||||
<option value="$PROJECT_DIR$/src/math/triangulator.rs" />
|
||||
<option value="$PROJECT_DIR$/src/scene/node.rs" />
|
||||
<option value="$PROJECT_DIR$/src/math/ray.rs" />
|
||||
<option value="$PROJECT_DIR$/src/engine/mod.rs" />
|
||||
<option value="$PROJECT_DIR$/src/scene/mod.rs" />
|
||||
<option value="$PROJECT_DIR$/src/renderer/surface.rs" />
|
||||
<option value="$PROJECT_DIR$/src/resource/fbx/mod.rs" />
|
||||
<option value="$PROJECT_DIR$/src/scene/node.rs" />
|
||||
<option value="$PROJECT_DIR$/src/utils/pool.rs" />
|
||||
<option value="$PROJECT_DIR$/src/physics/mod.rs" />
|
||||
<option value="$PROJECT_DIR$/src/renderer/surface.rs" />
|
||||
<option value="$PROJECT_DIR$/src/main.rs" />
|
||||
<option value="$PROJECT_DIR$/src/resource/fbx/mod.rs" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
@@ -196,6 +196,7 @@
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="Scope" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
@@ -266,12 +267,11 @@
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="Scope" />
|
||||
<pane id="PackagesPane" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1561057533857" />
|
||||
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1561193564344" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/../Program Files/Git/bin/git.exe" />
|
||||
<property name="org.rust.cargo.project.model.PROJECT_DISCOVERY" value="true" />
|
||||
<property name="project.structure.last.edited" value="Project" />
|
||||
@@ -393,7 +393,7 @@
|
||||
<frame x="0" y="0" width="1435" height="1400" extended-state="0" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.16218182" />
|
||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.16654545" />
|
||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||
<window_info id="Image Layers" order="2" />
|
||||
<window_info id="Designer" order="3" />
|
||||
@@ -416,9 +416,9 @@
|
||||
<window_info anchor="right" id="Palette" order="3" />
|
||||
<window_info anchor="right" id="Maven" order="4" weight="0.3295082" />
|
||||
<window_info anchor="right" id="Theme Preview" order="5" />
|
||||
<window_info anchor="right" id="Cargo" order="6" weight="0.3295082" />
|
||||
<window_info anchor="right" id="Capture Analysis" order="7" />
|
||||
<window_info anchor="right" id="Palette	" order="8" />
|
||||
<window_info anchor="right" id="Capture Analysis" order="6" />
|
||||
<window_info anchor="right" id="Palette	" order="7" />
|
||||
<window_info anchor="right" id="Cargo" order="8" weight="0.32945454" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
@@ -432,13 +432,6 @@
|
||||
<option name="FILTER_TARGETS" value="false" />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.21.0/src/lib.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="527">
|
||||
<caret line="61" column="36" selection-start-line="61" selection-start-column="35" selection-end-line="61" selection-end-column="36" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.21.0/src/dynimage.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="403">
|
||||
@@ -649,13 +642,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/utils/pool.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="17">
|
||||
<caret line="1" column="30" selection-start-line="1" selection-start-column="30" selection-end-line="1" selection-end-column="30" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/math/mod.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1632">
|
||||
@@ -663,13 +649,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/engine/mod.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="408">
|
||||
<caret line="24" selection-start-line="24" selection-end-line="24" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/resource/mod.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="187">
|
||||
@@ -736,6 +715,20 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/src/rust/src/libcore/cmp.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="17136">
|
||||
<caret line="1008" column="11" selection-start-line="1008" selection-start-column="11" selection-end-line="1008" selection-end-column="11" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/src/rust/src/libcore/ops/arith.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="8755">
|
||||
<caret line="515" column="7" selection-start-line="515" selection-start-column="7" selection-end-line="515" selection-end-column="7" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/math/ray.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="527">
|
||||
@@ -743,66 +736,73 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/src/rust/src/libcore/cmp.rs">
|
||||
<entry file="file://$PROJECT_DIR$/src/renderer/renderer.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="335">
|
||||
<caret line="1008" column="11" selection-start-line="1008" selection-start-column="11" selection-end-line="1008" selection-end-column="11" />
|
||||
<state relative-caret-position="3128">
|
||||
<caret line="184" column="31" selection-start-line="184" selection-start-column="31" selection-end-line="184" selection-end-column="31" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/scene/mod.rs">
|
||||
<entry file="file://$PROJECT_DIR$/src/engine/mod.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="429">
|
||||
<caret line="107" column="23" selection-start-line="107" selection-start-column="23" selection-end-line="107" selection-end-column="23" />
|
||||
<state relative-caret-position="599">
|
||||
<caret line="113" column="26" lean-forward="true" selection-start-line="113" selection-start-column="26" selection-end-line="113" selection-end-column="26" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/scene/node.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="327">
|
||||
<caret line="106" column="11" selection-start-line="106" selection-start-column="11" selection-end-line="106" selection-end-column="11" />
|
||||
<state relative-caret-position="666">
|
||||
<caret line="291" column="35" selection-start-line="291" selection-start-column="35" selection-end-line="291" selection-end-column="35" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/renderer/renderer.rs">
|
||||
<entry file="file://$PROJECT_DIR$/src/scene/mod.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="335">
|
||||
<caret line="184" column="31" selection-start-line="184" selection-start-column="31" selection-end-line="184" selection-end-column="31" />
|
||||
<state relative-caret-position="456">
|
||||
<caret line="127" column="46" selection-start-line="127" selection-start-column="46" selection-end-line="127" selection-end-column="46" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/renderer/surface.rs">
|
||||
<entry file="file://$PROJECT_DIR$/src/utils/pool.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="272">
|
||||
<caret line="51" column="13" selection-start-line="51" selection-start-column="13" selection-end-line="51" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/src/rust/src/libcore/ops/arith.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="930">
|
||||
<caret line="515" column="7" selection-start-line="515" selection-start-column="7" selection-end-line="515" selection-end-column="7" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/resource/fbx/mod.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1534">
|
||||
<caret line="1045" column="19" lean-forward="true" selection-start-line="1045" selection-start-column="19" selection-end-line="1045" selection-end-column="19" />
|
||||
<state relative-caret-position="68">
|
||||
<caret line="4" lean-forward="true" selection-start-line="4" selection-end-line="4" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/physics/mod.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="527">
|
||||
<caret line="142" lean-forward="true" selection-start-line="142" selection-end-line="142" />
|
||||
<state relative-caret-position="395">
|
||||
<caret line="147" column="38" selection-start-line="147" selection-start-column="38" selection-end-line="147" selection-end-column="38" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/renderer/surface.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="677">
|
||||
<caret line="332" column="51" lean-forward="true" selection-start-line="332" selection-start-column="51" selection-end-line="332" selection-end-column="51" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="408">
|
||||
<caret line="24" lean-forward="true" selection-start-line="24" selection-end-line="24" />
|
||||
<state relative-caret-position="2452">
|
||||
<caret line="260" column="17" lean-forward="true" selection-start-line="260" selection-start-column="17" selection-end-line="260" selection-end-column="17" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/src/rust/src/libcore/time.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="335">
|
||||
<caret line="326" column="17" selection-start-line="326" selection-start-column="17" selection-end-line="326" selection-end-column="17" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/resource/fbx/mod.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="286">
|
||||
<caret line="1118" column="13" lean-forward="true" selection-start-line="1118" selection-start-column="13" selection-end-line="1118" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
||||
+2
-2
@@ -105,13 +105,13 @@ impl Engine {
|
||||
&mut self.resource_manager
|
||||
}
|
||||
|
||||
pub fn update(&mut self) {
|
||||
pub fn update(&mut self, dt: f64) {
|
||||
let client_size = self.renderer.context.get_inner_size().unwrap();
|
||||
let aspect_ratio = (client_size.width / client_size.height) as f32;
|
||||
|
||||
for i in 0..self.scenes.capacity() {
|
||||
if let Some(scene) = self.scenes.at_mut(i) {
|
||||
scene.update(aspect_ratio);
|
||||
scene.update(aspect_ratio, dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+36
-36
@@ -22,6 +22,7 @@ use scene::node::*;
|
||||
use scene::*;
|
||||
use engine::*;
|
||||
use crate::physics::{Body, StaticGeometry, StaticTriangle};
|
||||
use std::time::{Instant, Duration};
|
||||
|
||||
pub struct Controller {
|
||||
move_forward: bool,
|
||||
@@ -45,7 +46,7 @@ pub struct Player {
|
||||
impl Player {
|
||||
pub fn new(scene: &mut Scene) -> Player {
|
||||
let mut camera = Node::new(NodeKind::Camera(Camera::default()));
|
||||
camera.set_local_position(Vec3 { x: 0.0, y: 2.0, z: 0.0 });
|
||||
camera.set_local_position(Vec3 { x: 0.0, y: 1.0, z: 0.0 });
|
||||
|
||||
let mut pivot = Node::new(NodeKind::Base);
|
||||
pivot.set_local_position(Vec3 { x: -1.0, y: 0.0, z: 1.0 });
|
||||
@@ -103,6 +104,8 @@ impl Player {
|
||||
}
|
||||
|
||||
if let Some(normalized_velocity) = velocity.normalized() {
|
||||
body.set_x_velocity(0.0);
|
||||
body.set_z_velocity(0.0);
|
||||
body.move_by(normalized_velocity.scale(self.move_speed));
|
||||
}
|
||||
}
|
||||
@@ -178,16 +181,10 @@ impl Player {
|
||||
pub struct Level {
|
||||
scene: Handle<Scene>,
|
||||
player: Player,
|
||||
|
||||
// Test stuff
|
||||
cubes: Vec<Handle<Node>>,
|
||||
angle: f32,
|
||||
}
|
||||
|
||||
impl Level {
|
||||
pub fn new(engine: &mut Engine) -> Level {
|
||||
let mut cubes: Vec<Handle<Node>> = Vec::new();
|
||||
|
||||
// Create test scene
|
||||
let mut scene = Scene::new();
|
||||
|
||||
@@ -248,23 +245,12 @@ impl Level {
|
||||
|
||||
Level {
|
||||
player,
|
||||
cubes,
|
||||
angle: 0.0,
|
||||
scene: engine.add_scene(scene),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(&mut self, engine: &mut Engine) {
|
||||
self.angle += 0.1;
|
||||
|
||||
let rotation = Quat::from_axis_angle(Vec3 { x: 0.0, y: 1.0, z: 0.0 }, self.angle);
|
||||
pub fn update(&mut self, engine: &mut Engine, dt: f64) {
|
||||
if let Some(scene) = engine.borrow_scene_mut(&self.scene) {
|
||||
for node_handle in self.cubes.iter() {
|
||||
if let Some(node) = scene.borrow_node_mut(node_handle) {
|
||||
node.set_local_rotation(rotation);
|
||||
}
|
||||
}
|
||||
|
||||
self.player.update(scene);
|
||||
}
|
||||
}
|
||||
@@ -275,6 +261,10 @@ pub struct Game {
|
||||
level: Level,
|
||||
}
|
||||
|
||||
fn duration_to_seconds_f64(duration: Duration) -> f64 {
|
||||
duration.as_secs() as f64 + duration.subsec_nanos() as f64 / 1_000_000_000.0
|
||||
}
|
||||
|
||||
impl Game {
|
||||
pub fn new() -> Game {
|
||||
let mut engine = Engine::new();
|
||||
@@ -285,31 +275,41 @@ impl Game {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(&mut self) {
|
||||
self.level.update(&mut self.engine);
|
||||
pub fn update(&mut self, dt: f64) {
|
||||
self.level.update(&mut self.engine, dt);
|
||||
}
|
||||
|
||||
pub fn run(&mut self) {
|
||||
let fixed_fps = 60.0;
|
||||
let fixed_timestep = 1.0 / fixed_fps;
|
||||
let clock = Instant::now();
|
||||
let mut game_time = 0.0;
|
||||
while self.engine.is_running() {
|
||||
self.engine.poll_events();
|
||||
while let Some(event) = self.engine.pop_event() {
|
||||
if let glutin::Event::WindowEvent { event, .. } = event {
|
||||
self.level.player.process_event(&event);
|
||||
match event {
|
||||
glutin::WindowEvent::CloseRequested => self.engine.stop(),
|
||||
glutin::WindowEvent::KeyboardInput {
|
||||
input: glutin::KeyboardInput {
|
||||
virtual_keycode: Some(glutin::VirtualKeyCode::Escape),
|
||||
let mut dt = duration_to_seconds_f64(clock.elapsed()) - game_time;
|
||||
while dt >= fixed_timestep {
|
||||
dt -= fixed_timestep;
|
||||
game_time += fixed_timestep;
|
||||
self.engine.poll_events();
|
||||
while let Some(event) = self.engine.pop_event() {
|
||||
if let glutin::Event::WindowEvent { event, .. } = event {
|
||||
self.level.player.process_event(&event);
|
||||
match event {
|
||||
glutin::WindowEvent::CloseRequested => self.engine.stop(),
|
||||
glutin::WindowEvent::KeyboardInput {
|
||||
input: glutin::KeyboardInput {
|
||||
virtual_keycode: Some(glutin::VirtualKeyCode::Escape),
|
||||
..
|
||||
},
|
||||
..
|
||||
},
|
||||
..
|
||||
} => self.engine.stop(),
|
||||
_ => ()
|
||||
} => self.engine.stop(),
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
self.update(fixed_timestep);
|
||||
self.engine.update(fixed_timestep);
|
||||
}
|
||||
self.update();
|
||||
self.engine.update();
|
||||
// Render at max speed
|
||||
self.engine.render();
|
||||
}
|
||||
}
|
||||
|
||||
+17
-1
@@ -99,7 +99,7 @@ impl Body {
|
||||
position: Vec3::zero(),
|
||||
last_position: Vec3::zero(),
|
||||
acceleration: Vec3::zero(),
|
||||
friction: 0.965,
|
||||
friction: 0.94,
|
||||
gravity: Vec3::make(0.0, -9.81, 0.0),
|
||||
radius: 1.0,
|
||||
sqr_radius: 1.0,
|
||||
@@ -134,6 +134,21 @@ impl Body {
|
||||
self.radius
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_x_velocity(&mut self, x: f32) {
|
||||
self.last_position.x = self.position.x - x;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_y_velocity(&mut self, y: f32) {
|
||||
self.last_position.y = self.position.y - y;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_z_velocity(&mut self, z: f32) {
|
||||
self.last_position.z = self.position.z - z;
|
||||
}
|
||||
|
||||
pub fn verlet(&mut self, sqr_delta_time: f32, air_friction: f32) {
|
||||
let friction = if self.contacts.len() > 0 {
|
||||
1.0 - self.friction
|
||||
@@ -146,6 +161,7 @@ impl Body {
|
||||
|
||||
let last_position = self.position;
|
||||
|
||||
// Verlet integration
|
||||
self.position = Vec3 {
|
||||
x: k1 * self.position.x - k2 * self.last_position.x + self.acceleration.x * sqr_delta_time,
|
||||
y: k1 * self.position.y - k2 * self.last_position.y + self.acceleration.y * sqr_delta_time,
|
||||
|
||||
+54
-1
@@ -6,11 +6,14 @@ use std::{ffi::c_void, rc::Rc, cell::RefCell, mem::size_of, fmt};
|
||||
use crate::resource::*;
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[repr(C)]
|
||||
pub struct Vertex {
|
||||
pub position: Vec3,
|
||||
pub tex_coord: Vec2,
|
||||
pub normal: Vec3,
|
||||
pub tangent: Vec4,
|
||||
pub bone_weights: Vec4,
|
||||
pub bone_indices: [u8; 4],
|
||||
}
|
||||
|
||||
pub struct SurfaceSharedData {
|
||||
@@ -36,7 +39,9 @@ impl SurfaceSharedData {
|
||||
|
||||
Self {
|
||||
need_upload: true,
|
||||
vbo, vao, ebo,
|
||||
vbo,
|
||||
vao,
|
||||
ebo,
|
||||
vertices: Vec::new(),
|
||||
indices: Vec::new(),
|
||||
}
|
||||
@@ -141,24 +146,32 @@ impl SurfaceSharedData {
|
||||
normal: Vec3 { x: 0.0, y: 0.0, z: 1.0 },
|
||||
tex_coord: Vec2 { x: 0.0, y: 0.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: -0.5, y: 0.5, z: 0.5 },
|
||||
normal: Vec3 { x: 0.0, y: 0.0, z: 1.0 },
|
||||
tex_coord: Vec2 { x: 0.0, y: 1.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: 0.5, y: 0.5, z: 0.5 },
|
||||
normal: Vec3 { x: 0.0, y: 0.0, z: 1.0 },
|
||||
tex_coord: Vec2 { x: 1.0, y: 1.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: 0.5, y: -0.5, z: 0.5 },
|
||||
normal: Vec3 { x: 0.0, y: 0.0, z: 1.0 },
|
||||
tex_coord: Vec2 { x: 1.0, y: 0.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
|
||||
// Back
|
||||
@@ -167,24 +180,32 @@ impl SurfaceSharedData {
|
||||
normal: Vec3 { x: 0.0, y: 0.0, z: -1.0 },
|
||||
tex_coord: Vec2 { x: 0.0, y: 0.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: -0.5, y: 0.5, z: -0.5 },
|
||||
normal: Vec3 { x: 0.0, y: 0.0, z: -1.0 },
|
||||
tex_coord: Vec2 { x: 0.0, y: 1.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: 0.5, y: 0.5, z: -0.5 },
|
||||
normal: Vec3 { x: 0.0, y: 0.0, z: -1.0 },
|
||||
tex_coord: Vec2 { x: 1.0, y: 1.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: 0.5, y: -0.5, z: -0.5 },
|
||||
normal: Vec3 { x: 0.0, y: 0.0, z: -1.0 },
|
||||
tex_coord: Vec2 { x: 1.0, y: 0.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
|
||||
// Left
|
||||
@@ -193,24 +214,32 @@ impl SurfaceSharedData {
|
||||
normal: Vec3 { x: -1.0, y: 0.0, z: 0.0 },
|
||||
tex_coord: Vec2 { x: 0.0, y: 0.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: -0.5, y: 0.5, z: -0.5 },
|
||||
normal: Vec3 { x: -1.0, y: 0.0, z: 0.0 },
|
||||
tex_coord: Vec2 { x: 0.0, y: 1.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: -0.5, y: 0.5, z: 0.5 },
|
||||
normal: Vec3 { x: -1.0, y: 0.0, z: 0.0 },
|
||||
tex_coord: Vec2 { x: 1.0, y: 1.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: -0.5, y: -0.5, z: 0.5 },
|
||||
normal: Vec3 { x: -1.0, y: 0.0, z: 0.0 },
|
||||
tex_coord: Vec2 { x: 1.0, y: 0.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
|
||||
// Right
|
||||
@@ -219,24 +248,32 @@ impl SurfaceSharedData {
|
||||
normal: Vec3 { x: 1.0, y: 0.0, z: 0.0 },
|
||||
tex_coord: Vec2 { x: 0.0, y: 0.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: 0.5, y: 0.5, z: -0.5 },
|
||||
normal: Vec3 { x: 1.0, y: 0.0, z: 0.0 },
|
||||
tex_coord: Vec2 { x: 0.0, y: 1.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: 0.5, y: 0.5, z: 0.5 },
|
||||
normal: Vec3 { x: 1.0, y: 0.0, z: 0.0 },
|
||||
tex_coord: Vec2 { x: 1.0, y: 1.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: 0.5, y: -0.5, z: 0.5 },
|
||||
normal: Vec3 { x: 1.0, y: 0.0, z: 0.0 },
|
||||
tex_coord: Vec2 { x: 1.0, y: 0.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
|
||||
// Top
|
||||
@@ -245,24 +282,32 @@ impl SurfaceSharedData {
|
||||
normal: Vec3 { x: 0.0, y: 1.0, z: 0.0 },
|
||||
tex_coord: Vec2 { x: 0.0, y: 0.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: -0.5, y: 0.5, z: -0.5 },
|
||||
normal: Vec3 { x: 0.0, y: 1.0, z: 0.0 },
|
||||
tex_coord: Vec2 { x: 0.0, y: 1.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: 0.5, y: 0.5, z: -0.5 },
|
||||
normal: Vec3 { x: 0.0, y: 1.0, z: 0.0 },
|
||||
tex_coord: Vec2 { x: 1.0, y: 1.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: 0.5, y: 0.5, z: 0.5 },
|
||||
normal: Vec3 { x: 0.0, y: 1.0, z: 0.0 },
|
||||
tex_coord: Vec2 { x: 1.0, y: 0.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
|
||||
// Bottom
|
||||
@@ -271,24 +316,32 @@ impl SurfaceSharedData {
|
||||
normal: Vec3 { x: 0.0, y: -1.0, z: 0.0 },
|
||||
tex_coord: Vec2 { x: 0.0, y: 0.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: -0.5, y: -0.5, z: -0.5 },
|
||||
normal: Vec3 { x: 0.0, y: -1.0, z: 0.0 },
|
||||
tex_coord: Vec2 { x: 0.0, y: 1.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: 0.5, y: -0.5, z: -0.5 },
|
||||
normal: Vec3 { x: 0.0, y: -1.0, z: 0.0 },
|
||||
tex_coord: Vec2 { x: 1.0, y: 1.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
Vertex {
|
||||
position: Vec3 { x: 0.5, y: -0.5, z: 0.5 },
|
||||
normal: Vec3 { x: 0.0, y: -1.0, z: 0.0 },
|
||||
tex_coord: Vec2 { x: 1.0, y: 0.0 },
|
||||
tangent: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0],
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
+148
-32
@@ -1,13 +1,9 @@
|
||||
use std::{rc::Rc, path::*, fs::File, io::Read, cell::RefCell, collections::HashMap};
|
||||
use std::{rc::Rc, path::*, fs::File, io::Read, cell::RefCell, collections::HashMap, time::Instant};
|
||||
use crate::utils::pool::*;
|
||||
use crate::math::{vec4::*, vec3::*, vec2::*, mat4::*, quat::*};
|
||||
use crate::math::{vec4::*, vec3::*, vec2::*, mat4::*, quat::*, triangulator::*};
|
||||
use crate::scene::{*, node::*};
|
||||
use crate::resource::fbx::FbxAnimationCurveNodeType::Rotation;
|
||||
use crate::renderer::surface::{SurfaceSharedData, Surface, Vertex};
|
||||
use crate::math::triangulator::triangulate;
|
||||
use crate::engine::ResourceManager;
|
||||
use core::borrow::Borrow;
|
||||
use std::time::Instant;
|
||||
|
||||
pub enum FbxAttribute {
|
||||
Double(f64),
|
||||
@@ -18,8 +14,10 @@ pub enum FbxAttribute {
|
||||
String(String), // ASCII Fbx always have every attribute in string form
|
||||
}
|
||||
|
||||
const FBX_TIME_UNIT: f64 = 1.0 / 46186158000.0;
|
||||
|
||||
impl FbxAttribute {
|
||||
pub fn as_int(&self) -> Result<i32, String> {
|
||||
pub fn as_i32(&self) -> Result<i32, String> {
|
||||
match self {
|
||||
FbxAttribute::Double(val) => Ok(*val as i32),
|
||||
FbxAttribute::Float(val) => Ok(*val as i32),
|
||||
@@ -35,7 +33,7 @@ impl FbxAttribute {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_int64(&self) -> Result<i64, String> {
|
||||
pub fn as_i64(&self) -> Result<i64, String> {
|
||||
match self {
|
||||
FbxAttribute::Double(val) => Ok(*val as i64),
|
||||
FbxAttribute::Float(val) => Ok(*val as i64),
|
||||
@@ -51,7 +49,7 @@ impl FbxAttribute {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_double(&self) -> Result<f64, String> {
|
||||
pub fn as_f64(&self) -> Result<f64, String> {
|
||||
match self {
|
||||
FbxAttribute::Double(val) => Ok(*val),
|
||||
FbxAttribute::Float(val) => Ok(*val as f64),
|
||||
@@ -67,7 +65,7 @@ impl FbxAttribute {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_float(&self) -> Result<f32, String> {
|
||||
pub fn as_f32(&self) -> Result<f32, String> {
|
||||
match self {
|
||||
FbxAttribute::Double(val) => Ok(*val as f32),
|
||||
FbxAttribute::Float(val) => Ok(*val),
|
||||
@@ -111,8 +109,47 @@ struct FbxSubDeformer {
|
||||
model: Handle<FbxComponent>,
|
||||
indices: Vec<i32>,
|
||||
weights: Vec<f32>,
|
||||
transform: Mat4,
|
||||
transform_link: Mat4,
|
||||
transform: Mat4
|
||||
}
|
||||
|
||||
impl FbxSubDeformer {
|
||||
fn read(sub_deformer_handle: &Handle<FbxNode>, nodes: &Pool<FbxNode>,
|
||||
stack: &mut Vec<Handle<FbxNode>>) -> Result<Self, String> {
|
||||
let indices_handle = find_node(nodes, stack, sub_deformer_handle, "Indexes")?;
|
||||
let indices = find_and_borrow_node(nodes, stack, &indices_handle, "a")?;
|
||||
|
||||
let weights_handle = find_node(nodes, stack, sub_deformer_handle, "Weights")?;
|
||||
let weights = find_and_borrow_node(nodes, stack, &weights_handle, "a")?;
|
||||
|
||||
let transform_handle = find_node(nodes, stack, sub_deformer_handle, "Transform")?;
|
||||
let transform_node = find_and_borrow_node(nodes, stack, &transform_handle, "a")?;
|
||||
|
||||
if transform_node.attrib_count() != 16 {
|
||||
return Err(format!("FBX: Wrong transform size! Expect 16, got {}", transform_node.attrib_count()));
|
||||
}
|
||||
|
||||
let mut transform= Mat4::identity();
|
||||
for i in 0..16 {
|
||||
transform.f[i] = transform_node.get_attrib(i)?.as_f64()? as f32;
|
||||
}
|
||||
|
||||
let mut sub_deformer = FbxSubDeformer {
|
||||
model: Handle::none(),
|
||||
indices: Vec::with_capacity(indices.attrib_count()),
|
||||
weights: Vec::with_capacity(weights.attrib_count()),
|
||||
transform,
|
||||
};
|
||||
|
||||
for i in 0..indices.attrib_count() {
|
||||
sub_deformer.indices.push(indices.get_attrib(i)?.as_i32()?);
|
||||
}
|
||||
|
||||
for i in 0..weights.attrib_count() {
|
||||
sub_deformer.weights.push(weights.get_attrib(i)?.as_f64()? as f32);
|
||||
}
|
||||
|
||||
Ok(sub_deformer)
|
||||
}
|
||||
}
|
||||
|
||||
struct FbxTexture {
|
||||
@@ -121,7 +158,7 @@ struct FbxTexture {
|
||||
|
||||
impl FbxTexture {
|
||||
fn read(texture_node_hanle: &Handle<FbxNode>, nodes: &Pool<FbxNode>,
|
||||
stack: &mut Vec<Handle<FbxNode>>) -> Result<FbxTexture, String> {
|
||||
stack: &mut Vec<Handle<FbxNode>>) -> Result<Self, String> {
|
||||
let mut texture = FbxTexture {
|
||||
filename: PathBuf::new()
|
||||
};
|
||||
@@ -152,10 +189,48 @@ struct FbxDeformer {
|
||||
sub_deformers: Vec<Handle<FbxComponent>>
|
||||
}
|
||||
|
||||
impl FbxDeformer {
|
||||
fn read(_sub_deformer_handle: &Handle<FbxNode>, _nodes: &Pool<FbxNode>,
|
||||
_stack: &mut Vec<Handle<FbxNode>>) -> Result<Self, String> {
|
||||
Ok(FbxDeformer{
|
||||
sub_deformers: Vec::new()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
struct FbxAnimationCurve {
|
||||
keys: Vec<FbxTimeValuePair>
|
||||
}
|
||||
|
||||
impl FbxAnimationCurve {
|
||||
pub fn read(curve_handle: &Handle<FbxNode>,
|
||||
nodes: &Pool<FbxNode>,
|
||||
stack: &mut Vec<Handle<FbxNode>>) -> Result<Self, String> {
|
||||
let key_time_handle = find_node(nodes, stack, curve_handle, "KeyTime")?;
|
||||
let key_time_array = find_and_borrow_node(nodes, stack, &key_time_handle, "a")?;
|
||||
|
||||
let key_value_handle = find_node(nodes, stack, curve_handle, "KeyValueFloat")?;
|
||||
let key_value_array = find_and_borrow_node(nodes, stack, &key_value_handle, "a")?;
|
||||
|
||||
if key_time_array.attrib_count() != key_value_array.attrib_count() {
|
||||
return Err(String::from("FBX: Animation curve contains wrong key data!"));
|
||||
}
|
||||
|
||||
let mut curve = FbxAnimationCurve {
|
||||
keys: Vec::new()
|
||||
};
|
||||
|
||||
for i in 0..key_value_array.attrib_count() {
|
||||
curve.keys.push(FbxTimeValuePair {
|
||||
time: ((key_time_array.get_attrib(i)?.as_i64()? as f64) * FBX_TIME_UNIT) as f32,
|
||||
value: key_value_array.get_attrib(i)?.as_f32()?,
|
||||
});
|
||||
}
|
||||
|
||||
Ok(curve)
|
||||
}
|
||||
}
|
||||
|
||||
enum FbxAnimationCurveNodeType {
|
||||
Unknown,
|
||||
Translation,
|
||||
@@ -168,6 +243,26 @@ struct FbxAnimationCurveNode {
|
||||
curves: Vec<Handle<FbxComponent>>,
|
||||
}
|
||||
|
||||
impl FbxAnimationCurveNode {
|
||||
pub fn read(node_handle: &Handle<FbxNode>,
|
||||
nodes: &Pool<FbxNode>,
|
||||
_stack: &mut Vec<Handle<FbxNode>>) -> Result<Self, String> {
|
||||
match nodes.borrow(node_handle) {
|
||||
Some(node) =>
|
||||
Ok(FbxAnimationCurveNode {
|
||||
actual_type: match node.get_attrib(0)?.as_string().as_str() {
|
||||
"T" | "AnimCurveNode::T" => FbxAnimationCurveNodeType::Translation,
|
||||
"R" | "AnimCurveNode::R" => FbxAnimationCurveNodeType::Rotation,
|
||||
"S" | "AnimCurveNode::S" => FbxAnimationCurveNodeType::Scale,
|
||||
_ => FbxAnimationCurveNodeType::Unknown
|
||||
},
|
||||
curves: Vec::new(),
|
||||
}),
|
||||
None => Err(String::from("Invalid FBX node handle!"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
enum FbxMapping {
|
||||
Unknown,
|
||||
@@ -195,16 +290,16 @@ struct FbxNode {
|
||||
impl FbxNode {
|
||||
fn get_vec3_at(&self, n: usize) -> Result<Vec3, String> {
|
||||
return Ok(Vec3 {
|
||||
x: self.get_attrib(n)?.as_float()?,
|
||||
y: self.get_attrib(n + 1)?.as_float()?,
|
||||
z: self.get_attrib(n + 2)?.as_float()?,
|
||||
x: self.get_attrib(n)?.as_f32()?,
|
||||
y: self.get_attrib(n + 1)?.as_f32()?,
|
||||
z: self.get_attrib(n + 2)?.as_f32()?,
|
||||
});
|
||||
}
|
||||
|
||||
fn get_vec2_at(&self, n: usize) -> Result<Vec2, String> {
|
||||
return Ok(Vec2 {
|
||||
x: self.get_attrib(n)?.as_float()?,
|
||||
y: self.get_attrib(n + 1)?.as_float()?,
|
||||
x: self.get_attrib(n)?.as_f32()?,
|
||||
y: self.get_attrib(n + 1)?.as_f32()?,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -289,7 +384,7 @@ impl FbxGeometry {
|
||||
let index_count = indices_array_node.attrib_count();
|
||||
geom.indices = Vec::with_capacity(index_count);
|
||||
for i in 0..index_count {
|
||||
let index = indices_array_node.get_attrib(i)?.as_int()?;
|
||||
let index = indices_array_node.get_attrib(i)?.as_i32()?;
|
||||
geom.indices.push(index);
|
||||
}
|
||||
|
||||
@@ -331,7 +426,7 @@ impl FbxGeometry {
|
||||
let uv_index_node = find_node(nodes, stack, &layer_element_uv_node_handle, "UVIndex")?;
|
||||
let uv_index_array_node = find_and_borrow_node(nodes, stack, &uv_index_node, "a")?;
|
||||
for i in 0..uv_index_array_node.attrib_count() {
|
||||
geom.uv_index.push(uv_index_array_node.get_attrib(i)?.as_int()?);
|
||||
geom.uv_index.push(uv_index_array_node.get_attrib(i)?.as_i32()?);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -347,7 +442,7 @@ impl FbxGeometry {
|
||||
let materials_node_handle = find_node(nodes, stack, &layer_element_material_node_handle, "Materials")?;
|
||||
let materials_array_node = find_and_borrow_node(nodes, stack, &materials_node_handle, "a")?;
|
||||
for i in 0..materials_array_node.attrib_count() {
|
||||
geom.materials.push(materials_array_node.get_attrib(i)?.as_int()?);
|
||||
geom.materials.push(materials_array_node.get_attrib(i)?.as_i32()?);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -863,6 +958,9 @@ fn convert_vertex(geom: &FbxGeometry,
|
||||
normal,
|
||||
tex_coord: uv,
|
||||
tangent: Vec4 { x: tangent.x, y: tangent.y, z: tangent.z, w: 1.0 },
|
||||
// FIXME
|
||||
bone_weights: Vec4 { x: 0.0, y: 0.0, z: 0.0, w: 0.0 },
|
||||
bone_indices: [0, 0, 0, 0], // Correct indices will be calculated later
|
||||
})
|
||||
}
|
||||
|
||||
@@ -876,7 +974,7 @@ impl Fbx {
|
||||
// Check version
|
||||
let header_handle = find_node(&self.nodes, &mut traversal_stack, &self.root, "FBXHeaderExtension")?;
|
||||
let version = find_and_borrow_node(&self.nodes, &mut traversal_stack, &header_handle, "FBXVersion")?;
|
||||
let version = version.get_attrib(0)?.as_int()?;
|
||||
let version = version.get_attrib(0)?.as_i32()?;
|
||||
if version < 7100 {
|
||||
return Err(format!("FBX: Unsupported {} version. Version must be >= 7100", version));
|
||||
}
|
||||
@@ -885,7 +983,7 @@ impl Fbx {
|
||||
let objects_node = find_and_borrow_node(&self.nodes, &mut traversal_stack, &self.root, "Objects")?;
|
||||
for object_handle in objects_node.children.iter() {
|
||||
let object = self.nodes.borrow(&object_handle).unwrap();
|
||||
let index = object.get_attrib(0)?.as_int64()?;
|
||||
let index = object.get_attrib(0)?.as_i64()?;
|
||||
let mut component_handle: Handle<FbxComponent> = Handle::none();
|
||||
match object.name.as_str() {
|
||||
"Geometry" => {
|
||||
@@ -908,13 +1006,25 @@ impl Fbx {
|
||||
//println!("reading a NodeAttribute");
|
||||
}
|
||||
"AnimationCurve" => {
|
||||
//println!("reading a AnimationCurve");
|
||||
component_handle = self.component_pool.spawn(FbxComponent::AnimationCurve(
|
||||
FbxAnimationCurve::read(object_handle, &self.nodes, &mut traversal_stack)?));
|
||||
}
|
||||
"AnimationCurveNode" => {
|
||||
//println!("reading a AnimationCurveNode");
|
||||
component_handle = self.component_pool.spawn(FbxComponent::AnimationCurveNode(
|
||||
FbxAnimationCurveNode::read(object_handle, &self.nodes, &mut traversal_stack)?));
|
||||
}
|
||||
"Deformer" => {
|
||||
//println!("reading a Deformer");
|
||||
match object.get_attrib(2)?.as_string().as_str() {
|
||||
"Cluster" => {
|
||||
component_handle = self.component_pool.spawn(FbxComponent::SubDeformer(
|
||||
FbxSubDeformer::read(object_handle, &self.nodes, &mut traversal_stack)?));
|
||||
},
|
||||
"Skin" => {
|
||||
component_handle = self.component_pool.spawn(FbxComponent::Deformer(
|
||||
FbxDeformer::read(object_handle, &self.nodes, &mut traversal_stack)?));
|
||||
},
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
@@ -928,8 +1038,8 @@ impl Fbx {
|
||||
let connections_node = find_and_borrow_node(&self.nodes, &mut traversal_stack, &self.root, "Connections")?;
|
||||
for connection_handle in connections_node.children.iter() {
|
||||
let connection = self.nodes.borrow(&connection_handle).unwrap();
|
||||
let child_index = connection.get_attrib(1)?.as_int64()?;
|
||||
let parent_index = connection.get_attrib(2)?.as_int64()?;
|
||||
let child_index = connection.get_attrib(1)?.as_i64()?;
|
||||
let parent_index = connection.get_attrib(2)?.as_i64()?;
|
||||
if let Some(parent_handle) = self.index_to_component.get(&parent_index) {
|
||||
if let Some(child_handle) = self.index_to_component.get(&child_index) {
|
||||
let child_type_id = self.component_pool.borrow(child_handle).unwrap().type_id();
|
||||
@@ -1076,7 +1186,7 @@ impl Fbx {
|
||||
}
|
||||
}
|
||||
}
|
||||
scene.update(0.0);
|
||||
scene.calculate_transforms();
|
||||
Ok(root)
|
||||
}
|
||||
|
||||
@@ -1098,17 +1208,23 @@ impl Fbx {
|
||||
|
||||
pub fn load_to_scene(scene: &mut Scene, resource_manager: &mut ResourceManager, path: &Path)
|
||||
-> Result<Handle<Node>, String> {
|
||||
let start_time = Instant::now();
|
||||
|
||||
println!("Trying to load {:?}", path);
|
||||
|
||||
let now = Instant::now();
|
||||
let ref mut fbx = read_ascii(path)?;
|
||||
println!("FBX: Parsing - {} ms", now.elapsed().as_millis());
|
||||
println!("\tFBX: Parsing - {} ms", now.elapsed().as_millis());
|
||||
|
||||
let now = Instant::now();
|
||||
fbx.prepare()?;
|
||||
println!("FBX: DOM Prepare - {} ms", now.elapsed().as_millis());
|
||||
println!("\tFBX: DOM Prepare - {} ms", now.elapsed().as_millis());
|
||||
|
||||
let now = Instant::now();
|
||||
let result = fbx.convert(scene, resource_manager);
|
||||
println!("FBX Conversion - {} ms", now.elapsed().as_millis());
|
||||
println!("\tFBX Conversion - {} ms", now.elapsed().as_millis());
|
||||
|
||||
println!("{:?} loaded in {} ms", path, start_time.elapsed().as_millis());
|
||||
|
||||
result
|
||||
}
|
||||
+25
-16
@@ -120,8 +120,8 @@ impl Scene {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn update_physics(&mut self) {
|
||||
self.physics.step(1.0 / 60.0);
|
||||
pub fn update_physics(&mut self, dt: f64) {
|
||||
self.physics.step(dt as f32);
|
||||
|
||||
// Sync node positions with assigned physics bodies
|
||||
for i in 0..self.nodes.capacity() {
|
||||
@@ -133,9 +133,7 @@ impl Scene {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(&mut self, aspect_ratio: f32) {
|
||||
self.update_physics();
|
||||
|
||||
pub fn calculate_transforms(&mut self) {
|
||||
// Calculate transforms on nodes
|
||||
let mut stack = self.stack.borrow_mut();
|
||||
stack.clear();
|
||||
@@ -149,20 +147,14 @@ impl Scene {
|
||||
}
|
||||
|
||||
// Extract parent's global transform
|
||||
let mut parent_global_transform = Mat4::identity();
|
||||
if let Some(parent) = self.nodes.borrow_mut(&parent_handle) {
|
||||
parent_global_transform = parent.global_transform;
|
||||
}
|
||||
let parent_global_transform =
|
||||
match self.nodes.borrow_mut(&parent_handle) {
|
||||
Some(parent) => parent.global_transform,
|
||||
None => Mat4::identity()
|
||||
};
|
||||
|
||||
if let Some(node) = self.nodes.borrow_mut(&handle) {
|
||||
node.global_transform = parent_global_transform * node.local_transform;
|
||||
let eye = node.get_global_position();
|
||||
let look = node.get_look_vector();
|
||||
let up = node.get_up_vector();
|
||||
|
||||
if let NodeKind::Camera(camera) = node.borrow_kind_mut() {
|
||||
camera.calculate_matrices(eye, look, up, aspect_ratio);
|
||||
}
|
||||
|
||||
// Queue children and continue traversal on them
|
||||
for child_handle in node.children.iter() {
|
||||
@@ -171,4 +163,21 @@ impl Scene {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(&mut self, aspect_ratio: f32, dt: f64) {
|
||||
self.update_physics(dt);
|
||||
|
||||
self.calculate_transforms();
|
||||
|
||||
for i in 0..self.nodes.capacity() {
|
||||
if let Some(node) = self.nodes.at_mut(i) {
|
||||
let eye = node.get_global_position();
|
||||
let look = node.get_look_vector();
|
||||
let up = node.get_up_vector();
|
||||
if let NodeKind::Camera(camera) = node.borrow_kind_mut() {
|
||||
camera.calculate_matrices(eye, look, up, aspect_ratio);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,5 +1,7 @@
|
||||
use std::marker::PhantomData;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::{
|
||||
marker::PhantomData,
|
||||
hash:: {Hash, Hasher}
|
||||
};
|
||||
|
||||
///
|
||||
/// Pool allows to create as many objects as you want in contiguous memory
|
||||
@@ -51,9 +53,7 @@ impl<T> PartialEq for Handle<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Eq for Handle<T> {
|
||||
|
||||
}
|
||||
impl<T> Eq for Handle<T> { }
|
||||
|
||||
impl<T> Hash for Handle<T> {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
|
||||
Reference in New Issue
Block a user