public void Modify(MaterialMorpher caller, string name, object val, ModifyType type)
        {
            var uniformVariable = GetUniform(name);

            if (uniformVariable != null)
            {
                uniformVariable.AddModifier(caller, val, type);
                //VisibilityCheck(name, uniformVariable);
            }
        }
        public override void AddModifier(MaterialMorpher caller, object val, ModifyType mod)
        {
            if (!CheckCompability(val))
            {
                return;
            }

            if (mods.ContainsKey(caller) &&
                (mod == ModifyType.Multiply && RetrieveValue(val) == Matrix4.Identity))
            {
                mods.Remove(caller);
            }
            else
            {
                mods[caller] = new UniformModifier(val, mod);
            }

            CalculateFinal();
        }
Example #3
0
        void ReadMorhps(Reader reader)
        {
            int morphCount = reader.ReadInt32();

            morphs = new Morph[morphCount];

            for (int i = 0; i < morphCount; i++)
            {
                string name    = reader.readString();
                string nameEng = reader.readString();
                int    panel   = reader.ReadByte();
                int    type    = reader.ReadByte();
                int    size    = reader.ReadInt32();

                if (type == (int)MorphType.Vertex)
                {
                    morphs[i] = new MorphVertex(name, nameEng, size, meshRigged.GetMorpher);
                }
                else if (type == (int)MorphType.Material)
                {
                    morphs[i] = new MorphMaterial(name, nameEng, size);
                }
                else if (type == (int)MorphType.Uv)
                {
                    morphs[i] = new MorphUV(name, nameEng, size, meshRigged.GetMorpher);
                }
                else if (type == (int)MorphType.Bone)
                {
                    morphs[i] = new MorphSkeleton(name, nameEng, size, boneController);
                }
                else if (type == (int)MorphType.Group)
                {
                    morphs[i] = new MorphGroup(name, nameEng, size, morphs);
                }


                for (int n = 0; n < size; n++)
                {
                    switch (type)
                    {
                    case 0:                             //group
                        var gId  = reader.readVal(header.GetMorphIndexSize);
                        var gval = reader.ReadSingle();
                        ((MorphGroup)morphs[i]).AddMorph(gId, gval);
                        break;

                    case 1:                             //vertex
                        int     index = reader.readVal(header.GetVertexIndexSize);
                        Vector3 pos   = reader.readVector3() * multipler;
                        pos.Z = -pos.Z;
                        ((MorphVertex)morphs[i]).AddVertex(pos, index);
                        break;

                    case 2:                              //bone morph
                        var id   = reader.readVal(header.GetBoneIndexSize);
                        var posB = reader.readVector3();
                        posB.Z = -posB.Z;
                        var rotB = reader.readVector4();
                        ((MorphSkeleton)morphs[i]).AddBone(id, posB, new Quaternion(rotB.X, rotB.Y, -rotB.Z, -rotB.W));
                        break;

                    case 3:                              //uv
                        int vIndex = reader.readVal(header.GetVertexIndexSize);
                        var value  = reader.readVector4();
                        ((MorphUV)morphs[i]).AddVertex(new Vector2(value.X, value.Y), vIndex);
                        break;

                    case 8:                             //material

                        int      idx = reader.readVal(header.GetMaterialIndexSize);
                        Material mat = null;
                        if (idx >= 0 && idx < mats.Length)
                        {
                            mat = mats[idx];
                        }

                        var MMorpher = new MaterialMorpher(mat);
                        MMorpher.mode          = reader.ReadByte();
                        MMorpher.DiffuseColor  = reader.readVector4();
                        MMorpher.SpecularColor = reader.readVector3();
                        reader.ReadSingle();
                        MMorpher.AmbientColor = reader.readVector3();
                        reader.readVector4();
                        reader.ReadSingle();
                        reader.readVector4();
                        reader.readVector4();
                        reader.readVector4();
                        ((MorphMaterial)morphs[i]).MaterialMorphers.Add(MMorpher);

                        break;

                    case 9:                             //flip
                        reader.readVal(header.GetMaterialIndexSize);
                        reader.ReadSingle();
                        break;

                    case 10:                             //impulse
                        reader.readVal(header.GetRigidBodyIndexSize);
                        reader.ReadByte();
                        reader.readVector3();
                        reader.readVector3();
                        break;

                    default:
                        Console.WriteLine(type);
                        break;
                    }
                }
            }
        }
Example #4
0
 public abstract void AddModifier(MaterialMorpher caller, object val, ModifyType mod);