Howdy, Stranger!

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

Codea 3.0 (106)

124

Comments

  • Posts: 1,724

    @pIinthesky - Couldn't load up files using Craft loader but I managed to get the Eiffel tower loaded in the @ignatz loader displayed in white. The NodeV7 wouldn't load in either and was failing in @ignatz loader due to an error in the object parser where it was trying to set the vertex colour.

    Hope that helps.

  • dave1707dave1707 Mod
    Posts: 8,396

    @Bri_G As for the dependencies, I think only projects that have more than 1 tab show up in the list. Is the project SpriteBatch just one tab. If so, put the usual functions in Main, and the functions you want to use as dependencies in another tab.

  • Posts: 1,724

    @dave1707 - thanks for that. Already pasted Spritebatch into another tab and works fine. Spritebatch is a Class in a single sheet, no other code - so no main etc.

    My interest was Partly to learn a little bit more about dependencies.

  • Posts: 534
    @Bri_G thanks for your feedback. It would be good if Codea could handle a missing or incorrect .mtl file.
  • Posts: 1,724

    @pIinthesky - yeah, it should have a default white texture in case of error with mtl files. Like the view of models in the Documents folder and many obj editors.

  • Posts: 1,724

    @pIinthesky - another thought, I think @John once commented that the current obj model loader wouldn’t load multiple part models. Your nodeV7.obj is a very sophisticated model. I haven’t checked the file could it contain several model sections?

  • Posts: 534

    @john @simeon i investigated a bit more the strange scaling effects in AR that i mentioned previously. It can be reproduced using the craft AR example with the following changes:
    in setup() add:
    sceneScale=scene:entity()
    sceneScale.scale=vec3(1,1,1)*0.2

    then in cube() add:
    cube.parent=sceneScale

    for small scaling it behaves strangely; the cubes become 3d rectangles or worse!

  • Posts: 534

    @John just to remind you about the 3D models and the AR scaling issues :)

  • Posts: 534

    @John , @Simeon , anybody!
    when i use applytorque on a craft.shape.box it seems to work i.e. i can make it rotate. it seems the rotation depends on the dimension of the box-is that correct?

    when i use applytorque on a craft.shape.model, i see no effect; it does not rotate?

  • dave1707dave1707 Mod
    Posts: 8,396

    @piinthesky Could you provide a simple box example showing what problem you’re having. It’s easier if I have your example then trying to create one that I think is like yours to try and work with.

  • SimeonSimeon Admin Mod
    Posts: 5,364

    @piinthesky definitely sounds like an issue @john could look into. I'll ask him

  • dave1707dave1707 Mod
    Posts: 8,396

    @Simeon I don’t know if this has been mentioned or when it started, but here’s something I ran across with listProjectTabs(). If I create project test1 that uses listProjectTabs(), it will list the correct tabs as I create or delete them when I run the current project. If I create another project test2 that uses listProjectTabs(“test1”), it won’t list the correct tabs in project test1 until I close Codea and reopen it. If project test1 has 5 tabs and project test2 shows them correctly, then if I delete all the tabs in project test1 except Main and run project test2, it will still show the 5 tabs in project test1. If I close Codea and reopen it and run project test2, it will then show only tab Main in project test1.

  • Posts: 534

    @John @dave1707 here is a simple test program that shows that applyTorque does not seem to work when craft.shape.model is used. It does work with craft.shape.box. Tap the screen to apply additional torque, this causes node1 (box in red) to rotate, but not node2 (model in green).


    -- test torque function setup() -- Create a new craft scene scene = craft.scene() scene.physics.gravity=vec3(0,0,0) --no gravity -- Create 1st entity node1=scene:entity() node1:add(craft.renderer) node1.model=craft.model("SpaceKit:meteorFullRound") node1.scale=vec3(1,1,1) node1.material = craft.material("Materials:Specular") node1.material.diffuse=color(199, 33, 33, 255) node1.position=vec3(20,0,100) node1Rigid=node1:add(craft.rigidbody,DYNAMIC,10) node1Rigid.sleepingAllowed=false node1:add(craft.shape.box, vec3(1,1,1), vec3(0,0,0) ) --shape is a box. this works --create 2nd entity (same as the first) node2=scene:entity() node2:add(craft.renderer) node2.model=craft.model("SpaceKit:meteorFullRound") node2.scale=vec3(1,1,1) node2.material = craft.material("Materials:Specular") node2.material.diffuse=color(33, 199, 61, 255) node2.position=vec3(-20,0,100) node2Rigid=node2:add(craft.rigidbody,DYNAMIC,10) node2Rigid.sleepingAllowed=false node2:add(craft.shape.model, node2.model ) --shape is the model. does not work? -- node1Rigid.angularDamping=0.2 -- node2Rigid.angularDamping=0.2 viewer = scene.camera:add(OrbitViewer, vec3(), 0, 0, 0) end function update(dt) -- Update the scene (physics, transforms etc) scene:update(dt) end -- Called automatically by codea function draw() update(DeltaTime) -- Draw the scene scene:draw() end function touched(touch) if touch.state==ENDED then node1Rigid:applyTorque(vec3(0,10,0) ) node2Rigid:applyTorque(vec3(0,10,0) ) end end
  • dave1707dave1707 Mod
    edited May 2018 Posts: 8,396

    @piinthesky Thanks for the demo. Apparently applyTorque doesn’t work, but angularVelocity does. Maybe that can be used until the applyTorque is fixed.

            node2Rigid:applyTorque(vec3(0,10,0))   
            node2Rigid.angularVelocity=vec3(0,10,0)
    
  • JohnJohn Admin Mod
    Posts: 616

    Hi @piinthesky! I'll be going through some of the reported issues shortly.

    As for craft.shape.model, this does not work for dynamic bodies as bullet does not calculate the moment of inertia and collisions don't generally work very well. What you want is an approximation of the model's shape using primitive shapes, such as capsules, boxes and spheres. Right now craft doesn't support compound shapes for physics, but this is something I'm working on.

  • Posts: 534
    @John ok, yes calculating the MoI of an arbitrary body could be tricky!
  • Posts: 534

    @John i guess i should abandon hope of improvement in the .obj model loading in the near future-you must have other priorities at the moment.

  • JohnJohn Admin Mod
    Posts: 616

    Hi @piinthesky, it's true that there are many competing priorities for Codea given the sheer number of features and 3.0 being universal.

    That said I've been considering the issues with 3D asset importing and the problems with the OBJ format in general. I'm currently integrating an open source import/export system called Asset Importer which will support more formats, features and hopefully fix the current issues we're having.

    This will enable the following formats to be loaded:

    3D, 3DS, 3MF, AC, AC3D, ACC, AMJ, ASE, ASK, 
    B3D, BLEND, BVH, CMS, COB, DAE/Collada, 
    DXF, ENFF, FBX, glTF 1.0 + GLB, glTF 2.0, HMB, 
    IFC-STEP, IRR / IRRMESH, LWO, LWS, LXO, MD2, 
    MD3, MD5, MDC, MDL, MESH / MESH.XML, MOT, 
    MS3D, NDO, NFF, OBJ, OFF, OGEX, PLY, PMX, PRJ, 
    Q3O, Q3S, RAW, SCN, SIB, SMD, STP, STL, TER, UC, 
    VTA, X, X3D, XGL, ZGL
    

    I tried some examples you sent me that currently do not work and this system is working a bit better. I've attached a screenshot showing these models. The actual issue with them wasn't missing materials or the loader itself but rather a built-in limit of 64k vertices, which was being exceeded. For now I've increased the limit to 4 billion vertices although it may result in worse performance. This is something I'll be looking into.

    IMG_0021.PNG 583.4K
  • Posts: 534

    @John, ahha i thought it might be due to the models being too big.

    The new import system sounds great. Being able to directly load .stl files will improve my workflow considerably; at the moment i have to convert my .stl files to .obj in Blender on the mac.

    Any chance you could release a testflight version with the 4 billion vertices limit? It would allow me to continue developing my neutrino telescope app- i am a bit stuck at the moment.

  • JohnJohn Admin Mod
    Posts: 616

    Hi @piinthesky, sure. I can probably get something out by tomorrow. I'm just working out what formats will be available as including all of them will bloat the app significantly.

  • AnatolyAnatoly Mod
    Posts: 889

    @simeon what about actually adding more language types, first we had Lua, now OpenGL, what would be very good is to have HTML formatting for e.g. for text() maybe something like text.html() which would actually be easier for much things!!

  • edited June 2018 Posts: 1,724
    Hi @John, not sure on the size of the models I thought they could be bigger than 64 vertices.

    Few ideas:

    1. How about sticking to two or three model types and releasing a compiled open converter based on the Asset Porter - look at their github post.

    2. Can we build models with the @Ignatz code and import them to Craft as a craft.entity().

    3. Just supply specialised code as dependency for loading bigger models.

    Why overload Codea with massive code for this?
  • edited June 2018 Posts: 1,724
    @John - , new idea, may not be best practice but could you change the current code to change the size of the vertices table to 64 but addressable as a global so that @piinthesky can adust for his needs?
  • dave1707dave1707 Mod
    Posts: 8,396

    I hope Codea isn’t going to be bloated just to add things that a few people might use. Maybe there can be addons or someway only the ones that want something can add it. As an example, Facebook on my iPad 1 is 78MB and works just fine for what I need. On my iPad Air, it’s 324 MB. So there’s 250 MB of code that I probably don’t need, but I have to download more and more code just to keep an updated version. The same goes for all the other apps that keep adding more useless code just so they can say they have a better version of code.

  • edited June 2018 Posts: 1,724
    @John, expanding/clarifying on the first suggestion above.

    What I was suggesting was incorporation of say the three most popular object model loaders into Codea.

    Then produce a free compiled model converter app which Codea users could download to use - could be iOS, Windows, Linux or MacOS or all formats. This from the model converter based on the open source model loader you mentioned - Asset importer.

    Edit: I:ve since learned that Asset Importer can now convert and export models. Do you know how to compile this?
  • Posts: 534

    @Bri_G the vertices limit john mentioned was 64,000 not 64. At least for me 64k is not enough. I agree that 3-4 of the most popular formats (.obj, .stl, ...) would suffice. i don’t think it is necessary to provide a format converter; many free web converters already exist. By the way, Apple just introduced a new format (USDZ) for augmented reality models!

  • Posts: 1,724
    @piinthesky - oops missed the k, thought 64 was way low. Still think the option to reset the limit locally is the best option with a few model file types.

    Not keen on using web converters for anything prefer locally installed apps, looking into Asset importer now.
  • JohnJohn Admin Mod
    Posts: 616

    @piinthesky 3.0 (105) has been submitted for beta review. Let me know if it solves your issues with model loading.

  • Posts: 69
    @John whats new in 3.0 (105)?
  • JohnJohn Admin Mod
    Posts: 616

    @GR00G0 This is just a minor update with improved support for model loading. You can now load the following formats: OBJ, FBX, STL and BLEND. This is experimental and may be somewhat buggy.

  • Posts: 505
    @John I‘ve tested latest update on iphone 6 plus and there there are some minor issues with the ui.

    there is no way to close the keyboard.

    when code is smaller than visible editor area, the tabs sometimes get scrolled out of view and can not be scrolled down anymore.

    docs cant be closed. it would be nice if it worked like project view, where swyping left/right opens or dismisses a shelf.
  • Posts: 1,724

    @John just installed together with iOS 11.4. No issues so far but I have only been using obj files.

  • Posts: 534

    @John many thanks for the update. I am now able to load my eiffel tower and the node objects using the .obj format. The eiffel tower image was not visible in the asset picker, but worked nevertheless. i also tried a .stl version of the eiffel tower and that worked, although again no image in the picker. I also tried a .blend version but that seemed to crash Codea when scrolling the asset picker.

  • JohnJohn Admin Mod
    Posts: 616

    @piinthesky Good to hear. The blend issue is most likely due to the preview generator using Apple's built-in model loading and rendering.

  • edited June 2018 Posts: 1,724

    @Simeon, @John - noticed something on the asset packs. I loaded a lot of sound effects into a new asset pack, one of them was music but the rest were sound effects. It put them all into a music category. So I proceeded to delete them in groups, when I used Edit > select the first few used a green tick image on the far right of each music entry, then it began to use a dark grey background to each chosen entry. On pressing delete all selected were deleted, so no issue - just confusing.

    Also I downloaded from Dropbox the files had all been labelled as music, when I used Fileapp the files went into the sound section. Note, one of the files was actually called music.

    Another funny when downloading from Dropbox the white dialogue box came up with a downloading message, but flicked to a different size as the file changed - odd but not an issue.

    Never used sounds before 3.0(105) and iOS 11.4 so this may may have been there/reported before.

    Note: I was transferring about 200 files in groups!!

  • Posts: 1,724

    @John - another funny that I picked up on, probably me not understanding but - I edited a copy of the info.plist from your examples, after changing the Author and Name entries to my own. I then placed that in the assets folder I was setting up - planning to edit it as and when I added assets into the folder. I then proceeded to add assets by sharing from Dropbox and then ran Codea.

    To my surprise all the sprites were visible in the assets file manager, but when I checked the info.plist the new additions were not listed.

    Questions:

    1. Is there a non-visible system file which Codea uses/edits directly to reflect the contents of the asset pack?
    2. Does the system just need a skeleton info.plist present in the assets folder to display all the assets?
    3. Do I still need to edit the info.plist to reflect the assets I have added?
  • Posts: 1,724

    @John - just out of curiosity followed your link to Assimp and it looks impressive. Noted that there is a viewer built on it, with some inbuilt conversion exports so downloaded open3mod for the pc. Installed then tried to load several models (different types) from my Dropbox. None of them would load, despite some of them running on my iPad with Ignatz loader and Craft. Curious?

    Have you tried the viewer?

  • Posts: 534

    @John in 105 it seems the ‘primitive’ objects no longer display.

  • Posts: 1,724

    @Simeon - had a few odd behaviours whilst playing around with images for the Tween demos in another thread. I had to modify an image to remove compression and rename to remove file type issues. I added the image to my Documents folder as IMG_0273.PNG, which was visible in the Documents file viewer but not accessible by code - twigged on and modified name and case but had to do that in Dropbox. Then copied back to Codea Dropbox by syncing. Then found my Dropbox folder had disappeared from my Assets list - later returned after closing and restarting Codea but syncing gave the problem - I was using the sync in the dialogue obtained from the code link.

    Shutting down my Pad and restarting seemed to resolve this. If it reoccurs I’ll have to re-install.

    The system file viewer shows files present in the file viewer, but won’t load unless they are in the correct case. Can we get round this by always forcing the file type, in the code to read it, to lower case when the code is run?

  • edited June 2018 Posts: 1,724
    @John - just reading your comments above with regard to model loading reply to @piinthesky. You mention Apples 'built-in model loading and rendering'. Do Apple provide access to their routines? Codea must link into many of the routines to comply with iOS operations/standards. By the way most of my models now load with 105.
  • Posts: 534

    I would like to use the OrbitViewer in different scenes, but have not been successful. It seems the touches handler get confused?

    If one replaces the main tab in the Cameras demo program with the following, you can duplicate my problem. Any ideas anyone?

    -- Cameras
    
    -- Use this function to perform your initial setup
    function setup()
        print("Hello Cameras! in multiple scenes")
    
        scene={}
        model={}
    
        scene[1] = craft.scene()
        local m = craft.model("CastleKit:knightBlue")
        model[1]= scene[1]:entity()
        model[1]:add(craft.renderer, m)    
        scene[1].camera:add(OrbitViewer, vec3(0,5,0), 5, 10, 20)
     --   scene[1].camera:add(FirstPersonViewer)
    
        scene[2] = craft.scene()
        local m = craft.model("CastleKit:knightRed")
        model[2]= scene[2]:entity()
        model[2]:add(craft.renderer, m)    
        scene[2].camera:add(OrbitViewer, vec3(0,5,0), 5, 10, 20)
    --    scene[2].camera:add(FirstPersonViewer)
    
        parameter.integer("currentScene", 1,2,1)
    end
    
    function update(dt)
        scene[currentScene]:update(dt)
    end
    
    -- This function gets called once every frame
    function draw()
        update(DeltaTime)
        scene[currentScene]:draw()
        text("scene "..currentScene,WIDTH/2,HEIGHT*0.9)
    end
    
  • dave1707dave1707 Mod
    edited June 2018 Posts: 8,396

    @piinthesky Since the OrbitViewer uses the normal touched function, one thing you can do is rename the touched function used by OrbitViewer. Then in the normal touched function, you can do whatever touches you want. You then check the touched function for what you want else you call the renamed function for OrbitVewer passing the touched info. I’ve done that so I know it works.

    PS. The touch function is in the touches tab of the touches example. If you make changes, then the other craft examples won’t work unless you fix them.

  • Posts: 534

    @dave1707 @John i thought the point of having a touch handler is that we don’t have to worry about this. Each instance of orbitviewer should handle its own touches no?

  • dave1707dave1707 Mod
    Posts: 8,396

    @piinthesky There can be only one touch function or else things will get confusing. The touches function used by Craft should have been named to something else, but I guess @John was in a hurry to get the Craft examples done so they could release Craft. If you want, you can copy the TouchHandler class and the OrbitViewer class into your code and rename the touched function in the TouchHandler without affecting the Craft examples.

  • Posts: 534

    its seems in the touches handler that once a touch is ‘captured’ by a registered handler it is not passed to other handlers. As the scene1 handler is declared first the touches are always captured and therefore the scene2 never sees the touches. I copied the touch handler to my app and modified it too allow all touches to go to all handlers then it works.

  • dave1707dave1707 Mod
    Posts: 8,396

    @piinthesky I never got too involved with the touches after I modified it. I just wanted to see if it would work after I renamed the TouchHandler touched function. Maybe you could post what changes you made so someone else could see what to do if they want to seperate touches and the OrbitViewer.

  • JohnJohn Admin Mod
    Posts: 616

    Hey @piinthesky, @dave1707

    The idea of the TouchHandler stuff is that you stop using the touched() function all together and register classes that you want to get touches. It then redirects those touch events to each of your classes. The reason I made this was to have the ability for individual objects to get events when they need to and capture touches for the duration of their interaction. It doesn't really play nicely with the standard touch functionality. You can modify it so that it doesn't replace the existing touched function and call it manually if you want.

    The way it works is touches.addHandler(handler, priority, multitouch = false). handler is assumed to be a class with a touched method. Priority is in ascending order, so the handler with the lower value gets the first shot at capturing a touch. Each touched method must return true if it wants to capture a touch when it receives a BEGAN event. This is where you typically check to see if you want the touch (if it's in the right area usually). If it doesn't then it wont see that touch again. There is a share function to allow touches to be passed between objects (the best example is the navigation buttons in the voxel character controls).

    That said I'm open to suggestions on how to improve this or better alternatives.

  • edited June 2018 Posts: 534

    yes, i had rough idea that was how it works. In my case the orbitviewer touch handler in scene1 interfered with an orbitviewer handler in scene2! I guess either the handler would need to ignore handlers not in the current scene or have an option that the touch is passed to all handlers and never trapped (my hack) or as you suggest the use the share function.

    By the way did you notice my previous post that the ‘primitive’ objects are screwed in version 105?

    Also noticed some weird things with scaling in AR (see earlier post).

  • JohnJohn Admin Mod
    Posts: 616

    @piinthesky If you are using them one after the other you'd probably need to call touches.removeHandler(viewer) to disable the one you don't want to be active. I'll think about how to make this a bit easier (like just disabling or destroying a viewer should turn off the touch handler).

    I'll look into the primitives not working. I still need to test the scaling issue with AR.

  • dave1707dave1707 Mod
    edited June 2018 Posts: 8,396

    @John You have a bug in the touches.removeHandler(target) function. Below is the function you have in touches. If it’s called and target isn’t found in the touches.handlers table, then the variable i remains nil. According to the documentation, the function table.remove(table,pos) will delete the last entry in table if pos isn’t given or is nil. So if target is invalid or was already removed, the last entry in the touches.handler table will be removed in error.

    EDIT: I was playing around with a Craft program where I added 2 different classes for buttons to the touch handler. The buttons worked OK and so did the Craft rotations. The buttons didn’t work at first until I gave them negative priorities. After checking, I see that Craft has a 0 priority and the lowest number gets first response to screen touches.

    function touches.removeHandler(target)
        local i = nil
    
        for k,v in pairs(touches.handlers) do
            if v.target == target then
                i = k
            end
        end
    
        table.remove(touches.handlers, i)
    end
    
Sign In or Register to comment.