Ejemplo n.º 1
0
        internal static void AddBillboardOriented(string material, Vector4 color, Vector3D origin, Vector3 leftVector, Vector3 upVector, float radius,
                                                  MyBillboard.BlenType blendType = MyBillboard.BlenType.Standard, float softParticleDistanceScale = 1.0f, int customViewProjection = -1)
        {
            if (!MyRender11.DebugOverrides.BillboardsDynamic)
            {
                return;
            }

            Debug.Assert(material != null);

            origin.AssertIsValid();
            leftVector.AssertIsValid();
            upVector.AssertIsValid();
            radius.AssertIsValid();
            MyDebug.AssertDebug(radius > 0);

            MyBillboard billboard = MyBillboardRenderer.AddBillboardOnce();

            if (billboard == null)
            {
                return;
            }

            billboard.CustomViewProjection = customViewProjection;
            billboard.BlendType            = blendType;

            MyQuadD quad;

            MyUtils.GetBillboardQuadOriented(out quad, ref origin, radius, ref leftVector, ref upVector);

            CreateBillboard(billboard, ref quad, material, ref color, ref origin, softParticleDistanceScale);
        }
Ejemplo n.º 2
0
        //  Add billboard for one frame only. This billboard isn't particle (it doesn't survive this frame, doesn't have update/draw methods, etc).
        //  It's used by other classes when they want to draw some billboard (e.g. rocket thrusts, reflector glare).
        public static void AddPointBillboard(string material,
                                             Vector4 color, Vector3D origin, int renderObjectID, ref MatrixD worldToLocal, float radius, float angle,
                                             int customViewProjection = -1, MyBillboard.BlenType blendType = MyBillboard.BlenType.Standard)
        {
            Debug.Assert(material != null);
            if (!IsEnabled)
            {
                return;
            }

            MyDebug.AssertIsValid(origin);
            MyDebug.AssertIsValid(angle);

            MyQuadD quad;
            Vector3 diff = MyTransparentGeometry.Camera.Translation - origin;

            if (MyUtils.GetBillboardQuadAdvancedRotated(out quad, origin, radius, radius, angle, (origin + (Vector3D)MyTransparentGeometry.Camera.Forward * diff.Length())) != false)
            {
                VRageRender.MyBillboard billboard = VRageRender.MyRenderProxy.BillboardsPoolWrite.Allocate();
                if (billboard == null)
                {
                    return;
                }

                CreateBillboard(billboard, ref quad, material, ref color, ref origin, customViewProjection);
                billboard.BlendType = blendType;

                if (renderObjectID != -1)
                {
                    Vector3D.Transform(ref billboard.Position0, ref worldToLocal, out billboard.Position0);
                    Vector3D.Transform(ref billboard.Position1, ref worldToLocal, out billboard.Position1);
                    Vector3D.Transform(ref billboard.Position2, ref worldToLocal, out billboard.Position2);
                    Vector3D.Transform(ref billboard.Position3, ref worldToLocal, out billboard.Position3);
                    billboard.ParentID = renderObjectID;
                }

                VRageRender.MyRenderProxy.AddBillboard(billboard);
            }
        }
Ejemplo n.º 3
0
        public static void AddLineBillboard(string material,
                                            Vector4 color, Vector3D origin, int renderObjectID, ref MatrixD worldToLocal, Vector3 directionNormalized, float length, float thickness,
                                            MyBillboard.BlenType blendType = MyBillboard.BlenType.Standard, int customViewProjection = -1)
        {
            Debug.Assert(material != null);
            if (!IsEnabled)
            {
                return;
            }


            MyDebug.AssertIsValid(origin);
            MyDebug.AssertIsValid(length);
            MyDebug.AssertDebug(length > 0);
            MyDebug.AssertDebug(thickness > 0);

            //VRageRender.MyBillboard billboard = m_preallocatedBillboards.Allocate();
            //VRageRender.MyBillboard billboard = new VRageRender.MyBillboard();
            VRageRender.MyBillboard billboard = VRageRender.MyRenderProxy.BillboardsPoolWrite.Allocate();
            if (billboard == null)
            {
                return;
            }

            billboard.BlendType = blendType;
            billboard.UVOffset  = Vector2.Zero;
            billboard.UVSize    = Vector2.One;

            MyPolyLineD polyLine;

            polyLine.LineDirectionNormalized = directionNormalized;
            polyLine.Point0    = origin;
            polyLine.Point1    = origin + directionNormalized * length;
            polyLine.Thickness = thickness;

            MyQuadD  quad;
            Vector3D cameraPosition = customViewProjection == -1 ? MyTransparentGeometry.Camera.Translation : VRageRender.MyRenderProxy.BillboardsViewProjectionWrite[customViewProjection].CameraPosition;
            Vector3D cameraToPoly   = cameraPosition - polyLine.Point0;

            if (Vector3D.IsZero(cameraToPoly, 1e-6))
            {
                return;
            }
            MyUtils.GetPolyLineQuad(out quad, ref polyLine, cameraPosition);

            CreateBillboard(billboard, ref quad, material, ref color, ref origin, customViewProjection);

            if (renderObjectID != -1)
            {
                Vector3D.Transform(ref billboard.Position0, ref worldToLocal, out billboard.Position0);
                Vector3D.Transform(ref billboard.Position1, ref worldToLocal, out billboard.Position1);
                Vector3D.Transform(ref billboard.Position2, ref worldToLocal, out billboard.Position2);
                Vector3D.Transform(ref billboard.Position3, ref worldToLocal, out billboard.Position3);
                billboard.ParentID = renderObjectID;
            }

            billboard.Position0.AssertIsValid();
            billboard.Position1.AssertIsValid();
            billboard.Position2.AssertIsValid();
            billboard.Position3.AssertIsValid();

            VRageRender.MyRenderProxy.AddBillboard(billboard);
        }
Ejemplo n.º 4
0
 //  Add billboard for one frame only. This billboard isn't particle (it doesn't survive this frame, doesn't have update/draw methods, etc).
 //  It's used by other classes when they want to draw some billboard (e.g. rocket thrusts, reflector glare).
 public static void AddLineBillboard(string material,
                                     Vector4 color, Vector3D origin, Vector3 directionNormalized, float length, float thickness,
                                     MyBillboard.BlenType blendType = MyBillboard.BlenType.Standard, int customViewProjection = -1)
 {
     AddLineBillboard(material, color, origin, -1, ref MatrixD.Identity, directionNormalized, length, thickness, blendType, customViewProjection);
 }
Ejemplo n.º 5
0
 //  Add billboard for one frame only. This billboard isn't particle (it doesn't survive this frame, doesn't have update/draw methods, etc).
 //  It's used by other classes when they want to draw some billboard (e.g. rocket thrusts, reflector glare).
 public static void AddPointBillboard(string material,
                                      Vector4 color, Vector3D origin, float radius, float angle, int customViewProjection = -1, MyBillboard.BlenType blendType = MyBillboard.BlenType.Standard)
 {
     AddPointBillboard(material, color, origin, -1, ref MatrixD.Identity, radius, angle, customViewProjection, blendType);
 }