4 using System.Collections.Generic;
5 using System.ComponentModel;
9 using SharpYaml.Serialization;
11 using SiliconStudio.Assets;
12 using SiliconStudio.Assets.Compiler;
13 using SiliconStudio.Core;
14 using SiliconStudio.Core.Diagnostics;
15 using SiliconStudio.Core.Mathematics;
16 using SiliconStudio.Core.Yaml;
17 using SiliconStudio.Paradox.Effects;
21 [DataContract(
"Model")]
22 [AssetFileExtension(FileExtension)]
23 [AssetCompiler(typeof(ModelAssetCompiler))]
24 [ThumbnailCompiler(PreviewerCompilerNames.ModelThumbnailCompilerQualifiedName)]
25 [AssetFactory((Type)null)]
27 [AssetFormatVersion(AssetFormatVersion, typeof(Upgrader))]
30 public const int AssetFormatVersion = 1;
35 public const string FileExtension =
".pdxm3d";
42 MeshParameters =
new Dictionary<string, MeshMaterialParameters>();
43 Nodes =
new List<NodeInformation>();
54 public List<NodeInformation> Nodes {
get;
private set; }
65 public Vector3? ViewDirectionForTransparentZSort {
get; set; }
92 public Dictionary<string, MeshMaterialParameters> MeshParameters {
get;
private set; }
102 return Nodes.Any(x => !x.Preserve);
113 public List<string> PreservedNodes
117 return Nodes.Where(x => x.Preserve).Select(x => x.Name).ToList();
127 foreach (var nodeName
in nodesToPreserve)
129 foreach (var node
in Nodes)
131 if (node.Name.Equals(nodeName))
132 node.Preserve =
true;
142 foreach (var node
in Nodes)
143 node.Preserve =
false;
151 foreach (var node
in Nodes)
152 node.Preserve =
true;
160 foreach (var node
in Nodes)
161 node.Preserve = !node.Preserve;
167 UpAxis = Vector3.UnitY;
168 FrontAxis = Vector3.UnitZ;
175 protected override void UpgradeAsset(
ILogger log, dynamic asset)
177 foreach (var keyValue
in asset.MeshParameters)
179 var parameters = asset.MeshParameters[keyValue.Key].Parameters[
"~Items"];
180 parameters.Node.Style = YamlStyle.Block;
188 var emptyGuid = Guid.Empty.ToString().ToLowerInvariant();
190 if (
id != null &&
id.Node.Value != emptyGuid)
191 asset.Id = Guid.NewGuid().ToString().ToLowerInvariant();
194 asset.SerializedVersion = AssetFormatVersion;
195 asset.MoveChild(
"SerializedVersion", asset.IndexOf(
"Id") + 1);
198 public void MoveToParameters(dynamic asset, dynamic parameters,
object key,
string paramName,
ParameterKey pk)
200 var paramValue = asset.MeshParameters[key][paramName];
201 if (paramValue != null)
203 parameters[pk.Name] = paramValue;
204 asset.MeshParameters[key].RemoveChild(paramName);
Key of an effect parameter.
ModelAsset()
Initializes a new instance of the ModelAsset class.
static readonly ParameterKey< RenderLayers > RenderLayer
The compact style (style embraced by [] or {})
Represents a three dimensional mathematical vector.
void PreserveAllNodes()
Preserve all the nodes.
override void SetDefaults()
Sets the defaults values for this instance
void PreserveNoNode()
No longer preserve any node.
static readonly ParameterKey< bool > ReceiveShadows
Flag stating if the mesh receives shadows.
An importable asset with a content that need to be tracked if original asset is changing.
static readonly ParameterKey< bool > CastShadows
Flag stating if the mesh casts shadows.
void PreserveNodes(List< string > nodesToPreserve)
Preserve the nodes.
Contains user-friendly names and descriptions of an asset type.
void InvertPreservation()
Invert the preservation of the nodes.
Collection of Mesh, each one usually being a different LOD of the same Model. The effect system will ...