void register.IRegisterable.RenderRegister(register.Viewpoint viewpoint, ref Viewport viewport, render.RenderQueueGroup queueGroup, PoolManager poolManager) { ContainmentType containment; viewpoint.Frustum.Contains(ref _boundingSphere, out containment); if (containment == ContainmentType.Disjoint) { return; } queueGroup.Register( EllipsoidPrimitiveRenderable.CreateInstance(poolManager.GetPool<EllipsoidPrimitiveRenderable>(), _verticesCount, _indicesWFCount, _indicesCount, _vertexBuffer, _indicesWFBuffer, _indicesBuffer, _world, viewpoint.View, viewpoint.Projection, _color, _isOpaque), render.RenderQueueNames.Custom4); }
public virtual void Render(render.GraphicsDeviceManager manager, string technique) { if (!String.IsNullOrEmpty(technique)) { return; } manager.BasicEffect.World = _world; manager.BasicEffect.View = _view; manager.BasicEffect.Projection = _projection; manager.BasicEffect.DiffuseColor = _color.ToVector3(); manager.BasicEffect.VertexColorEnabled = false; manager.GraphicsDevice.VertexDeclaration = manager.VertexPositionColor; manager.GraphicsDevice.Vertices[0].SetSource(_vertexBuffer, 0, manager.VertexPositionColor.GetVertexStrideSize(0)); if (!_isOpaque) { manager.BasicEffect.Alpha = 0.1f; } manager.BasicEffect.Begin(); foreach (EffectPass effectPass in manager.BasicEffect.CurrentTechnique.Passes) { effectPass.Begin(); if (!_isOpaque) { manager.GraphicsDevice.Indices = _indicesWFBuffer; manager.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, _verticesCount, 0, _indicesWFCount / 2); bool oldAB = manager.GraphicsDevice.RenderState.AlphaBlendEnable; bool oldDBW = manager.GraphicsDevice.RenderState.DepthBufferWriteEnable; Blend oldSrcBlend = manager.GraphicsDevice.RenderState.SourceBlend; Blend oldDestBlend = manager.GraphicsDevice.RenderState.DestinationBlend; manager.GraphicsDevice.RenderState.DepthBufferWriteEnable = false; manager.GraphicsDevice.RenderState.AlphaBlendEnable = true; manager.GraphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha; manager.GraphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha; manager.GraphicsDevice.Indices = _indicesBuffer; manager.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, _verticesCount, 0, _indicesCount / 3); manager.GraphicsDevice.RenderState.DepthBufferWriteEnable = oldDBW; manager.GraphicsDevice.RenderState.AlphaBlendEnable = oldAB; manager.GraphicsDevice.RenderState.SourceBlend = oldSrcBlend; manager.GraphicsDevice.RenderState.DestinationBlend = oldDestBlend; } else { manager.GraphicsDevice.Indices = _indicesBuffer; manager.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, _verticesCount, 0, _indicesCount / 3); } effectPass.End(); } manager.BasicEffect.End(); manager.BasicEffect.Alpha = 1.0f; }
public override void Register(List<register.IRegisterable> registerables, register.ReflectSet reflects, render.GpuTaskManager gpuManager, MaterialManager materialManager, PoolManager poolManager) { base.Register(registerables, reflects, gpuManager, materialManager, poolManager); BoundingSphere currentBounding; Helpers.TransformBoundingSphere(ref _boundingSphere, ref _lastWorld, out currentBounding); registerables.Add(EllipsoidPrimitiveRegisterable.CreateInstance( poolManager.GetPool<EllipsoidPrimitiveRegisterable>(), _vertices.Length, _indicesWF.Length, _indices.Length, _vertexBuffer, _indexWFBuffer, _indexBuffer, _lastWorld, Color, IsOpaque, currentBounding)); }