示例#1
0
        public void Render(IEffect effect)
        {
            effect.SetTexture("tex0", _noTexture);
            effect.CommitChanges();

            _vertexRenderer.RenderForShader(PrimitiveType.LineList, 0, 3);
        }
示例#2
0
        public void Render(ModelInstance modelInstance, IEffect effect)
        {
            foreach (var meshInstance in modelInstance.MeshInstances)
            {
                var renderer = GetRendererFor(meshInstance);

                var dataStream = renderer.LockVertexBuffer();
                dataStream.WriteRange(meshInstance.VertexBuffer);
                renderer.UnlockVertexBuffer();

                if (meshInstance.TextureArea == null)
                {
                    meshInstance.TextureArea = _graphicsContext.GetTexture(meshInstance.TextureName);
                }

                if (meshInstance.TextureName != _lastTextureName)
                {
                    _lastTextureName = meshInstance.TextureName;

                    effect.SetTexture("tex0", meshInstance.TextureArea);
                    effect.CommitChanges();
                }

                renderer.RenderForShader(PrimitiveType.TriangleList, 0, meshInstance.TriangleCount);
            }
        }
示例#3
0
        private void Render()
        {
            GraphicsContext.CullMode = CullMode.None;
            GraphicsContext.Clear(1.0f);

            SetFilterMode();

            _modelRenderer.SetEffect(_effect);
            _modelRenderer.SelectedAnchor = _editor.FocusAnchor;

            _effect.Technique = _techniqueHandle;
            _effect.Begin();

            _effect.BeginPass(0);

            _effect.SetMatrix("worldMat", Matrix.Identity);
            var wvpm = _viewMat * _projection;

            _effect.SetMatrix("worldViewProjMat", wvpm);

            _effect.CommitChanges();

            _ray = BasicCamera.ScreenToWorldRay(GraphicsContext, MousePosition.X, MousePosition.Y);

            RenderModel();

            _effect.SetMatrix("worldMat", Matrix.Identity);
            _effect.SetMatrix("worldViewProjMat", wvpm);
            _effect.CommitChanges();
            GraphicsContext.World      = Matrix.Identity;
            GraphicsContext.View       = _viewMat;
            GraphicsContext.Projection = _projection;

            _modelRenderer.Wireframe = false;
            _coordinateMarkerRenderer.Render(_effect);
            _modelRenderer.FloorPlane();

            _effect.EndPass();

            _effect.End();

            _guiRenderer.Render(_guiManager);

            _consoleRenderer.Render();
        }
示例#4
0
 /// <summary>
 /// Render the particle system.
 /// </summary>
 /// <param name="effect">The effect used for rendering the particle system.</param>
 public override void Render(IEffect effect)
 {
     if (particles.Count > 1)
     {
         // Render all particles
         Device.Instance.VertexUnit  = vertexUnit;
         Device.Instance.IndexStream = indexStream;
         textures.Apply();
         effect.CommitChanges();
         Device.Instance.DrawIndexed(vertexUnit.Position, 0, particles.Count * 4, indexStream.Position, particles.Count * 2);
     }
 }
示例#5
0
        /// <summary>
        /// Draws a subset with given index.
        /// </summary>
        /// <remarks>
        /// For drawing a whole mesh, the method <c>Draw</c> should be used for optimized speed.
        /// </remarks>
        /// <param name="effect">The current effect that is used for rendering.</param>
        /// <param name="index">Index of the subSet to draw.</param>
        public void DrawSubSet(IEffect effect, int index)
        {
            // Apply next texture if there is one in the texture list.
            if (Textures.Count > index)
            {
                (Textures[index] as Textures).Apply();
            }

            effect.CommitChanges();
            SubSet s = (SubSet)subSets[index];

            (subSets[index] as SubSet).Draw();
        }
示例#6
0
        private void RenderBatches()
        {
            int i              = 0;
            int iPass          = 0;
            int startIndex     = 0;
            int startIndexPass = 0;

            while (i < batchFilled)
            {
                Batch   batch  = batches[i];
                IEffect effect = batch.QuadFactory.Effect;
                // get and apply vertexUnit
                VertexUnit vertexUnit = batch.QuadFactory.VertexUnit;
                Device.Instance.VertexUnit = vertexUnit;
                // begin effect
                int steps = effect.Begin();
                for (int iStep = 0; iStep < steps; iStep++)
                {
                    // set i and startIndex back to the value of the first pass
                    i          = iPass;
                    startIndex = startIndexPass;
                    // apply the texture and other quad specific variables
                    batch.Quad.Apply();
                    // begin pass
                    effect.BeginPass(iStep);
                    do
                    {
                        // get the current bach, apply and draw it.
                        batch = batches[i];
                        // if (i != iPass) OctoberUpdate Bug
                        {
                            batch.Quad.Apply();
                            effect.CommitChanges();
                        }

                        Device.Instance.DrawIndexed(vertexUnit.Position, batch.VertexBufferStart, batch.VertexBufferEnd,
                                                    indexStream.Position + startIndex, batch.PrimitiveCount);
                        startIndex += batch.PrimitiveCount * 3;
                        i++;
                    } while (i < batchFilled && batches[i].QuadFactory == null);
                    effect.EndPass();
                }
                // end the effect
                effect.End();
                // set new pass base values
                iPass          = i;
                startIndexPass = startIndex;
            }
        }
示例#7
0
 /// <summary>
 /// Commits changes within a pass.
 /// </summary>
 public void CommitChanges()
 {
     effect.CommitChanges();
 }