예제 #1
0
    /// <summary>
    /// Called when all fix-ups are executed and the asset is fully loaded.
    /// </summary>
    /// <param name="sender">The sender.</param>
    /// <param name="eventArgs">
    /// The <see cref="EventArgs"/> instance containing the event data.
    /// </param>
    internal void OnAssetLoaded(object sender, EventArgs eventArgs)
    {
      // Meshes are shared resources, so they are loaded deferred.
      // OnAssetLoaded is called when all shared resources are loaded.
      _materialInstances = new MaterialInstanceCollection(Mesh.Materials);
      _passHashes = _materialInstances.PassHashes;
      SetHasAlpha();

      // Ensure that MorphWeights are set. (Required for correct rendering.)
      if (_mesh.HasMorphTargets())
        MorphWeights = new MorphWeightCollection(_mesh);

      OnInitializeShape();
      
      // Note: The SkeletonPose is created by the ModelNode when the asset is loaded.
    }
예제 #2
0
    /// <inheritdoc/>
    protected override void CloneCore(SceneNode source)
    {
      // Clone SceneNode properties.
      base.CloneCore(source);

      // Clone MeshNode properties.
      var sourceTyped = (MeshNode)source;
      _mesh = sourceTyped.Mesh;
      _materialInstances = new MaterialInstanceCollection(sourceTyped.MaterialInstances);
      _passHashes = _materialInstances.PassHashes;

      if (sourceTyped.MorphWeights != null)
        MorphWeights = sourceTyped.MorphWeights.Clone();

#if ANIMATION
      if (sourceTyped.SkeletonPose != null)
        _skeletonPose = sourceTyped.SkeletonPose.Clone();
#endif
    }
예제 #3
0
    /// <summary>
    /// Initializes a new instance of the <see cref="MeshNode"/> class.
    /// </summary>
    /// <param name="mesh">The <see cref="Mesh"/>.</param>
    /// <exception cref="ArgumentNullException">
    /// <paramref name="mesh"/> is <see langword="null"/>. 
    /// </exception>
    public MeshNode(Mesh mesh)
    {
      if (mesh == null)
        throw new ArgumentNullException("mesh");

      IsRenderable = true;
      CastsShadows = true;

      _mesh = mesh;

      _materialInstances = new MaterialInstanceCollection(_mesh.Materials);
      _passHashes = _materialInstances.PassHashes;
      SetHasAlpha();

      // Ensure that MorphWeights are set. (Required for correct rendering.)
      if (mesh.HasMorphTargets())
        MorphWeights = new MorphWeightCollection(mesh);

      // We do not call OnInitializeShape here because virtual methods should not be called
      // in constructor.
      Shape = mesh.BoundingShape;
    }