Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Codea 2.5.2 (99) beta

SimeonSimeon Admin Mod
edited February 2018 in Beta Posts: 5,613

A small update to address some bugs you reported:

• Some editor scrolling bugs came to light and were fixed, especially relating to selecting results from the find/replace sidebar

• Invoking find/replace from the keyboard shortcut should work now (Update: this seems intermittent. It still occurs for me and I can't consistently reproduce the find/replace bar not working from the keyboard)

• Hides the Materials pack from the Shader Lab. Shader Lab isn't built to handle those, yet


  • AnatolyAnatoly Mod
    Posts: 891

    I posted in previous thread. Nobody took in care.

  • SimeonSimeon Admin Mod
    Posts: 5,613

    @TokOut I logged your issue in the tracker when you posted it for @john to look at. I don't think he has had a chance to yet.

  • dave1707dave1707 Mod
    Posts: 9,241

    Using find in the editor seems to be working OK. Tapping on found words moves the words into the viewing area instead of scrolling to the beginning or end of the code.

  • SimeonSimeon Admin Mod
    Posts: 5,613

    Thanks for testing and letting us know @dave1707

  • dave1707dave1707 Mod
    Posts: 9,241

    @Simeon Here’s something that’s probably existed forever. According to the reference, readProjectTab(name) should return nothing if it can’t find name, but instead causes an error. Another thing, the project name looks like it’s case insensitive, but the tab name is case sensitive. In the code below, the first 2 readProjectTabs work, but the third causes an. It would be nice if both were case insensitive and returned nil if nothing is found.

    function setup()
        a=readProjectTab("CaRgO-bOt:Main")  -- mixed case project name, correct tab name
        print("size ",#a)     — above line works
        a=readProjectTab("cargo-bot:Main")  -- lower case project name, correct tab name
        print("size ",#a)     — above line works
        a=readProjectTab("cargo-bot:main")  -- lower case project and tab name
        print("size ",#a)     — above line causes an error    
  • dave1707dave1707 Mod
    Posts: 9,241

    @Simeon Something else that’s kind of weird. Sometimes when I close Codea with a project still open in the editor, then at a later time start Codea, there is a different project open in the editor. I thought when this happened in the past, that I might have been in that project, but just now when I opened Codea, I was in a project that I know I haven’t been in for maybe months. I’ll keep an eye out for this, and see if I can come up with a cause.

  • @John entity.worldRotation prints ’nil`.

    I'm trying to work out how AR keeps track of where an entity is relative to the camera. Any hints on this? The world positions of the camera and entity don't seem to change as I move the iPad around, and I can't check world rotations as they print nil.

  • JohnJohn Admin Mod
    Posts: 643
    Hi @LoopSpace
    This is a bit of an oversight which I’ll need to fix. ARKit provides matrices in a different handedness than what we’re using which I’ll need to compensate for.
  • @John I think that entity.inverseTransformPoint uses the wrong rotation matrix. Specifically, it uses entity.rotation instead of its inverse. I haven't experimented with entity.inverseTransformDirection yet.

    What I'm trying to do is interact with something that I've placed in AR. So I need to transform the touch point into the entity's local space. Without entity.worldRotation, I wanted to use entity.inverseTransformPoint instead.

  • JohnJohn Admin Mod
    Posts: 643

    @LoopSpace I just checked my code. You're right, I'm using the wrong matrix. This fix will be in the next beta.

  • @John Great!

  • By inverting the forward transformation, I've managed to do what I wanted: interact with an AR-projected scene. The core functionality can be seen in the video on this tweet. As I have a few more than 140 (or 280) characters here, let me give a bit more detail.

    There are four entities:

    1. A Desert Cliff cube
    2. A Water cube, which is a child of the Desert Cliff cube
    3. A purple cube, which is a child of the Water cube
    4. A yellow sphere, which is not a child of anything

    The cubes rotate, move, and scale as time passes, so the transformation from world space to the purple cube is non-trivial.

    To position the yellow sphere, we take the vector vec3(1,0,0) in the local space of the water cube and translate it to a position in world space.

    To position the purple cube, we take the current touch and project it onto a plane through the origin which is orthogonal to the vector from the camera at the centre of the screen. Then we transform that point into the local space of the water cube so that we can position the purple cube correctly. It stays in the right place - the green circle is a 2d ellipse at the CurrentTouch location - but the fact that it turns and changes shape shows that it is genuinely a child of the water cube.

    At the moment, I'm doing this by taking the forward transformation and inverting it. Once @John has fixed the transformation, it'll be possible using the entity:inverseTransformPoint routine directly.

    I also checked it with one of my AR projects and it works just fine. I projected an AR image, moved around it, and then could interact with it via touch exactly as I wanted.

    Have I said recently just how awesome Codea is???

  • Posts: 1,166

    Just checking in to say yay, you fixed that scrolling thing, great job!

  • Posts: 1,166

    May I make a feature request? It would be fantastic if you could type in letters in a search bar at the top of the dependencies list, to find specific projects for dependencies, just the same way you can do that in the main Projects screen of Codea.

  • Posts: 1,166

    Oh man oh man oh man oh man

    What was that thing that I thought I saw someone else talking about, and that I thought was fixed, about losing tabs? I just lost like four tabs in a project and I'm freaking out.

    What I did was:

    • have a project where "Main" was like the third or fourth tab
    • duplicate that project
    • delete the original (I was basically just renaming it)

    ...and when I opened the duplicate, everything before the "Main" tab was gone


    Is there any hope of getting those tabs back?

  • dave1707dave1707 Mod
    Posts: 9,241

    @UberGoober I gave an example long ago of a way that tabs were being deleted, but I don’t know if that had anything to do with how your tabs were deleted. I don’t know if that led to any fixes. Codea has the Export Projects that works. It copies all of your projects into a zip file and it lets you import them all or just selected projects. A lot of times I’ll make a duplicate of any project I’m making major changes to so if I screw something up, I have the original. Here’s a suggestion for next time, make sure the copied project is OK before you delete the original. If you don’t have any backups, the only way to get the tabs back is to re-key them. A lot of times when you have to recreate a deleted project or tab, you do a better job of coding it.

  • dave1707dave1707 Mod
    edited November 2017 Posts: 9,241

    @John Can you show an example of how to use craft.noise.cache(). Also, you didn’t include craft.noise.multiply() or craft.noise.invert() in the documentation.

    EDIT: Also, any noise function that requires an input causes an error if it isn’t supplied. Instead of causing an error, a 0 should be assumed if an input isn’t supplied.

  • JohnJohn Admin Mod
    Posts: 643

    @dave1707 Thanks, I'll make sure to fix those. Default parameters shouldn't be a problem either.

  • JohnJohn Admin Mod
    Posts: 643

    @dave1707 The craft.noise.cache() module is helpful when you want to prevent redundant calculations. Here's an example:

    noise = craft.noise
    -- Semi-expensive noise function
    perlin = noise.perlin()
    cachedPerlin = noise.cache()
    cachedPerlin:setSource(0, perlin)
    multipliedPerlin = noise.multiply()
    multipliedPerlin:setSource(0, cachedPerlin)
    multipliedPerlin:setSource(1, cachedPerlin)

    Normally if you evaluated the multipliedPerlin module (which is just the perlin noise multiplied by itself) you would have to evaluate the perlin noise module twice. By using the cache module you only evaluate perlin once per call. There is another version of this for voxels called chunkCache2D which caches a grid of values for a voxel chunk which speeds up terrain generation quite a bit for some expensive noise modules.

  • dave1707dave1707 Mod
    Posts: 9,241

    @John Thanks for the explanation and example. I’ve been playing with the noise functions just to see how they work and the cache always gave me an error. I saw the chunkCache2D function when I came across the multiply and invert functions. Those three weren’t listed in the documentation, so it was trial and error to get them to work. The multiply and invert were easy to use, but the chunkCache2D always gave me an error.

  • dave1707dave1707 Mod
    Posts: 9,241

    @John Did the craft.noise.cache() example above work for you. When I run it, I get an error message, the same error message I got when I was trying to use cache originally.

    Main:7: attempt to call a table value (field 'cache')
    stack traceback:
        Main:7: in function 'setup'
  • JohnJohn Admin Mod
    Posts: 643
    @dave1707 I’ll have to look into that.
  • texture for icosphere?

    i tried to wrap a texture around an craft icosphere with, but it does not seem to work? Do i have to define all the normals, texcoord,s etc explicitly myself? (For a cube it just works).

  • Posts: 2,218

    Hi @John - just a quick note to raise a query and maybe a suggestion. You know I’ve had problems loading models, mostly resolved now, but one problem I have is with a couple of models which appear to load but are not visible. Tracked this down on one model to being at a distant location I know examining the model would help resolve that but since your loader has parsed every vertice you could calculate an average position for the models location. I will be trying to use model:position(index,x,y,z) to do this but not sure about the syntax - is index the vertex array? It could save us a lot of trouble in future if we can print out the average model(x,y,z) location to resolve locating models.

    One other thing - how do camera and variable locations relate to pixels - seem to be an Oder of magnitude difference.

Sign In or Register to comment.