Howdy, Stranger!

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

Prototyping floor plans using slider UI system?

edited July 13 in Questions Posts: 46

So to not confuse you guys with what I am trying to say. I am linking a video for a app on ios called Home Design 3D by anuman

Can we create a sliders UI system in the inspector window and use these sliders to transform basic shapes? rectangles, circles, and even have the ability to move them in x,y,z grid.

I would like to use this to create simple home floor plans at first A floor, some walls - done!
Once I get enough practice with the code, I can eventually do something better add some more intricate shapes.

I keep reading in here that Codea was meant to be used as a prototyping engine. What I am saying above in my mind is prototyping - so Codea should be able to do it?

Maybe not as deep as the video link, but on a simpler level?

please advise. thank you.

Comments

  • SimeonSimeon Admin Mod
    Posts: 5,054

    Yes you can use parameter.number("Name", min, max, callback) to create a named parameter slider. Then you can just reference the global variable Name in your code to use the value of the parameter (or write your code in the callback function.

  • dave1707dave1707 Mod
    edited July 15 Posts: 7,872

    @tactfulgamer Here's a simple example of moving things around using the sliders.

    PS. There's going to be a lot more code to do what your video does.

    function setup()
        parameter.integer("c1x",-50,50,0)
        parameter.integer("c1z",-50,50,0)
        parameter.integer("c2x",-50,50,20)
        parameter.integer("c2z",-50,50,20)
        parameter.integer("p1x",-45,45,20)
        assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")
        scene = craft.scene()
        v=scene.camera:add(OrbitViewer, vec3(0,0,0), 200, 0, 600)
        v.rx,v.ry=20,20
        createFloor()
        createWall1()
        createWall2()
        createRect1()
        createRect2()
        createPic1()
        print("Slide print window down")
    end
    
    function draw()
        update(DeltaTime)
        scene:draw()    
    end
    
    function update(dt)
        scene:update(dt)
        c1.position=vec3(c1x,0,c1z)
        c2.position=vec3(c2x,0,c2z)
        p1.position=vec3(p1x,15,49)
    end
    
    function createFloor() 
        f1=scene:entity()
        f1.position=vec3(0,-5,0)
        f1.model = craft.model.cube(vec3(100,1,100))
        f1.material = craft.material("Materials:Standard")
        f1.material.map = readImage("Blocks:Wood Red")
    end
    
    function createWall1() 
        f1=scene:entity()
        f1.position=vec3(50,10,0)
        f1.model = craft.model.cube(vec3(1,30,100))
        f1.material = craft.material("Materials:Standard")
        f1.material.map = readImage("Blocks:Trunk White Side")
    end
    
    function createWall2() 
        f1=scene:entity()
        f1.position=vec3(0,10,50)
        f1.model = craft.model.cube(vec3(100,30,1))
        f1.material = craft.material("Materials:Standard")
        f1.material.map = readImage("Blocks:Dirt")
    end
    
    function createRect1() 
        c1=scene:entity()
        c1.position=vec3(0,0,0)
        c1.model = craft.model.cube(vec3(10,10,10))
        c1.material = craft.material("Materials:Standard")
        c1.material.map = readImage("Blocks:Trunk White Top")
    end
    
    function createRect2() 
        c2=scene:entity()
        c2.position=vec3(30,0,30)
        c2.model = craft.model.cube(vec3(10,10,10))
        c2.material = craft.material("Materials:Standard")
        c2.material.map = readImage("Blocks:Fence Stone")
    end
    
    function createPic1() 
        p1=scene:entity()
        p1.position=vec3(10,15,49)
        p1.model = craft.model.cube(vec3(8,12,1))
        p1.material = craft.material("Materials:Standard")
        p1.material.map = readImage("Blocks:Error")
    end
    
  • Posts: 46

    @Simeon thank you.

    @dave1707 As always, bringing the recipes to the kitchen so us new chefs learn to cook. Thanks man!

Sign In or Register to comment.