public static void AddLineBillboard(string material, Color color, Vector3D origin, int renderObjectID, ref MatrixD worldToLocal, Vector3 directionNormalized, float length, float thickness, int priority = 0, bool near = false, 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.Priority = priority; 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; MyUtils.GetPolyLineQuad(out quad, ref polyLine, cameraPosition); CreateBillboard(billboard, ref quad, material, ref color, ref origin, false, near, false, 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); }
// 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); } }
// 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, Color color, Vector3D origin, int renderObjectID, ref MatrixD worldToLocal, float radius, float angle, int priority = 0, bool colorize = false, bool near = false, bool lowres = false, int customViewProjection = -1) { Debug.Assert(material != null); if (!IsEnabled) { return; } MyDebug.AssertIsValid(origin); MyDebug.AssertIsValid(angle); MyQuadD quad; if (MyUtils.GetBillboardQuadAdvancedRotated(out quad, origin, radius, radius, angle, MyTransparentGeometry.Camera.Translation) != false) { VRageRender.MyBillboard billboard = VRageRender.MyRenderProxy.BillboardsPoolWrite.Allocate(); if (billboard == null) { return; } billboard.Priority = priority; CreateBillboard(billboard, ref quad, material, ref color, ref origin, colorize, near, lowres, 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; } VRageRender.MyRenderProxy.AddBillboard(billboard); } }