Пример #1
0
 public VertexMorph(PmxMorphData morph)
 {
     MorphName    = morph.MorphName;
     MorphNameE   = morph.MorphNameE;
     MorphSlot    = morph.SlotType;
     VertexMorphs = morph.MorphArray.Cast <PmxMorphVertexData>( ).ToList();
 }
Пример #2
0
 public void AddMorphKeyFrame(PmxMorphData morph, VmdMorphFrameData frame)
 {
     if (frame.FrameTime >= 0)
     {
         MorphFrameDict[morph].Add(frame);
     }
 }
        public void SetupMaterialMorph(ShotProperty prop, PmxMorphData morph, int materialCount, int appliedMaterialCount)
        {
            morph.MorphName = "MO_" + MorphList.Count.ToString();
            morph.SlotType  = MorphSlotType.RIP;
            morph.MorphType = MorphType.MATERIAL;

            morph.MorphArray = new IPmxMorphTypeData[appliedMaterialCount];

            for (int i = 0; i < appliedMaterialCount; i++)
            {
                morph.MorphArray[i] = new PmxMorphMaterialData()
                {
                    CalcType      = 0,
                    Ambient       = new Vector3(1, 1, 1),
                    Diffuse       = new Vector4(1, 1, 1, 0),
                    Specular      = new Vector3(1, 1, 1),
                    Shininess     = 1.0F,
                    Edge          = new Vector4(1, 1, 1, 1),
                    EdgeThick     = 1.0F,
                    Texture       = new Vector4(1, 1, 1, 1),
                    SphereTexture = new Vector4(1, 1, 1, 1),
                    ToonTexture   = new Vector4(1, 1, 1, 1),
                };
            }

            for (int i = 0; i < appliedMaterialCount; i++)
            {
                morph.MorphArray[i].Index = materialCount + i;
            }
            MorphList.Add(morph);
        }
Пример #4
0
 public override PmxMorphData[] CreateMorphs(World world, ShotProperty prop)
 {
     PmxMorphData[] result = new PmxMorphData[OriginalData.MorphArray.Length];
     for (int i = 0; i < result.Length; i++)
     {
         result[i] = CloneUtil.Clone(OriginalData.MorphArray[i]);
     }
     return(result);
 }
Пример #5
0
        public PmxMorphData CreateUVMorph(string name, int id, MorphType type, Func <Vector3, Vector4> func)
        {
            if (!Morphs.ContainsKey(id))
            {
                Morphs[id] = new PmxMorphData()
                {
                    MorphName = name,
                    SlotType  = MorphSlotType.RIP,
                    MorphType = type,

                    MorphArray =
                        Enumerable.Range(0, Property.Type.OriginalData.VertexArray.Length)
                        .Select(i => (IPmxMorphTypeData) new PmxMorphUVData()
                    {
                        Index = i, Uv = func((Vector4)Property.Type.OriginalData.VertexArray[i].Pos * Property.Scale)
                    }).ToArray()
                };
            }
            return(Morphs[id]);
        }
Пример #6
0
        public void AddMorphKeyFrame(PmxMorphData morph, float weight, int frameOffset = 0, int priority = 0)
        {
            var frame = new VmdMorphFrameData(morph.MorphName, World.FrameCount + World.FrameOffset + frameOffset, weight);

            World.VmdSequence.AddMorphKeyFrame(frame, priority);
        }
Пример #7
0
        private void SetupShotModelData(ShotModelData data)
        {
            int[] indices = Array.ConvertAll(data.Indices, i => i + VertexList.Count);
            IndexList.AddRange(indices);

            PmxVertexData[] vertices = data.Vertices;
            foreach (var vertex in vertices)
            {
                vertex.VertexId = VertexList.Count;
                vertex.BoneId   = Array.ConvertAll(vertex.BoneId, i => i + BoneList.Count);
                VertexList.Add(vertex);
            }

            PmxMaterialData[] materials = data.Materials;
            PmxMorphData      morph     = data.MaterialMorph;

            morph.MorphName  = data.Property.Type.Name[0] + MorphList.Count.ToString();
            morph.Type       = 4;
            morph.MorphArray = ArrayUtil.Set(new PmxMorphMaterialData[materials.Length], i => new PmxMorphMaterialData());

            for (int i = 0; i < materials.Length; i++)
            {
                morph.MorphArray[i].Index = MaterialList.Count + i;
                morph.MorphId             = MorphList.Count + i;
            }
            MorphList.Add(morph);

            string[] textures = data.Textures;
            foreach (var texture in textures)
            {
                if (!TextureList.Contains(texture))
                {
                    TextureList.Add(texture);
                }
            }

            foreach (PmxMaterialData material in materials)
            {
                material.MaterialName = data.Property.Type.Name[0] + MaterialList.Count.ToString();

                if (0 <= material.TextureId && material.TextureId < textures.Length)
                {
                    material.TextureId = TextureList.IndexOf(textures[material.TextureId]);
                }
                else
                {
                    material.TextureId = -1;
                }

                if (0 <= material.SphereId && material.SphereId < textures.Length)
                {
                    material.SphereId = TextureList.IndexOf(textures[material.SphereId]);
                }
                else
                {
                    material.SphereId = -1;
                }
                material.MaterialId = MaterialList.Count;
                MaterialList.Add(material);
            }
            SetupBone(data, data.Bones);

            ModelDataList.Add(data);
        }
 public void AddMorph(PmxMorphData morph)
 {
     MorphDict.Add(morph.MorphName, morph);
     World.PmxModel.Morphs.MorphList.Add(morph);
 }
Пример #9
0
 public void AddMorph(PmxMorphData morph)
 {
     Morphs.MorphList.Add(morph);
 }