windows11で、sketchup6 その97

# 概要
windows11に、sketchup6を入れてみた。
rubyで、3Dを書く。
練習問題やってみた。

# 練習問題
bvhファイルをパースして、初期ポーズを描画せよ。

# 写真

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/18104/344bdafc-080c-4635-9214-4c850b4ebf13.png)

# サンプルコード

```
def testbvh1
	model = Sketchup.active_model
	entities = model.active_entities
	fso = UI.openpanel "Select .bvh file", "", "*.bvh"
	return unless fso
	$bvh = BVH.new.load(File.read(fso))

	hips = entities.add_group
	circle = hips.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = hips.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	hips.transform! trans

	chest = entities.add_group
	circle = chest.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = chest.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	chest.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[1].offset
	chest.transform! trans

	neck = entities.add_group
	circle = neck.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = neck.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	neck.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[1].offset
	neck.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[2].offset
	neck.transform! trans

	head = entities.add_group
	circle = head.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = head.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	head.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[1].offset
	head.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[2].offset
	head.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[3].offset
	head.transform! trans


	leftCollar = entities.add_group
	circle = leftCollar.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = leftCollar.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	leftCollar.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[4].offset
	leftCollar.transform! trans

	leftUpArm = entities.add_group
	circle = leftUpArm.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = leftUpArm.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	leftUpArm.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[4].offset
	leftUpArm.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[5].offset
	leftUpArm.transform! trans

	leftLowArm = entities.add_group
	circle = leftLowArm.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = leftLowArm.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	leftLowArm.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[4].offset
	leftLowArm.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[5].offset
	leftLowArm.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[6].offset
	leftLowArm.transform! trans

	rightHand = entities.add_group
	circle = rightHand.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = rightHand.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	rightHand.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[4].offset
	rightHand.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[5].offset
	rightHand.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[6].offset
	rightHand.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[7].offset
	rightHand.transform! trans


	rightCollar = entities.add_group
	circle = rightCollar.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = rightCollar.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	rightCollar.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[8].offset
	rightCollar.transform! trans

	rightUpArm = entities.add_group
	circle = rightUpArm.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = rightUpArm.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	rightUpArm.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[8].offset
	rightUpArm.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[9].offset
	rightUpArm.transform! trans

	rightLowArm = entities.add_group
	circle = rightLowArm.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = rightLowArm.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	rightLowArm.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[8].offset
	rightLowArm.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[9].offset
	rightLowArm.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[10].offset
	rightLowArm.transform! trans

	rightHand = entities.add_group
	circle = rightHand.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = rightHand.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	rightHand.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[8].offset
	rightHand.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[9].offset
	rightHand.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[10].offset
	rightHand.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[11].offset
	rightHand.transform! trans


	leftUpLeg = entities.add_group
	circle = leftUpLeg.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = leftUpLeg.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	leftUpLeg.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[12].offset
	leftUpLeg.transform! trans

	leftLowLeg = entities.add_group
	circle = leftLowLeg.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = leftLowLeg.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	leftLowLeg.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[12].offset
	leftLowLeg.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[13].offset
	leftLowLeg.transform! trans

	leftFoot = entities.add_group
	circle = leftFoot.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = leftFoot.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	leftFoot.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[12].offset
	leftFoot.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[13].offset
	leftFoot.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[14].offset
	leftFoot.transform! trans

	rightUpLeg = entities.add_group
	circle = rightUpLeg.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = rightUpLeg.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	rightUpLeg.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[15].offset
	rightUpLeg.transform! trans

	rightLowLeg = entities.add_group
	circle = rightLowLeg.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = rightLowLeg.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	rightLowLeg.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[15].offset
	rightLowLeg.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[16].offset
	rightLowLeg.transform! trans

	rightFoot = entities.add_group
	circle = rightFoot.entities.add_circle [0, 0, 0], [0, 1, 0], 1, 8
	circle_face = rightFoot.entities.add_face circle
	circle_face.pushpull -3.0
	trans = Geom::Transformation.translation $bvh.joint[0].offset
	rightFoot.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[15].offset
	rightFoot.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[16].offset
	rightFoot.transform! trans
	trans = Geom::Transformation.translation $bvh.joint[17].offset
	rightFoot.transform! trans
end



```

以上。