それで、全部同じ設定にしてみよう!と思っても、3Dソフトによって3DソフトによってFOVの設定方法も異なります。
FOVはこんな感じになります
------------------------------
■Maya : Focal Length
35
■Softimage :
Field of View Angle Horizontal
perspective : 28.072
camera : 53.638
※ Vertical(垂直) も可能
■ZBrush : Field of View Angle Diagonal
50
■3DCoat : Field of View Vertical
50
※ 3DCoatの情報は見つからなかったので、色々試してみたら垂直かなって感じです。
------------------------------
これじゃ、どう合わせれば良いのか分からない !
今までは合わせられれば良いなと思いながら全く何もせずになんとなーく作業していた。
たまになんとなーく合わせていました。見た目で。
最近Mayaのツールばっかりを書いているから、ついでにこれもやってみようと思って、
FOVを変換してくれる関数を書いてみました。
これは単なるPythonでの計算だからSoftimageでもMayaでも実行が出来る。
スクリプトとかは分からない人へ:このコードを全部コピーして、SoftimageかMayaのスクリプトエディターにペーストしてから
実行コマンドを足してください。実行コマンドについては最後に書いておきます。
そそ、最近はMaya用ツールばっかり書いてるからもう Python しか使っていません。
とは言ってもまだ慣れていないなーPythonらしい書き方に。 あれだね、かっこよくて色々省略する書き方。
無駄にコードが長くても、とりあえず動けば良いって感じで色々書いてる。
因みにMayaは使いにくいけど、Mayaのスクリプトも書きにくい・・・。便利なところもあるけど、だいたいは書きにくい。
Pymelに少し助かってるけど、Softimageみたいにオブジェクトの上手い使い方はまだ良く分かってない。
ミスった時もどこが悪いかMayaのエディターは教えてくれないし。
ま、その話は置いといて
from __future__ import division
import math
def convertFOV(in_value=35, in_type=0, out_type=3, aspect=16/9):
#type:
#0 = Focal Length
#1 = FOV_H
#2 = FOV_V
#3 = FOV_D
film_width_35 = 36
film_height_35 = film_width_35 / aspect
film_diag_35 = (math.sqrt((film_width_35 * film_width_35) + (film_height_35 * film_height_35)))
flen_mult = 1
film_height_35 = math.sqrt( (film_diag_35*film_diag_35)/((aspect*aspect) + 1) )
film_width_35 = aspect * film_height_35
sensor_width = film_width_35 / flen_mult
sensor_height = film_height_35 / flen_mult
sensor_diag = math.sqrt((sensor_width * sensor_width) + (sensor_height * sensor_height))
#From Focus Length (Maya)
#-----------------------------------
if in_type == 0:
if out_type ==0:
result = in_value
#To FOV Horizontal
elif out_type ==1:
result = 2 * math.atan(sensor_width / (2 * in_value)) * 180 / math.pi
#To FOV Vertical
elif out_type ==2:
result = 2 * math.atan(sensor_height / (2 * in_value)) * 180 / math.pi
#To FOV Diagonal
elif out_type ==3:
result = 2 * math.atan(sensor_diag / (2 * in_value)) * 180 / math.pi
#From FOV Horizontal
#-----------------------------------
elif in_type == 1:
#To Focus Length (Maya)
if out_type == 0:
result = sensor_width / (2 * math.tan( in_value * ( math.pi / 180 ) / 2))
#To FOV Horizontal
elif out_type == 1:
result = in_value
#To FOV Vertical
elif out_type ==2:
result = 2 * math.atan(math.tan(in_value * ( math.pi / 180 ) / 2) / aspect)* 180 / math.pi
#To FOV Diagonal
elif out_type ==3:
result = 2 * math.atan(sensor_diag / (2 * ( sensor_width / (2 * math.tan( in_value * ( math.pi / 180 ) / 2)) ))) * 180 / math.pi
#From FOV Vertical
#-----------------------------------
elif in_type == 2:
#To Focus Length (Maya)
if out_type == 0:
result = sensor_height / (2 * math.tan( in_value * ( math.pi / 180 ) / 2))
#To FOV Horizontal
elif out_type == 1:
result = 2 * math.atan( aspect * math.tan( in_value * ( math.pi / 180 ) / 2))* 180 / math.pi
#To FOV Vertical
elif out_type ==2:
result = in_value
#To FOV Diagonal
elif out_type ==3:
result = 2 * math.atan(sensor_diag / (2 * ( sensor_height / (2 * math.tan( in_value * ( math.pi / 180 ) / 2)) ))) * 180 / math.pi
#From FOV Diagonal
#-----------------------------------
elif in_type == 3:
#To Focus Length (Maya)
if out_type == 0:
result = ( sensor_diag / (2 * math.tan( in_value * ( math.pi / 180 ) / 2)) )
#To FOV Horizontal
elif out_type == 1:
result = 2 * math.atan(sensor_width / (2 * ( sensor_diag / (2 * math.tan( in_value * ( math.pi / 180 ) / 2)) ))) * 180 / math.pi
#To FOV Vertical
elif out_type ==2:
result = 2 * math.atan(sensor_height / (2 * ( sensor_diag / (2 * math.tan( in_value * ( math.pi / 180 ) / 2)) ))) * 180 / math.pi
#To FOV Diagonal
elif out_type ==3:
result = in_value
return result
僕的には少し難しい三角法レベルになる為、100%自信があるというわけではありませんが、
大体は上手く行っているようです^^;

↑の画像では3DCoatとZbrushのカメラの移動値などを設定ができるところが分からなくてカメラアングルは手動で合わせてみました。移動値とかありますか?
この関数の使い方は:
convertFOV ( 変換したい数, 数値のタイプ, 変換したいタイプ)
0 = Focal Length ( Maya )
1 = FOV Horizontal ( Softimage )
2 = FOV Vertical ( 3D Coat, Softimage )
3 = FOV Diagonal ( ZBrush )
例:
Maya のデフォルトカメラ(35) を ZBrush に設定したいケース。
Focal Length (0) から FOV Diagonal(3) になるので:
print convertFOV ( 35, 0, 3 )
# 61.0866854386
Pythonが分からない人へ:print は関数の結果をログに残す為のコマンドです。
ZBrush のカメラ設定を 61.09 にすればMayaと同じ見栄えになるはずです。
逆にZBrushのデフォルトのカメラ設定をMayaにしたい場合は:
print convertFOV ( 50, 3, 0 )
# 44.2889031701
Maya のカメラを44.29にすればOK。
PySideとかも良く分からないからGUIとかはまだ作ってないので、
とりあえずこんな感じです。
では、また。
参考にしたページ:
http://sortadone.blogspot.jp/p/zbrush-focal-angle-tutorial.html Read more