Пример #1
0
        public void Render()
        {
            if (!gameProperties.ShowAreaTriggers)
            {
                return;
            }

            foreach (var areaTrigger in areaTriggerStore)
            {
                if (areaTrigger.ContinentId != gameContext.CurrentMap.Id)
                {
                    continue;
                }

                var areaTriggerPosition = new Vector3(areaTrigger.X, areaTrigger.Y, areaTrigger.Z);

                if ((cameraManager.Position - areaTriggerPosition.ToOpenGlPosition()).LengthSquared() > AreaTriggerVisibilityDistanceSquare)
                {
                    continue;
                }

                t.Position = areaTriggerPosition.ToOpenGlPosition();
                float height = 0;

                if (areaTrigger.Shape == AreaTriggerShape.Box)
                {
                    height     = areaTrigger.BoxHeight / 2;
                    t.Scale    = new Vector3(areaTrigger.BoxWidth / 2, areaTrigger.BoxHeight / 2, areaTrigger.BoxLength / 2);
                    t.Rotation = Quaternion.FromEuler(0, MathUtil.RadiansToDegrees(-areaTrigger.BoxYaw), 0.0f);

                    renderManager.Render(boxMesh, transcluentMaterial, 0, t);
                    renderManager.Render(boxMesh, wireframe, 0, t);
                    renderManager.Render(boxMesh, wireframeBehind, 0, t);
                }
                else if (areaTrigger.Shape == AreaTriggerShape.Sphere)
                {
                    t.Scale = new Vector3(areaTrigger.Radius);
                    height  = areaTrigger.Radius;

                    renderManager.Render(sphereMesh, transcluentMaterial, 0, t);
                    renderManager.Render(sphereMesh, wireframe, 0, t);
                    renderManager.Render(sphereMesh, wireframeBehind, 0, t);
                }

                uiManager.DrawWorldText("calibri", new Vector2(0.5f, 1f), "Areatrigger " + areaTrigger.Id, 2.5f, Matrix.TRS(t.Position + Vector3.Up * height, in Quaternion.Identity, in Vector3.One));
            }
        }