Exemplo n.º 1
0
 public Sprite(VertexPool.VertexSegment segment, float width, float height, STYPE type, ORIPOINT oripoint, Camera cam, int uvStretch, float maxFps)
 {
     this.MyTransform.position = Vector3.zero;
     this.MyTransform.rotation = Quaternion.identity;
     this.LocalMat             = this.WorldMat = Matrix4x4.identity;
     this.Vertexsegment        = segment;
     this.UVStretch            = uvStretch;
     this.LastMat     = Matrix4x4.identity;
     this.ElapsedTime = 0f;
     this.Fps         = 1f / maxFps;
     this.OriPoint    = oripoint;
     this.RotateAxis  = Vector3.zero;
     this.SetSizeXZ(width, height);
     this.RotateAxis.y = 1f;
     this.Type         = type;
     this.MainCamera   = cam;
     this.ResetSegment();
 }
Exemplo n.º 2
0
        public void OnDestroy()
        {
            if (!mInited)
            {
                return;
            }
            Stop();
            if (Application.isEditor)
            {
                DestroyImmediate(mMeshObj);
            }
            else
            {
                ResNode.DestroyRes(ref mMeshObj);
            }

            mVertexPool    = null;
            mVertexSegment = null;
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
0
 public Sprite(VertexPool.VertexSegment segment, float width, float height, STYPE type, ORIPOINT oripoint, Camera cam, int uvStretch, float maxFps)
 {
     UVChanged            = (ColorChanged = false);
     MyTransform.position = Vector3.zero;
     MyTransform.rotation = Quaternion.identity;
     LocalMat             = (WorldMat = Matrix4x4.identity);
     Vertexsegment        = segment;
     UVStretch            = uvStretch;
     LastMat     = Matrix4x4.identity;
     ElapsedTime = 0f;
     Fps         = 1f / maxFps;
     OriPoint    = oripoint;
     RotateAxis  = Vector3.zero;
     SetSizeXZ(width, height);
     RotateAxis.y = 1f;
     Type         = type;
     MainCamera   = cam;
     ResetSegment();
 }
Exemplo n.º 5
0
 public RibbonTrail(VertexPool.VertexSegment segment, float width, int maxelemnt, float len, Vector3 pos, int stretchType, float maxFps)
 {
     if (maxelemnt <= 2)
     {
         Debug.LogError("ribbon trail's maxelement should > 2!");
     }
     this.MaxElements   = maxelemnt;
     this.Vertexsegment = segment;
     this.ElementArray  = new RibbonTrail.Element[this.MaxElements];
     this.Head          = (this.Tail = 99999);
     this.SetTrailLen(len);
     this.UnitWidth    = width;
     this.HeadPosition = pos;
     this.StretchType  = stretchType;
     RibbonTrail.Element dtls = new RibbonTrail.Element(this.HeadPosition, this.UnitWidth);
     this.IndexDirty = false;
     this.Fps        = 1f / maxFps;
     this.AddElememt(dtls);
     RibbonTrail.Element dtls2 = new RibbonTrail.Element(this.HeadPosition, this.UnitWidth);
     this.AddElememt(dtls2);
 }
    public XEffectSprite(VertexPool.VertexSegment segment, float width, float height, STYPE type,ORIPOINT oripoint, Camera cam,int uvStretch,float maxFps)
    {
        UVChanged = ColorChanged = false;
        MyTransform.position = Vector3.zero;
        MyTransform.rotation = Quaternion.identity;
        LocalMat = WorldMat = Matrix4x4.identity;
        Vertexsegment = segment;
        UVStretch = uvStretch;

        LastMat = Matrix4x4.identity;
        ElapsedTime = 0f;
        Fps = 1f / maxFps;

        OriPoint = oripoint;

        RotateAxis = Vector3.zero;
        SetSizeXZ(width, height);
        RotateAxis.y = 1;
        Type = type;
        MainCamera = cam;
        ResetSegment();
    }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
0
    public RibbonTrail(VertexPool.VertexSegment segment, float width, int maxelemnt, float len, Vector3 pos, int stretchType, float maxFps)
    {
        if (maxelemnt <= 2)
        {
            Debug.LogError("ribbon trail's maxelement should > 2!");
        }
        MaxElements   = maxelemnt;
        Vertexsegment = segment;
        ElementArray  = new Element[MaxElements];
        Head          = (Tail = 99999);
        SetTrailLen(len);
        UnitWidth    = width;
        HeadPosition = pos;
        StretchType  = stretchType;
        Element dtls = new Element(HeadPosition, UnitWidth);

        IndexDirty = false;
        Fps        = 1f / maxFps;
        AddElememt(dtls);
        Element dtls2 = new Element(HeadPosition, UnitWidth);

        AddElememt(dtls2);
    }
Exemplo n.º 9
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;

            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;
        }
Exemplo n.º 10
0
    public RibbonTrail(VertexPool.VertexSegment segment, float width, int maxelemnt, float len, Vector3 pos, int stretchType,float maxFps)
    {
        if (maxelemnt <= 2)
        {
            Debug.LogError("ribbon trail's maxelement should > 2!");
        }
        MaxElements = maxelemnt;
        Vertexsegment = segment;
        ElementArray = new Element[MaxElements];
        Head = Tail = CHAIN_EMPTY;
        SetTrailLen(len);
        UnitWidth = width;
        HeadPosition = pos;
        StretchType = stretchType;
        Element dtls = new Element(HeadPosition, UnitWidth);
        IndexDirty = false;
        Fps = 1f / maxFps;

        // Add the start position
        AddElememt(dtls);
        // Add another on the same spot, this will extend
        Element dtls2 = new Element(HeadPosition, UnitWidth);
        AddElememt(dtls2);
    }
Exemplo n.º 11
0
 public global::Sprite AddSprite(float width, float height, STYPE type, ORIPOINT ori, Camera cam, int uvStretch, float maxFps)
 {
     VertexPool.VertexSegment vertices = this.GetVertices(4, 6);
     return(new global::Sprite(vertices, width, height, type, ori, cam, uvStretch, maxFps));
 }
Exemplo n.º 12
0
 public RibbonTrail AddRibbonTrail(float width, int maxelemnt, float len, Vector3 pos, int stretchType, float maxFps)
 {
     VertexPool.VertexSegment vertices = this.GetVertices(maxelemnt * 2, (maxelemnt - 1) * 6);
     return(new RibbonTrail(vertices, width, maxelemnt, len, pos, stretchType, maxFps));
 }