示例#1
0
        public static void GenerateSpaceTranslationSurfaceInputs(
            NeededCoordinateSpace neededSpaces,
            InterpolatorType interpolatorType,
            ShaderGenerator surfaceInputs,
            string toReplace = "float3 {0};")
        {
            if ((neededSpaces & NeededCoordinateSpace.Object) > 0)
            {
                surfaceInputs.AddShaderChunk(string.Format(toReplace, CoordinateSpace.Object.ToVariableName(interpolatorType)), false);
            }

            if ((neededSpaces & NeededCoordinateSpace.World) > 0)
            {
                surfaceInputs.AddShaderChunk(string.Format(toReplace, CoordinateSpace.World.ToVariableName(interpolatorType)), false);
            }

            if ((neededSpaces & NeededCoordinateSpace.View) > 0)
            {
                surfaceInputs.AddShaderChunk(string.Format(toReplace, CoordinateSpace.View.ToVariableName(interpolatorType)), false);
            }

            if ((neededSpaces & NeededCoordinateSpace.Tangent) > 0)
            {
                surfaceInputs.AddShaderChunk(string.Format(toReplace, CoordinateSpace.Tangent.ToVariableName(interpolatorType)), false);
            }
        }
示例#2
0
        public static void GenerateSpaceTranslationSurfaceInputs(
            NeededCoordinateSpace neededSpaces,
            InterpolatorType interpolatorType,
            ShaderStringBuilder builder,
            string format = "float3 {0};")
        {
            if ((neededSpaces & NeededCoordinateSpace.Object) > 0)
            {
                builder.AppendLine(format, CoordinateSpace.Object.ToVariableName(interpolatorType));
            }

            if ((neededSpaces & NeededCoordinateSpace.World) > 0)
            {
                builder.AppendLine(format, CoordinateSpace.World.ToVariableName(interpolatorType));
            }

            if ((neededSpaces & NeededCoordinateSpace.View) > 0)
            {
                builder.AppendLine(format, CoordinateSpace.View.ToVariableName(interpolatorType));
            }

            if ((neededSpaces & NeededCoordinateSpace.Tangent) > 0)
            {
                builder.AppendLine(format, CoordinateSpace.Tangent.ToVariableName(interpolatorType));
            }
        }
示例#3
0
        static internal IInterpolator GetInterpolator(Type type, InterpolatorType interpolatorType)
        {
            Dictionary <Type, IInterpolator> interpolatorDictionary = null;

            switch (interpolatorType)
            {
            case InterpolatorType.Linear:
                interpolatorDictionary = mInterpolators;
                break;

            case InterpolatorType.ClosestRotation:
                interpolatorDictionary = mRotationInterpolators;
                break;
            }


            if (interpolatorDictionary.ContainsKey(type))
            {
                return(interpolatorDictionary[type]);
            }
            else
            {
                throw new InvalidOperationException("There is no interpolator registered for type " + type.ToString());
            }
        }
        public static void GenerateSpaceTranslations(
            NeededCoordinateSpace neededSpaces,
            InterpolatorType type,
            CoordinateSpace from,
            InputType inputType,
            ShaderStringBuilder pixelShader,
            Dimension dimension)
        {
            if ((neededSpaces & NeededCoordinateSpace.Object) > 0 && from != CoordinateSpace.Object)
            {
                pixelShader.AppendLine("float{0} {1} = {2};", DimensionToString(dimension),
                                       CoordinateSpace.Object.ToVariableName(type), ConvertBetweenSpace(from.ToVariableName(type), from, CoordinateSpace.Object, inputType, from));
            }

            if ((neededSpaces & NeededCoordinateSpace.World) > 0 && from != CoordinateSpace.World)
            {
                pixelShader.AppendLine("float{0} {1} = {2};", DimensionToString(dimension),
                                       CoordinateSpace.World.ToVariableName(type), ConvertBetweenSpace(from.ToVariableName(type), from, CoordinateSpace.World, inputType, from));
            }

            if ((neededSpaces & NeededCoordinateSpace.View) > 0 && from != CoordinateSpace.View)
            {
                pixelShader.AppendLine("float{0} {1} = {2};", DimensionToString(dimension),
                                       CoordinateSpace.View.ToVariableName(type),
                                       ConvertBetweenSpace(from.ToVariableName(type), from, CoordinateSpace.View, inputType, from));
            }

            if ((neededSpaces & NeededCoordinateSpace.Tangent) > 0 && from != CoordinateSpace.Tangent)
            {
                pixelShader.AppendLine("float{0} {1} = {2};", DimensionToString(dimension),
                                       CoordinateSpace.Tangent.ToVariableName(type),
                                       ConvertBetweenSpace(from.ToVariableName(type), from, CoordinateSpace.Tangent, inputType, from));
            }
        }
示例#5
0
        public static string ToVariableName(this CoordinateSpace space, InterpolatorType type)
        {
            var index = (int)space + (int)type * s_SpaceCount;

            if (string.IsNullOrEmpty(s_VariableNames[index]))
            {
                s_VariableNames[index] = string.Format("{0}Space{1}", space, type);
            }
            return(s_VariableNames[index]);
        }
示例#6
0
        static internal IInterpolator GetInterpolator(Type type, string memberName)
        {
            InterpolatorType interpolatorType = InterpolatorType.Linear;

            if (mRotationMembers.Contains(memberName))
            {
                interpolatorType = InterpolatorType.ClosestRotation;
            }

            return(GetInterpolator(type, interpolatorType));
        }
示例#7
0
    public void Effort2LowLevel()
    {
        //     Tval = (-1f * Ind + Mathf.Min(Ind, Fre)) + Dir; //EMOTE and chi
        Tval = (-1f * Mathf.Max(Ind, Fre)) + Mathf.Max(Dir, Bnd);  //Funda

        //	WbMag = Mathf.Max(0.6f * ind, Mathf.Max(0.5f * lgt, 1.0f * fre) ); //In Chi's thesis
        WbMag = Mathf.Max(0.6f * Ind, Mathf.Max(0.5f * Lgt, 0.4f * Fre));          //In emote paper

        //WxMag = -0.3f * lgt + (0.2f *  fre - 0.8f * Mathf.Min(str,  fre )); //In Chi's thesis
        WxMag = -0.3f * Lgt + (0.3f * Fre - 0.9f * Mathf.Min(Str, Fre));            //In emote paper

        DMag = EtMag = WtMag = 0.4f * Ind;

        EfMag = WfMag = 2f * Ind;

        Texp = 1f + 2f * Sud + (0.2f * Mathf.Min(Str, Sud) - 0.6f * Mathf.Min(Fre, Sud)) - 0.2f * Mathf.Max(Str, 0.5f * Mathf.Min(Dir, Sus)) - 0.4f * Fre - 0.1f * Mathf.Min(Ind, Fre); //chi
        //  Texp = 1f + 2f * Sud + (0.2f * Mathf.Min(Str, Sud) - 0.1f * Mathf.Min(Fre, Sud)) - 0.2f * Mathf.Max(Str, Mathf.Min(Dir, Sus)) - 0.4f * Fre - 0.5f * Mathf.Min(Ind, Fre); //emote ==> causes strange behaviors in ind + fre


        Ti = 0.5f + 0.4f * Mathf.Max(Str, Sud) - 0.4f * Mathf.Max(Lgt, Sus) + 0.8f * Mathf.Min(Bnd, Lgt);          //both


        //    V0 = 0.1f * Str - Mathf.Max(0.06f * Mathf.Min(Sus, Str), 0.1f * Mathf.Min(Fre, Str));
        V0 = 0.2f * Str - Mathf.Max(0.06f * Mathf.Min(Sus, Str), 0.1f * Mathf.Min(Fre, Str)); //funda

        V1 = Mathf.Max(0.03f * Mathf.Max(Lgt, Sus), 0.2f * Fre - 0.1f * Mathf.Min(Ind, Fre));


        T0 = 0.2f * Str + 0.01f;

        SquashMag = Mathf.Max(0.2f * Lgt, 0.15f * Fre);

        //speed = 2 in neutral state

        //TODO: Bound also affects speed
        SetSpeed(2 + Mathf.Max(Sud, 0.5f * Str) - Mathf.Max(Sus, 0.2f * Lgt, 0.2f * Bnd));
        _interpolatorType = InterpolatorType.EndEffector;

        /*
         * if (fre > 0)
         *  _interpolatorType = InterpolatorType.elbowAngle;
         * else if (ind > 0 )
         *  _interpolatorType = InterpolatorType.elbowPos;
         * else
         *  _interpolatorType = InterpolatorType.endEffector;
         */
    }
示例#8
0
 public void ResetParameters()
 {
     SetSpeed(2f);
     V0                = V1 = 0f;
     Ti                = 0.5f;
     Texp              = 1.0f;
     Tval              = 0f;
     T0                = 0.01f;
     T1                = 0.99f;
     TrMag             = TfMag = 0f;
     HrMag             = HfMag = 0f;
     SquashMag         = 0f;
     WbMag             = 0f;
     WxMag             = WtMag = WfMag = 0f;
     EtMag             = DMag = EfMag = 0f;
     _interpolatorType = InterpolatorType.EndEffector;
 }
示例#9
0
    public void Reset()
    {
        _animInfo = GetComponent <AnimationInfo>();
        _animInfo.InitKeyPoints(); //should always update interpolators
        _animInfo.InitInterpolators(Tval, Continuity, Bias);

        _interpolatorType = InterpolatorType.EndEffector;
        // FUNDA Effort2LowLevel(); //initialize low level parameters

        #if DEBUGMODE
        _targetRPrev = new List <Vector3>();
        _targetLPrev = new List <Vector3>();
        #endif

        _velArr = new List <float>();
        _tppArr = new List <float>();
    }
示例#10
0
        public void LoadSettings()
        {
            try
            {
                if (File.Exists(backupOldSettingsFile) || File.Exists(oldSettingsFile))
                {
                    DarkLog.Debug("[Settings]: Loading old settings");
                    LoadOldSettings();
                    SaveSettings();
                    File.Delete(backupOldSettingsFile);
                    File.Delete(oldSettingsFile);
                }

                bool       saveAfterLoad = false;
                ConfigNode mainNode      = new ConfigNode();

                if (File.Exists(backupSettingsFile) && !File.Exists(settingsFile))
                {
                    DarkLog.Debug("[Settings]: Restoring backup file");
                    File.Copy(backupSettingsFile, settingsFile);
                }

                if (!File.Exists(settingsFile))
                {
                    mainNode   = GetDefaultSettings();
                    playerName = DEFAULT_PLAYER_NAME;
                    mainNode.Save(settingsFile);
                }

                if (!File.Exists(backupSettingsFile))
                {
                    DarkLog.Debug("[Settings]: Backing up settings");
                    File.Copy(settingsFile, backupSettingsFile);
                }

                mainNode = ConfigNode.Load(settingsFile);

                ConfigNode settingsNode = mainNode.GetNode("SETTINGS");
                ConfigNode playerNode   = settingsNode.GetNode("PLAYER");
                ConfigNode bindingsNode = settingsNode.GetNode("KEYBINDINGS");

                playerName = playerNode.GetValue("name");

                if (!int.TryParse(settingsNode.GetValue("cacheSize"), out cacheSize))
                {
                    DarkLog.Debug("[Settings]: Adding cache size to settings file");
                    cacheSize     = DEFAULT_CACHE_SIZE;
                    saveAfterLoad = true;
                }

                if (!int.TryParse(settingsNode.GetValue("disclaimer"), out disclaimerAccepted))
                {
                    DarkLog.Debug("[Settings]: Adding disclaimer to settings file");
                    disclaimerAccepted = 0;
                    saveAfterLoad      = true;
                }

                if (!int.TryParse(settingsNode.GetValue("serverlist-mode"), out serverlistMode))
                {
                    DarkLog.Debug("[Settings]: Adding serverlist-mode to settings file");
                    serverlistMode = 0;
                    saveAfterLoad  = true;
                }

                if (!playerNode.TryGetValue("color", ref playerColor))
                {
                    DarkLog.Debug("[Settings]: Adding color to settings file");
                    playerColor   = PlayerColorWorker.GenerateRandomColor();
                    saveAfterLoad = true;
                }

                int chatKey = (int)KeyCode.BackQuote, screenshotKey = (int)KeyCode.F8;
                if (!int.TryParse(bindingsNode.GetValue("chat"), out chatKey))
                {
                    DarkLog.Debug("[Settings]: Adding chat key to settings file");
                    this.chatKey  = KeyCode.BackQuote;
                    saveAfterLoad = true;
                }
                else
                {
                    this.chatKey = (KeyCode)chatKey;
                }

                if (!int.TryParse(bindingsNode.GetValue("screenshot"), out screenshotKey))
                {
                    DarkLog.Debug("[Settings]: Adding screenshot key to settings file");
                    this.screenshotKey = KeyCode.F8;
                    saveAfterLoad      = true;
                }
                else
                {
                    this.screenshotKey = (KeyCode)screenshotKey;
                }

                if (!playerNode.TryGetValue("flag", ref selectedFlag))
                {
                    DarkLog.Debug("[Settings]: Adding selected flag to settings file");
                    selectedFlag  = "Squad/Flags/default";
                    saveAfterLoad = true;
                }

                if (!settingsNode.TryGetValue("compression", ref compressionEnabled))
                {
                    DarkLog.Debug("[Settings]: Adding compression flag to settings file");
                    compressionEnabled = true;
                    saveAfterLoad      = true;
                }

                if (!settingsNode.TryGetValue("revert", ref revertEnabled))
                {
                    DarkLog.Debug("[Settings]: Adding revert flag to settings file");
                    revertEnabled = true;
                    saveAfterLoad = true;
                }

                string interpolatorString = null;
                int    interpolatorInt    = 0;
                try
                {
                    //Make sure we haven't saved to the old int type
                    if (settingsNode.TryGetValue("interpolation", ref interpolatorString) && !int.TryParse(interpolatorString, out interpolatorInt))
                    {
                        interpolatorType = (InterpolatorType)Enum.Parse(typeof(InterpolatorType), interpolatorString);
                    }
                    else
                    {
                        DarkLog.Debug("[Settings]: Adding interpolation flag to settings file");
                        interpolatorType = InterpolatorType.INTERPOLATE1S;
                        saveAfterLoad    = true;
                    }
                }
                catch
                {
                    interpolatorType = InterpolatorType.INTERPOLATE1S;
                    saveAfterLoad    = true;
                }

                int toolbarType;
                if (!int.TryParse(settingsNode.GetValue("toolbar"), out toolbarType))
                {
                    DarkLog.Debug("[Settings]: Adding toolbar flag to settings file");
                    this.toolbarType = DMPToolbarType.BLIZZY_IF_INSTALLED;
                    saveAfterLoad    = true;
                }
                else
                {
                    this.toolbarType = (DMPToolbarType)toolbarType;
                }

                ConfigNode serversNode = settingsNode.GetNode("SERVERS");
                servers.Clear();
                if (serversNode.HasNode("SERVER"))
                {
                    foreach (ConfigNode serverNode in serversNode.GetNodes("SERVER"))
                    {
                        ServerEntry newServer = new ServerEntry();
                        newServer.name    = serverNode.GetValue("name");
                        newServer.address = serverNode.GetValue("address");
                        serverNode.TryGetValue("port", ref newServer.port);
                        servers.Add(newServer);
                    }
                }

                if (saveAfterLoad)
                {
                    SaveSettings();
                }
            }
            catch (Exception e)
            {
                DarkLog.Debug("Error while loading settings:");
                DarkLog.Debug(e.ToString());
            }

            //Read player token
            try
            {
                //Restore backup if needed
                if (File.Exists(backupPublicKeyFile) && File.Exists(backupPrivateKeyFile) && (!File.Exists(publicKeyFile) || !File.Exists(privateKeyFile)))
                {
                    DarkLog.Debug("[Settings]: Restoring backed up keypair!");
                    File.Copy(backupPublicKeyFile, publicKeyFile, true);
                    File.Copy(backupPrivateKeyFile, privateKeyFile, true);
                }
                //Load or create token file
                if (File.Exists(privateKeyFile) && File.Exists(publicKeyFile))
                {
                    playerPublicKey  = File.ReadAllText(publicKeyFile);
                    playerPrivateKey = File.ReadAllText(privateKeyFile);
                }
                else
                {
                    DarkLog.Debug("[Settings]: Creating new keypair!");
                    GenerateNewKeypair();
                }
                //Save backup token file if needed
                if (!File.Exists(backupPublicKeyFile) || !File.Exists(backupPrivateKeyFile))
                {
                    DarkLog.Debug("[Settings]: Backing up keypair");
                    File.Copy(publicKeyFile, backupPublicKeyFile, true);
                    File.Copy(privateKeyFile, backupPrivateKeyFile, true);
                }
            }
            catch
            {
                DarkLog.Debug("Error processing keypair, creating new keypair");
                GenerateNewKeypair();
                DarkLog.Debug("[Settings]: Backing up keypair");
                File.Copy(publicKeyFile, backupPublicKeyFile, true);
                File.Copy(privateKeyFile, backupPrivateKeyFile, true);
            }
        }
示例#11
0
	public void Effort2LowLevel() {

   //     Tval = (-1f * Ind + Mathf.Min(Ind, Fre)) + Dir; //EMOTE and chi
        Tval = (-1f * Mathf.Max(Ind, Fre)) + Mathf.Max( Dir, Bnd); //Funda
        				
	//	WbMag = Mathf.Max(0.6f * ind, Mathf.Max(0.5f * lgt, 1.0f * fre) ); //In Chi's thesis
		WbMag = Mathf.Max(0.6f * Ind, Mathf.Max(0.5f * Lgt, 0.4f * Fre) ); //In emote paper
					
		//WxMag = -0.3f * lgt + (0.2f *  fre - 0.8f * Mathf.Min(str,  fre )); //In Chi's thesis
		WxMag = -0.3f * Lgt + (0.3f *  Fre - 0.9f * Mathf.Min(Str,  Fre )); //In emote paper
		
		DMag = EtMag = WtMag = 0.4f  *  Ind;
		
		EfMag = WfMag = 2f *Ind;

        Texp = 1f + 2f* Sud + (0.2f * Mathf.Min(Str, Sud) - 0.6f* Mathf.Min(Fre, Sud)) - 0.2f * Mathf.Max(Str, 0.5f* Mathf.Min(Dir, Sus)) - 0.4f * Fre - 0.1f * Mathf.Min(Ind, Fre); //chi
      //  Texp = 1f + 2f * Sud + (0.2f * Mathf.Min(Str, Sud) - 0.1f * Mathf.Min(Fre, Sud)) - 0.2f * Mathf.Max(Str, Mathf.Min(Dir, Sus)) - 0.4f * Fre - 0.5f * Mathf.Min(Ind, Fre); //emote ==> causes strange behaviors in ind + fre
     

		Ti  = 0.5f + 0.4f * Mathf.Max(Str, Sud) - 0.4f * Mathf.Max(Lgt, Sus) + 0.8f * Mathf.Min(Bnd, Lgt); //both


    //    V0 = 0.1f * Str - Mathf.Max(0.06f * Mathf.Min(Sus, Str), 0.1f * Mathf.Min(Fre, Str));
        V0 = 0.2f * Str - Mathf.Max(0.06f * Mathf.Min(Sus, Str), 0.1f * Mathf.Min(Fre, Str)); //funda

		V1 = Mathf.Max(0.03f * Mathf.Max( Lgt ,  Sus ), 0.2f * Fre - 0.1f * Mathf.Min( Ind  ,  Fre  ));
        

        T0 = 0.2f * Str + 0.01f;

        SquashMag = Mathf.Max(0.2f * Lgt, 0.15f * Fre);

        //speed = 2 in neutral state

        //TODO: Bound also affects speed
        SetSpeed(2+  Mathf.Max(Sud, 0.5f * Str) - Mathf.Max( Sus, 0.2f * Lgt, 0.2f * Bnd) );
        _interpolatorType = InterpolatorType.EndEffector;
        /*
        if (fre > 0)
            _interpolatorType = InterpolatorType.elbowAngle;
        else if (ind > 0 )
            _interpolatorType = InterpolatorType.elbowPos;
        else
            _interpolatorType = InterpolatorType.endEffector;
        */
    }
示例#12
0
 public void ResetParameters() {
     SetSpeed(2f);
     V0 = V1 = 0f;
     Ti = 0.5f;
     Texp = 1.0f;
     Tval = 0f;
     T0 = 0.01f;
     T1 = 0.99f;
     TrMag = TfMag = 0f;
     HrMag = HfMag = 0f;
     SquashMag = 0f;
     WbMag = 0f;
     WxMag = WtMag = WfMag = 0f;
     EtMag = DMag = EfMag = 0f;
     _interpolatorType = InterpolatorType.EndEffector;
 }
示例#13
0
    public void Reset(){
        
		_animInfo = GetComponent<AnimationInfo>();        
    	_animInfo.InitKeyPoints(); //should always update interpolators
        _animInfo.InitInterpolators(Tval, Continuity, Bias);

        _interpolatorType = InterpolatorType.EndEffector;
		// FUNDA Effort2LowLevel(); //initialize low level parameters

        #if DEBUGMODE
        _targetRPrev = new List<Vector3>();
        _targetLPrev = new List<Vector3>();
        #endif

         _velArr = new List<float>();
        _tppArr = new List<float>();

    }