Example #1
0
        /// <summary>
        /// Sets the new submesh.
        /// </summary>
        /// <param name="context">The render context.</param>
        /// <param name="submesh">The submesh.</param>
        /// <param name="effectPassBinding">The effect pass binding.</param>
        /// <param name="effectPassParameterBindings">
        /// The effect parameter bindings containing per-pass parameter bindings.
        /// (Can also contain other parameter binding, e.g. per-instance, which are ignored.
        /// </param>
        /// <remarks>
        /// The current batch is automatically flushed when the submesh is changed.
        /// </remarks>
        public void SetSubmesh(RenderContext context, Submesh submesh, EffectPassBinding effectPassBinding,
                               EffectParameterBindingCollection effectPassParameterBindings)
        {
            Flush();

            _renderContext               = context;
            _submesh                     = submesh;
            _effectPassBinding           = effectPassBinding;
            _effectPassParameterBindings = effectPassParameterBindings;
        }
        protected virtual void CloneCore(EffectBinding source)
        {
            EffectEx = source.EffectEx;
              MaterialBinding = source.MaterialBinding;
              // Note: MorphWeights need to be set by MeshNode.
              TechniqueBinding = source.TechniqueBinding.Clone();
              OpaqueData = source.OpaqueData;
              UserData = source.UserData;

              // Clone parameter bindings (deep copy).
              ParameterBindings = new EffectParameterBindingCollection(source.Hints);
              foreach (var binding in source.ParameterBindings)
            ParameterBindings.Add(binding.Clone());
        }
Example #3
0
        /// <summary>
        /// Releases all resources used by an instance of the <see cref="RenderBatch{TVertex,TIndex}"/> class.
        /// </summary>
        public void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            _renderContext               = null;
            _submesh                     = null;
            _effectPassBinding           = new EffectPassBinding();
            _effectPassParameterBindings = null;

            _instanceVertexBuffer.Dispose();
            IsDisposed = true;
        }
Example #4
0
        public EffectBinding(IGraphicsService graphicsService, Effect effect, IDictionary<string, object> opaqueData, EffectParameterHint hints)
        {
            if (graphicsService == null)
            throw new ArgumentNullException("graphicsService");
              if (effect == null)
            throw new ArgumentNullException("effect");

              if (effect is AlphaTestEffect && !(effect is WrappedAlphaTestEffect)
              || effect is BasicEffect && !(effect is WrappedBasicEffect)
              || effect is DualTextureEffect && !(effect is WrappedDualTextureEffect)
              || effect is EnvironmentMapEffect && !(effect is WrappedEnvironmentMapEffect)
              || effect is SkinnedEffect && !(effect is WrappedSkinnedEffect))
              {
            throw new ArgumentException("The EffectBinding class cannot be used with XNA stock effects (e.g. BasicEffect). Use a derived effect binding instead (e.g. BasicEffectBinding).");
              }

              // Initialize additional information, if not already initialized.
              EffectEx = EffectEx.From(effect, graphicsService);

              if (KeepOpaqueData)
            OpaqueData = opaqueData;

              // Initialize effect bindings.
              ParameterBindings = new EffectParameterBindingCollection(hints);
              InitializeBindings(graphicsService, opaqueData);
        }