Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
- Finish document
- Fix mtl export bug
- Fix browse typo
- Add new menu item
  • Loading branch information
yyc12345 committed Jun 3, 2020
1 parent a1693f0 commit 00bec55
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 47 deletions.
63 changes: 53 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,62 @@

Virtools Obj Plugin.

A interface plugin of Virtools which allows you to export some models as `.obj` file.
An interface plugin of Virtools which allows you to export some models as `.obj` file.

Support Virtools 3.5 and 5.0

Features:
## Features

* Support omit world matrix (comparing with `vt2obj`).
* Support rrepostion script generator (for 3ds Max and Blender).
* Support option of right-hand, left-hand coordinate system convertion.
* Support more texture export option.
### Advantages

Shortcomings:
* Can omit world matrix (better than vt2obj. Omiting world matrix will omit object's move, rotation and scale).
* Support Blender and 3ds Max's repostion script for placing object (Place each object with the correct status in 3d software when you omit world matrix)
* Better right-hand left-hand coordinate system conversion. (From fliping Z axis to swaping YZ axis. This is more suit for Blender and 3ds Max 3d system)
* More material export options
* Comparing with vt2obj, it support Virtools 3.5. It is convenient for Ballance object operation.
* Support *one file per object*. It is convenient for exporting object component.

* Right-left hand coordinate system convertion only support swaping Z/Y axis.
* Don't support detecting texture original format.
* Smoothing group and some weird bugs.
### Shortcomings

* Right-hand left-hand coordinate system conversion only support swaping YZ axis.
* For avoiding same name, all export objects will be attach a unique prefix.
* Use group to split each object and don't provide any option for changing this.
* No smooth group
* Only export 3d object. Don't support 2 dimension structure such as Line and etc.
* Couldn't detect original texture format and save it automatically

## Usage

1. Put plugin dll into Virtools's `InterfacePlugins` folder
1. Launch Virtools and open the document which you want to export objects from.
1. According to your need, considering whether you need do some extra operations.
1. Click menu`Vtobj`-`Export object`
1. Set all options in dialog and click OK to export objects.

## Import tips

There are some tips for importing obj files generated by this plugin in 3ds Max and Blender. Following tips is under defualt setting (the initial settings when you first launch this plugin)

### Blender

* Choose Y forward, Z up (same as Blender default system)
* Check Image search
* Check Group in Split

For reposition, load script file `blender.py` in Scripting tab and run it.

### 3ds Max

* Do not check Filp YZ Axis
* For normals, select imported from file
* Check import material

For reposition, Click MAXScript-Run script in menu. Select `3dsmax.ms` and run it.

## Build

This project have 2 configuration which corresponding with Virtools 3.5 and 5.0. It need their corresponding Virtools SDK to build.

Project configuration have too much absolute path. For beginner, it is hard to build this project.

It is strongly not recommended that you compile by yourself unless you know Virtools SDK very well.
4 changes: 2 additions & 2 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Virtools Obj 插件

## 操作方法

1. 将插件安装到Virtools的InterfacePlugins文件夹中
1. 将插件安装到Virtools的`InterfacePlugins`文件夹中
1. 启动Virtools,加载需要导出的文档。
1. 根据需要,考虑是否需要做额外操作,比如只想导出路面或者某些物体,需要把相关物体归到一个新组中,或者不做任何操作,例如导出单个物体或全部物体。
1. 点击菜单栏Vtobj-Export object。
Expand Down Expand Up @@ -65,7 +65,7 @@ Virtools Obj 插件

## 导入提示

此处就Blender和3ds Max导入做一些提示
此处就Blender和3ds Max导入做一些提示。此处的设置是以对默认设置(即第一次使用此插件时的设置)为前提进行讲述的

### Blender

Expand Down
28 changes: 16 additions & 12 deletions obj_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void obj_export::ExportAllWarpper() {
CK3dEntity* obj = NULL;
int storedV = 0;
StartFile(&fObj, "obj");
StartFile(&fMtl, "mtl");
if (cfg->export_mtl) StartFile(&fMtl, "mtl");
StartReposition();

for (int i = 0; i < count; i++) {
Expand All @@ -47,17 +47,19 @@ void obj_export::ExportAllWarpper() {
// if multifile, export here for each object
if (cfg->file_mode == FILEMODE_MULTIFILE) {
storedV = 0;
NextFile(&fMtl, obj->GetName(), "mtl");
ExportMaterial();
if (cfg->export_mtl) {
NextFile(&fMtl, obj->GetName(), "mtl");
ExportMaterial();
}
}
}

//if one file, export mtl here to make sure some material can be shared using
ExportMaterial();
if (cfg->export_mtl) ExportMaterial();

EndRepostition();
EndFile(&fObj);
EndFile(&fMtl);
if (cfg->export_mtl) EndFile(&fMtl);
}
void obj_export::ExportGroupWarpper() {
XObjectPointerArray objArray = ctx->GetObjectListByType(CKCID_3DENTITY, TRUE);
Expand All @@ -67,7 +69,7 @@ void obj_export::ExportGroupWarpper() {
CKGroup* grp = (CKGroup*)ctx->GetObjectA(cfg->selected_item);
int storedV = 0;
StartFile(&fObj, "obj");
StartFile(&fMtl, "mtl");
if (cfg->export_mtl) StartFile(&fMtl, "mtl");
StartReposition();

for (int i = 0; i < count; i++) {
Expand All @@ -82,17 +84,19 @@ void obj_export::ExportGroupWarpper() {
// if multifile, export here for each object
if (cfg->file_mode == FILEMODE_MULTIFILE) {
storedV = 0;
NextFile(&fMtl, obj->GetName(), "mtl");
ExportMaterial();
if (cfg->export_mtl) {
NextFile(&fMtl, obj->GetName(), "mtl");
ExportMaterial();
}
}
}

//if one file, export mtl here to make sure some material can be shared using
ExportMaterial();
if (cfg->export_mtl) ExportMaterial();

EndRepostition();
EndFile(&fObj);
EndFile(&fMtl);
if (cfg->export_mtl) EndFile(&fMtl);
}
void obj_export::ExportObjectWarpper() {
int storedV = 0;
Expand All @@ -101,7 +105,7 @@ void obj_export::ExportObjectWarpper() {

//obj mtl
StartFile(&fObj, "obj");
StartFile(&fMtl, "mtl");
if (cfg->export_mtl) StartFile(&fMtl, "mtl");
StartReposition();

NextFile(&fObj, obj->GetName(), "obj");
Expand All @@ -114,7 +118,7 @@ void obj_export::ExportObjectWarpper() {

EndRepostition();
EndFile(&fObj);
EndFile(&fMtl);
if (cfg->export_mtl) EndFile(&fMtl);

}

Expand Down
56 changes: 33 additions & 23 deletions vt_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,38 +43,48 @@ void RemoveMenu() {
}

void UpdateMenu() {
s_Plugininterface->ClearPluginMenu(s_MainMenu); //clear menu
s_Plugininterface->ClearPluginMenu(s_MainMenu);

s_Plugininterface->AddPluginMenuItem(s_MainMenu, 0, "Export object");
s_Plugininterface->AddPluginMenuItem(s_MainMenu, -1, NULL, TRUE);
s_Plugininterface->AddPluginMenuItem(s_MainMenu, 1, "Report bug");
s_Plugininterface->AddPluginMenuItem(s_MainMenu, 2, "About vtobjplugin");

s_Plugininterface->UpdatePluginMenu(s_MainMenu); //update menu,always needed when you finished to update the menu
//unless you want the menu not to have Virtools Dev main menu color scheme.

s_Plugininterface->UpdatePluginMenu(s_MainMenu);
}

void PluginMenuCallback(int commandID) {
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CKContext* ctx = s_Plugininterface->GetCKContext();

ExportSetting* es = new ExportSetting(ctx);
if (es->DoModal() != IDOK) {
delete es;
return;
}
if (commandID == 0) {
CKContext* ctx = s_Plugininterface->GetCKContext();

exporter->Ready4Export(ctx, es->res_settings);
switch (es->res_settings->export_mode) {
case EXPORTMODE_ALL:
exporter->ExportAllWarpper();
break;
case EXPORTMODE_GROUP:
exporter->ExportGroupWarpper();
break;
case EXPORTMODE_OBJECT:
exporter->ExportObjectWarpper();
break;
}
ExportSetting* es = new ExportSetting(ctx);
if (es->DoModal() != IDOK) {
delete es;
return;
}

exporter->Ready4Export(ctx, es->res_settings);
switch (es->res_settings->export_mode) {
case EXPORTMODE_ALL:
exporter->ExportAllWarpper();
break;
case EXPORTMODE_GROUP:
exporter->ExportGroupWarpper();
break;
case EXPORTMODE_OBJECT:
exporter->ExportObjectWarpper();
break;
}

ctx->OutputToConsole("[vtobjplugin] Export OK!");
delete es;
ctx->OutputToConsole("[vtobjplugin] Export OK!");
delete es;
} else if (commandID == 1)
ShellExecute(NULL, "open", "https://github.com/yyc12345/vtobjplugin/issues", NULL, NULL, SW_SHOWNORMAL);
else if (commandID == 2)
AfxMessageBox("vtobjplugin - An OBJ export plugin for Virtools.\nUnder GPL v3 License.\nProject homepage: https://github.com/yyc12345/vtobjplugin", MB_ICONINFORMATION + MB_OK);
else;

}
Binary file modified vtobjplugin.rc
Binary file not shown.

0 comments on commit 00bec55

Please sign in to comment.