Slide 32
Slide 32 text
Let’s now build our sheep
// Create the Anchor.
val anchorNode = AnchorNode(hitResult.createAnchor())
anchorNode.setParent(arFragment!!.arSceneView.scene)
sheepNode = SheepNode(this).apply {
setParent(anchorNode)
}
val legPositions = arrayOf(
Vector3(-0.1f, 0f, 0.1f), Vector3(0.1f, 0f, 0.1f),
Vector3(-0.1f, 0f, -0.1f), Vector3(0.1f, 0f, -0.1f)
)
val legRenderables = arrayOf(
sheepRightBackLeg, sheepRightFrontLeg,
sheepLeftBackLeg, sheepLeftFrontLeg
)
legPositions.forEachIndexed { index, legPosition ->
Node().apply {
renderable = legRenderables[index]
localPosition = legPosition
setParent(sheepNode)
}
}
Here is a code sample to add the 4 legs of our sheep