Third person 3d

Whoa @dave1707 - that’s an excellent example of texturing a mesh, there’s a few learning points for me. I noticed the grass image @dmoeller is using is very big and you picked that up. Your pt.model is very interesting.

dmoeller, the code you posted is from @Ignatz and I have posted the error on a separate thread - I found that previously but struggled with it. I think it arose from previous updates to Codea. The example posted by @dave1707 shows you how to use the noise function in Craft.

Here’s a smaller version of my above code to create a textured terrain.

displayMode(FULLSCREEN)

function setup()
    assert(craft, "Please include Craft as a dependency")
    assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")        
    scene = craft.scene()
    skyMaterial=scene.sky.material
    skyMaterial.sky=color(137, 186, 223, 255)
    skyMaterial.horizon=color(98, 142, 229, 255)
    scene.sun.rotation=quat.eulerAngles(30,30,0)
    v=scene.camera:add(OrbitViewer,vec3(0,0,0), 1000, 0, 2000)
    v.camera.farPlane=3000
    v.rx=15
    
    texture=readImage("Dropbox:grass")  -- your grass image
    
    local size=1000
    local groundHeight=200    
    local step=.2
    h=craft.noise.perlin()
    for x=-2,2,step do
        for z=-2,2,step do           
            local y=h:getValue(x,0,z)
            local p1=vec3(x*size,y*groundHeight,z*size)
            y=h:getValue(x+step,0,z)
            local p2=vec3((x+step)*size,y*groundHeight,z*size)
            y=h:getValue(x+step,0,z+step)
            local p3=vec3((x+step)*size,y*groundHeight,(z+step)*size)
            y=h:getValue(x,0,z+step)
            local p4=vec3(x*size,y*groundHeight,(z+step)*size)
            createTile(p1,p2,p3,p4)
        end
    end
end

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

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

function createTile(p1,p2,p3,p4)
    local c=color(255)
    local pt=scene:entity()
    pt.model = craft.model()
    pt.model.positions={p1,p3,p4,p1,p2,p3}
    pt.model.indices={1,2,3,4,5,6,6,5,4,3,2,1}
    pt.model.colors={c,c,c,c,c,c}
    pt.model.uvs={vec2(0,0),vec2(1,1),vec2(0,1),vec2(0,0),vec2(1,0),vec2(1,1)}
    pt.material = craft.material("Materials:Basic")  
    pt.material.map=texture    
end

@dmoeller the error in Ignatz’s code has been resolved by Loopspace, in the AddTerrain function replace arg with {…} and in the parameter configurations there are three variables posX, posY and posZ which need flooring so replace with math.floor(posX) etc. That allowed the project to run on my iPad.

I got terrain and moving to work thanks to you and Ignatz But, I want to not be able to pass through trees and have a limit for how fast I can move, here is my code, you will need these pictures

https://gist.github.com/D-Robot-M/8d65fa447442e6092e80fdbd2e4031de

@dmoeller - got the code running, I think you need Ignatz’s original trees, I’ll see if I can find/post them. On your way forward you might continue to work through Ignatz’s code, it answers a number of issues for you:

Your initial code above

Adding trees figures etc
https://coolcodea.wordpress.com/2013/05/23/62-3d-adding-stand-alone-images-trees-animals/

Not walking intro trees
https://coolcodea.wordpress.com/2013/05/30/70-3d-how-not-to-walk-through-solid-objects/

Items 63 to 70a in Ignatz’s website.

You could also look at

His RPG maze
Items 171 to 178

His castle in 3D
Items 203 to 207

His pool game
Items 90 to 93

His tank game
Items 239 to 245

His battleship game
Items 218 to 228

His racing track game
Items 35 to 36

His spitfire vs mescherschmidt flying game
Item 141 to 149

Enough to keep you going for months if you are wanting to learn the tricks. Also he has several pdf volumes on 3D programming which are linked to on hi website. If you hit problems we’re always here.

Also remember when Ignatz wrote all of these it was based on hard detailed work with meshes. Now a lot of that is done for you with Craft, in theory that should be easier to program - you just need to appreciate the basics of 3D programming.

Greetings good friends suggestion I would like to know if there is any update and where I can get it available for download and make designs in 3d format Thanks I am attentive to any help you can give me

@3dmodels - thanks for the link to your website, a few interesting models there. Not sure how Codea can help you as there is no printing option other than capturing screens and printing images.