Mikal's Forum Posts

  • construct.net/en/make-games/manuals/construct-3/scripting/scripting-reference/plugin-interfaces/array

    I think you want to use:

    runtime.objects.Array.getFirstInstance() to get the object instance and then use the method:

    setAt(val, x, y = 0, z = 0)

    Set an element in the array at the given X, Y and Z co-ordinates. val must be a number or string. For one or two dimensional arrays, the later parameters can be omitted as they default to 0.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Updated with fix, version 1.0.1, the test project now plays the GIF on start of layout without resizing or any other C3 objects. Thanks for the bug report and test project.

    kindeyegames.itch.io/gifplayer-construct-3-addon

  • Thanks!

    I think I know why you are seeing that issue, I should be able to fix it in the plugin. Thanks for the bug report and supplying an example project, which is always very helpful for debug.

    Meanwhile for further testing in your project add a rotating sprite in your layout. This will make sure the GIF render to C3 happens every frame, including at the start.

    On the memory side, the GIF is not storing much data in the GPU memory, but a lot in CPU memory (each decoded frame.) So the memory usage may show up in another way, just something to be aware of.

  • From latest beta:

    JSON plugin: script interface to access JSON data

    Thank you Scirra, will try it out!

  • Here's an idea, create an object that includes a1 and a2 and then use currentbox to access them in the object using the 'key' currentbox. To make my example work, I also added a2 to the family.

  • New plugin to play GIFs (with control on a per frame basis, speed, pause, play, etc.) You can also apply effects and the usual general object ACEs.

    kindeyegames.itch.io/gifplayer-construct-3-addon

    If you try it out, please leave feedback here or in the addon comments.

  • Added TextureWrap to my Construct Effects Itch page.

    kindeyegames.itch.io/effects-for-construct

    Use with 'nearest' filtering. Create a texture offset and texture wrap on objects such as animated sprites. Similar behavior to the Tiled Background object, but also allows for animations. Also includes scaling texture up and down with wrapping / tiling. Bilinear or Trilinear filtering will have a seam on the texture edges.

  • Agree, this would be really great! I also am always doing stringify and parse for scripting and C3 functions / events.

    Right now I pass into C3 Functions that call scripting JSON.GetAsCompactString and then in the scripting I must parse, then for output from scripting back as a C3 return value meant for a C3 JSON object, I must again do JSON.stringify and then on C3 side, must do a JSON -> parse.

    If we had the scripting control for the C3 JSON object. Instead we could pass in JSON.UIDs as parameters for the function, in scripting we can select the object and read the JSON values and then we can also update another JSON object (or the same JSON object) as an 'output' of the function.

    Yay! Local project folder is back after I updated to Chrome 83. Thanks to Ashley and the Chrome team. This is a great feature for Git / version control.

  • There are a lot of tutorials and examples for Babylon and three.js by themselves.

    With C3 scripting in events, the integration is pretty good, you can call Babylon functions and scripting can call C3 functions.

    Try it out...

    Another example. Adding C3 Warp Object effect on the Babylon render:

  • Nice work, I see a lot of demand for this in the forum and discord, video tutorials and example projects will really help folks trying to use it (easy for me to say, I've only done example projects for my own plugin :) ) Good luck!

  • Yes, I know about Spritesheets and their complications.

    I think my solution may be to use rcTex coordinates for the subset of the spritesheet texture, place the full texture on an offscreen canvas and use that canvas as the 'data' for UpdateTexture.

    Here's an example. I will do a couple of changes:

    - gl.readPixels needs to read from the rectangle subset based on rcTex subset of the spritesheet

    - UpdateTexture() can use a Canvas directly, so we don't need to create the img from it, can return the canvas instead.

    function createImageFromTexture(gl, texture, width, height) {
     // Create a framebuffer backed by the texture
     var framebuffer = gl.createFramebuffer();
     gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
     gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
    
     // Read the contents of the framebuffer
     var data = new Uint8Array(width * height * 4);
     gl.readPixels(<change based on rcTex and texture width to get lower x>, <change based on rcTex and texture height to get get lower y>, <change based on rcTex width and texel width>, <change based on rcTex height and texel height>, gl.RGBA, gl.UNSIGNED_BYTE, data);
    
     gl.deleteFramebuffer(framebuffer);
    
     // Create a 2D canvas to store the result 
     var canvas = document.createElement('canvas');
     canvas.width = width;
     canvas.height = height;
     var context = canvas.getContext('2d');
    
     // Copy the pixels to a 2D canvas
     var imageData = context.createImageData(width, height);
     imageData.data.set(data);
     context.putImageData(imageData, 0, 0);
    
     var img = new Image();
     img.src = canvas.toDataURL();
     return img;
    }
  • In the context of a plugin with an animation:

    Is it possible to enable wrapping of a texture, instead of edge clamp?

    With spritesheets, it represents a little more difficult (though it may be possible with an effect and manual wrapping of srcOriginStart to/from srcOriginEnd.)

    With CreateDynamicTexture() it seems possible with using opts of isTiled:true and tileType:repeat. The question I have is it possible to use an existing texture (imageInfo.GetTexture()) to UpdateTexture(data, texture, opts)? imageInfo.GetTexture does not seem to be directly one of the 'data' types for UpdateTexture(), is there another way to get a compatible data type from an existing animation frame / texture?

  • Example of Babylon and C3 (Plane is 3D Babylon model rendered with Canvas and ElementQuad plugin, the rest is C3 Sprites, note that plane can be in front of some C3 objects (e.g. background), but behind others (e.g. trees.)

  • There are a number of different ways to mix another javascript 'engine's' 3D render with the C3 render (which mostly appears as 2D render, but typically is actually 3D webgl render with a fixed camera and lookat point with they same x,y, but different Z, so it appears '2D'.)

    You can render using three.js, Babylon, etc. to a different canvas and put that canvas in front of or behind the C3 canvas with transparency.

    You can also render to a different canvas and use that for a C3 object's texture, which makes it easier to place the object in C3's Z order.

    Generally it requires another 3D 'engine' like three.js, modelviewer (which I just saw another dev cleverly use), Babylon, etc. to do the 3D render and then a method to include it in the display.

    Here's a C3 & Babylon example I did a while back

    construct.net/en/forum/construct-3/general-discussion-7/babylon-3d-simple-js-147886