Skip to content

Commit

Permalink
[Assimp] Apply code review changes, refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jklawreszuk committed Aug 7, 2023
1 parent 04bd38c commit c6d467e
Show file tree
Hide file tree
Showing 16 changed files with 1,804 additions and 1,745 deletions.
20 changes: 20 additions & 0 deletions sources/tools/Stride.Importer.Assimp/Material/Flags.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.

using System;

namespace Stride.Importer.Assimp.Material
{
/// <summary>
/// Enumeration of the new Assimp's flags.
/// </summary>

[Flags]
public enum Flags
{
None = 0,
Invert = 1,
ReplaceAlpha = 2
}
}
16 changes: 16 additions & 0 deletions sources/tools/Stride.Importer.Assimp/Material/MappingMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.

namespace Stride.Importer.Assimp.Material
{
/// <summary>
/// Enumeration of the different mapping modes in the new Assimp's material stack.
/// </summary>
public enum MappingMode
{
Wrap,
Clamp,
Decal,
Mirror
}
}
237 changes: 6 additions & 231 deletions sources/tools/Stride.Importer.Assimp/Material/MaterialStack.cs
Original file line number Diff line number Diff line change
@@ -1,243 +1,18 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Stride.Core.Mathematics;
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.

using System.Collections.Generic;
namespace Stride.Importer.Assimp.Material
{
/// <summary>
/// Enumeration of the different types of node in the new Assimp's material stack.
/// </summary>
public enum StackType
{
Color = 0,
Texture,
Operation
}
/// <summary>
/// Enumeration of the new Assimp's flags.
/// </summary>
public enum Flags
{
Invert = 1,
ReplaceAlpha = 2
}
/// <summary>
/// Enumeration of the different operations in the new Assimp's material stack.
/// </summary>
public enum Operation
{
Add = 0,
Add3ds,
AddMaya,
Average,
Color,
ColorBurn,
ColorDodge,
Darken3ds,
DarkenMaya,
Desaturate,
Difference3ds,
DifferenceMaya,
Divide,
Exclusion,
HardLight,
HardMix,
Hue,
Illuminate,
In,
Lighten3ds,
LightenMaya,
LinearBurn,
LinearDodge,
Multiply3ds,
MultiplyMaya,
None,
Out,
Over3ds,
Overlay3ds,
OverMaya,
PinLight,
Saturate,
Saturation,
Screen,
SoftLight,
Substract3ds,
SubstractMaya,
Value,
Mask
}
/// <summary>
/// Enumeration of the different mapping modes in the new Assimp's material stack.
/// </summary>
public enum MappingMode
{
Wrap,
Clamp,
Decal,
Mirror
}
/// <summary>
/// Class representing an element in the new Assimp's material stack.
/// </summary>
public abstract class StackElement
{
/// <summary>
/// Initializes a new instance of the <see cref="StackElement"/> class.
/// </summary>
/// <param name="Alpha">The alpha of the node.</param>
/// <param name="Blend">The blending coefficient of the node.</param>
/// <param name="flags">The flags of the node.</param>
/// <param name="Type">The type of the node.</param>
public StackElement(float Alpha, float Blend, int flags, StackType Type)
{
alpha = Alpha;
blend = Blend;
type = Type;
}
/// <summary>
/// Gets the alpha of the node.
/// </summary>
/// <value>
/// The alpha of the node.
/// </value>
public float alpha { get; private set; }
/// <summary>
/// Gets the blending coefficient of the node.
/// </summary>
/// <value>
/// The blending coefficient of the node.
/// </value>
public float blend { get; private set; }
/// <summary>
/// Gets the flags of the node.
/// </summary>
/// <value>
/// The flags of the node.
/// </value>
public int flags { get; private set; }
/// <summary>
/// Gets the type of the node.
/// </summary>
/// <value>
/// The type of the node.
/// </value>
public StackType type { get; private set; }
}
/// <summary>
/// Class representing an operation in the new Assimp's material stack.
/// </summary>
public class StackOperation : StackElement
{
/// <summary>
/// Initializes a new instance of the <see cref="StackOperation"/> class.
/// </summary>
/// <param name="Operation">The operation of the node.</param>
/// <param name="Alpha">The alpha of the node.</param>
/// <param name="Blend">The blending coefficient of the node.</param>
/// <param name="Flags">The flags.</param>
public StackOperation(Operation Operation, float Alpha = 1.0f, float Blend = 1.0f, int Flags = 0)
: base(Alpha, Blend, Flags, StackType.Operation)
{
operation = Operation;
}
/// <summary>
/// Gets the operation of the node.
/// </summary>
/// <value>
/// The operation of the node.
/// </value>
public Operation operation { get; private set; }
}
/// <summary>
/// Class representing a color in the new Assimp's material stack.
/// </summary>
public class StackColor : StackElement
{
/// <summary>
/// Initializes a new instance of the <see cref="StackColor"/> class.
/// </summary>
/// <param name="Color">The color of the node.</param>
/// <param name="Alpha">The alpha of the node.</param>
/// <param name="Blend">The blending coefficient of the node.</param>
/// <param name="Flags">The flags of the node.</param>
public StackColor(Color3 Color, float Alpha = 1.0f, float Blend = 1.0f, int Flags = 0)
: base(Alpha, Blend, Flags, StackType.Color)
{
color = Color;
}
/// <summary>
/// Gets the color of the node.
/// </summary>
/// <value>
/// The color of the node.
/// </value>
public Color3 color { get; private set; }
}
/// <summary>
/// Class representing a texture in the new Assimp's material stack.
/// </summary>
public class StackTexture : StackElement
{
/// <summary>
/// Initializes a new instance of the <see cref="StackTexture"/> class.
/// </summary>
/// <param name="TexturePath">The texture path.</param>
/// <param name="Channel">The uv channel used by the texture.</param>
/// <param name="MappingModeU">The U mapping mode.</param>
/// <param name="MappingModeV">The V mapping mode.</param>
/// <param name="Alpha">The alpha of the node.</param>
/// <param name="Blend">The blending coefficient of the node.</param>
/// <param name="Flags">The flags of the node.</param>
public StackTexture(String TexturePath, int Channel, MappingMode MappingModeU, MappingMode MappingModeV, float Alpha = 1.0f, float Blend = 1.0F, int Flags = 0)
: base(Alpha, Blend, Flags, StackType.Texture)
{
texturePath = TexturePath;
channel = Channel;
mappingModeU = MappingModeU;
mappingModeV = MappingModeV;
}
/// <summary>
/// Gets the texture path.
/// </summary>
/// <value>
/// The texture path.
/// </value>
public String texturePath { get; private set; }
/// <summary>
/// Gets the uv channel.
/// </summary>
/// <value>
/// The uv channel.
/// </value>
public int channel { get; private set; }
/// <summary>
/// Gets the U mapping mode.
/// </summary>
/// <value>
/// The U mapping mode.
/// </value>
public MappingMode mappingModeU { get; private set; }
/// <summary>
/// Gets the Vmapping mode.
/// </summary>
/// <value>
/// The V mapping mode.
/// </value>
public MappingMode mappingModeV { get; private set; }
}
/// <summary>
/// Class representing the new Assimp's material stack in c#.
/// </summary>
public class Stack
public class MaterialStack
{
/// <summary>
/// Initializes a new instance of the <see cref="Stack"/> class.
/// Initializes a new instance of the <see cref="MaterialStack"/> class.
/// </summary>
public Stack()
public MaterialStack()
{
stack = new Stack<StackElement>();
}
Expand Down
Loading

0 comments on commit c6d467e

Please sign in to comment.