Writeups on Assets, Craft, AR, etc?

probably kenny assets, could be blender 3d objects in .obj .mtl format

yes. i guess i’ll need to learn how to get textures onto blender objects …

@RonJeffries This gets the shield attached to the robot, but I haven’t figured out how to turn the shield around so the white part shows.

-- Craft Entities

function setup()
    -- Create a new craft scene
    scene = craft.scene()
    scene.sky.active = false
    --createGround(-1.125)

    -- Create a new entity
    myEntity = scene:entity()

    -- Set its model for drawing
    myEntity.model = craft.model("Blocky Characters:Robot")

    -- Adjust position and scale
    myEntity.y = -1
    myEntity.z = 0
    myEntity.scale = vec3(1,1,1) / 8

    ronEntity = scene:entity()
    ronEntity.model = craft.model("CastleKit:shieldRed")
    ronEntity.x = 0
    ronEntity.y = 10
    ronEntity.z = 3
    ronEntity.scale = vec3(1,1,1)

    -- Move camera back a little
    scene.camera.z = -4
    
    ronEntity.parent=myEntity

    parameter.number("Rotate", 0, 360, 180)
end

function update(dt)
    myEntity.eulerAngles = vec3(0, Rotate, 0)
    scene:update(dt)
end

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

@RonJeffries This one I got the shield turned the right way.

PS. Made some changes for the shield size.

-- Craft Entities

function setup()
    -- Create a new craft scene
    scene = craft.scene()
    scene.sky.active = false
    --createGround(-1.125)

    -- Create a new entity
    myEntity = scene:entity()

    -- Set its model for drawing
    myEntity.model = craft.model("Blocky Characters:Robot")

    -- Adjust position and scale
    myEntity.y = -1
    myEntity.z = 0
    myEntity.scale = vec3(1,1,1) / 8

    ronEntity = scene:entity()
    ronEntity.model = craft.model("CastleKit:shieldRed")
    ronEntity.x = 0
    ronEntity.y = 7
    ronEntity.z = 3
    ronEntity.scale = vec3(3,3,.1)
    ronEntity.rotation=quat(0,1,0)

    -- Move camera back a little
    scene.camera.z = -4
    
    ronEntity.parent=myEntity

    parameter.number("Rotate", 0, 360, 180)
end

function update(dt)
    myEntity.eulerAngles = vec3(0, Rotate, 0)
    scene:update(dt)
end

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

Weird, thanks, forced an insight. All I can figure out is that somewhere in my first example, where I just set parent, the relative coordinates hid the shield, and that by the time I tried the table insert, I’d made some other change to make it appear. So … I conclude that setting parent does suffice, and I suppose if I look at the robot’s children the shield will be in there.

Today’s mission, should I choose to accept it, is going to be to try to figure out how to import an asset. I made a little object in second life and exported it. Pointers on that will be welcome, but I’ll start searching. Thanks!

@RonJeffries I added more thing to your robot. Slide the parameter window down to show all parameters.

-- Craft Entities

function setup()
    parameter.number("Rotate", 0, 360, 208)
    parameter.number("swx",-180,180,45)
    parameter.number("swy",-180,180,0)
    parameter.number("swz",-180,180,0)
    parameter.number("shx",-180,180,180)
    parameter.number("shy",-180,180,-30)
    parameter.number("shz",-180,180,30)
    
    scene = craft.scene()
    scene.sky.active = false
    
    ground = scene:entity()
    ground.model = craft.model.cube(vec3(10,.2,10))
    ground.material = craft.material("Materials:Specular")
    ground.material.map = readImage("Blocks:Dirt")
    ground.material.specular = color(0, 0, 0, 255)
    ground.material.offsetRepeat = vec4(0,0,1,1)
    ground.y = -1

    robot = scene:entity()
    robot.model = craft.model("Blocky Characters:Robot")
    robot.y = -1
    robot.z = 0
    robot.scale = vec3(1,1,1) / 8

    shield = scene:entity()
    shield.model = craft.model("CastleKit:shieldRed")
    shield.x = -3
    shield.y = 7
    shield.z = 3
    shield.scale = vec3(2.5,2.5,.1)
    
    sword = scene:entity()
    sword.model = craft.model("CastleKit:sword")
    sword.x = 3.2
    sword.y = 6
    sword.z = 1
    sword.scale = vec3(1,1,1)*1.6

    scene.camera.z = -6
    
    shield.parent=robot
    sword.parent=robot
end

function update(dt)
    robot.eulerAngles = vec3(0, Rotate, 0)
    sword.eulerAngles=vec3(swx,swy,swz)
    shield.eulerAngles=vec3(shx,shy,shz)
    scene:update(dt)
end

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

Super, I’ll check that out. Good approach, better than my usual print and fiddle. Thanks!

Two interesting things. First, when I pasted that into the Learn Camera example, it totally breaks the example: no tabs work. I’ve not looked into that yet.
Second, the z rotation of the sword confuses me. I’ll have to think about that.
Thanks!

Ah, OK, helps if you zero the others, then it’s a bit more clear what z rotation does. Interesting …