Exemplo n.º 1
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;
        }
Exemplo n.º 2
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.
        }
Exemplo n.º 3
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.
    }
Exemplo n.º 4
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;
    }