.MQOを自力で読み込んでみる1(解析編)

前回はGLMetaseqを使わせて頂きましたが、今回からは .MQO を自力で
読み込んでみたいと思います。
ただ使っているだけでは理解した事にはならないので実際に解析してみましょう。
まず、どのようなデータがあり、どのデータが必要となるのか、そこから探っていきたいと
思います。
では、メタセコイアを起動して何もせずにいきなり名前を付けて保存したデータを見て
みます。

1.MQO

Metasequoia Document
Format Text Ver 1.0

Scene {
 pos 0.0000 0.0000 1500.0000
 lookat 0.0000 0.0000 0.0000
 head -0.5236
 pich 0.5236
 ortho 0
 zoom2 5.0000
 amb 0.250 0.250 0.250
}
Object "obj1" {
 depth 0
 folding 0
 scale 1.000000 1.000000 1.000000
 rotation 0.000000 0.000000 0.000000
 translation 0.000000 0.000000 0.000000
 visible 15
 locking 0
 shading 1
 facet 59.5
 color 0.898 0.498 0.698
 color_type 0
 vertex 0 {
 }
 face 0 {
 }
}
Eof

このようになりました。
それでは三角ポリゴンを一枚だけ作って保存したデータを見てみます。

2.MQO

Metasequoia Document
Format Text Ver 1.0

Scene {
 pos 0.0000 0.0000 1500.0000
 lookat 0.0000 0.0000 0.0000
 head -0.5236
 pich 0.5236
 ortho 0
 zoom2 5.0000
 amb 0.250 0.250 0.250
}
Object "obj1" {
 depth 0
 folding 0
 scale 1.000000 1.000000 1.000000
 rotation 0.000000 0.000000 0.000000
 translation 0.000000 0.000000 0.000000
 visible 15
 locking 0
 shading 1
 facet 59.5
 color 0.898 0.498 0.698
 color_type 0
 vertex 3 {
  -100.9615 75.5277 7.9388
  76.0882 55.9196 -81.2090
  14.5374 -91.8674 52.8524
 }
 face 1 {
  3 V(0 1 2)
 }
}
Eof

このようになりました。
なにやら vertex と face の辺りが変化していますね。
この vertex というのは頂点情報の集まりです。
そして face は面を、どの頂点を使って作るかという情報です。
それでは、マテリアルに赤い色を設定して名前を付けて保存してみます。

3.MQO

Metasequoia Document
Format Text Ver 1.0

Scene {
 pos 0.0000 0.0000 1500.0000
 lookat 0.0000 0.0000 0.0000
 head -0.5236
 pich 0.5236
 ortho 0
 zoom2 5.0000
 amb 0.250 0.250 0.250
}
Material 1 {
 "mat1" shader(3) col(1.000 0.000 0.000 1.000) dif(0.800) amb(0.600) emi(0.000) spc(0.000) power(5.00)
}
Object "obj1" {
 depth 0
 folding 0
 scale 1.000000 1.000000 1.000000
 rotation 0.000000 0.000000 0.000000
 translation 0.000000 0.000000 0.000000
 visible 15
 locking 0
 shading 1
 facet 59.5
 color 0.898 0.498 0.698
 color_type 0
 vertex 3 {
  -100.9615 75.5277 7.9388
  76.0882 55.9196 -81.2090
  14.5374 -91.8674 52.8524
 }
 face 1 {
  3 V(0 1 2) M(0)
 }
}
Eof

このようになりました。
Material というチャンクが追加されていますね。
そして face の所に M(0) が追加されています。
それではテクスチャとUVを設定して保存してみます。

4.MQO

Metasequoia Document
Format Text Ver 1.0

Scene {
 pos 0.0000 0.0000 1500.0000
 lookat 0.0000 0.0000 0.0000
 head -0.3136
 pich 0.3836
 ortho 0
 zoom2 5.0000
 amb 0.250 0.250 0.250
}
Material 1 {
 "mat1" shader(3) col(1.000 0.000 0.000 1.000) dif(0.800) amb(0.600) emi(0.000) spc(0.000) power(5.00) tex("test.bmp")
}
Object "obj1" {
 depth 0
 folding 0
 scale 1.000000 1.000000 1.000000
 rotation 0.000000 0.000000 0.000000
 translation 0.000000 0.000000 0.000000
 visible 15
 locking 0
 shading 1
 facet 59.5
 color 0.898 0.498 0.698
 color_type 0
 vertex 3 {
  -100.9615 75.5277 7.9388
  76.0882 55.9196 -81.2090
  14.5374 -91.8674 52.8524
 }
 face 1 {
  3 V(0 1 2) M(0) UV(-0.00481 0.12236 0.88044 0.22040 0.57269 0.95934)
 }
}
Eof

こんなふうになりました。
tex("test.bmp") と UV(-0.00481 0.12236 0.88044 0.22040 0.57269 0.95934) が
追加されていますね。
ここまでの実験で必要なデータとそうでないデータが大体わかったと思います。
まず、最初の方にある Scene チャンクは、シーン全体の情報なので読み込まなくても
良いです。
それから Object チャンクの vertex と face 以外は必要なさそうです。
それから、鏡面オブジェクトやメタボールなども今回の読み込みでは使いません。
では、取りあえず、必要なデータがわかったので次回、.MQOを自力で読み込んでみる(読み込み編)で
読み込んで配列に格納してみたいと思います。
尚、詳しいデータのリファレンスはこちらにあります。↓

http://www.metaseq.net/metaseq/format.html

 

 

 

 

 

 

 

最終更新:2010年05月30日 13:48