Esempio n. 1
0
        /// <summary>
        /// Updates the muscle that is currently being placed to end at the
        /// specified position
        /// </summary>
        public void UpdateCurrentMuscleEnd(Vector3 endPoint, Bone hoveringBone)
        {
            if (currentMuscle != null)
            {
                // Check if user is hovering over an ending joint which is not the same as the starting
                // joint of the currentMuscle
                var endingPoint = endPoint;

                if (hoveringBone != null)
                {
                    if (!hoveringBone.Equals(currentMuscle.startingBone))
                    {
                        endingPoint = hoveringBone.Center;
                        currentMuscle.endingBone = hoveringBone;
                        var oldData = currentMuscle.MuscleData;
                        var newData = new MuscleData(
                            oldData.id, oldData.startBoneID, hoveringBone.BoneData.id,
                            oldData.strength, oldData.canExpand
                            );
                        currentMuscle.MuscleData = newData;
                    }
                    else
                    {
                        currentMuscle.endingBone = null;
                    }
                }
                else
                {
                    currentMuscle.endingBone = null;
                }

                currentMuscle.SetLinePoints(currentMuscle.startingBone.Center, endingPoint);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Instantiates a muscle at the specified point.
        /// </summary>
        private void CreateMuscleFromBone(Bone bone)
        {
            var muscleData = new MuscleData(idCounter++, bone.BoneData.id, bone.BoneData.id, Muscle.Defaults.MaxForce, true);

            currentMuscle = Muscle.CreateFromData(muscleData);
            currentMuscle.startingBone = bone;
            currentMuscle.SetLinePoints(bone.Center, bone.Center);
        }
Esempio n. 3
0
        private Muscle CreateMuscleBetween(Bone startingBone, Bone endingBone, MuscleData data)
        {
            var muscle = Muscle.CreateFromData(data);

            muscle.startingBone = startingBone;
            muscle.endingBone   = endingBone;

            muscle.SetLinePoints(startingBone.Center, endingBone.Center);
            return(muscle);
        }
Esempio n. 4
0
        private void CreateMuscleFromData(MuscleData data)
        {
            // Find the connecting joints
            var startingBone = FindBoneWithId(data.startBoneID);
            var endingBone   = FindBoneWithId(data.endBoneID);

            if (startingBone == null || endingBone == null)
            {
                Debug.Log(string.Format("The connecting joints for bone {0} were not found!", data.id));
                return;
            }
            var muscle = CreateMuscleBetween(startingBone, endingBone, data);

            muscle.ConnectToJoints();
            muscle.AddCollider();
            muscles.Add(muscle);
        }
Esempio n. 5
0
        public MuscleSettingsManager(Muscle muscle, AdvancedBodyControlsViewController viewController) : base()
        {
            this.muscle         = muscle;
            this.viewController = viewController;

            viewController.Reset();
            viewController.SetTitle("Muscle Settings");
            strengthSlider = viewController.AddSlider("Strength");
            strengthSlider.onValueChanged += delegate(float value) {
                var oldData  = muscle.MuscleData;
                var strength = SliderToStrength(value);
                if (strength != oldData.strength)
                {
                    DataWillChange();
                }
                var data = new MuscleData(
                    oldData.id, oldData.startBoneID, oldData.endBoneID,
                    strength, oldData.canExpand
                    );

                muscle.MuscleData = data;
                Refresh();
            };

            canExpandToggle = viewController.AddToggle("Can Expand");
            canExpandToggle.onValueChanged += delegate(bool canExpand) {
                var oldData = muscle.MuscleData;
                if (canExpand != oldData.canExpand)
                {
                    DataWillChange();
                }
                var data = new MuscleData(
                    oldData.id, oldData.startBoneID, oldData.endBoneID,
                    oldData.strength, canExpand
                    );

                muscle.MuscleData = data;
                Refresh();
            };

            Refresh();
        }
Esempio n. 6
0
    void HighLightMuscleClike(SkinnedMeshRenderer skinnedMeshRenderer, GameObject go)
    {
        MuscleData muscleData = skinnedMeshRenderer.gameObject.GetComponent <MuscleData>();

        if (!muscleData.isHighLight)
        {
            skinnedMeshRenderer.sharedMaterial = muscleData.highLightMaterial;
            muscleData.isHighLight             = true;
            tittleText.text = muscleData.CngName;
            if (muscleData.ismain)
            {
                go.GetComponent <Image>().color = buttonColor[0];
                go.transform.GetChild(1).GetComponent <Image>().sprite = buttonImage[0];
            }
            else
            {
                go.GetComponent <Image>().color = buttonColor[1];
                go.transform.GetChild(1).GetComponent <Image>().sprite = buttonImage[1];
            }
        }
        else
        {
            skinnedMeshRenderer.sharedMaterial = muscleData.localMaterial;
            muscleData.isHighLight             = false;
            tittleText.text = "";
            if (muscleData.ismain)
            {
                go.GetComponent <Image>().color = buttonColor[2];
                go.transform.GetChild(1).GetComponent <Image>().sprite = buttonImage[2];
            }
            else
            {
                go.GetComponent <Image>().color = buttonColor[2];
                go.transform.GetChild(1).GetComponent <Image>().sprite = buttonImage[3];
            }
        }

        // lastSkinnedMeshRenderer
    }
Esempio n. 7
0
    public static Muscle CreateFromData(MuscleData data)
    {
        Material muscleMaterial    = Resources.Load(MATERIAL_PATH) as Material;
        Material blueMaterial      = Resources.Load(BLUE_MATERIAL_PATH) as Material;
        Material invisibleMaterial = Resources.Load(INVISIBLE_MATERIAL_PATH) as Material;

        GameObject muscleEmpty = new GameObject();

        muscleEmpty.name  = "Muscle";
        muscleEmpty.layer = LayerMask.NameToLayer("Creature");
        var muscle = muscleEmpty.AddComponent <Muscle>();

        muscle.AddLineRenderer();
        muscle.SetMaterial(muscleMaterial);

        muscle.MuscleData = data;

        muscle.redMaterial       = muscleMaterial;
        muscle.blueMaterial      = blueMaterial;
        muscle.invisibleMaterial = invisibleMaterial;

        return(muscle);
    }
Esempio n. 8
0
    void addMuscleData(GameObject child, bool ismain)
    {
        MuscleData muscleData = child.GetComponent <MuscleData>();

        for (int i = 0; i < MuscleCngName.Length; i++)
        {
            if (child.gameObject.name == MuscleEngName[i])
            {
                muscleData.CngName = MuscleCngName[i];
                break;
            }
        }

        muscleData.localMaterial = child.GetComponent <SkinnedMeshRenderer>().sharedMaterial;
        string name = child.GetComponent <SkinnedMeshRenderer>().sharedMaterial.name;

        if (ismain)
        {
            switch (name)
            {
            case "DB_Diff":
                muscleData.highLightMaterial = mainHighLightMaterials[0];
                break;

            case "DT_Diff":
                muscleData.highLightMaterial = mainHighLightMaterials[1];
                break;

            case "JB_Diff":
                muscleData.highLightMaterial = mainHighLightMaterials[2];
                break;

            case "JZ_Diff":
                muscleData.highLightMaterial = mainHighLightMaterials[3];
                break;

            case "QB_Diff":
                muscleData.highLightMaterial = mainHighLightMaterials[4];
                break;

            case "TB_Diff":
                muscleData.highLightMaterial = mainHighLightMaterials[5];
                break;

            case "XF_Diff":
                muscleData.highLightMaterial = mainHighLightMaterials[6];
                break;

            case "XT_Diff":
                muscleData.highLightMaterial = mainHighLightMaterials[7];
                break;
            }
        }
        else
        {
            switch (name)
            {
            case "DB_Diff":
                muscleData.highLightMaterial = secondaryHighLightMaterials[0];
                break;

            case "DT_Diff":
                muscleData.highLightMaterial = secondaryHighLightMaterials[1];
                break;

            case "JB_Diff":
                muscleData.highLightMaterial = secondaryHighLightMaterials[2];
                break;

            case "JZ_Diff":
                muscleData.highLightMaterial = secondaryHighLightMaterials[3];
                break;

            case "QB_Diff":
                muscleData.highLightMaterial = secondaryHighLightMaterials[4];
                break;

            case "TB_Diff":
                muscleData.highLightMaterial = secondaryHighLightMaterials[5];
                break;

            case "XF_Diff":
                muscleData.highLightMaterial = secondaryHighLightMaterials[6];
                break;

            case "XT_Diff":
                muscleData.highLightMaterial = secondaryHighLightMaterials[7];
                break;
            }
        }
        muscleData.ismain = ismain;
    }