@@ -43,54 +43,52 @@ run_action.SetLoop(impeller::scene::AnimationAction::kLoopForever);
43
43
run_action.SetWeight(0.3f);
44
44
run_action.Play();
45
45
46
- scene.Add (
46
+ scene.GetRoot().AddChild (
47
47
impeller::scene::DirectionalLight(
48
48
/* color * / impeller::Color::AntiqueWhite(),
49
49
/* intensity * / 5,
50
50
/* direction * / {2, 3, 4}));
51
51
52
- impeller::scene::StaticMeshEntity sphere_entity;
53
- sphere_entity.SetGlobalTransform(
52
+ Node sphere_node;
53
+ Mesh sphere_mesh;
54
+ sphere_node.SetGlobalTransform(
54
55
Matrix::MakeRotationEuler({kPiOver4, kPiOver4, 0}));
55
- sphere_entity.SetCullingMode(impeller::scene::CullingMode::kFrustum);
56
56
57
- std::unique_ptr < impeller::scene::SphereGeometry > sphere =
57
+ auto sphere_geometry =
58
58
impeller::scene::Geometry::MakeSphere(allocator, /* radius * / 2);
59
59
60
- sphere_entity.SetGeometry(sphere);
61
-
62
60
auto material = impeller::scene::Material::MakeStandard();
63
- material. SetAlbedo(impeller::Color::Red());
64
- material. SetRoughness(0.4);
65
- material. SetMetallic(0.2);
61
+ material-> SetAlbedo(impeller::Color::Red());
62
+ material-> SetRoughness(0.4);
63
+ material-> SetMetallic(0.2);
66
64
// Common properties shared by all materials.
67
- material. SetEnvironmentMap(environment_hdri);
68
- material. SetFlatShaded(true);
69
- material. SetBlendConfig({
65
+ material-> SetEnvironmentMap(environment_hdri);
66
+ material-> SetFlatShaded(true);
67
+ material-> SetBlendConfig({
70
68
impeller::BlendOperation::kAdd, // color_op
71
69
impeller::BlendFactor::kOne, // source_color_factor
72
70
impeller::BlendFactor::kOneMinusSourceAlpha, // destination_color_factor
73
71
impeller::BlendOperation::kAdd, // alpha_op
74
72
impeller::BlendFactor::kOne, // source_alpha_factor
75
73
impeller::BlendFactor::kOneMinusSourceAlpha, // destination_alpha_factor
76
74
});
77
- material. SetStencilConfig({
75
+ material-> SetStencilConfig({
78
76
impeller::StencilOperation::kIncrementClamp, // operation
79
77
impeller::CompareFunction::kAlways, // compare
80
78
});
81
-
82
- sphere_entity->SetMaterials({material} );
83
-
84
-
85
- impeller::scene::StaticMeshEntity cube_entity ;
86
- cube_entity.GetGeometry(
87
- impeller::scene::Geometry::MakeCube(allocator, {4, 4, 4}));
88
- cube_entity.SetMaterials({material });
89
-
90
- cube_entity.SetLocalTransform(Matrix::MakeTranslation({4, 0, 0}) );
91
-
92
- sphere_entity->Add(sube_entity );
93
- scene.Add(sphere_entity );
79
+ sphere_mesh.AddPrimitive({sphere_geometry, material});
80
+ sphere_node.SetMesh(sphere_mesh );
81
+
82
+ Node cube_node;
83
+ cube_node.SetLocalTransform(Matrix::MakeTranslation({4, 0, 0})) ;
84
+ Mesh cube_mesh;
85
+ auto cube_geometry = impeller::scene::Geometry::MakeCuboid(
86
+ allocator, {4, 4, 4 });
87
+ cube_mesh.AddPrimitive({cube_geometry, material});
88
+ cube_node.SetMesh(cube_mesh );
89
+
90
+ sphere_node.AddChild(cube_node );
91
+ scene.GetRoot().AddChild(sphere_node );
94
92
95
93
/// Post processing.
96
94
0 commit comments