Ejemplo n.º 1
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~helper functions~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    /*
     * attaches an identifier script to the go, sets id to given, and adds to local
     * identified list
     */
    private void setIdentifier(GameObject go, string id)
    {
        identifier i = go.AddComponent <identifier>();

        i.setID(id);
        identified.Add(i);
    }
Ejemplo n.º 2
0
        private Texture(identifier id, int open_gl_id, int width, int height, List <byte> raw_data)
        {
            Identifier = id;
            ObjectID   = open_gl_id;
            Width      = width;
            Height     = height;
            RawData    = raw_data;
            HasRawData = true;

            Debug.LogDebug($"Created texture '{id}' with a resolution of {width}{SpecialCharacters.Multiply}{Height} px");
        }
        private static Cell CreateCell(identifier i, string s)
        {
            var c = new Cell();

            c.SetBorder(border);
            c.SetMinHeight(0);

            if (i == null || i.Value == null)
            {
                return(null);
            }

            return(c.Add(new Paragraph(s + i.Value)));
        }
Ejemplo n.º 4
0
        public static Texture Load(identifier id, string filename, bool suppress_extension_warning = false, bool store_raw_data = false,
                                   TextureWrapMode wrap_u      = TextureWrapMode.ClampToEdge, TextureWrapMode wrap_v  = TextureWrapMode.ClampToEdge,
                                   TextureMinFilter min_filter = TextureMinFilter.Linear, TextureMagFilter mag_filter = TextureMagFilter.Linear)
        {
            return(Debug.Profile($"Loading texture '{id}'", true, new Task <Texture>(() =>
            {
                FileManager.VerifyExtension(ref filename, suppress_extension_warning, "png", "jpg", "jpeg");
                Image <Rgba32> image = FileManager.LoadTexture(filename);
                if (image == null)
                {
                    throw new AssetLoadFailedException(filename);
                }

                Rgba32[]   temp_pixels = image.GetPixelSpan().ToArray();
                List <byte> pixels = new List <byte>();

                foreach (Rgba32 pixel in temp_pixels)
                {
                    pixels.Add(pixel.R);
                    pixels.Add(pixel.G);
                    pixels.Add(pixel.B);
                    pixels.Add(pixel.A);
                }

                int texture_id = GL.GenTexture();
                GL.BindTexture(TextureTarget.Texture2D, texture_id);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)wrap_u);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)wrap_v);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)min_filter);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)mag_filter);
                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, image.Width, image.Height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, pixels.ToArray());

                return store_raw_data
                                               ? new Texture(id, texture_id, image.Width, image.Height, pixels)
                                               : new Texture(id, texture_id, image.Width, image.Height);
            })) as Texture);
        }
Ejemplo n.º 5
0
 get => new NetworkDataData(identifier, attribute, value);
Ejemplo n.º 6
0
 Last = new AccessStep(identifier, location);
Ejemplo n.º 7
0
 from n in optional(identifier)
 select(t, n)))
Ejemplo n.º 8
0
 public void removeFromIdentified(identifier i)
 {
     identified.Remove(i);
 }
Ejemplo n.º 9
0
 foreach (var(identifier, value) in values)
Ejemplo n.º 10
0
 public static Shader Load(identifier id, string vertex_filename, string fragment_filename, bool suppress_extension_warning = false)
 {
     return(Debug.Profile($"Loading shader '{id}'", true, new Task <Shader>(() =>
     {
         // Validate file extensions
         FileManager.VerifyExtension(ref vertex_filename, suppress_extension_warning, "glsl", "vs", "vert", "shader");
         FileManager.VerifyExtension(ref fragment_filename, suppress_extension_warning, "glsl", "fs", "frag", "shader");
         // Load the vertex shader source
         string vertex_source = FileManager.ReadAssetToString(vertex_filename);
         if (vertex_source == null)
         {
             throw new AssetLoadFailedException(vertex_filename);
         }
         // Load the fragment shader source
         string fragment_source = FileManager.ReadAssetToString(fragment_filename);
         if (fragment_source == null)
         {
             throw new AssetLoadFailedException(fragment_filename);
         }
         // Compile the vertex shader
         int vertex_shader = GL.CreateShader(ShaderType.VertexShader);
         Debug.LogDebug($"Created temporary vertex shader {vertex_shader}");
         GL.ShaderSource(vertex_shader, vertex_source);
         GL.CompileShader(vertex_shader);
         string vertex_info_log = GL.GetShaderInfoLog(vertex_shader);
         if (!string.IsNullOrEmpty(vertex_info_log))
         {
             GL.DeleteShader(vertex_shader);
             Debug.LogDebug($"Deleted temporary vertex shader {vertex_shader}");
             throw new ShaderCompilationFailedException(id, ShaderType.VertexShader, vertex_info_log);
         }
         // Compile the fragment shader
         int fragment_shader = GL.CreateShader(ShaderType.FragmentShader);
         Debug.LogDebug($"Created temporary fragment shader {fragment_shader}");
         GL.ShaderSource(fragment_shader, fragment_source);
         GL.CompileShader(fragment_shader);
         string fragment_info_log = GL.GetShaderInfoLog(fragment_shader);
         if (!string.IsNullOrEmpty(fragment_info_log))
         {
             GL.DeleteShader(vertex_shader);
             Debug.LogDebug($"Deleted temporary vertex shader {vertex_shader}");
             GL.DeleteShader(fragment_shader);
             Debug.LogDebug($"Deleted temporary fragment shader {fragment_shader}");
             throw new ShaderCompilationFailedException(id, ShaderType.FragmentShader, fragment_info_log);
         }
         // Create the shader program
         int program = GL.CreateProgram();
         Debug.LogDebug($"Created shader program {fragment_shader}");
         // Bind shaders
         GL.AttachShader(program, vertex_shader);
         GL.AttachShader(program, fragment_shader);
         string program_info_log = GL.GetProgramInfoLog(program);
         if (!string.IsNullOrEmpty(program_info_log))
         {
             GL.DeleteShader(vertex_shader);
             Debug.LogDebug($"Deleted temporary vertex shader {vertex_shader}");
             GL.DeleteShader(fragment_shader);
             Debug.LogDebug($"Deleted temporary fragment shader {fragment_shader}");
             GL.DeleteProgram(program);
             Debug.LogDebug($"Deleted shader program {fragment_shader}");
             throw new ApplicationException($"Failed to attach shaders to the shader program for '{id}': {program_info_log}");
         }
         Debug.LogDebug("Bound shaders to shader program");
         // Link the shader program
         GL.LinkProgram(program);
         program_info_log = GL.GetProgramInfoLog(program);
         if (!string.IsNullOrEmpty(program_info_log))
         {
             GL.DeleteShader(vertex_shader);
             Debug.LogDebug($"Deleted temporary vertex shader {vertex_shader}");
             GL.DeleteShader(fragment_shader);
             Debug.LogDebug($"Deleted temporary fragment shader {fragment_shader}");
             GL.DeleteProgram(program);
             Debug.LogDebug($"Deleted shader program {fragment_shader}");
             throw new ApplicationException($"Failed to link shaders to the shader program for '{id}': {program_info_log}");
         }
         Debug.LogDebug($"Linked shader program {program}");
         // Cleanup
         GL.DetachShader(program, vertex_shader);
         GL.DeleteShader(vertex_shader);
         Debug.LogDebug($"Deleted temporary vertex shader {vertex_shader}");
         GL.DetachShader(program, fragment_shader);
         GL.DeleteShader(fragment_shader);
         Debug.LogDebug($"Deleted temporary fragment shader {fragment_shader}");
         // Create and return the shader
         return new Shader(id, program);
     })) as Shader);
 }
Ejemplo n.º 11
0
 private Shader(identifier id, int open_gl_id)
 {
     Identifier = id;
     ObjectID   = open_gl_id;
 }
Ejemplo n.º 12
0
 public ShaderCompilationFailedException(identifier id, ShaderType type, string info_log)
     : base($"Failed to compile {type.ToString().ToLower()} shader '{id}': {info_log}")
 {
 }
Ejemplo n.º 13
0
 select new OtObject(identifier, pairs.Select(c =>
Ejemplo n.º 14
0
 .Let(identifier = first.Concat(rest))
Ejemplo n.º 15
0
 Set(identifier, value);
Ejemplo n.º 16
0
 foreach (var(identifier, value) in changes)
Ejemplo n.º 17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Web.UI.WebControls.Label label = new Label();

            // enclosing in try/catch for easier debugging, primarily
            try
            {
                // get a handle to the asset operation service
                proxy = new AssetOperationHandlerService();

                // contruct a path object referencing the 'about' page from the example.com site
                // note:  change this path to a page that actually exists in your cms instance, if necessary
                pagePath = new path();
                // set the relative path (from the Base Folder) to the asset
                pagePath.path1 = "/about";
                // set the site name of the path object (note: set siteName to 'Global' if the asset is not in a Site)
                pagePath.siteName = "example.com";

                // contruct asset identifier used for read() operation
                id = new identifier();
                // set the asset type
                id.type = entityTypeString.page;
                // set asset path (may use either path or id, but never both)
                id.path = pagePath;

                // contruct authentication element to be used in all operations
                auth = new authentication();
                // change username / password as necessary
                auth.username = "******";
                auth.password = "******";

                // attempt to read the asset
                result = proxy.read(auth, id);

                // print asset contents to page label
                label.Text = CascadeWSUtils.printAssetContents(result.asset);

                // edit the asset
                // create an empty asset for use with edit() operation
                // (note: this is assuming the authentication user has bypass workflow abilities --
                // if not, you will also need to supply workflowConfig information)
                asset editAsset = new asset();
                editAsset.page = result.asset.page;
                // add some content to the exiting page xhtml
                editAsset.page.xhtml += "<h1>Added via .NET</h1>";
                // must call this method to avoid sending both id and path values in
                // component references in the asset -- will generate SOAP errors otherwise
                CascadeWSUtils.nullPageValues(editAsset.page);

                // attempt to edit
                operationResult editResult = proxy.edit(auth, editAsset);
                // check results
                label.Text += "<br/><br/>edit success? " + editResult.success + "<br/>message = " + editResult.message;


                // create new asset (using read asset as a model)
                asset newAsset = new asset();
                page  newPage  = result.asset.page;

                // must call this method to avoid sending both id and path values in
                // component references in the asset -- will generate SOAP errors otherwise
                CascadeWSUtils.nullPageValues(newPage);

                // since this will be a new asset, change its name
                newPage.name = "new-page-created-via-dot-net";
                // remove id from read asset
                newPage.id = null;
                // remove other system properties brought over from read asset
                newPage.lastModifiedBy             = null;
                newPage.lastModifiedDate           = null;
                newPage.lastModifiedDateSpecified  = false;
                newPage.lastPublishedBy            = null;
                newPage.lastPublishedDate          = null;
                newPage.lastPublishedDateSpecified = false;
                newPage.pageConfigurations         = null;

                newAsset.page = newPage;

                // attempt to create
                createResult createResults = proxy.create(auth, newAsset);

                // check create results
                label.Text = label.Text + "<br/><br/>create success? " + createResults.success + "<br/>message = " + createResults.message;

                // debugging -- writes the serialzed XML of the asset element sent in create request to a file

                /*
                 * // Serializing the returned object
                 * System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(newAsset.GetType());
                 *
                 * System.IO.MemoryStream ms = new System.IO.MemoryStream();
                 *
                 * x.Serialize(ms, newAsset);
                 *
                 * ms.Position = 0;
                 *
                 * // Outputting to client
                 *
                 * byte[] byteArray = ms.ToArray();
                 *
                 * Response.Clear();
                 * Response.AddHeader("Content-Disposition", "attachment; filename=results.xml");
                 *
                 * Response.AddHeader("Content-Length", byteArray.Length.ToString());
                 *
                 * Response.ContentType = "text/xml";
                 *
                 * Response.BinaryWrite(byteArray);
                 * Response.End();
                 * */
            }
            catch (Exception booboo) { label.Text = "Exception thrown:<br>" + booboo.GetBaseException() + "<br/><br/>STACK TRACE:<br/>" + booboo.StackTrace; }

            WSContent.Controls.Add(label);
        }