Ejemplo n.º 1
0
 private void AddVMDFace(string vmdFaceName, Dictionary <string, float> valueMap)
 {
     float[] array = new float[faceMorph.BlendDatas.Count];
     foreach (string key in valueMap.Keys)
     {
         float num  = valueMap[key];
         bool  flag = false;
         for (int i = 0; i < faceMorph.BlendDatas.Count; i++)
         {
             BlendData val = faceMorph.BlendDatas[i];
             if (val != null && val.name == key)
             {
                 array[i] = num;
                 flag     = true;
                 break;
             }
         }
         if (!flag)
         {
             Console.WriteLine("BlendName {0} not found for {1}", key, vmdFaceName);
         }
         else
         {
             Console.WriteLine("BlendName {0} set for {1} successfully", key, vmdFaceName);
         }
     }
     VMDFaceName[vmdFaceName] = array;
     FacesToCheck.Add(vmdFaceName);
 }
Ejemplo n.º 2
0
 private void InitDic()
 {
     BlendMod = new Dictionary <string, FaceBlendModifier>();
     for (int i = 0; i < faceMorph.MorphCount; i++)
     {
         BlendData val = faceMorph.BlendDatas[i];
         if (val != null)
         {
             FaceBlendModifier faceBlendModifier = new FaceBlendModifier();
             faceBlendModifier.controller = this;
             faceBlendModifier.index      = i;
             faceBlendModifier.name       = val.name;
             BlendMod[val.name]           = faceBlendModifier;
         }
     }
     BlendSet = new Dictionary <string, FaceBlendSetPattern>();
     foreach (string key in faceMorph.dicBlendSet.Keys)
     {
         FaceBlendSetPattern faceBlendSetPattern = new FaceBlendSetPattern();
         faceBlendSetPattern.controller         = this;
         faceBlendSetPattern.face               = faceMorph;
         faceBlendSetPattern.faceName           = key;
         BlendSet[faceBlendSetPattern.faceName] = faceBlendSetPattern;
     }
 }
    private void _ExecuteBlendOut(CutsceneController cc)
    {
        if (!_IsAnimStopped(cc))
        {
            return;
        }

        if (m_BlendOutElapsedTime > m_BlendOutTime)
        { //if no blend-out, m_BlendOutTime will be negative, so _ExecuteEndAction will be executed no matter we have blend-out or not
            _ExecuteEndAction(cc);
            for (var ie = cc.m_BlendOutCtrl.GetEnumerator(); ie.MoveNext();)
            {
                BlendOutData boData = ie.Current.Value;
                boData.m_InternalGO.SetActive(true);
            }
            m_BlendOutCtrl.Clear();
        }
        else
        {
            float t = m_BlendOutElapsedTime / cc.m_BlendOutTime;

            for (var ie = cc.m_BlendOutCtrl.GetEnumerator(); ie.MoveNext();)
            {
                BlendOutData boData = ie.Current.Value;
                for (int idx = 0; idx < boData.m_BlendDataLst.Count; ++idx)
                {
                    BlendData bdata = boData.m_BlendDataLst[idx];
                    bdata.DoBlend(t);
                }
            }
            m_BlendOutElapsedTime += Time.deltaTime;
        }
    }
        private void CreateMorphs(TBodySkin skin)
        {
            if (skin == null || skin.morph == null || skin.morph.BlendDatas.Count <= 0)
            {
                return;
            }
            if (!vertexIndexMap.ContainsKey(skin.obj.name))
            {
                Debug.Log($"Morph: {skin.obj.name} -> Missing vertex base!");
                return;
            }
            int vertexBase = vertexIndexMap[skin.obj.name];

            Debug.Log($"Morph: {skin.obj.name} -> {skin.morph.BlendDatas.Count} ({vertexBase})");
            for (int j = 0; j < skin.morph.BlendDatas.Count; j++)
            {
                BlendData blendData = skin.morph.BlendDatas[j];
                if (blendData != null)
                {
                    PmxMorph pmxMorph = GetOrCreateMorph(blendData.name);
                    for (int k = 0; k < blendData.v_index.Length; k++)
                    {
                        PmxVertexMorph pmxVertexMorph = new PmxVertexMorph(blendData.v_index[k] + vertexBase, new PmxLib.Vector3(-blendData.vert[k].x, blendData.vert[k].z, blendData.vert[k].y));
                        pmxVertexMorph.Offset *= scaleFactor;
                        pmxMorph.OffsetList.Add(pmxVertexMorph);
                    }
                }
            }
        }
 private static void _ExecuteRevertPose(ReplData rData)
 {
     for (int idx = 0; idx < rData.m_ExtGOBlendData.Count; ++idx)
     {
         BlendData bdata = rData.m_ExtGOBlendData[idx];
         bdata.DoRevert();
     }
 }
Ejemplo n.º 6
0
    public override void CopyFrom(BlendData target)
    {
        CameraRigBlendData t = (CameraRigBlendData)target;

        LocalPosition = t.LocalPosition;
        LocalRotation = t.LocalRotation;
        FovRatio      = t.FovRatio;
    }
Ejemplo n.º 7
0
        public override void FromJson(Dictionary <string, Node> nodes, string data)
        {
            BlendData d = JsonConvert.DeserializeObject <BlendData>(data);

            SetBaseNodeDate(d);
            Enum.TryParse <BlendType>(d.mode, out mode);
            alpha = d.alpha;
        }
Ejemplo n.º 8
0
        public override void FromJson(string data)
        {
            BlendData d = JsonConvert.DeserializeObject <BlendData>(data);

            SetBaseNodeDate(d);
            Enum.TryParse <AlphaModeType>(d.alphaMode, out alphaMode);
            Enum.TryParse <BlendType>(d.mode, out mode);
            alpha = d.alpha;
        }
Ejemplo n.º 9
0
    public override void CaculateAdd(BlendData lhs, BlendData rhs)
    {
        CameraRigBlendData l = (CameraRigBlendData)lhs;
        CameraRigBlendData r = (CameraRigBlendData)rhs;

        LocalPosition = l.LocalPosition + r.LocalPosition;
        LocalRotation = l.LocalRotation * r.LocalRotation;
        FovRatio      = l.FovRatio + r.FovRatio;
    }
Ejemplo n.º 10
0
    public override void CaculateLerp(BlendData from, BlendData to, float lerpRatio)
    {
        CameraRigBlendData f = (CameraRigBlendData)from;
        CameraRigBlendData t = (CameraRigBlendData)to;

        LocalPosition = Vector3.Lerp(f.LocalPosition, t.LocalPosition, lerpRatio);
        LocalRotation = Quaternion.Lerp(f.LocalRotation, t.LocalRotation, lerpRatio);
        FovRatio      = Mathf.Lerp(f.FovRatio, t.FovRatio, lerpRatio);
    }
Ejemplo n.º 11
0
 public FishOptReduction(float actionSpeed, ReductionData reduction, float delay, BlendData bd) : base(FishOptType.FOT_REDUCTION)
 {
     m_Reduction   = reduction;
     m_ActionSpeed = actionSpeed;
     m_AllTime     = reduction.Duration1 + reduction.Duration2 + reduction.Duration3;
     m_OptData     = bd;
     m_Delay       = delay;
     m_bInitTex    = false;
 }
Ejemplo n.º 12
0
        public override string GetJson()
        {
            BlendData d = new BlendData();

            FillBaseNodeData(d);
            d.mode  = mode.ToString();
            d.alpha = alpha;

            return(JsonConvert.SerializeObject(d));
        }
Ejemplo n.º 13
0
 public void DumpMorphNames()
 {
     for (int i = 0; i < faceMorph.MorphCount; i++)
     {
         BlendData val = faceMorph.BlendDatas[i];
         if (val != null)
         {
             Console.WriteLine(val.name);
         }
     }
 }
    /// <summary>
    /// record recursively
    /// </summary>
    private void _PrepareBlend(Transform extTr, List <BlendData> blendDatas)
    {
        BlendData newData = new BlendData();

        newData.m_Tr          = extTr;
        newData.m_StartTrData = XformData.Create(extTr);
        blendDatas.Add(newData);

        for (int idx = 0; idx < extTr.childCount; ++idx)
        {
            Transform tr = extTr.GetChild(idx);
            _PrepareBlend(tr, blendDatas);
        }
    }
Ejemplo n.º 15
0
 public float GetBlend(string charcode, string SourceAni, string TargetAni)
 {
     if (this.m_mapBlendTime.ContainsKey(charcode))
     {
         BlendData[] array  = this.m_mapBlendTime[charcode];
         BlendData[] array2 = array;
         for (int i = 0; i < array2.Length; i++)
         {
             BlendData blendData = array2[i];
             if (blendData._strSourceName.Equals(SourceAni) && blendData._strTagetName.Equals(TargetAni))
             {
                 return(blendData._fBlendingTime);
             }
         }
     }
     return(0.3f);
 }
    /// <summary>
    /// execute blend-in
    /// </summary>
    private static void _ExecuteBlendIn(CutsceneController cc)
    {
        if (cc.m_ReplRecord.Count == 0)
        {
            return;
        }

        float curAnimTime = cc.m_AnimState.time;

        if (curAnimTime > cc.m_BlendInTime)
        {
            return;
        }

        float t = curAnimTime / cc.m_BlendInTime;

        for (var ie = cc.m_ReplRecord.GetEnumerator(); ie.MoveNext();)
        {
            ReplData  rData = ie.Current.Value;
            Transform extTr = ie.Current.Key.transform;
            for (int idx = 0; idx < rData.m_ExtGOBlendData.Count; ++idx)
            {
                BlendData bdata = rData.m_ExtGOBlendData[idx];
                if (bdata.m_Tr == extTr)
                {
                    XformData origBasedOnCC = rData.m_ExtGOTrDataBasedOnCC;
                    extTr.localPosition = Vector3.Lerp(origBasedOnCC.pos, extTr.localPosition, t);
                    extTr.localRotation = Quaternion.Slerp(origBasedOnCC.rot, extTr.localRotation, t);
                    extTr.localScale    = Vector3.Lerp(origBasedOnCC.scale, extTr.localScale, t);
                }
                else
                {
                    bdata.DoBlend(t);
                }
            }
        }
    }
Ejemplo n.º 17
0
 public abstract void CaculateAdd(BlendData lhs, BlendData rhs);
		public bool BlendAnimationClip(BlendData blendData)
		{
			AnimationInfo info = new AnimationInfo ();
			info.Animation = blendData.Animation;
			info.BlendInfo = blendData;

			AnimationInfo last = GetLastAnimation ();
			if (last == null) {
				info.BlendAmount = 1f;
			}
			if ((last == null) || (last.Animation != info.Animation)) {
				animationInfoList.Add (info);
				return true;
			}

			return false;
		}
 public static string GetChunkTxt(BlendData blendData)
 {
     return(GetChunkTxt(blendData.OutputPath));
 }
Ejemplo n.º 20
0
 public abstract void CopyFrom(BlendData target);
Ejemplo n.º 21
0
        /// <summary>
        /// Reads a mesh from a stream.
        /// </summary>
        /// <param name="stream">A Stream instance holding a mesh.</param>
        public unsafe void Read(Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream))
            {
                var version = io.ReadInt32();
                var boneCount = io.ReadInt32();
                var boneNames = new string[boneCount];
                for (var i = 0; i < boneCount; i++){
                    boneNames[i] = io.ReadPascalString();
                }

                var faceCount = io.ReadInt32();
                NumPrimitives = faceCount;

                IndexBuffer = new short[faceCount * 3];
                int offset = 0;
                for (var i = 0; i < faceCount; i++){
                    IndexBuffer[offset++] = (short)io.ReadInt32();
                    IndexBuffer[offset++] = (short)io.ReadInt32();
                    IndexBuffer[offset++] = (short)io.ReadInt32();
                }

                /** Bone bindings **/
                var bindingCount = io.ReadInt32();
                BoneBindings = new BoneBinding[bindingCount];
                for (var i = 0; i < bindingCount; i++)
                {
                    BoneBindings[i] = new BoneBinding
                    {
                        BoneIndex = io.ReadInt32(),
                        FirstRealVertex = io.ReadInt32(),
                        RealVertexCount = io.ReadInt32(),
                        FirstBlendVertex = io.ReadInt32(),
                        BlendVertexCount = io.ReadInt32()
                    };

                    BoneBindings[i].BoneName = boneNames[BoneBindings[i].BoneIndex];
                }

                var realVertexCount = io.ReadInt32();
                VertexBuffer = new VitaboyVertex[realVertexCount];

                for (var i = 0; i < realVertexCount; i++){
                    VertexBuffer[i].TextureCoordinate.X = io.ReadFloat();
                    VertexBuffer[i].TextureCoordinate.Y = io.ReadFloat();
                }

                /** Blend data **/
                var blendVertexCount = io.ReadInt32();
                BlendData = new BlendData[blendVertexCount];
                for (var i = 0; i < blendVertexCount; i++)
                {
                    BlendData[i] = new BlendData
                    {
                        Weight = (float)io.ReadInt32() / 0x8000,
                        OtherVertex = io.ReadInt32()
                    };
                }

                var realVertexCount2 = io.ReadInt32();

                for (int i = 0; i < realVertexCount; i++)
                {
                    VertexBuffer[i].Position = new Microsoft.Xna.Framework.Vector3(
                        -io.ReadFloat(),
                        io.ReadFloat(),
                        io.ReadFloat()
                    );

                    VertexBuffer[i].Normal = new Microsoft.Xna.Framework.Vector3(
                        -io.ReadFloat(),
                        io.ReadFloat(),
                        io.ReadFloat()
                    );
                }

                BlendVerts = new Vector3[blendVertexCount];

                for (int i = 0; i < blendVertexCount; i++)
                {
                    BlendVerts[i] = new Vector3(
                        -io.ReadFloat(),
                        io.ReadFloat(),
                        io.ReadFloat()
                    );

                    var normal = new Vector3(
                        -io.ReadFloat(),
                        io.ReadFloat(),
                        io.ReadFloat()
                    ); //todo: read this in somewhere and maybe use it.
                }

                BlendVertBoneIndices = new int[blendVertexCount];
            }
        }
Ejemplo n.º 22
0
 public abstract void CaculateLerp(BlendData from, BlendData to, float lerpRatio);
 public static string GetChunksFolder(BlendData blendData)
 {
     return(GetChunksFolder(blendData.OutputPath));
 }