Skip to content

Commit 42cc57a

Browse files
committed
Refactor material and texture classes, update builders
- Add XML docs and DiffuseFactor to Material; remove unused properties - Improve FbxMaterialBuilder property extraction and naming - Move TextureFilterType and WrapMode enums to separate files - Update Texture class to use new enums and clarify property order - Clean up GltfMaterialBuilder: remove unused method, minor logic changes
1 parent 39ca36f commit 42cc57a

6 files changed

Lines changed: 51 additions & 32 deletions

File tree

src/MeshIO/Formats/Fbx/Builders/FbxMaterialBuilder.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,26 @@ protected override void buildProperties(Dictionary<string, FbxProperty> properti
4040
_element.EmissiveFactor = emissiveFactor.ToProperty().GetValue<double>();
4141
}
4242

43-
if (properties.Remove("AmbientColor", out FbxProperty AmbientColor))
43+
if (properties.Remove("AmbientColor", out FbxProperty ambientColor))
4444
{
45-
_element.AmbientColor = emissiveFactor.ToProperty().GetValue<Color>();
45+
_element.AmbientColor = ambientColor.ToProperty().GetValue<Color>();
4646
}
4747

4848
if (properties.Remove("AmbientFactor", out FbxProperty ambientFactor))
4949
{
5050
_element.AmbientFactor = ambientFactor.ToProperty().GetValue<double>();
5151
}
5252

53+
if (properties.Remove("DiffuseColor", out FbxProperty diffuseColor))
54+
{
55+
_element.DiffuseColor = diffuseColor.ToProperty().GetValue<Color>();
56+
}
57+
58+
if (properties.Remove("DiffuseFactor", out FbxProperty diffuseFactor))
59+
{
60+
_element.DiffuseFactor = diffuseFactor.ToProperty().GetValue<double>();
61+
}
62+
5363
base.buildProperties(properties);
5464
}
5565
}

src/MeshIO/Formats/Gltf/Builders/GltfMaterialBuilder.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public override void Build(GlbFileBuilder builder)
1717

1818
if (this.GltfObject.PbrMetallicRoughness != null)
1919
{
20+
2021
}
2122

2223
if (this.GltfObject.NormalTexture != null
@@ -40,9 +41,4 @@ public override void Build(GlbFileBuilder builder)
4041
pbrMat.EmissiveTexture = emissiveBuilder.Texture;
4142
}
4243
}
43-
44-
private Texture processTexture(GlbFileBuilder builder)
45-
{
46-
throw new System.NotImplementedException();
47-
}
4844
}

src/MeshIO/Materials/Material.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
namespace MeshIO.Materials;
22

3+
/// <summary>
4+
/// Represents the base class for 3D materials that define the appearance of surfaces in a scene, including color and
5+
/// lighting properties.
6+
/// </summary>
7+
/// <remarks>The Material class provides common properties for ambient, diffuse, and emissive lighting components.
8+
/// Derived classes can extend this class to implement specific material behaviors or additional properties. Materials
9+
/// are typically assigned to 3D objects to control how they interact with light sources in the rendering
10+
/// environment.</remarks>
311
public abstract class Material : Element3D
412
{
513
public Color AmbientColor { get; set; }
@@ -8,16 +16,12 @@ public abstract class Material : Element3D
816

917
public Color DiffuseColor { get; set; }
1018

19+
public double DiffuseFactor { get; set; }
20+
1121
public Color EmissiveColor { get; set; }
1222

1323
public double EmissiveFactor { get; set; }
1424

15-
public int? MultiLayer { get; set; }
16-
17-
public double ShininessExponent { get; set; }
18-
19-
public double TransparencyFactor { get; set; }
20-
2125
public Material() : this(string.Empty)
2226
{
2327
}

src/MeshIO/Materials/Texture.cs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,22 @@
11
namespace MeshIO.Materials;
22

3-
public enum TextureFilterType
4-
{
5-
None = 0,
6-
7-
Nearest = 1,
8-
9-
Linear = 2,
10-
}
11-
12-
public enum WrapMode
13-
{
14-
Clamp = 0,
15-
Repeat = 1,
16-
MirroredRepeat = 2,
17-
}
18-
193
public class Texture : Element3D
204
{
215
public TextureFilterType MagnificationFilter { get; set; }
6+
227
public TextureFilterType MinificationFilter { get; set; }
8+
239
public TextureFilterType MipFilter { get; set; }
24-
public WrapMode WrapModeT { get; set; }
25-
public WrapMode WrapModeS { get; set; }
10+
11+
public WrapMode WrapModeS { get; set; }
12+
13+
public WrapMode WrapModeT { get; set; }
14+
2615
public Texture() : base()
2716
{
2817
}
2918

3019
public Texture(string name) : base(name)
3120
{
3221
}
33-
}
22+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace MeshIO.Materials;
2+
3+
public enum TextureFilterType
4+
{
5+
None = 0,
6+
7+
Nearest = 1,
8+
9+
Linear = 2,
10+
}

src/MeshIO/Materials/WrapMode.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace MeshIO.Materials;
2+
3+
public enum WrapMode
4+
{
5+
Clamp = 0,
6+
7+
Repeat = 1,
8+
9+
MirroredRepeat = 2,
10+
}

0 commit comments

Comments
 (0)