private void ApplyDNA(TestDNA testDNA)
    {
        SkinnedMeshRenderer renderer = testDNA.GetComponent <SkinnedMeshRenderer>();

        Transform[] boneTransforms = renderer.bones;
        Transform   transform      = renderer.transform;


        string  boneName = testDNA.DNABoneName;
        Vector3 dna      = testDNA.DNA;
        DNAType dnaType  = testDNA.DNAType;


        int boneIndex = FindBoneIndex(boneTransforms, boneName);

        if (boneIndex == -1)
        {
            Debug.LogFormat("骨骼名字{0}不存在", boneName);
            return;
        }

        Mesh mesh = renderer.sharedMesh;

        Matrix4x4[] bindposes = mesh.bindposes;

        // 在原来的bindposes上,再乘以dna的结果
        Matrix4x4 dnaMatrix = MakeDNAMatrix(dna, dnaType);

        bindposes[boneIndex] = dnaMatrix * testDNA.OriginBindposes[boneIndex];

        mesh.bindposes = bindposes;
    }
    private Matrix4x4 MakeDNAMatrix(Vector3 dna, DNAType dnaType)
    {
        switch (dnaType)
        {
        case DNAType.Position:
            return(Matrix4x4.Translate(dna));

            break;

        case DNAType.Rotation:
            return(Matrix4x4.Rotate(Quaternion.Euler(dna.x, dna.y, dna.z)));

            break;

        case DNAType.Scale:
            return(Matrix4x4.Scale(dna));

            break;
        }
        return(Matrix4x4.identity);
    }
Exemple #3
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            switch (version)
            {
            case 3:
            {
                m_MountID = reader.ReadInt();
                goto case 2;
            }

            case 2:
            {
                m_DNAAcidRain = reader.ReadBool();
                goto case 1;
            }

            case 1:
            {
                m_DNACallOfNature = reader.ReadBool();
                goto case 0;
            }

            case 0:
            {
                m_DNAType           = (DNAType)reader.ReadInt();
                m_DNAQuality        = (DNAQuality)reader.ReadInt();
                m_DNAName           = reader.ReadString();
                m_DNAStr            = reader.ReadInt();
                m_DNADex            = reader.ReadInt();
                m_DNAInt            = reader.ReadInt();
                m_DNAHits           = reader.ReadInt();
                m_DNAStam           = reader.ReadInt();
                m_DNAMana           = reader.ReadInt();
                m_DNAFireResist     = reader.ReadInt();
                m_DNAColdResist     = reader.ReadInt();
                m_DNAEnergyResist   = reader.ReadInt();
                m_DNAPoisonResist   = reader.ReadInt();
                m_DNAPhysicalResist = reader.ReadInt();
                m_DNADamageMin      = reader.ReadInt();
                m_DNADamageMax      = reader.ReadInt();
                m_DNAArmor          = reader.ReadInt();
                m_DNAMagery         = reader.ReadDouble();
                m_DNAEvalInt        = reader.ReadDouble();
                m_DNAMeditation     = reader.ReadDouble();
                m_DNAMagicResist    = reader.ReadDouble();
                m_DNAPoisoning      = reader.ReadDouble();
                m_DNAAnatomy        = reader.ReadDouble();
                m_DNATactics        = reader.ReadDouble();
                m_DNAWrestling      = reader.ReadDouble();
                m_DNABluntAttack    = reader.ReadBool();
                m_DNAHealAttack     = reader.ReadBool();
                m_DNAPoisonAttack   = reader.ReadBool();
                m_DNATrialByFire    = reader.ReadBool();
                m_DNAIceBlast       = reader.ReadBool();
                m_DNACometAttack    = reader.ReadBool();
                m_DNABodyValue      = reader.ReadInt();
                m_DNASoundID        = reader.ReadInt();

                break;
            }
            }
        }
Exemple #4
0
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();

			switch ( version )
			{
				case 3:
				{
					m_MountID = reader.ReadInt();
					goto case 2;
				}
				case 2:
				{
					m_DNAAcidRain = reader.ReadBool();
					goto case 1;
				}
				case 1:
				{
					m_DNACallOfNature = reader.ReadBool();
					goto case 0;
				}
				case 0:
				{
					m_DNAType = (DNAType)reader.ReadInt();
					m_DNAQuality = (DNAQuality)reader.ReadInt();
					m_DNAName = reader.ReadString();
					m_DNAStr = reader.ReadInt();
					m_DNADex = reader.ReadInt();
					m_DNAInt = reader.ReadInt();
					m_DNAHits = reader.ReadInt();
					m_DNAStam = reader.ReadInt();
					m_DNAMana = reader.ReadInt();
					m_DNAFireResist = reader.ReadInt();
					m_DNAColdResist = reader.ReadInt();
					m_DNAEnergyResist = reader.ReadInt();
					m_DNAPoisonResist = reader.ReadInt();
					m_DNAPhysicalResist = reader.ReadInt();
					m_DNADamageMin = reader.ReadInt();
					m_DNADamageMax = reader.ReadInt();
					m_DNAArmor = reader.ReadInt();
					m_DNAMagery = reader.ReadDouble();
					m_DNAEvalInt = reader.ReadDouble();
					m_DNAMeditation = reader.ReadDouble();
					m_DNAMagicResist = reader.ReadDouble();
					m_DNAPoisoning = reader.ReadDouble();
					m_DNAAnatomy = reader.ReadDouble();
					m_DNATactics = reader.ReadDouble();
					m_DNAWrestling = reader.ReadDouble();
					m_DNABluntAttack = reader.ReadBool();
					m_DNAHealAttack = reader.ReadBool();
					m_DNAPoisonAttack = reader.ReadBool();
					m_DNATrialByFire = reader.ReadBool();
					m_DNAIceBlast = reader.ReadBool();
					m_DNACometAttack = reader.ReadBool();
					m_DNABodyValue = reader.ReadInt();
					m_DNASoundID = reader.ReadInt();

					break;
				}
			}
		}