Import 3D object for asset?

OK, I give up. The internet doesn’t know how to import a 3D file into Codea, or at least I can’t find it.

Suppose I had a robot like Kenny Li’s in some 3D system. Blender, to be specific. I’ve seen hints that Codea can understand blend files, obj files, stl files. But what file formats does it understand, and given that I had one of those in my Dropbox or Documents, what do I do to make it available in Assets, or at least to get it into my program.

Thanks!

@RonJeffries I used this to show a 3D object created with 3DC.io . I just exported the object from 3DC to Dropbox and sync it with Codea. I don’t know if this is kind of what you’re after.

displayMode(FULLSCREEN)

function setup()
    -- use a model from 3DC.io
    assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")
    scene = craft.scene()
    m = scene:entity()

    m.model = craft.model("Dropbox:export")

    m.material = craft.material("Materials:Specular")
    m.material.diffuse=color(159, 187, 222, 255)
    m.material.map = readImage("Surfaces:Basic Bricks AO")

    viewer = scene.camera:add(OrbitViewer, vec3(0), 600, 20, 2000)
    viewer.camera.farPlane=3000
end

function update(dt)
    scene:update(dt)
end

function draw()
    update(DeltaTime)
    scene:draw()    
end

Discovery! I DL’d uMake, which seems like an amazingly cool 3D editor for iPad. (Subscription, though, $100 a year, 16 / month). Made some odd shape, exported to obj, into my Codea folder, and loaded it into the model where the robot was. It actually worked! :smile:

So that’s nice. Not sure how to color it: I don’t think uMake can do that. Inch by inch …

Thanks, Dave, that’s roughly what I’ve done. Our notes crossed in the mail, I guess. What does the call to farPlane accomplish for you? Thanks!

@RonJeffries Sometime when you draw objects that extend far away, they disappear. Setting farPlane lets you see those objects.

Here’s an example using farPlane. All the spheres are drawn. Reducing the value of far (farPlane) reduces how far away you’re allowed to view.

function setup()
    parameter.integer("far",100,5000,5000)
    assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")        
    scene = craft.scene()
    skyMaterial=scene.sky.material
    skyMaterial.sky=color(187, 224, 221, 255)
    skyMaterial.horizon=color(209, 223, 168, 255)
    v=scene.camera:add(OrbitViewer, vec3(0,0,0), 450, 0, 1000)
    v.rx=15
    v.ry=8   
    for z=1,50 do
        createSphere(vec3(0,-100,z*100))
    end
end

function draw()
    update(DeltaTime)
    scene:draw()
    
    v.camera.farPlane=far
end

function update(dt)
    scene:update(dt)
end

function createSphere(p)
    local pt=scene:entity()
    pt.position=vec3(p.x,p.y,p.z)
    pt.model = craft.model.icosphere(3,2)
    pt.material = craft.material("Materials:Specular")
    pt.material.diffuse=color(255,0,0)
end

super, thanks … now if the ipad would just let me copy that code … :slight_smile:

Tried more of your example, Dave, and it worked (of course). Thanks!

If DropBox if linked with codea just go to Codea and hit the sync button in the cornor of the screen.

if it is not then you should get iZip you can move your files into there and then with the “files” app you can hold down the file you want and move it to codea and put it in the dropbox folder.

that is how with itunes I move my 3d files from my pc to my ipad.

@RonJeffries “super, thanks … now if the ipad would just let me copy that code”

Are you having an issue with long press on a word which brings up the select box - drag to cover the text you want to copy then tap copy?

@West Yes, I am finding long press flaky, and of course at best it’s a pain to select that way. :slight_smile:

@pac Thanks for hint on assets, I’ll see if I can make that work. Am I supposed to have a specific Dropbox-Codea folder? Link to info? Thanks!

When I copy code, I long press in a blank area to the right of a line. When I lift my finger the word at the end of the line is highlighted. I drag the right circle down and the left circle up. Then copy.

Yes, that often works. I must be doing it wrong because also it often doesn’t.

Some forums have a button at the top of code blocks to copy the block. That would be sweet here.