Пример #1
0
        /**
         * Returns a name currently not being used by any other object. The returned
         * name is of the form "prefix_n" where n is an integer starting at 1. Only
         * a simple linear search is performed, so this method should be used only
         * when there is no other way to guarentee uniqueness.
         *
         * @param prefix name prefix
         * @return a unique name not used by any rendering object
         */
        public string getUniqueName(string prefix)
        {
            // generate a unique name based on the given prefix
            int    counter = 1;
            string name;

            do
            {
                name = string.Format("{0}_{1}", prefix, counter);
                counter++;
            } while (renderObjects.has(name));
            return(name);
        }
Пример #2
0
 /**
  * Defines a shader with a given name. If the shader type name is left
  * <code>null</code>, the shader with the given name will be updated (if
  * it exists).
  *
  * @param name a unique name given to the shader
  * @param shaderType a shader plugin type
  */
 public void shader(string name, string shaderType)
 {
     if (!isIncremental(shaderType))
     {
         // we are declaring a shader for the first time
         if (renderObjects.has(name))
         {
             UI.printError(UI.Module.API, "Unable to declare shader \"{0}\", name is already in use", name);
             parameterList.clear(true);
             return;
         }
         IShader shader = PluginRegistry.shaderPlugins.createObject(shaderType);
         if (shader == null)
         {
             UI.printError(UI.Module.API, "Unable to create shader of type \"{0}\"", shaderType);
             return;
         }
         renderObjects.put(name, shader);
     }
     // update existing shader (only if it is valid)
     if (lookupShader(name) != null)
     {
         update(name);
     }
     else
     {
         UI.printError(UI.Module.API, "Unable to update shader \"{0}\" - shader object was not found", name);
         parameterList.clear(true);
     }
 }