Exemple #1
0
    //
    public void ResetData(SolitaireData data, Transform transform)
    {
        //データの初期化

        data.pos          = new Vector3();
        data.positions    = _positions;
        data._v.x         = _v.x;
        data._v.y         = _v.y;
        data._v.z         = _v.z;
        data.uv.x         = _uv.x;
        data.uv.y         = _uv.y;
        data.uv.z         = _uv.z;
        data.uv.w         = _uv.w;
        data.parentMatrix = transform.localToWorldMatrix;

        data.scale = SolitaireParams.BASE_SCALE;

        data.time = Random.value * Time.deltaTime;

        //rotation = Quaternion.Euler(0,Mathf.Atan2(_v.z,_v.x)/Mathf.PI*180f*0.5f,0);

        if (Random.value < 0.02f)
        {
            Reset();
        }

        //_counterLimit = 30 + Mathf.FloorToInt( 30 * Random.value );
    }
    private Vector4[] _uvs;// = new Vector4[MAX];


    void Start()
    {
        //モーションを10個くらいつくっとく
        //


        //motion
        int numMotion = 7;

        _motions = new SolitaireMotion[numMotion];
        for (int i = 0; i < numMotion; i++)
        {
            _motions[i]        = new SolitaireMotion();
            _motions[i]._limit = _bottomDistance;
            _motions[i].Init(_startPosSpace);
        }

        _propertyBlock = new MaterialPropertyBlock();
        _matrices      = new Matrix4x4[_count];
        _data          = new SolitaireData[_count];
        _colors        = new Vector4[_count];
        _randoms       = new Vector4[_count];
        _uvs           = new Vector4[_count];

        for (int i = 0; i < _count; i++)
        {
            _matrices[i] = Matrix4x4.identity;
            _data[i]     = new SolitaireData();//
            _data[i].rot = Quaternion.Euler(
                0, 0, 0
                );
            _randoms[i] = _data[i].random;
            _colors[i]  = new Vector4(
                1f,
                1f,
                1f,
                1f
                );

            _matrices[i].SetTRS(
                _data[i].pos,
                _data[i].rot,
                _data[i].scale
                );

            _uvs[i] = SolitaireUV.GetUV(0, 0, 4, 13);
            //_uvs[i] = SolitaireUV.GetUV2(0,0);
        }

        _mat.SetVectorArray("_Random", _randoms);
        _propertyBlock.SetVectorArray("_Uv", _uvs);
        _propertyBlock.SetVectorArray("_Color", _colors);

        //_Loop();
    }