コード例 #1
0
ファイル: MAvatarSound.cs プロジェクト: BigFun123/Massive
 public override void Setup()
 {
     base.Setup();
     _avatar   = (MAvatar)Parent;
     _listener = (MAudioListener)MScene.Camera.FindModuleByType(EType.AudioListener);
     WalkSound = new MSound();
     Add(WalkSound);
 }
コード例 #2
0
ファイル: MMIAvatar.cs プロジェクト: dr-iskandar/MOSIM_Core
        /// <summary>
        /// Method to setup the actual retargeting
        /// </summary>
        protected virtual void SetupRetargeting()
        {
            //Only do the retargeting setup if not happened in before
            if (!setupRetargeting)
            {
                setupRetargeting = true;
                // find and load retargeting configuration file
                //Create a unique id for the avatar (only valid in the current session -> otherwise UUID required)
                string id = UnitySceneAccess.CreateAvatarID();

                //Only load the configuration if defined
                if (LoadRetargetingConfiguration)
                {
                    if (!System.IO.File.Exists(Application.dataPath + "/" + this.ConfigurationFilePath))
                    {
                        Debug.LogError($"Problem setting up retargeting: The required file: {Application.dataPath + "/" + this.ConfigurationFilePath} is not available");
                        return;
                    }

                    string skelConf = System.IO.File.ReadAllText(Application.dataPath + "/" + this.ConfigurationFilePath);



                    MAvatarPosture p = MMICSharp.Common.Communication.Serialization.FromJsonString <MAvatarPosture>(skelConf);//JsonConvert.DeserializeObject<MAvatarPosture>(skelConf);
                    p.AvatarID = id;

                    this.SetupRetargeting(id, p);
                    this.AssignPostureValues(retargetingService.RetargetToIntermediate(p));
                }

                //If not defined use the global posture
                else
                {
                    this.SetupRetargeting(id);
                }

                MAvatarDescription avatarDescription = this.GetSkeletonAccess().GetAvatarDescription(id);

                //Create a new MAvatar (the representation within MMI framework)
                MAvatarPostureValues zeroPosture = this.GetSkeletonAccess().GetCurrentPostureValues(id);

                //Create the avatar
                this.MAvatar = new MAvatar()
                {
                    Name          = this.name,
                    ID            = id,
                    Description   = avatarDescription,
                    PostureValues = zeroPosture,
                    Properties    = new Dictionary <string, string>(),
                    SceneObjects  = new List <string>()
                };

                //Add the avatar to the scene access
                UnitySceneAccess.AddAvatar(this.MAvatar);

                Debug.Log("Retargeting successfully set up");
            }
        }
コード例 #3
0
        /// <summary>
        /// Implementation of the check prerequisites method which is used by the co-simulation to determine whether the MMU can be started
        /// </summary>
        /// <param name="instruction"></param>
        /// <returns></returns>
        public override MBoolResponse CheckPrerequisites(MInstruction instruction)
        {
            //Get the min distance parameter
            if (instruction.Properties != null && instruction.Properties.ContainsKey("MinDistance"))
            {
                instruction.Properties.GetValue(out minReachDistance, "MinDistance");
            }
            else
            {
                minReachDistance = minDistanceDefault;
            }

            if (instruction.Properties.ContainsKey("TargetID"))
            {
                MSceneObject sceneObject = this.SceneAccess.GetSceneObjectByID(instruction.Properties["TargetID"]);

                MAvatar avatar = this.SceneAccess.GetAvatarByID(this.AvatarDescription.AvatarID);

                if (sceneObject != null && avatar != null)
                {
                    this.SkeletonAccess.SetChannelData(avatar.PostureValues);

                    //Get the root position
                    MVector3 rootPosition = this.SkeletonAccess.GetGlobalJointPosition(this.AvatarDescription.AvatarID, MJointType.PelvisCentre);
                    rootPosition.Y = 0;

                    //Get the object position
                    MVector3 objectPosition = new MVector3(sceneObject.Transform.Position.X, 0, sceneObject.Transform.Position.Z);

                    //Compute the distance between root and object
                    float distance = rootPosition.Subtract(objectPosition).Magnitude();

                    //Check if below distance
                    if (distance < this.minReachDistance)
                    {
                        if (this.debug)
                        {
                            Logger.Log(Log_level.L_DEBUG, $"Check prerequisites of reach successfull! Distance: {distance}/{minReachDistance}");
                        }

                        return(new MBoolResponse(true));
                    }
                    else
                    {
                        if (this.debug)
                        {
                            Logger.Log(Log_level.L_DEBUG, $"Check prerequisites of reach failed! Distance: {distance}/{minReachDistance}");
                        }

                        return(new MBoolResponse(false));
                    }
                }
            }

            return(new MBoolResponse(true));
        }
コード例 #4
0
        public static MAvatar Clone(this MAvatar avatar)
        {
            MAvatar clone = new MAvatar();

            clone.ID   = avatar.ID;
            clone.Name = avatar.Name;

            //To do -> proper cloning
            clone.Description   = avatar.Description;
            clone.PostureValues = avatar.PostureValues;
            clone.SceneObjects  = avatar.SceneObjects;

            return(clone);
        }