Пример #1
0
        public GameObject loadSkeleton(GenderType gender, RigType rig)
        {
            var prefab = Resources.Load("Animation/" + gender.ToString() + "/" + rig.ToString() + "/skeleton");
            var clone  = GameObject.Instantiate(prefab);

            return(clone as GameObject);
        }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            RigType rigtype = db.RigTypes.Find(id);

            db.RigTypes.Remove(rigtype);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
 public ActionResult Edit([Bind(Include = "ID,RigType1")] RigType rigtype)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rigtype).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(rigtype));
 }
Пример #4
0
    private void LoadPlayerSkeleton(GenderType gender, WeaponType weapType, RigType rig, int weapon, int body, int arms, int foot, int hair, int face, int back, int cap, int shield)
    {
        // First destroy any children of player
        int childs = player.transform.childCount;

        for (int i = childs - 1; i > 0; i--)
        {
            Utils.Destroy(player.transform.GetChild(i).gameObject);
        }

        Utils.Destroy(skeleton);

        if (rig == RigType.FOOT)
        {
            skeleton = rm.loadSkeleton(gender, weapType);
        }
        else
        {
            skeleton = rm.loadSkeleton(gender, rig);
        }

        bindPoses = rm.loadBindPoses(skeleton, gender, weapType);
        skeleton.transform.parent        = player.transform;
        skeleton.transform.localPosition = new Vector3(0, 0, 0);
        skeleton.transform.localRotation = Quaternion.Euler(new Vector3(0, 0, 0));


        // If player has already been initialized, make sure it knows that the skeleton has changed in order to restart its state machine with new animations
        PlayerController controller = player.GetComponent <PlayerController> ();

        if (controller != null)
        {
            controller.OnSkeletonChange();
        }

        //load all objects
        playerBounds = new Bounds(player.transform.position, Vector3.zero);

        playerBounds.Encapsulate(LoadObject(BodyPartType.BODY, body));
        playerBounds.Encapsulate(LoadObject(BodyPartType.ARMS, arms));
        playerBounds.Encapsulate(LoadObject(BodyPartType.FOOT, foot));
        playerBounds.Encapsulate(LoadObject(BodyPartType.FACE, face));
        LoadObject(BodyPartType.CAP, cap);
        String hairOffsetStr = rm.stb_cap_list.Cells[cap][34];
        int    hairOffset    = (hairOffsetStr == "") ? 0 : int.Parse(hairOffsetStr);

        playerBounds.Encapsulate(LoadObject(BodyPartType.HAIR, hair - hair % 5 + hairOffset));

        LoadObject(BodyPartType.SUBWEAPON, shield);
        LoadObject(BodyPartType.WEAPON, weapon);
        LoadObject(BodyPartType.BACK, back);

        //player.SetActive(true);
    }
Пример #5
0
        public ActionResult Create([Bind(Include = "ID,RigType1")] RigType rigtype)
        {
            if (ModelState.IsValid)
            {
                db.RigTypes.Add(rigtype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(rigtype));
        }
Пример #6
0
        // GET: /RigType/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RigType rigtype = db.RigTypes.Find(id);

            if (rigtype == null)
            {
                return(HttpNotFound());
            }
            return(View(rigtype));
        }
Пример #7
0
        public void SetAnimationStateMachine(RigType rig, States initialState)
        {
            state = initialState;
            switch (rig)
            {
                case RigType.FOOT:
                    animationStateMachine = new PlayerState(initialState, "Player State Machine", this.gameObject);
                    break;
                case RigType.CHARSELECT:
                    animationStateMachine = new CharSelectState(initialState, "Char Select State Machine", this.gameObject);
                    break;
                default:
                    break;
            }

            animationStateMachine.Entry();
        }
Пример #8
0
        public void LoadClips(GameObject skeleton, ZMD zmd, GenderType gender, RigType rig, Dictionary <String, String> zmoPaths)
        {
            List <AnimationClip> clips = new List <AnimationClip>();

            foreach (KeyValuePair <String, String> motion in zmoPaths)
            {
                string unityPath = "Assets/Resources/Animation/" + gender.ToString() + "/" + rig.ToString() + "/clips/" + motion.Key + ".anim";

                AnimationClip clip = new ZMO("Assets/" + motion.Value).buildAnimationClip(zmd);
                clip.name   = motion.Key;
                clip.legacy = true;
                clip        = (AnimationClip)Utils.SaveReloadAsset(clip, unityPath, ".anim");
                clips.Add(clip);
            }

            Animation animation = skeleton.AddComponent <Animation>();

            AnimationUtility.SetAnimationClips(animation, clips.ToArray());
        }
Пример #9
0
        public void SetAnimationStateMachine(RigType rig, States initialState)
        {
            state = initialState;
            switch (rig)
            {
            case RigType.FOOT:
                animationStateMachine = new PlayerState(initialState, "Player State Machine", this.gameObject);
                break;

            case RigType.CHARSELECT:
                animationStateMachine = new CharSelectState(initialState, "Char Select State Machine", this.gameObject);
                break;

            default:
                break;
            }

            animationStateMachine.Entry();
        }
Пример #10
0
        public void GenerateAnimationAsset(GenderType gender, RigType rig, Dictionary <String, String> zmoPaths)
        {
            GameObject skeleton = new GameObject("skeleton");
            bool       male     = (gender == GenderType.MALE);
            ZMD        zmd      = new ZMD(male ? "Assets/3DData/Avatar/MALE.ZMD" : "Assets/3DData/Avatar/FEMALE.ZMD");

            zmd.buildSkeleton(skeleton);

            BindPoses poses = ScriptableObject.CreateInstance <BindPoses>();

            poses.bindPoses      = zmd.bindposes;
            poses.boneNames      = getBoneNames(zmd.boneTransforms);
            poses.boneTransforms = zmd.boneTransforms;
            LoadClips(skeleton, zmd, gender, rig, zmoPaths);
            string path = "Assets/Resources/Animation/" + gender.ToString() + "/" + rig.ToString() + "/skeleton.prefab";

            AssetDatabase.CreateAsset(poses, path.Replace("skeleton.prefab", "bindPoses.asset"));
            AssetDatabase.SaveAssets();
            PrefabUtility.CreatePrefab(path, skeleton);
        }
Пример #11
0
        public List <RigDetail> GetRigDetail()
        {
            Country country = new Country()
            {
                CountryId   = 1,
                CountryName = "abc"
            };
            Region region = new Region()
            {
                RegionId   = 1,
                RegionName = "Abc",
                Country    = country,
                IsActive   = true
            };
            RigManager rigManager = new RigManager()
            {
                RigManagerId   = 1,
                RigManagerName = "abc"
            };
            RigType rigType = new RigType()
            {
                RigTypeId   = 1,
                RigTypeName = "abc",
                IsActive    = true
            };
            List <RigDetail> rigDetails = new List <RigDetail>();

            rigDetails.Add(new RigDetail()
            {
                RigDetailId              = 1,
                RigName                  = "Abc",
                RigWaterDepth            = 300,
                RigDrillingDepth         = 30000,
                CurrentBlockOrWell       = "abc",
                CurrentLocationEndDate   = DateTime.Parse("01-01-2020"),
                CurrentLocationStartDate = DateTime.Parse("10-10-2020"),
                CurrentLocation          = region,
                RigManager               = rigManager
            });
            return(rigDetails);
        }
Пример #12
0
        public void LoadClips(GameObject skeleton, ZMD zmd, GenderType gender, RigType rig, Dictionary<String, String> zmoPaths)
        {
            List<AnimationClip> clips = new List<AnimationClip>();

            foreach (KeyValuePair<String, String> motion in zmoPaths)
            {
                string unityPath = "Assets/Resources/Animation/" + gender.ToString() + "/" + rig.ToString() + "/clips/" + motion.Key + ".anim";

                AnimationClip clip = new ZMO("Assets/" + motion.Value).buildAnimationClip(zmd);
                clip.name = motion.Key;
                clip.legacy = true;
                clip = (AnimationClip)Utils.SaveReloadAsset(clip, unityPath, ".anim");
                clips.Add(clip);
            }

            Animation animation = skeleton.AddComponent<Animation>();
            AnimationUtility.SetAnimationClips(animation, clips.ToArray());
        }
Пример #13
0
        public void GenerateAnimationAsset(GenderType gender, RigType rig, Dictionary<String,String> zmoPaths)
        {
            GameObject skeleton = new GameObject("skeleton");
            bool male = (gender == GenderType.MALE);
            ZMD zmd = new ZMD(male ? "Assets/3DData/Avatar/MALE.ZMD" : "Assets/3DData/Avatar/FEMALE.ZMD");
            zmd.buildSkeleton(skeleton);

            BindPoses poses = ScriptableObject.CreateInstance<BindPoses>();
            poses.bindPoses = zmd.bindposes;
            poses.boneNames = getBoneNames(zmd.boneTransforms);
            poses.boneTransforms = zmd.boneTransforms;
            LoadClips(skeleton, zmd, gender, rig, zmoPaths);
            string path = "Assets/Resources/Animation/" + gender.ToString() + "/" + rig.ToString() + "/skeleton.prefab";
            AssetDatabase.CreateAsset(poses, path.Replace("skeleton.prefab", "bindPoses.asset"));
            AssetDatabase.SaveAssets();
            PrefabUtility.CreatePrefab(path, skeleton);
        }
Пример #14
0
 public GameObject loadSkeleton(GenderType gender, RigType rig)
 {
     var prefab = Resources.Load("Animation/" + gender.ToString() + "/" + rig.ToString() + "/skeleton");
     var clone = GameObject.Instantiate(prefab);
     return clone as GameObject;
 }
Пример #15
0
    private void LoadPlayerSkeleton(GenderType gender, WeaponType weapType, RigType rig, int weapon, int body, int arms, int foot, int hair, int face, int back, int cap, int shield)
    {
        // First destroy any children of player
        int childs = player.transform.childCount;

        for (int i = childs - 1; i > 0; i--)
            Utils.Destroy(player.transform.GetChild(i).gameObject);

        Utils.Destroy (skeleton);

        if( rig == RigType.FOOT)
            skeleton = rm.loadSkeleton(gender, weapType);
        else
            skeleton = rm.loadSkeleton(gender, rig);

        bindPoses = rm.loadBindPoses (skeleton, gender, weapType);
        skeleton.transform.parent = player.transform;
        skeleton.transform.localPosition = new Vector3 (0, 0, 0);
        skeleton.transform.localRotation = Quaternion.Euler (new Vector3 (0, 0, 0));

        // If player has already been initialized, make sure it knows that the skeleton has changed in order to restart its state machine with new animations
        PlayerController controller = player.GetComponent<PlayerController> ();
        if( controller != null )
            controller.OnSkeletonChange ();

        //load all objects
        playerBounds = new Bounds(player.transform.position, Vector3.zero);

        playerBounds.Encapsulate(LoadObject(BodyPartType.BODY, body));
        playerBounds.Encapsulate(LoadObject(BodyPartType.ARMS, arms));
        playerBounds.Encapsulate(LoadObject(BodyPartType.FOOT, foot));
        playerBounds.Encapsulate(LoadObject(BodyPartType.FACE, face));
        LoadObject(BodyPartType.CAP, cap);
        String hairOffsetStr = rm.stb_cap_list.Cells[cap][34];
        int hairOffset = (hairOffsetStr == "") ? 0 : int.Parse(hairOffsetStr);
        playerBounds.Encapsulate(LoadObject(BodyPartType.HAIR, hair - hair%5 + hairOffset));

        LoadObject(BodyPartType.SUBWEAPON, shield);
        LoadObject(BodyPartType.WEAPON, weapon);
        LoadObject(BodyPartType.BACK, back);

        //player.SetActive(true);
    }