Beispiel #1
0
        public void Setup(TrailInitData initData, Transform pointStart, Transform pointEnd, Material material, bool editor)
        {
            PointStart        = pointStart;
            PointEnd          = pointEnd;
            Material          = material;
            Granularity       = initData.Granularity;
            TrailLength       = initData.TrailLength;
            Whitestep         = initData.Whitestep;
            SamplingFrequency = initData.SamplingFrequency;

            gameObject.layer = 12;
            if (editor)
            {
                SortingOrder = 3;
            }

            _elemPool      = new ElementPool(TrailLength);
            _vertexPool    = new VertexPool(Material, this);
            _vertexSegment = _vertexPool.GetVertices(Granularity * 3, (Granularity - 1) * 12);
            UpdateIndices();

            _vertexPool.SetMeshObjectActive(false);

            _inited = true;
        }
Beispiel #2
0
        public void Setup(TrailInitData initData, Transform pointStart, Transform pointEnd, Material material)
        {
            PointStart  = pointStart;
            PointEnd    = pointEnd;
            MyMaterial  = material;
            Granularity = initData.Granularity;
            TrailLength = initData.TrailLength;
            Whitestep   = initData.Whitestep;

            _elemPool      = new ElementPool(TrailLength);
            _trailWidth    = (PointStart.position - PointEnd.position).magnitude;
            _vertexPool    = new VertexPool(MyMaterial, this);
            _vertexSegment = _vertexPool.GetVertices(Granularity * 3, (Granularity - 1) * 12);
            UpdateIndices();

            _vertexPool.SetMeshObjectActive(false);

            _inited = true;
        }
Beispiel #3
0
        void InitMeshObj()
        {
            //create a new mesh obj
            mMeshObj           = new GameObject("WeaponTrialObje: " + gameObject.name);
            mMeshObj.layer     = gameObject.layer;
            mMeshObj.hideFlags = HideFlags.HideAndDontSave;
            mMeshObj.SetActive(true);
            MeshFilter mf = mMeshObj.AddComponent <MeshFilter>();

            m_Render = mMeshObj.AddComponent <MeshRenderer>();
            m_Render.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
            m_Render.receiveShadows    = false;
            mf.sharedMesh      = new Mesh();
            mf.sharedMesh.name = "WeaponTrialMesh";

            //init vertexpool
            mVertexPool    = new VertexPool(mf.sharedMesh, GenerateMaterialInstance());
            mVertexSegment = mVertexPool.GetVertices(GetGranularity() * 3, (GetGranularity() - 1) * 12);

            UpdateMaterial();
            UpdateIndices();
        }