Beispiel #1
0
        public int GetPositionIndex(CIwVec3 v, CIwAnimSkinSetKey bonesKey, IList<float> w)
        {
            int i;
            if (positions.TryGetValue(v, out i))
                return i;
            i = TargetMesh.Verts.Positions.Count;
            TargetMesh.Verts.Positions.Add(v);
            positions[v] = i;

            if (modelMesh.Skin != null)
            {
                int animSetId = 0;
                if (!animSets.TryGetValue(bonesKey, out animSetId))
                {
                    animSetId = modelMesh.Skin.SkinSets.Count;
                    animSets[bonesKey] = animSetId;
                    modelMesh.Skin.SkinSets.Add(new CIwAnimSkinSet() { useBones = bonesKey });
                }
                modelMesh.Skin.SkinSets[animSetId].vertWeights.Add(GetSortedWeights(i, modelMesh.Skin.SkinSets[animSetId].useBones, bonesKey, w));
            }

            return i;
        }
Beispiel #2
0
 private CIwAnimSkinSetVertWeights GetSortedWeights(int v, CIwAnimSkinSetKey cIwAnimSkinSetKey, CIwAnimSkinSetKey bonesKey, IList<float> w)
 {
     var res = new CIwAnimSkinSetVertWeights() {Vertex=v,Weights = new float[bonesKey.Bones.Count]};
     for (int i = 0; i < bonesKey.Bones.Count; ++i)
         res.Weights[cIwAnimSkinSetKey.GetBoneIndex(bonesKey.Bones[i])] = w[i];
     return res;
 }
Beispiel #3
0
        public CTrisVertex GetVertex(CIwVec3 p, CIwAnimSkinSetKey bonesKey, IList<float> w, CIwVec3 n, CIwVec2 uv0, CIwVec2 uv1, CIwColour col)
        {
            int vertexIndex = GetPositionIndex(p,bonesKey,w);

            return new CTrisVertex(vertexIndex, GetNormalIndex(n), GetUV0Index(uv0), GetUV1Index(uv1), GetColorIndex(col));
        }