-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from cmilatinov/feature/property-store
Add ability to load scenes with custom properties
- Loading branch information
Showing
10 changed files
with
652 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use russimp::node::Node; | ||
use russimp::property::Property; | ||
use russimp::scene::PostProcess; | ||
use russimp::sys::AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS; | ||
use russimp::{property::PropertyStore, scene::Scene}; | ||
|
||
fn traverse_nodes(node: &Node, indent: String) { | ||
println!("{}{}", indent, node.name); | ||
for child in node.children.borrow().iter() { | ||
traverse_nodes(&*child, format!(" {}", indent)); | ||
} | ||
} | ||
|
||
fn main() { | ||
// NOTE: You can construct this from a HashMap | ||
// or any iterator if you want. | ||
// | ||
// The cast here is only necessary because | ||
// the array only contains one entry and rust | ||
// tries to make an iterator returning a reference | ||
// to a sized array instead of a slice. | ||
let props: PropertyStore = [( | ||
AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS as &[u8], | ||
Property::Integer(0), | ||
)] | ||
.into_iter() | ||
.into(); | ||
|
||
let scene = Scene::from_file_with_props( | ||
"models/FBX/y_bot_run.fbx", | ||
vec![ | ||
PostProcess::Triangulate, | ||
PostProcess::GenerateSmoothNormals, | ||
PostProcess::FlipUVs, | ||
PostProcess::FlipWindingOrder, | ||
PostProcess::JoinIdenticalVertices, | ||
PostProcess::OptimizeGraph, | ||
], | ||
&props, | ||
) | ||
.unwrap(); | ||
|
||
if let Some(root) = &scene.root { | ||
traverse_nodes(&*root, String::from("")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?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 4.0.2 commit date:2023-12-05, commit time:07:41, hash:9be62e85b727</authoring_tool> | ||
</contributor> | ||
<created>2024-02-02T16:02:18</created> | ||
<modified>2024-02-02T16:02:18</modified> | ||
<unit name="meter" meter="1"/> | ||
<up_axis>Z_UP</up_axis> | ||
</asset> | ||
<library_images/> | ||
<library_geometries> | ||
<geometry id="Cube_001-mesh" name="Cube.001"> | ||
<mesh> | ||
<source id="Cube_001-mesh-positions"> | ||
<float_array id="Cube_001-mesh-positions-array" count="24">-1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 1 -1 1 1 1 -1 1 1 1</float_array> | ||
<technique_common> | ||
<accessor source="#Cube_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="Cube_001-mesh-normals"> | ||
<float_array id="Cube_001-mesh-normals-array" count="18">-1 0 0 0 1 0 1 0 0 0 -1 0 0 0 -1 0 0 1</float_array> | ||
<technique_common> | ||
<accessor source="#Cube_001-mesh-normals-array" count="6" stride="3"> | ||
<param name="X" type="float"/> | ||
<param name="Y" type="float"/> | ||
<param name="Z" type="float"/> | ||
</accessor> | ||
</technique_common> | ||
</source> | ||
<source id="Cube_001-mesh-map-0"> | ||
<float_array id="Cube_001-mesh-map-0-array" count="72">0.625 0 0.375 0.25 0.375 0 0.625 0.25 0.375 0.5 0.375 0.25 0.625 0.5 0.375 0.75 0.375 0.5 0.625 0.75 0.375 1 0.375 0.75 0.375 0.5 0.125 0.75 0.125 0.5 0.875 0.5 0.625 0.75 0.625 0.5 0.625 0 0.625 0.25 0.375 0.25 0.625 0.25 0.625 0.5 0.375 0.5 0.625 0.5 0.625 0.75 0.375 0.75 0.625 0.75 0.625 1 0.375 1 0.375 0.5 0.375 0.75 0.125 0.75 0.875 0.5 0.875 0.75 0.625 0.75</float_array> | ||
<technique_common> | ||
<accessor source="#Cube_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="Cube_001-mesh-vertices"> | ||
<input semantic="POSITION" source="#Cube_001-mesh-positions"/> | ||
</vertices> | ||
<triangles count="12"> | ||
<input semantic="VERTEX" source="#Cube_001-mesh-vertices" offset="0"/> | ||
<input semantic="NORMAL" source="#Cube_001-mesh-normals" offset="1"/> | ||
<input semantic="TEXCOORD" source="#Cube_001-mesh-map-0" offset="2" set="0"/> | ||
<p>1 0 0 2 0 1 0 0 2 3 1 3 6 1 4 2 1 5 7 2 6 4 2 7 6 2 8 5 3 9 0 3 10 4 3 11 6 4 12 0 4 13 2 4 14 3 5 15 5 5 16 7 5 17 1 0 18 3 0 19 2 0 20 3 1 21 7 1 22 6 1 23 7 2 24 5 2 25 4 2 26 5 3 27 1 3 28 0 3 29 6 4 30 4 4 31 0 4 32 3 5 33 1 5 34 5 5 35</p> | ||
</triangles> | ||
</mesh> | ||
</geometry> | ||
</library_geometries> | ||
<library_visual_scenes> | ||
<visual_scene id="Scene" name="Scene"> | ||
<node id="Cube" name="Cube" 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="#Cube_001-mesh" name="Cube"/> | ||
</node> | ||
</visual_scene> | ||
</library_visual_scenes> | ||
<scene> | ||
<instance_visual_scene url="#Scene"/> | ||
</scene> | ||
</COLLADA> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?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 4.0.2 commit date:2023-12-05, commit time:07:41, hash:9be62e85b727</authoring_tool> | ||
</contributor> | ||
<created>2024-02-02T16:28:47</created> | ||
<modified>2024-02-02T16:28:47</modified> | ||
<unit name="meter" meter="1"/> | ||
<up_axis>Z_UP</up_axis> | ||
</asset> | ||
<library_images/> | ||
<library_geometries> | ||
<geometry id="Plane-mesh" name="Plane"> | ||
<mesh> | ||
<source id="Plane-mesh-positions"> | ||
<float_array id="Plane-mesh-positions-array" count="12">-1 -1 0 1 -1 0 -1 1 0 1 1 0</float_array> | ||
<technique_common> | ||
<accessor source="#Plane-mesh-positions-array" count="4" 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="3">0 0 1</float_array> | ||
<technique_common> | ||
<accessor source="#Plane-mesh-normals-array" count="1" 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="12">1 0 0 1 0 0 1 0 1 1 0 1</float_array> | ||
<technique_common> | ||
<accessor source="#Plane-mesh-map-0-array" count="6" 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 count="2"> | ||
<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>1 0 0 2 0 1 0 0 2 1 0 3 3 0 4 2 0 5</p> | ||
</triangles> | ||
</mesh> | ||
</geometry> | ||
</library_geometries> | ||
<library_visual_scenes> | ||
<visual_scene id="Scene" name="Scene"> | ||
<node id="Plane" name="Plane" 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="#Plane-mesh" name="Plane"/> | ||
</node> | ||
</visual_scene> | ||
</library_visual_scenes> | ||
<scene> | ||
<instance_visual_scene url="#Scene"/> | ||
</scene> | ||
</COLLADA> |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.