0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

windows11で、sketchup6 その57

Posted at

概要

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

練習問題

rubyスクリプトでカメラを動かせ。

写真

image.png

サンプルコード

def camera_vp_targ
	model = Sketchup.active_model
	view = model.active_view
	camera = view.camera
	eye = camera.eye
	vx = eye.x
	vy = eye.y
	vz = eye.z
	target = camera.target
	tx = target.x
	ty = target.y
	tz = target.z
	vfovdeg = camera.fov
	w = Float(view.vpwidth)
	h = Float(view.vpheight)
	vfovrad = vfovdeg * Math::PI / 180.0
	f = (h / 2) / Math.tan(vfovrad / 2.0)
	hfovrad = 2.0 * Math.atan2((w / 2), f)
	hfovdeg = hfovrad * 180.0 / Math::PI
	prompts = ["Position X", "Position Y", "Position Z", "Target X", "Target Y", "Target Z", "angle focal"]
	values = [vx, vy, vz, tx, ty, tz, hfovdeg]
	results = inputbox prompts, values, "Point de vue Camera / Mire"
	vx, vy, vz, tx, ty, tz, hfovdeg = results
	eye.x = vx 
	eye.y = vy 
	eye.z = vz 
	target.x = tx
	target.y = ty
	target.z = tz
	up = camera.up
	up.set!(0.0, 0.0, 1.0)
	camera.set eye, target, up
	hfovrad = hfovdeg * Math::PI / 180.0
	f = (w / 2) / Math.tan(hfovrad / 2.0)
	vfovrad = 2.0 * Math.atan2((h / 2), f)
	vfovdeg = vfovrad * 180.0 / Math::PI
	camera.fov = vfovdeg
end 

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?