public override void DrawModel(GLContext control, GLFrameworkEngine.Pass pass, Vector4 highlightColor) { if (!ModelInFrustum(control) || !IsVisible) { return; } if (ProbeDebugger.ForceUpdate) { UpdateProbeMap = true; } if (Runtime.DebugRendering != Runtime.DebugRender.Default) { control.CurrentShader = GlobalShaders.GetShader("DEBUG"); } else if (control.CurrentShader != BfresRender.DefaultShader) { control.CurrentShader = BfresRender.DefaultShader; } Transform.UpdateMatrix(); foreach (BfresModelAsset model in Models) { if (model.IsVisible) { model.Draw(control, pass, this); } } if (Runtime.DisplayBones) { DrawSkeleton(control); } if (Runtime.RenderBoundingBoxes) { DrawBoundings(control); } }
public void Draw(GLContext control, GLFrameworkEngine.Pass pass, BfresRender parentRender) { if (disposed || !IsVisible) { return; } GL.Enable(EnableCap.TextureCubeMapSeamless); if (pass == GLFrameworkEngine.Pass.OPAQUE && Meshes.Any(x => x.IsSelected)) { GL.Enable(EnableCap.StencilTest); GL.Clear(ClearBufferMask.StencilBufferBit); GL.ClearStencil(0); GL.StencilFunc(StencilFunction.Always, 0x1, 0x1); GL.StencilOp(StencilOp.Keep, StencilOp.Replace, StencilOp.Replace); } //Go through each mesh and map materials using shader programs var meshes = RenderLayer.Sort(this); foreach (var mesh in meshes) { if (mesh.Pass != pass || !mesh.IsVisible || mesh.IsDepthShadow || mesh.IsCubeMap || mesh.UseColorBufferPass) { continue; } //Load the material data var material = (FMAT)mesh.Shape.Material; mesh.Material = material; //Update the parent renderer ((BfresMaterialAsset)mesh.MaterialAsset).ParentRenderer = parentRender; if (!ModelData.Skeleton.Bones[mesh.BoneIndex].Visible) { continue; } RenderMesh(control, mesh); } GL.DepthMask(true); GL.BindTexture(TextureTarget.Texture2D, 0); GL.Enable(EnableCap.DepthTest); GL.Disable(EnableCap.TextureCubeMapSeamless); GL.Disable(EnableCap.AlphaTest); GL.Disable(EnableCap.Blend); GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); if (meshes.Any(x => x.UseColorBufferPass)) { ScreenBufferTexture.FilterScreen(control); } foreach (var mesh in meshes.Where(x => x.UseColorBufferPass)) { if (pass != mesh.Pass || !mesh.IsVisible) { continue; } //Load the material data var material = (FMAT)mesh.Shape.Material; mesh.Material = material; ((BfresMaterialAsset)mesh.MaterialAsset).ParentRenderer = parentRender; if (!ModelData.Skeleton.Bones[mesh.BoneIndex].Visible) { continue; } RenderMesh(control, mesh); } if (Runtime.RenderSettings.WireframeOverlay) { DrawWireframeOutline(control); } if (pass == GLFrameworkEngine.Pass.TRANSPARENT) { DrawSelection(control, parentRender.IsSelected || this.IsSelected); } GL.DepthMask(true); GL.Enable(EnableCap.DepthTest); GL.Disable(EnableCap.TextureCubeMapSeamless); GL.Disable(EnableCap.AlphaTest); GL.Disable(EnableCap.Blend); GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); }