Skip to content

Commit f334751

Browse files
authored
Merge pull request #2 from s520/refactor
Fix: various issues
2 parents 3c9c368 + 09240f1 commit f334751

32 files changed

Lines changed: 1876 additions & 1421 deletions

‎.gitignore‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
__pycache__/
2-
.idea/
3-
debug.py
1+
__pycache__/
2+
.mypy_cache/
3+
.vscode/
4+
.idea/
5+
debug.py

‎.gitmodules‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "io_scene_csv/chardet"]
2+
path = io_scene_csv/chardet
3+
url = https://github.com/chardet/chardet
4+
branch = stable

‎README-ja.md‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
[English](README.md)
2+
3+
# Blender plugin for Import|Export OpenBVE \*.csv objects
4+
5+
本プラグインはBlender2.79に対応しております。**現在のバージョンは2.80への対応しておりません。**
6+
7+
## 1. インストールガイド
8+
9+
1. 最新のリリースを [Releases section](https://github.com/maisvendoo/blenderCSV/releases) からダウンロードして下さい。
10+
2. Blenderを開き、メインメニューのファイル -> ユーザー設定 -> アドオンを選択します。
11+
3. "ファイルからアドオンをインストール"を選択します。
12+
![user-Preferences1-jp](images/user-Preferences1-jp.jpg)
13+
4. プラグインのzipファイルを選択します。
14+
![user-Preferences2-jp](images/user-Preferences2-jp.jpg)
15+
5. 有効化するために、チェックボックスをONにします。
16+
![user-Preferences3-jp](images/user-Preferences3-jp.jpg)
17+
6. "ユーザー設定の保存"を押し、変更を有効にした上でBlenderを再起動します。
18+
## 2. プラグインを使う
19+
### 2.1 \*.csvをBlenderにインポートする
20+
21+
1. ファイル -> インポート -> OpenBVE CSV model (\*.csv)と選択します。
22+
![import1-jp](images/import1-jp.jpg)
23+
24+
2. インポートオプションを選択します。
25+
26+
![import2](images/import2.jpg)
27+
28+
- *Set logging Level*: ログへ出力する情報の閾値を選択します。デフォルトでは"INFO"です。
29+
- *Transform coordinates*: OpenBVEの左手座標系からBlenderの右手座標系へ変換するか選択します。デフォルトでは有効です。
30+
- *Split AddFace2:* AddFace2で生成される面を別々の面に分割して取り込みます。その際、AddFace2フラグは解除されます。
31+
32+
3. ファイルシステムからモデルを選択後、"OpenBVE model (\*.csv)"ボタンを押し、現在のワークスペースにインポートします。
33+
![import3-jp](images/import3-jp.jpg)
34+
35+
インポートオプションの*Transform coordinates*を無効にすると下図のようになります。
36+
![import4-jp](images/import4-jp.jpg)
37+
38+
### 2.2 Blenderから\*.csvへエクスポートする
39+
40+
1. Blenderでエクスポートしたいモデルを**オブジェクトモードにしてから**選択します。
41+
![export1-jp](images/export1-jp.jpg)
42+
2. ファイル -> エクスポート -> OpenBVE CSV model (\*.csv)と選択します。
43+
3. エクスポートオプションを選択します
44+
45+
![export2](images/export2.jpg)
46+
47+
- *Set logging Level*: ログへ出力する情報の閾値を選択します。デフォルトでは"INFO"です。
48+
- *Transform coordinates*: Blenderの右手座標系からOpenBVEの左手座標系へ変換するか選択します。デフォルトでは有効です。
49+
- *Set global scale*: 大きさの倍率を変更します。デフォルトでは1.0です。
50+
- *Output Normals*: 法線を出力するか選択します。デフォルトでは有効です。
51+
- *Copy textures in separated folder*: 全てのテクスチャファイルを新たなフォルダを作成し、コピーします。csvファイルと同じフォルダ階層に作られ、フォルダ名はモデル名-texturesになります。デフォルトでは有効です。
52+
53+
4. ファイルシステムからモデルの出力先を選択後、"OpenBVE model (\*.csv)"ボタンを押し、エクスポートします。
54+
55+
5. 結果をOpenBVEのObjectViewerで確認します。
56+
![export3](images/export3.jpg)
57+
## 3. OpenBVE特有の属性
58+
Additional properties for CSV meshにおいて、OpenBVE特有の属性を付与することが出来ます。
59+
60+
**注意: これらの属性はBlenderの3Dビューの表示に反映されません。**
61+
62+
### 3.1 オブジェクトプロパティ
63+
![Object-setting-jp](images/Object-setting-jp.jpg)
64+
65+
- *SetEmissiveColor*: SetEmissiveColorの有効/無効と、その色を設定できます。
66+
- *SetBlendMode*: SetBlendModeのBlendMode(Normal/Additive)、GlowHalfDistanceの距離、GlowAttenuationMode(DivideExponent2もしくは4)を設定できます。
67+
- *SetDecalTransparentColor*: BMPなどSetDecalTransparentColorが必要なテクスチャを用いる場合、ここで有効/無効と色を設定できます。
68+
69+
### 3.2 マテリアルプロパティ
70+
71+
![material-setting-jp](images/material-setting-jp.jpg)
72+
73+
- *Use AddFace2*: マテリアルをエクスポート時にAddFace2で両面化させる際に有効/無効が指定できます。
74+
- *LoadTexture*: LoadTextureのNighttimeTextureを指定できます。
75+
76+
## 4. デバッグ
77+
78+
このプラグインはログをホームディレクトリ直下の`io_scene_csv_log.txt`へ出力します。
79+
80+
具体的には下記の通りです。
81+
82+
- Windows
83+
`C:\Users\<UserName>\io_scene_csv_log.txt`
84+
- Linux/macOS
85+
`~/io_scene_csv_log.txt`
86+
87+
## 5. ライセンス
88+
89+
このプラグインは*GPL-2.0*の下でライセンスされています。
90+
### サードパーティのライブラリ
91+
- このプラグインは**Chardet**を文字エンコーディングを決定するために使用しています。これは`io_scene_csv/chardet/LICENSE`に従い、*LGPL-2.1*の下でライセンスされています。

‎README.md‎

Lines changed: 64 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,92 @@
1-
# Blender plugin for Import|Export OpenBVE *.csv objects
1+
[Japanese](README-ja.md)
22

3-
## 1. Installation guide
4-
5-
* Donwload last release of plugin from [Releases section](https://github.com/maisvendoo/blenderCSV/releases)
6-
* Open Blender, go from main menu by path File -> User Preferences -> Add-ons
7-
* Select "Install add-on from file"
8-
9-
![](https://habrastorage.org/webt/kc/y4/dv/kcy4dvv4t-prv5ax-hy_lxahehk.png)
10-
11-
* Choose plugin zip-archive in your filesystem
3+
# Blender plugin for Import|Export OpenBVE \*.csv objects
124

13-
![](https://habrastorage.org/webt/rf/wj/lr/rfwjlruesl3vqjtrovo7tpnzlcg.png)
5+
This plugin only works on Blender 2.79. **Please note that it will NOT work on 2.80.**
146

15-
* Select checkbox for addon activation
16-
17-
![](https://habrastorage.org/webt/zp/le/pb/zplepbd5-2yii9zd7mzqsszmqow.png)
18-
19-
* Press "Save user setting" for apply changes to next start of Blender
7+
## 1. Installation guide
208

9+
1. Please download from [Releases section](https://github.com/maisvendoo/blenderCSV/releases) the newest release.
10+
2. Open Blender, and choose File -> User Preferences... -> Add-ons from main menu.
11+
3. Choose "Install Add-on from File...".
12+
![user-Preferences1-en](images/user-Preferences1-en.jpg)
13+
4. Choose plugins zip file.
14+
![user-Preferences2-en](images/user-Preferences2-en.jpg)
15+
5. To enable the plugin, turn on the checkbox.
16+
![user-Preferences3-en](images/user-Preferences3-en.jpg)
17+
6. To enabled the setting, press "Save User Settings", and restart Blender.
2118
## 2. Using plugin
19+
### 2.1 Import \*.csv model file to Blender
2220

23-
### 2.1. Import *.csv to blender
24-
25-
Now, you can import any csv model into Blender workspace. Go to menu File -> Import -> OpenBVE *.csv model
26-
27-
![](https://habrastorage.org/webt/oz/wl/wo/ozwlwoh7nv55fjng8zjg6imq08q.png)
28-
29-
and open your model from filesystem.
30-
31-
![](https://habrastorage.org/webt/lj/ok/vh/ljokvh3odnpolo2z7mcqbfmyxo8.png)
32-
33-
In import settings, you can choose option for model transformation from OpenBVE left hand coordinate system to Blender right hand coordinate system
34-
35-
![](https://habrastorage.org/webt/kw/9g/qn/kw9gqnkbrcd9hpkk6s-asdvre1a.png)
36-
37-
This setting enable by default, but you can disabled it
21+
1. Choose File -> Import -> OpenBVE CSV model (\*.csv) from main menu.
22+
![import1-en](images/import1-en.jpg)
3823

39-
![](https://habrastorage.org/webt/js/y6/qu/jsy6qumzoanb66n0hq_6e0zifee.png)
24+
2. Select import options.
4025

41-
### 2.2. Export from Blender to *.csv
26+
![import2](images/import2.jpg)
4227

43-
1. Select your model in Blender and switch to **Object Mode**
28+
- *Set logging Level*: select threshold level for the log file. The default setting is "INFO".
29+
- *Transform coordinates*: If you want to change OpenBVE 's Left-handed coordinate system to Blender's Right-handed coordinate system, check this option. The default is enable.
30+
- *Split AddFace2:* If this option is enabled, AddFace2's double-sided is split to an each face. After split, each faces Material's AddFace2 option is turn off automatically.
4431

45-
![](https://habrastorage.org/webt/n1/ok/dp/n1okdpwjr9d6i5r0e8x_ux_hggk.png)
32+
3. After choose the \*.csv model from filesystem, press the "OpenBVE model (\*.csv)" button, then import the model.
33+
![import3-en](images/import3-en.jpg)
4634

47-
2. Select menu item File -> Export -> OpenBVE *.csv model
48-
3. Choose export options
35+
If you are turn off the *Transform coordinates* option, the imported model is as shown below.
36+
![import4-en](images/import4-en.jpg)
4937

50-
![](https://habrastorage.org/webt/lf/x_/1h/lfx_1hv9cbinoy2xzid0d_ycziy.png)
38+
### 2.2 Exporting from Blender to \*.csv model file
5139

52-
* Transform coordinate system - conversion to OpenBVE left hand coordinates. It option enabled by default
53-
* Use Face2 command - all face generation commands will be present in CSV as AddFace2
54-
* Use decale transparent color - set components for decale color
40+
1. Before the choose export object, **you must change mode to "Object Mode"**. After changed, you can choose export object(s).
41+
![export1-en](images/export1-en.jpg)
42+
2. Choose File -> Export -> OpenBVE CSV model (\*.csv) from main menu.
43+
3. Choose export options.
5544

56-
**Attantion!** In current version decale color applied to all meshes in model
45+
![export2](images/export2.jpg)
5746

58-
* Copy textures in separated folder - all textures will copired to separated folder, which will created near CSV file and will has name *model file name-textures*
47+
- *Set logging Level*: select threshold level for the log file. The default setting is "INFO".
48+
- *Transform coordinates*: If you want to change Blender's Right-handed coordinate system to OpenBVE 's Left-handed coordinate system, check this option. The default is enable.
49+
- *Set global scale*: Set the scale factor. The default value is 1.0.
50+
- *Output Normals*: If you want to export add normals, check this option. The default is enable.
51+
- *Copy textures in separated folder*: All texture files are copy to the new folder. the new folder is the same folder level, and folder name is 'model name'-textures. This option is enable by default.
52+
4.
53+
After choose the \*.csv model from filesystem, press the "OpenBVE model (\*.csv)" button, then export the model.
54+
55+
5. Check the export result by the ObjectViewer of OpenBVE.
56+
![export3](images/export3.jpg)
57+
## 3. The specific attributes for OpenBVE
58+
At the Additional properties for CSV mesh, you can be assigns the specific attributes for OpenBVE.
5959

60-
* Press button "OpenBVE model (*.csv)" to export
61-
* Check result in OpenBVE ObjectViewer
60+
**NOTE: These specific attributes are not reflected to the Blender's 3D view.**
6261

63-
![](https://habrastorage.org/webt/-v/no/ix/-vnoixjsdb-jnyzgve0usawv0he.png)
62+
### 3.1 Object Property
63+
![Object-setting-en](images/Object-setting-en.jpg)
6464

65-
Enjoy!
65+
- *SetEmissiveColor*: Enable/Disable ,and set color of SetEmissiveColor.
66+
- *SetBlendMode*: You can set the SetBlendMode's BlendMode(Normal/Additive), GlowHalfDistance's distance, and GlowAttenuationMode(DivideExponent2 or 4).
67+
- *SetDecalTransparentColor*: For example of the BMP, If you want to use the case of require SetDecalTransparentColor, you can set Enable/Disable ,and set color of SetDecalTransparentColor.
6668

69+
### 3.2 Material Property
6770

71+
![material-setting-en](images/material-setting-en.jpg)
6872

73+
- *Use AddFace2*: If this option is enabled, when you are the exporting, you can enable the material to the double-sided by Addface2.
74+
- *LoadTexture*: If this file is selected, you can set the NighttimeTexture for LoadTexture.
6975

76+
## 4. Debugging
7077

78+
This plugin is output a log file of `io_scene_csv_log.txt` at the under the home directory.
7179

80+
Specifically, the folder placing is showing below.
7281

82+
- Windows
83+
`C:\Users\<UserName>\io_scene_csv_log.txt`
84+
- Linux/macOS
85+
`~/io_scene_csv_log.txt`
7386

87+
## 5. License
7488

89+
This plugin is licensed under *GPL-2.0*.
7590

91+
### Third party license
92+
- This plugin uses **Chardet** to determine the character encoding. This is licensed under the *LGPL-2.1* as per `io_scene_csv/chardet/LICENSE`.

‎images/Object-setting-en.jpg‎

29.9 KB
Loading

‎images/Object-setting-jp.jpg‎

27.9 KB
Loading

‎images/export1-en.jpg‎

245 KB
Loading

‎images/export1-jp.jpg‎

246 KB
Loading

‎images/export2.jpg‎

10.4 KB
Loading

‎images/export3.jpg‎

111 KB
Loading

0 commit comments

Comments
 (0)