예제 #1
0
            internal void Draw(uint renderId, DefenseShields shield)
            {
                try
                {
                    var ib = _backing.IndexBuffer[_lod];

                    int index       = 0;
                    var damageColor = shield.GetModulatorColor();
                    damageColor.W = 0.5f;

                    while (index < _impactRings.Count)
                    {
                        bool retain = false;

                        var impactRingData = _impactRings[index];

                        float progress;
                        float ringIntesity;
                        float ringSize;
                        float ringSizeCofficient;

                        if (impactRingData.AnimationStartClock <= ImpactRingExpandTicks)
                        {
                            progress           = ((float)impactRingData.AnimationStartClock / ImpactRingExpandTicks) * 0.75f + 0.25f;
                            ringIntesity       = (progress * 0.5f) + 0.5f;
                            ringSize           = 1 - ((1 - progress) * (1 - progress));
                            ringSizeCofficient = 0.5f / ringSize;
                        }
                        else
                        {
                            progress           = 1 - (((float)impactRingData.AnimationStartClock - ImpactRingExpandTicks) / ImpactRingFadeTicks);
                            ringIntesity       = (progress * 0.5f) + 0.5f;
                            ringSize           = 1;
                            ringSizeCofficient = 0.5f;
                        }

                        impactRingData.AnimationStartClock++;

                        var v4 = new Vector4
                        {
                            W = damageColor.W,
                            X = damageColor.X * 2f * ringIntesity,
                            Y = damageColor.Y * 2f * ringIntesity,
                            Z = damageColor.Z * 2f * ringIntesity
                        };

                        if (impactRingData.LodLevel == _lod)
                        {
                            for (int x = 0; x < impactRingData.RingTriangles.Count; x++)
                            {
                                TriangleData triangleData = impactRingData.RingTriangles[x];

                                int i = triangleData.TriangleIndex * 3;

                                var i0 = ib[i];
                                var i1 = ib[i + 1];
                                var i2 = ib[i + 2];

                                var v0 = _vertexBuffer[i0];
                                var v1 = _vertexBuffer[i1];
                                var v2 = _vertexBuffer[i2];

                                var n0 = _normalBuffer[i0];
                                var n1 = _normalBuffer[i1];
                                var n2 = _normalBuffer[i2];
                                MyTransparentGeometry.AddTriangleBillboard(v0, v1, v2,
                                                                           n0, n1, n2,
                                                                           triangleData.UVInfoV0 * ringSizeCofficient + HalfShift,
                                                                           triangleData.UVInfoV1 * ringSizeCofficient + HalfShift,
                                                                           triangleData.UVInfoV2 * ringSizeCofficient + HalfShift,
                                                                           _impactRingMaterial, renderId, (v0 + v1 + v2) / 3, v4, BlendTypeEnum.PostPP);
                            }

                            if (impactRingData.AnimationStartClock <= ImpactRingExpandTicks + ImpactRingFadeTicks)
                            {
                                retain = true;
                            }
                        }

                        if (retain)
                        {
                            index++;
                        }
                        else
                        {
                            var last     = _impactRings.Count - 1;
                            var lastData = _impactRings[last];
                            _impactRings.RemoveAtFast(last);
                            Session.Instance.RingPool.Return(lastData);

                            //_impactRings[index] = _impactRings[_impactRings.Count - 1];
                            //_impactRings.RemoveAt(_impactRings.Count - 1);
                        }
                    }

                    /* Superseded
                     * if (ImpactsFinished && !_refresh) return;
                     * var ib = _backing.IndexBuffer[_lod];
                     * Vector4 color;
                     * if (!ImpactsFinished)
                     * {
                     *  color = _waveColor;
                     *  _faceMaterial = _faceWave;
                     * }
                     * else
                     * {
                     *  color = _refreshColor;
                     *  _faceMaterial = _faceCharge;
                     * }
                     * for (int i = 0, j = 0; i < ib.Length; i += 3, j++)
                     * {
                     *  var face = _triColorBuffer[j];
                     *  if (face != 1 && face != 2) continue;
                     *
                     *  var i0 = ib[i];
                     *  var i1 = ib[i + 1];
                     *  var i2 = ib[i + 2];
                     *
                     *  var v0 = _vertexBuffer[i0];
                     *  var v1 = _vertexBuffer[i1];
                     *  var v2 = _vertexBuffer[i2];
                     *
                     *  var n0 = _normalBuffer[i0];
                     *  var n1 = _normalBuffer[i1];
                     *  var n2 = _normalBuffer[i2];
                     *
                     *  MyTransparentGeometry.AddTriangleBillboard(v0, v1, v2, n0, n1, n2, _v20, _v21, _v22, _faceMaterial, renderId, (v0 + v1 + v2) / 3, color);
                     * }
                     */
                }
                catch (Exception ex) { Log.Line($"Exception in IcoSphere Draw - renderId {renderId.ToString()}: {ex}"); }
            }
예제 #2
0
            internal void Draw(uint renderId, bool sphereOnCamera, DefenseShields shield)
            {
                try
                {
                    var ib = _backing.IndexBuffer[_lod];

                    int index       = 0;
                    var damageColor = shield.GetModulatorColor();
                    damageColor.W = 0.5f;

                    while (index < ImpactRings.Count)
                    {
                        bool retain = false;

                        var impactRingData = ImpactRings[index];

                        float progress;
                        float ringIntesity;
                        float ringSize;
                        float ringSizeCofficient;

                        if (impactRingData.AnimationStartClock <= ImpactRingExpandTicks)
                        {
                            progress           = ((float)impactRingData.AnimationStartClock / ImpactRingExpandTicks) * 0.75f + 0.25f;
                            ringIntesity       = (progress * 0.5f) + 0.5f;
                            ringSize           = 1 - ((1 - progress) * (1 - progress));
                            ringSizeCofficient = 0.5f / ringSize;
                        }
                        else
                        {
                            progress           = 1 - (((float)impactRingData.AnimationStartClock - ImpactRingExpandTicks) / ImpactRingFadeTicks);
                            ringIntesity       = (progress * 0.5f) + 0.5f;
                            ringSize           = 1;
                            ringSizeCofficient = 0.5f;
                        }

                        impactRingData.AnimationStartClock++;


                        var v4 = new Vector4
                        {
                            W = damageColor.W,
                            X = damageColor.X * 2f * ringIntesity,
                            Y = damageColor.Y * 2f * ringIntesity,
                            Z = damageColor.Z * 2f * ringIntesity
                        };

                        if (impactRingData.LodLevel == _lod)
                        {
                            if (sphereOnCamera)
                            {
                                for (int x = 0; x < impactRingData.RingTriangles.Count; x++)
                                {
                                    TriangleData triangleData = impactRingData.RingTriangles[x];

                                    int i = triangleData.TriangleIndex * 3;

                                    var i0 = ib[i];
                                    var i1 = ib[i + 1];
                                    var i2 = ib[i + 2];

                                    var v0 = _vertexBuffer[i0];
                                    var v1 = _vertexBuffer[i1];
                                    var v2 = _vertexBuffer[i2];

                                    var n0 = _normalBuffer[i0];
                                    var n1 = _normalBuffer[i1];
                                    var n2 = _normalBuffer[i2];
                                    MyTransparentGeometry.AddTriangleBillboard(v0, v1, v2,
                                                                               n0, n1, n2,
                                                                               triangleData.UVInfoV0 * ringSizeCofficient + HalfShift,
                                                                               triangleData.UVInfoV1 * ringSizeCofficient + HalfShift,
                                                                               triangleData.UVInfoV2 * ringSizeCofficient + HalfShift,
                                                                               _impactRingMaterial, renderId, (v0 + v1 + v2) / 3, v4, BlendTypeEnum.PostPP);
                                }
                            }

                            if (impactRingData.AnimationStartClock <= ImpactRingExpandTicks + ImpactRingFadeTicks)
                            {
                                retain = true;
                            }
                        }

                        if (retain)
                        {
                            index++;
                        }
                        else
                        {
                            var last     = ImpactRings.Count - 1;
                            var lastData = ImpactRings[last];
                            ImpactRings.RemoveAtFast(last);
                            Session.Instance.RingPool.Return(lastData);
                            Session.Instance.ActiveShieldRings--;
                        }
                    }
                }
                catch (Exception ex) { Log.Line($"Exception in IcoSphere Draw - renderId {renderId.ToString()}: {ex}"); }
            }