Howdy, Stranger!

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

Codea Craft 2.5 (84) Beta - Updated 8/9/2017

edited September 2017 in Beta Posts: 71

Not sure if this is in the right place or anything, but hey! Codea Craft is here!

From what I've experimented with so far I've found that the included Voxel Editor example project errors without starting. Does anyone else have that problem?

Tagged:
IMG_3691.PNG 121.5K
«134

Comments

  • JohnJohn Admin Mod
    Posts: 583

    Hi @Attila717

    I should have mentioned this in the patch notes. The Voxel Editor project is currently broken due to some API changes. Next release will have it working as normal.

  • edited April 2017 Posts: 1,384

    Hi All,

    Just found a new beta for Codea and was surprised to find the Codea Craft was included. Quickly installing and checking it out I found an interesting array of new tools on the reference section. But no examples to demonstrate their use!!

    Hearing that a Beta was about to be launched I was going to question how it would run - in Codea or alongside ? Also what features could be used in Codea itself.

    So I now find myself with a new toy and no means to try it out - any Suggestions?

    Just a couple of trivial observations - no icon on the reference for Codea Craft. Also the word noise at the bottom of the Codea Craft feature list in the reference section.

  • SimeonSimeon Admin Mod
    Posts: 5,054

    @Bri_G for now you'll have to restore all example projects to get the Craft projects.

  • Posts: 1,384

    @Simeon - thanks for the prompt feedback, restored and functional - very impressive!!

  • dave1707dave1707 Mod
    Posts: 7,907

    Received the TestFlight message for the update a little while ago. Looks like I'm a little behind for the testing.

  • Posts: 71

    Watching with intense envy :)

  • Posts: 1,384

    Hi guys,

    Another quick query - been on to the kenny site and 'imported' the nature package of graphics into Codea but can't see the images in the appropriate Assets store. How do you get these up?

    The demos run and use some of the assets but can't see them in my resources - except for the UI package.

  • dave1707dave1707 Mod
    Posts: 7,907

    Been looking at the examples and trying to compare the code to what's in the reference. I'm finding some things, but not everything. Not sure if the reference is missing a lot of stuff or I'm not understanding Codea Craft yet. I guess it's going to be a while before I can say this or that doesn't work since I don't know what's going on yet. But then that's what Codea is all about, the learning curve and what can be done once you do learn it.

  • Posts: 1,384

    Hi @dave1707,

    I have experienced problems with the Voxel Editor. I installed the update on two iPads an iPad Pro and an iPad 2 to compare performance/compatibility. The Pro first then the pad 2 some time later. The Voxel Editor ran OK on the pad 2 but not on the Pro. Comparing the code, in main, the former initialised with:


    craft.scene.ambientColor = color(101, 101, 101, 255)

    The latter initialised with:


    world.ambientColor = color(101, 101, 101, 255)

    There was obviously other differences in code. I suspect from different authors. Slowly working through the code and updating line by line I hit a problem with an error referring to Touches: note the capital T.

    A re-installation of the examples, on the iPad Pro, solved the problem and the code is now consistent on both kits.

  • dave1707dave1707 Mod
    Posts: 7,907

    @Bri_G I'm currently running on an iPad Air and haven't run into any errors. My problem is I don't know what I'm doing. I never heard of Voxels until it was mentioned that it would be added to Codea. So I'm on a steep learning curve. I don't mind because that's what keeps me interested. What I don't like is not knowing enough to find any errors that might be in the code. I also don't know enough to answer questions anyone has about Codea Craft. Being retired, I have a lot of time to learn so hopefully I'll be up to speed in no time.

  • dave1707dave1707 Mod
    Posts: 7,907

    @Simeon Here's something strange. If I load any of the craft examples that use Craft as a dependency, then tap the + (dependencies) and uncheck Craft, the next project gets checked. If Craft is unchecked and I check it, the next project also gets checked.

  • JohnJohn Admin Mod
    Posts: 583
    Hi @dave1707 don't worry you are absolutely correct that the documentation is missing a fair bit of information. I'm still writing it! This first beta release is focusing on stability, bug fixes and testing the new examples.

    I will be writing more and also be creating a manual as well as tutorial videos.
  • SimeonSimeon Admin Mod
    Posts: 5,054

    @athros you can join the beta if you feel like playing with it (see https://codea.io/talk/discussion/8296/codea-craft-call-for-testers)

  • dave1707dave1707 Mod
    Posts: 7,907

    @John I've had the Voxel Terrain crash several times but only when I tried to do a restart. It doesn't do it every time and I haven't found a pattern yet.

  • Posts: 71
    @Simeon - I sent you a DM on the forum, though I don't know if you got it
  • SimeonSimeon Admin Mod
    Posts: 5,054

    Haha so you did! Sorry I missed it

  • JohnJohn Admin Mod
    Posts: 583

    @dave1707 Yes, this is a known issue that I'm still tracking down. The crash reports we get should help us figure it out though. Thanks!

  • Posts: 71

    No worries :)

  • Posts: 2,020

    Haven't had a chance to really dig into this yet, just ran the examples.

    But I just want to say congratulations. Craft is an incredible achievement which will completely revolutionise 3D on Codea.

    I can't wait to see how people put it to use. This could be a massive hit.

  • edited April 2017 Posts: 1,384

    Hi @dave1707 - retired myself and until recently had a reasonable time to play now I have to make the time. As far as Codea Craft goes I'm like you need to get a grounding in the basics.

    @John it could be useful for a few of us if you could provide, or point us to, any documentation/code that outlines what is needed in the virtual 3D world involved with Codea Craft (possibly something from Minecraft?)

  • JohnJohn Admin Mod
    Posts: 583

    @Bri_G I'm currently working on a manual and some fairly simple step-by-step example projects to demonstrate the basic 3D features and how they work.

    If you want to display a cube on the screen, this would be a simple example project:

    -- Make sure to enable Craft in the dependency settings
    function setup()  
      cube = craft.entity()
    
      -- Create a basic unit cube mesh
      local cubeMesh = craft.mesh.cube(vec3(1,1,1))
    
      -- Add the renderer component, which will actually draw our mesh
      renderer = cube:add(craft.renderer, cubeMesh)
    
      -- Apply a material to the cube
      renderer.material = craft.material("Materials:Standard")
      -- Use renderer.material.map to apply a texture
    
      -- Move the camera forwards and rotate 180 degrees
      craft.scene.camera.position = vec3(0,0,10)
      craft.scene.camera.rotation = quat.eulerAngles(0,0,180)
    end
    
    function update()
      local r = ElapsedTime * 45
      cube.rotation = quat.eulerAngles(r,r,r)
    end
    
    function draw()
    end
    

    craft.scene gives you access to some basic built-in objects such as camera, sun and sky, which you can use to alter lighting, the camera and the background. Each of those are entities so you have to get components from them which you can then modify (such as making the camera orthographic, changing the sun into a point light or setting the sky color). This will all be in the documentation soon in addition to the manual and some tutorial videos.

  • dave1707dave1707 Mod
    Posts: 7,907

    @John Thanks for the little demo. I was trying to take one of the examples and chop it down to bare minimum, but l didn't have any luck. I see that the draw function isn't needed for Craft. Can't wait for the manual, documentation, and the tutorials because there seems to be a lot going on that doesn't make sense.

  • edited April 2017 Posts: 71

    @John I modified your code a bit to experiment with physics, but I get an error whenever I try to call applyForce on the cube. Is it one of the things that isn't implemented yet?

    Also, I can't future out the material.map feature, could you explain how it works/is going to work?

    IMG_3696.PNG 98.4K
    IMG_3695.PNG 420.8K
  • edited April 2017 Posts: 71

    Aaand, I'll answer my own question because I actually read the example code now. To apply force to an object, you've got to put the cube rigidbody in a variable and apply force to that variable.

    cubep = cube:add(craft.rigidbody, DYNAMIC, 1)
    cubep:applyForce(vec3(100,100,0))
    

    And the reason the material.map didn't work is because the asset I assigned it didn't exist. Hmm.

  • dave1707dave1707 Mod
    Posts: 7,907

    @Attila717 Good job. I hope the manual and documentation comes out soon.

  • dave1707dave1707 Mod
    Posts: 7,907

    Here's the above program with some changes as I experiment. I changed some of the names to make it easier for me to understand. Hope the manual comes out soon.

    -- Make sure to enable Craft in the dependency settings
    
    displayMode(FULLSCREEN)
    
    function setup()  
        c1 = craft.entity()
        c2 = craft.entity()
    
        -- Create a basic unit cube mesh
        local c1Mesh = craft.mesh.cube(vec3(1,12,3))
        local c2Mesh = craft.mesh.cube(vec3(8,2,1))
    
        -- Add the renderer component, which will actually draw our mesh
        local r1 = c1:add(craft.renderer, c1Mesh)
        local r2 = c2:add(craft.renderer, c2Mesh)
    
        -- Apply a material to the cube
        r1.material = craft.material("Materials:Specular")
        r1.material.diffuse = color(0, 19, 255, 255)
        r1.material.specular = color(0, 206, 255, 255)
    
        r2.material = craft.material("Materials:Specular")
        r2.material.diffuse = color(255,0,0)
        r2.material.specular = color(0, 255, 0, 255)
    
        -- Set camera position
        craft.scene.camera.position = vec3(0,0,15)
        craft.scene.camera.rotation = quat.eulerAngles(0,0,180)
    end
    
    function update()
        local r = ElapsedTime * 15
        c1.rotation = quat.eulerAngles(r*2,r,r)
        c2.rotation = quat.eulerAngles(r,r*3,-r)
    end
    
  • Posts: 71

    I guess I'll share my code based off this example too. I've got most of the basic physics down and a lot of comments to explain what I've learned.

    -- Make sure to enable Craft in the dependency settings
    function setup()  
      -- for fps function
      frame = 0
      etime = 0 
      parameter.watch("fps")
    
      -- positions in space
      cubexyz = vec3(0,5,0)
      platformxyz = vec3(0,-5,0)
    
      -- init two entities, cube and platform
      cube = craft.entity()
      platform = craft.entity()
    
      -- Create a basic unit cube mesh
      local cubeMesh = craft.mesh.cube(vec3(1,1,1))
      local platformMesh = craft.mesh.cube(vec3(8,1,8))
    
      -- Add the renderer component, which will actually draw our mesh
      renderer = cube:add(craft.renderer, cubeMesh)
      renderer2 = platform:add(craft.renderer, platformMesh)
    
      -- move cubes to certain positions and rotate the cube a bit
      cube.y = cubexyz.y
      platform.y = platformxyz.y
      local r = 45
      cube.rotation = quat.eulerAngles(r,r,r)
    
      -- add physics collision bodies
      cubep = cube:add(craft.rigidbody, DYNAMIC, 0.5)
      platform:add(craft.rigidbody, STATIC)
    
      -- give a shape to the collision area
      -- for box, first argument is shape, second is dimentions of the bounding box, and third is the offset from your mesh
      cube:add(craft.shape.box, vec3(1,1,1), vec3(0,0,0))
      platform:add(craft.shape.box, vec3(8,1,8), vec3(0,0,0))
    
      -- Apply a material to the cube
      renderer.material = craft.material("Materials:Standard")
      renderer2.material = craft.material("Materials:Standard")
    
      -- Use renderer.material.map to apply a texture
      renderer.material.map = "Blocks:Greystone"
      renderer2.material.map = "Blocks:Wood Red"
    
      -- bounciness doesn't seem to work yet
      cubep.restitution = 50
    
      -- Move the camera forwards and rotate 180 degrees
      craft.scene.camera.position = vec3(0,0,15)
      craft.scene.camera.rotation = quat.eulerAngles(0,0,180)
    end
    
    function update()
      -- I think this is called every time the physics engine updates
        fpsEval()
    end
    
    function fpsEval()
        -- just counting fps
        frame = frame + 1
        etime = etime + DeltaTime
        fps = math.floor(frame/etime+.5)
    end
    
    function draw()
        -- Nothing happening here D:
    end
    
    function touched(touch)
        if touch.state == BEGAN then
            -- wake up cube every time a touch registers
            cubep.awake = true
            if touch.x > WIDTH/3*2 then
                -- apply force to cube (up and right)
                cubep:applyForce(vec3(75,75,0))
            elseif touch.x < WIDTH/3 then
                -- apply force to cube (up and left)
                cubep:applyForce(vec3(-75,75,0))
            else
                -- apply force to cube (up)
                cubep:applyForce(vec3(0,75,0))
            end
        end
    end
    
  • dave1707dave1707 Mod
    Posts: 7,907

    @Attila717 Nice job. You're getting good experience with your coding.

  • Posts: 71

    @dave1707 Thanks! I'm always trying to improve

  • JohnJohn Admin Mod
    Posts: 583

    Hey everyone

    I'm currently working on the manual for Craft. The current work-in-progress version can be found here:

    https://twolivesleft.com/CodeaCraft/Manual

  • edited April 2017 Posts: 71

    @John The manual is looking great so far! Do you think you could elaborate a bit more on the inner workings of the Generate Terrain tab? It'd be nice to know more about how the split, warp, and hills functions work.

    Also, I nocticed a thin line of transparency between blocks in the Block Library, Voxel Player, and Voxel Terrain projects. Is that a bug? A feature? Something that could be turned off?

  • Posts: 71

    Still playing with physics...

    @Simeon @John Is it possible to assign an icosphere mesh collision shape

    sphere:add(craft.shape.mesh, craft.mesh.icoSphere(1,1))
    

    to an icosphere with a rigidbody and still let it rotate on its axis(s) like if I assigned it a sphere collision shape

    sphere:add(craft.shape.sphere, 1, vec3(0,0,0))
    

    ?

  • Posts: 455

    I noticed the word "quaternion" fly by in Codea Craft. I'm going to be exploring that to see how much it can replace my old code.

    Just in case it's of any interest, my Quaternion write-up is now at:

    http://loopspace.mathforge.org/HowDidIDoThat/Codea/Quaternions/

  • dave1707dave1707 Mod
    Posts: 7,907

    @LoopSpace I just did a quick pass of your writeup, looks interesting. I'll have to spend more time reading it later on.

  • Posts: 455

    @dave1707 Any comments for making it clearer would be gratefully received.

    @John, I notice that there aren't many methods available for quat. I have quite an extensive quaternion library for Codea on github (written as an extension of the native vec4). Feel free to steal ideas. As a start, I think that quat() with no arguments should return the quaternion 1 + 0i + 0j + 0k as that corresponds to the identity rotation.

  • edited April 2017 Posts: 71

    @John @Simeon I've found a bug, probably in the 3d physics engine, that crashes Codea. When I run the Planet 3D project with only a minor change and then refresh a number of times, Codea crashes. I've been able to recreate this bug three times so I'm pretty sure it's not a fluke.

    (The change was that I uncommented these two lines:

    pivot:add(craft.rigidbody, DYNAMIC)
    pivot:add(craft.shape.box, bs, vec3(0, bs.y * 0.5, 0))
    

    )

  • JohnJohn Admin Mod
    Posts: 583
    Thanks @Attila717 I have a physics bug fix in the pipeline, hopefully it will address this exact issue:

    @LoopSpace I will have a look at your library. Defaulting to the identity is probably a good idea, cheers!
  • Posts: 71

    @John Thanks for looking at the bug. I'm still wondering wether the mesh shape can roll and react to being hit like the box and sphere shapes do. When I tried using the mesh shape, it collided well, but stayed frozen in the same rotation. Is this a bug?

  • JohnJohn Admin Mod
    Posts: 583

    @Attila717 mesh shapes should only be used with kinematic or static rigidbodies (this is a bullet limitation).

    There is a thing called btGImpactMeshShape which could work for dynamic bodies so I might look into that.

    I'm also going to add shape.hull which would allow for optimised dynamic mesh shapes that are convex.

  • Posts: 71

    @John Ah, ok. That makes more sense now. Looking forward to that shape.hull!

  • Posts: 237

    @John Will there be an example on how to use the environments that are offered. Also, an example of how to use the blocky characters would be great. Every single time I use codea craft, I experience a joy that some would call me a nerd for (They already do). What I'm trying to say is great job! Can't wait to see the final result.

  • edited May 2017 Posts: 71

    @CamelCoder John's working on a manual for Codea Craft currently. His work in progress draft is here: https://twolivesleft.com/CodeaCraft/Manual

  • Posts: 71

    @CamelCoder Here's an example that uses the character mesh and texture. It's just an image wrapped around an obj, so you'd have to do some thinking to get it to move its different extremities individually, but this shows you how to at least put it on the screen.

    -- B
    
    -- Use this function to perform your initial setup
    function setup()
        -- Light Intensity? Maybe? Color? Maybe?
        craft.scene.sun:get(craft.light).color = vec3(1, 1, 1)
        -- Create an entity
        cube = craft.entity()
        -- Create a unit cube mesh
        cubeMesh = craft.mesh("Blocky Characters:Character")
        -- Add a renderer component to the entity (this will actually draw the cube)
        renderer = cube:add(craft.renderer, cubeMesh)
        -- Set a material on the renderer (this determines the appearance of the surface)
        renderer.material = craft.material("Materials:Standard")
        -- Set the map image for the material (the surface texture)
        renderer.material.map = readImage("Blocky Characters:Skin Adventurer")
    
        -- Create some parameters to modify the material appearance
        parameter.color("AmbientColor", color(50,50,50))
        parameter.color("Diffuse", color(255,255,255))
        parameter.color("Emissive", color(0,0,0))
    
        --Orbit around 0,10,0 zoomed out by 20
        viewer = craft.scene.camera:add(OrbitViewer, vec3(0,10,0), 20)
    end
    
    function update()
    end
    
    -- This function gets called once every frame
    function draw()
    
    end
    
    
  • Posts: 414

    looks amazing @Simeon , @John congratulations!

    i tried the new camera recording of the screen-very happy to see it now records the sound as well. There are some minor bugs though-the time counter does not increase, also when i cancel the recording it exits the running of the program and puts me back to the editor.

  • Posts: 71

    @John I saw in the work in progress manual that you can assign an entity a parent. I tried it out in my own code and it worked visually, however I couldn't get the child entity to work as a dynamic physics object. It just followed the parent entity and ghosted through any other physics objects it was meant to collide with. How could I fix this so that the child object would collide just like the parent object, but still have the parent-child relationship?

  • Posts: 1,384

    Hi @Simeon,

    I know this is not a specific feature of 74/75 but I thought I'd raise the issue. I generated a Project using :


    createProject("App_Buttons:But001")

    Then I tried to make a duplicate of the file in that Project, Codea allowed me to make one but not in the Project - it created a copy in the general section of the files i.e.. But001 Copy.

    I see the copying of files within the Project as the best way to control files, the alternative is to create a new Project file then manually copy each tab. Is there a better way?

    If not any chance of duplicating Project files within the Project in a future upgrade?

  • JohnJohn Admin Mod
    Posts: 583

    @piinthesky Yeah that's a known issue that we are currently working on.
    @Attila717 That's a bug, you should be able to do do that, will fix.

  • SimeonSimeon Admin Mod
    Posts: 5,054

    @Bri_G yeah that custom project collection syntax ("App_Buttons") is not going to be supported properly until we have UI support in place in Codea (soon).

  • Posts: 175

    @Simeon @John Fantastic work, Codea Craft is truly impressive! I haven't had much chance to try out a larger project yet but just trying out some small things has still been very enjoyable.

    I've found a minor bug when running the Block library and Voxel player examples. I'm only posting it because it seems that the examples have worked as expected for others excluding some crashing in the Voxel terain example.

    The problem is that the player entity starts off in a position where it falls past the terrain instead of onto it. A quick fix for both examples is replace the creation of player with the following so that it lands on the terrain.

    player = craft.entity():add(BasicPlayer, craft.camera.main, 10, 20, 10)
    
    image.jpg 131.9K
  • JohnJohn Admin Mod
    Posts: 583

    @XanDDemoX

    This is probably due to voxel generation lagging behind the physics temporarily (so you end up falling faster than the ground appears). I'll look into some better solutions than just spawning the player higher.

Sign In or Register to comment.