예제 #1
0
        public void RenderScreenSpace(RenderInfo info, Matrix4x4 transformMatrix, Viewport viewport)
        {
            if (info.showAnnotations)
            {
                Font font = new Font("Calibri", 12.0f * 0.75f);
                List <DebugRenderPrimitive> primitivesToRender = GetCachedPrimitives();
                foreach (DebugRenderPrimitive primitive in primitivesToRender)
                {
                    if (primitive.Annotation != null && primitive.Annotation.IsValidAt(info.time))
                    {
                        Vector3 screenPosition = GeometryMath.Project(primitive.WorldBounds.Center, transformMatrix, viewport);
                        if (screenPosition.z >= 0.0)
                        {
                            Size    textSize     = TextRenderer.MeasureText(primitive.Annotation.Text, font);
                            Vector3 textHalfSize = new Vector3((double)textSize.Width, (double)textSize.Height, 0.0) * 0.5;

                            OpenGLDrawHelper.FillRectangle(DebugRenderControl.gl, screenPosition - textHalfSize, screenPosition + textHalfSize, primitive.Annotation.Color.Brightness > 0.5 ? new Color32(0, 0, 0, 255) : new Color32(255, 255, 255, 255), false);

                            DebugRenderControl.gl.DrawText((int)(screenPosition.x - textHalfSize.x) + 2, (int)(screenPosition.y - textHalfSize.y * 0.4),
                                                           primitive.Annotation.Color.R, primitive.Annotation.Color.G, primitive.Annotation.Color.B,
                                                           "Calibri", 12.0f, primitive.Annotation.Text);
                        }
                    }
                }
            }
        }