Esempio n. 1
0
 public void AddObject(MMDMesh mesh)
 {
     lock (MMDMeshLoadList)
     {
         MMDMeshLoadList.Add(mesh);
     }
 }
Esempio n. 2
0
 public MMDMesh GetMesh()
 {
     if (meshInstance == null)
     {
         meshInstance = MMDMesh.Load1(verticesDataAnotherPart, pmx.TriangleIndexs, c_vertexStride, PrimitiveTopology._POINTLIST);
     }
     return(meshInstance);
 }
Esempio n. 3
0
 public void UnsafeAdd(MMDMesh mesh)
 {
     MMDMeshLoadList.Add(mesh);
 }
        public void ComputeVertexMorph(MMDMorphStateComponent morphStateComponent)
        {
            prevflip = flip;
            flip     = ((int)(morphStateComponent.currentTimeA / MMDMorphStateComponent.c_frameInterval) & 1) == 1;
            amountAB = flip ? (1 - morphStateComponent.amountAB) : morphStateComponent.amountAB;
            if (prevflip != flip)
            {
                morphStateComponent.FlipAB();
            }
            for (int i = 0; i < morphStateComponent.morphs.Count; i++)
            {
                if (morphStateComponent.morphs[i].Type == MorphType.Vertex)
                {
                    MorphVertexDesc[] morphVertexStructs2 = morphStateComponent.morphs[i].MorphVertexs;

                    MorphVertexDesc[] morphVertexA = vertexMorphsA[i];
                    MorphVertexDesc[] morphVertexB = vertexMorphsB[i];
                    if (!flip)
                    {
                        if (morphStateComponent.ComputedWeightNotEqualsPrevA(i, out float computedWeightA))
                        {
                            //for optimization
                            if (computedWeightA != 0)
                            {
                                for (int j = 0; j < morphVertexA.Length; j++)
                                {
                                    morphVertexA[j].Offset = morphVertexStructs2[j].Offset * computedWeightA;
                                }
                            }
                            meshNeedUpdateA = true;
                        }
                        if (morphStateComponent.ComputedWeightNotEqualsPrevB(i, out float computedWeightB))
                        {
                            if (computedWeightB != 0)
                            {
                                for (int j = 0; j < morphVertexB.Length; j++)
                                {
                                    morphVertexB[j].Offset = morphVertexStructs2[j].Offset * computedWeightB;
                                }
                            }
                            meshNeedUpdateB = true;
                        }
                    }
                    else
                    {
                        if (morphStateComponent.ComputedWeightNotEqualsPrevA(i, out float computedWeightA))
                        {
                            if (computedWeightA != 0)
                            {
                                for (int j = 0; j < morphVertexB.Length; j++)
                                {
                                    morphVertexB[j].Offset = morphVertexStructs2[j].Offset * computedWeightA;
                                }
                            }
                            meshNeedUpdateB = true;
                        }
                        if (morphStateComponent.ComputedWeightNotEqualsPrevB(i, out float computedWeightB))
                        {
                            if (computedWeightB != 0)
                            {
                                for (int j = 0; j < morphVertexA.Length; j++)
                                {
                                    morphVertexA[j].Offset = morphVertexStructs2[j].Offset * computedWeightB;
                                }
                            }
                            meshNeedUpdateA = true;
                        }
                    }
                }
            }
            if (meshNeedUpdateA)
            {
                MMDMesh.CopyPosData(meshPosData1, meshPosData);
                ComputeMorphVertex(meshPosData1, vertexMorphsA, flip ? morphStateComponent.WeightComputedB : morphStateComponent.WeightComputedA);
            }
            if (meshNeedUpdateB)
            {
                MMDMesh.CopyPosData(meshPosData2, meshPosData);
                ComputeMorphVertex(meshPosData2, vertexMorphsB, flip ? morphStateComponent.WeightComputedA : morphStateComponent.WeightComputedB);
            }
        }