├── RenderdocResourceExporter ├── fbx_res │ ├── __init__.py │ ├── libfbxsdk.dll │ ├── RenderdocCSVToFBX.exe │ ├── RenderdocCSVToFBX │ │ ├── RenderdocCSVToFBX │ │ │ ├── CommonMath.cpp │ │ │ ├── CommonMath.h │ │ │ ├── FileStream.cpp │ │ │ ├── FileStream.h │ │ │ ├── RenderdocCSVToFBX.vcxproj.user │ │ │ ├── RenderdocCSVToFBX.vcxproj.filters │ │ │ ├── CSVFile.h │ │ │ ├── RenderdocCSVToFBX.vcxproj │ │ │ ├── RenderdocCSVToFBX.cpp │ │ │ ├── unchecked.h │ │ │ ├── core.h │ │ │ ├── checked.h │ │ │ └── CSVFile.cpp │ │ └── RenderdocCSVToFBX.sln │ ├── csv_to_fbx.bat │ ├── mesh_to_csv.py │ ├── csv_to_fbx.py │ ├── fbx_export_option_dialog_const_mapper.py │ └── fbx_export_option_dialog.py ├── qt_utilities │ ├── __init__.py │ ├── setting_utility.py │ ├── root_const_mapper.py │ └── progress_bar_utility.py ├── extension.json └── __init__.py ├── .gitignore ├── install.bat ├── README.md └── LICENSE /RenderdocResourceExporter/fbx_res/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/qt_utilities/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore python 2 | __pycache__/ 3 | 4 | # ignore c++ 5 | .vs/ 6 | x64/ 7 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/libfbxsdk.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rrtt2323/RenderdocResourceExporter/HEAD/RenderdocResourceExporter/fbx_res/libfbxsdk.dll -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rrtt2323/RenderdocResourceExporter/HEAD/RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX.exe -------------------------------------------------------------------------------- /install.bat: -------------------------------------------------------------------------------- 1 | set src=RenderdocResourceExporter 2 | 3 | set dst=%APPDATA%\qrenderdoc\extensions\%src% 4 | if not exist "%dst%" mkdir "%dst%" 5 | xcopy "%~dp0%src%\*" "%dst%" /i /e /Y /C 6 | 7 | ::pause -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/CommonMath.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rrtt2323/RenderdocResourceExporter/HEAD/RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/CommonMath.cpp -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/CommonMath.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rrtt2323/RenderdocResourceExporter/HEAD/RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/CommonMath.h -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/FileStream.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rrtt2323/RenderdocResourceExporter/HEAD/RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/FileStream.cpp -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/FileStream.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rrtt2323/RenderdocResourceExporter/HEAD/RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/FileStream.h -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/csv_to_fbx.bat: -------------------------------------------------------------------------------- 1 | :: 用来调用 RenderdocCSVToFBX.exe 的批处理文件 2 | 3 | ::cd /d %~dp0 4 | set current_path=%~dp0 5 | 6 | echo current_path=%current_path% 7 | start %current_path%RenderdocCSVToFBX.exe %1 %2 %3 %4 %5 %6 8 | 9 | ::pause 10 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/RenderdocCSVToFBX.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/extension.json: -------------------------------------------------------------------------------- 1 | { 2 | "extension_api": 1, 3 | "name": "Renderdoc Resource Exporter", 4 | "version": "1.0", 5 | "minimum_renderdoc": "1.2", 6 | "description": "Used to export the resources captured by Renderdoc \n-------------------------------- \n用于导出 Renderdoc 捕获的资源", 7 | "author": "rrtt_2323 ", 8 | "url": "https://github.com/rrtt2323/RenderdocResourceExporter" 9 | } -------------------------------------------------------------------------------- /RenderdocResourceExporter/qt_utilities/setting_utility.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 配置文件实用工具 3 | ''' 4 | 5 | import os, tempfile 6 | 7 | from PySide2 import QtWidgets, QtCore, QtGui 8 | 9 | class SettingUtility: 10 | 11 | @staticmethod 12 | def get_tempdir_setting(iniName): 13 | path = os.path.join(tempfile.gettempdir(), iniName) 14 | settings = QtCore.QSettings(path, QtCore.QSettings.IniFormat) 15 | return path, settings 16 | pass 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RenderdocResourceExporter 2 | The main feature is to export renderdoc captured mesh. 3 | Because I don't want to export csv and then convert it to fbx in other software. 4 | So I wrote this thing. 5 | 6 | C++ code modified from https://github.com/chineseoldghost/csv2fbx 7 | 8 | install: 9 | 10 | ![image](https://user-images.githubusercontent.com/12709491/193525642-72e231b9-88b4-4d16-92ec-5802e83208d6.png) 11 | ![image](https://user-images.githubusercontent.com/12709491/193525544-19983e33-db7e-49ed-92c7-859f43e95e1e.png) 12 | 13 | use: 14 | 15 | ![image](https://user-images.githubusercontent.com/12709491/193525856-08ad94b6-b19d-4ad1-a755-ee563e0e3b78.png) 16 | 17 | --- 18 | 19 | 主要功能是导出renderdoc捕获的mesh。 20 | 因为我不想先导出csv,然后到别的软件中去转换成fbx。 21 | 所以我写了这个东西。 22 | 23 | c++代码修改自 https://github.com/chineseoldghost/csv2fbx 24 | 25 | 安装,使用见上图 26 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.2.32630.192 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RenderdocCSVToFBX", "RenderdocCSVToFBX\RenderdocCSVToFBX.vcxproj", "{32B66845-400B-47AD-A69F-4A52CDAC7CB1}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {32B66845-400B-47AD-A69F-4A52CDAC7CB1}.Debug|x64.ActiveCfg = Debug|x64 17 | {32B66845-400B-47AD-A69F-4A52CDAC7CB1}.Debug|x64.Build.0 = Debug|x64 18 | {32B66845-400B-47AD-A69F-4A52CDAC7CB1}.Debug|x86.ActiveCfg = Debug|Win32 19 | {32B66845-400B-47AD-A69F-4A52CDAC7CB1}.Debug|x86.Build.0 = Debug|Win32 20 | {32B66845-400B-47AD-A69F-4A52CDAC7CB1}.Release|x64.ActiveCfg = Release|x64 21 | {32B66845-400B-47AD-A69F-4A52CDAC7CB1}.Release|x64.Build.0 = Release|x64 22 | {32B66845-400B-47AD-A69F-4A52CDAC7CB1}.Release|x86.ActiveCfg = Release|Win32 23 | {32B66845-400B-47AD-A69F-4A52CDAC7CB1}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {97F1C158-FEEB-4820-A8AD-3FFE496350C5} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/mesh_to_csv.py: -------------------------------------------------------------------------------- 1 | ''' 2 | mesh 数据导出为 CSV 文件 3 | ''' 4 | 5 | import os, csv, sys 6 | from pathlib import Path 7 | 8 | from PySide2 import QtWidgets, QtCore, QtGui 9 | 10 | current_folder = Path(__file__).absolute().parent 11 | father_folder = str(current_folder.parent) 12 | sys.path.append(father_folder) 13 | 14 | from qt_utilities.progress_bar_utility import ProgressBarUtility 15 | 16 | 17 | class MeshToCsv: 18 | 19 | emgr = None 20 | 21 | def __init__(self, emgr_): 22 | self.emgr = emgr_ 23 | pass 24 | 25 | def execute(self, table_, save_path_): 26 | 27 | # 先把旧的删掉 28 | if os.path.exists(save_path_): 29 | os.remove(save_path_) 30 | 31 | model = table_.model() 32 | row_count = model.rowCount() 33 | column_count = model.columnCount() 34 | rows = range(row_count) 35 | columns = range(column_count) 36 | 37 | head_names = list() 38 | row_data_list = list() 39 | 40 | for _, c_i in ProgressBarUtility.loop(columns, status_='Collect mesh data'): 41 | head = model.headerData(c_i, QtCore.Qt.Horizontal) 42 | row_data = [model.data(model.index(r_i, c_i)) for r_i in rows] 43 | 44 | head_names.append(head) 45 | row_data_list.append(row_data) 46 | 47 | with open(save_path_, "w", newline='') as csvFile: 48 | writer = csv.writer(csvFile) 49 | writer.writerow(head_names) 50 | 51 | for _, r_i in ProgressBarUtility.loop(rows, status_='Write to the csv file'): 52 | write_data = list() 53 | for row_data in row_data_list: 54 | row_item = row_data[r_i] 55 | write_data.append(row_item) 56 | writer.writerow(write_data) 57 | 58 | pass 59 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/csv_to_fbx.py: -------------------------------------------------------------------------------- 1 | ''' 2 | CSV 文件导出成 FBX 文件 3 | ''' 4 | 5 | import os 6 | import sys 7 | from pathlib import Path 8 | 9 | current_folder = Path(__file__).absolute().parent 10 | father_folder = str(current_folder.parent) 11 | sys.path.append(father_folder) 12 | 13 | from qt_utilities.setting_utility import SettingUtility 14 | from fbx_res.fbx_export_option_dialog_const_mapper import FbxExportOptionDialogConstMapper as FCM 15 | 16 | 17 | class CsvToFbx: 18 | 19 | emgr = None 20 | 21 | def __init__(self, emgr_): 22 | self.emgr = emgr_ 23 | pass 24 | 25 | def get_arg(self, config_, key_): 26 | if config_.get(key_): 27 | return '1' 28 | else: 29 | return '0' 30 | pass 31 | 32 | def execute(self, csv_path_, fbx_path_, export_config_): 33 | 34 | # 先把旧的删掉 35 | if os.path.exists(fbx_path_): 36 | os.remove(fbx_path_) 37 | 38 | # 读取设置 39 | export_normal = self.get_arg(export_config_, FCM.c_export_normal) 40 | export_tangent = self.get_arg(export_config_, FCM.c_export_tangent) 41 | export_uv = self.get_arg(export_config_, FCM.c_export_uv) 42 | export_uv2 = self.get_arg(export_config_, FCM.c_export_uv2) 43 | export_uv3 = self.get_arg(export_config_, FCM.c_export_uv3) 44 | 45 | # 拼接bat路径 46 | current_folder = Path(__file__).absolute() 47 | bat_path = str(current_folder.parent) + '\\csv_to_fbx.bat' 48 | 49 | # 运行参数格式化 50 | args = "%s %s %s %s %s %s %s " % (bat_path, csv_path_, export_normal, export_tangent, export_uv, export_uv2, export_uv3) 51 | # 通过执行命令行脚本来执行exe文件 52 | result = os.system(args) 53 | 54 | if result == 1: 55 | self.emgr.ErrorDialog('csv_to_fbx.bat return 1') 56 | 57 | pass 58 | 59 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/RenderdocCSVToFBX.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | 源文件 23 | 24 | 25 | 源文件 26 | 27 | 28 | 源文件 29 | 30 | 31 | 32 | 33 | 头文件 34 | 35 | 36 | 头文件 37 | 38 | 39 | 头文件 40 | 41 | 42 | 头文件 43 | 44 | 45 | 头文件 46 | 47 | 48 | 头文件 49 | 50 | 51 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/fbx_export_option_dialog_const_mapper.py: -------------------------------------------------------------------------------- 1 | ''' 2 | FBX 导出选项设置窗 - 常量管理器 3 | ''' 4 | 5 | import sys 6 | from pathlib import Path 7 | 8 | current_folder = Path(__file__).absolute().parent 9 | father_folder = str(current_folder.parent) 10 | sys.path.append(father_folder) 11 | 12 | from qt_utilities.root_const_mapper import RootConstMapper 13 | from qt_utilities.setting_utility import SettingUtility 14 | 15 | 16 | class FbxExportOptionDialogConstMapper: 17 | 18 | # key值 19 | c_dialog_title = 'dialog_title' 20 | c_language = 'language' 21 | c_cancel = 'cancel' 22 | c_ok = 'ok' 23 | 24 | c_export_normal = 'export_normal' 25 | c_export_tangent = 'export_tangent' 26 | c_export_uv = 'export_uv' 27 | c_export_uv2 = 'export_uv2' 28 | c_export_uv3 = 'export_uv3' 29 | 30 | # 文本字典 31 | text_en = { 32 | c_dialog_title : 'FBX Export Option', 33 | c_language : 'Language', 34 | c_cancel : 'Cancel', 35 | c_ok : 'Ok', 36 | 37 | c_export_normal : 'Export Normal', 38 | c_export_tangent : 'Export Tangent', 39 | c_export_uv : 'Export UV', 40 | c_export_uv2 : 'Export UV2', 41 | c_export_uv3 : 'Export UV3', 42 | } 43 | text_cn = { 44 | c_dialog_title : 'FBX导出选项', 45 | c_language : '语言', 46 | c_cancel : '取消', 47 | c_ok : '确定', 48 | 49 | c_export_normal : '导出法线', 50 | c_export_tangent : '导出切线', 51 | c_export_uv : '导出 UV', 52 | c_export_uv2 : '导出 UV2', 53 | c_export_uv3 : '导出 UV3', 54 | } 55 | 56 | @staticmethod 57 | def get_text(key_): 58 | path, settings = SettingUtility.get_tempdir_setting(RootConstMapper.setting_preference) 59 | 60 | language = settings.value(RootConstMapper.c_language) 61 | 62 | if language == RootConstMapper.c_cn: 63 | return FbxExportOptionDialogConstMapper.text_cn[key_] 64 | else: 65 | return FbxExportOptionDialogConstMapper.text_en[key_] 66 | 67 | pass 68 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/qt_utilities/root_const_mapper.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 根 - 常量管理器 3 | ''' 4 | 5 | import sys 6 | from pathlib import Path 7 | 8 | # 切换到上一层目录,以便导入父目录的模块 9 | current_folder = Path(__file__).absolute().parent 10 | father_folder = str(current_folder.parent) 11 | sys.path.append(father_folder) 12 | 13 | from qt_utilities.setting_utility import SettingUtility 14 | 15 | 16 | class RootConstMapper: 17 | 18 | setting_preference = 'renderdoc_resource_exporter_preference.ini' 19 | 20 | c_language = 'language' 21 | c_en = 'en' 22 | c_cn = 'cn' 23 | 24 | c_welcome_1 = 'welcome_1' 25 | c_welcome_2 = 'welcome_2' 26 | c_export_fbx = 'export_fbx' 27 | c_save_fbx_file_to = 'save_fbx_file_to' 28 | c_save_path_error = 'save_path_error' 29 | c_not_mesh_data = 'not_mesh_data' 30 | c_export_complete = 'export_complete' 31 | 32 | text_en = { 33 | c_welcome_1 : 'The resource exporter was registered successfully.', 34 | c_welcome_2 : 'Hey! Cowboy!', 35 | c_export_fbx : 'Export FBX', 36 | c_save_fbx_file_to : 'Save FBX File To', 37 | c_save_path_error : 'Save Path Error!!!', 38 | c_not_mesh_data : 'Not Mesh Data!!!', 39 | c_export_complete : 'Export complete. The save location then opens automatically.', 40 | } 41 | text_cn = { 42 | c_welcome_1 : '资源导出器注册成功', 43 | c_welcome_2 : '嘿!牛仔!', 44 | c_export_fbx : '导出FBX', 45 | c_save_fbx_file_to : '保存FBX文件到', 46 | c_save_path_error : '保存路径错误!!!', 47 | c_not_mesh_data : '没有网格数据!!!', 48 | c_export_complete : '导出完成。自动打开保存位置。', 49 | } 50 | 51 | @staticmethod 52 | def get_text(key_): 53 | path, settings = SettingUtility.get_tempdir_setting(RootConstMapper.setting_preference) 54 | 55 | language = settings.value(RootConstMapper.c_language) 56 | 57 | if language == RootConstMapper.c_cn: 58 | return RootConstMapper.text_cn[key_] 59 | else: 60 | return RootConstMapper.text_en[key_] 61 | 62 | pass 63 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/qt_utilities/progress_bar_utility.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 进度条实用工具 3 | ''' 4 | 5 | from PySide2 import QtWidgets, QtCore, QtGui 6 | 7 | 8 | class ProgressBarUtility(QtWidgets.QProgressDialog): 9 | 10 | #构造函数 11 | def __init__(self, 12 | status_ = u"progress...", 13 | button_text_ = u"Cancel", 14 | minimum_ = 0, 15 | maximum_ = 100, 16 | parent_ = None, 17 | title_ = "", 18 | ): 19 | super(ProgressBarUtility, self).__init__(parent_) 20 | 21 | self.setWindowFlags(self.windowFlags()) 22 | self.setWindowModality(QtCore.Qt.WindowModal) 23 | self.setWindowTitle(status_ if title_ else title_) 24 | 25 | bar = QtWidgets.QProgressBar(self) 26 | bar.setStyleSheet( 27 | """ 28 | QProgressBar { 29 | color:white; 30 | border: 1px solid black; 31 | background: gray; 32 | } 33 | 34 | QProgressBar::chunk { 35 | background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, 36 | stop: 0 #78d, 37 | stop: 0.4999 #46a, 38 | stop: 0.5 #45a, 39 | stop: 1 #238 ); 40 | border: 1px solid black; 41 | } 42 | """ 43 | ) 44 | bar.setAlignment(QtCore.Qt.AlignCenter) 45 | 46 | self.setBar(bar) 47 | self.setLabelText(status_) 48 | self.setCancelButtonText(button_text_) 49 | self.setRange(minimum_, maximum_) 50 | self.setValue(minimum_) 51 | 52 | # NOTE show the progressbar without blocking 53 | self.show() 54 | QtWidgets.QApplication.processEvents() 55 | 56 | 57 | #补充构造函数 58 | @classmethod 59 | def loop(cls, seq_, **kwargs_): 60 | self = cls(**kwargs_) 61 | 62 | #如果参数里没有规定最大值,就用序列的长度 63 | if not kwargs_.get("maximum"): 64 | self.setMaximum(len(seq_)) 65 | 66 | for i, item in enumerate(seq_, 1): 67 | if self.wasCanceled(): 68 | break 69 | try: 70 | yield i, item # with body executes here 71 | except: 72 | import traceback 73 | traceback.print_exc() 74 | self.deleteLater() 75 | self.setValue(i) 76 | 77 | self.deleteLater() 78 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 资源导出插件的入口类 3 | ''' 4 | 5 | import os 6 | 7 | import qrenderdoc as qrd 8 | from PySide2 import QtWidgets, QtCore, QtGui 9 | 10 | from .qt_utilities.root_const_mapper import RootConstMapper as RCM 11 | 12 | from .fbx_res.fbx_export_option_dialog import FbxExportOptionDialog 13 | from .fbx_res.mesh_to_csv import MeshToCsv 14 | from .fbx_res.csv_to_fbx import CsvToFbx 15 | 16 | 17 | # 注册入口 18 | def register(version_, pyrenderdoc_): 19 | emgr = pyrenderdoc_.Extensions() 20 | 21 | emgr.MessageDialog(RCM.get_text(RCM.c_welcome_1), RCM.get_text(RCM.c_welcome_2)) 22 | 23 | if pyrenderdoc_.HasMeshPreview(): 24 | emgr.RegisterPanelMenu(qrd.PanelMenu.MeshPreview, [RCM.get_text(RCM.c_export_fbx)], ExportFbx) 25 | 26 | 27 | # 异常捕获 28 | def error_log(func_): 29 | def wrapper(pyrenderdoc, data): 30 | emgr = pyrenderdoc.Extensions() 31 | try: 32 | func_(pyrenderdoc, data) 33 | except: 34 | import traceback 35 | exc = traceback.format_exc() 36 | emgr.ErrorDialog(exc, "Error!!!") 37 | 38 | return wrapper 39 | 40 | # 导出fbx 41 | @error_log 42 | def ExportFbx(pyrenderdoc_, data_): 43 | emgr = pyrenderdoc_.Extensions() 44 | 45 | dialog = FbxExportOptionDialog(emgr) # 进行导出配置 46 | if not dialog.mqt.ShowWidgetAsDialog(dialog.init_ui()): return # 是不是主动取消的 47 | 48 | # 选择保存位置 49 | fbx_save_path = emgr.SaveFileName(RCM.get_text(RCM.c_save_fbx_file_to), '', '*.fbx') 50 | if not fbx_save_path: 51 | emgr.ErrorDialog(RCM.get_text(RCM.c_save_path_error), 'Error!!!') 52 | return 53 | # csv的地址 54 | csv_save_path = fbx_save_path.replace('.fbx', '.csv') 55 | 56 | # 直接从 QTableView 界面获取数据 57 | main_window = pyrenderdoc_.GetMainWindow().Widget() 58 | table = main_window.findChild(QtWidgets.QTableView, 'inTable') 59 | model = table.model() 60 | row_count = model.rowCount() 61 | column_count = model.columnCount() 62 | rows = range(row_count) 63 | columns = range(column_count) 64 | if len(rows) <=1 and len(columns) <= 2: 65 | emgr.ErrorDialog(RCM.get_text(RCM.c_not_mesh_data), 'Error!!!') 66 | return 67 | 68 | # 导出CSV数据表 69 | meshToCsv = MeshToCsv(emgr) 70 | pyrenderdoc_.Replay().BlockInvoke(meshToCsv.execute(table, csv_save_path)) 71 | # 读取CSV文件,导出FBX文件 72 | if os.path.exists(csv_save_path): 73 | csvToFbx = CsvToFbx(emgr) 74 | pyrenderdoc_.Replay().BlockInvoke(csvToFbx.execute(csv_save_path, fbx_save_path, dialog.export_config)) 75 | 76 | emgr.MessageDialog(RCM.get_text(RCM.c_export_complete), '\(^o^)/') 77 | 78 | # 打开保存位置 79 | fbx_dir = os.path.dirname(fbx_save_path) 80 | if os.path.exists(fbx_dir): 81 | os.startfile(fbx_dir) 82 | 83 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/CSVFile.h: -------------------------------------------------------------------------------- 1 | #ifndef CSVFILE_H_INCLUDE 2 | #define CSVFILE_H_INCLUDE 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class CCSVFileRow 9 | { 10 | public: 11 | CCSVFileRow() 12 | { 13 | 14 | } 15 | 16 | ~CCSVFileRow() 17 | { 18 | m_vecData.clear(); 19 | } 20 | std::string const& operator[](std::size_t index) const 21 | { 22 | return m_vecData[index]; 23 | } 24 | std::string & operator[](std::size_t index) 25 | { 26 | return m_vecData[index]; 27 | } 28 | 29 | std::size_t Size() const 30 | { 31 | return m_vecData.size(); 32 | } 33 | void ParseRow(std::string& strLine); 34 | 35 | void Reserve(int iElemCount); 36 | private: 37 | std::vector m_vecData; 38 | }; 39 | 40 | class CCSVFile 41 | { 42 | public: 43 | CCSVFile(const char* szCSVFile); 44 | ~CCSVFile(); 45 | 46 | bool OpenCSVFile(const char* file); 47 | void WriteCSVFile(const char* szFileName); 48 | 49 | int GetRowNum(); 50 | 51 | bool GetCellValue(const char* fieldName,int rowIndex,std::wstring& resValue); 52 | bool GetCellValue(int colIndex,int rowIndex,std::wstring& resValue); 53 | bool GetCellValue(const char* fieldName,int rowIndex,std::string& resValue); 54 | bool GetCellValue(int colIndex,int rowIndex,std::string& resValue); 55 | bool GetCellValue(const char* fieldName,int rowIndex,int& resValue); 56 | bool GetCellValue(int colIndex,int rowIndex,int& resValue); 57 | bool GetCellValue(const char* fieldName,int rowIndex,unsigned char& resValue); 58 | bool GetCellValue(int colIndex,int rowIndex,unsigned char& resValue); 59 | bool GetCellValue(const char* fieldName,int rowIndex,float& resValue); 60 | bool GetCellValue(int colIndex,int rowIndex,float& resValue); 61 | bool GetCellValue(const char* fieldName,int rowIndex,bool& resValue); 62 | bool GetCellValue(int colIndex,int rowIndex,bool& resValue); 63 | 64 | 65 | bool SetCellValue(const char* fieldName,int rowIndex,std::wstring& resValue); 66 | bool SetCellValue(int colIndex,int rowIndex,std::wstring& resValue); 67 | bool SetCellValue(const char* fieldName,int rowIndex,std::string& resValue); 68 | bool SetCellValue(int colIndex,int rowIndex,std::string& resValue); 69 | bool SetCellValue(const char* fieldName,int rowIndex,int resValue); 70 | bool SetCellValue(int colIndex,int rowIndex,int resValue); 71 | bool SetCellValue(const char* fieldName,int rowIndex,unsigned char resValue); 72 | bool SetCellValue(int colIndex,int rowIndex,unsigned char resValue); 73 | bool SetCellValue(const char* fieldName,int rowIndex,float resValue); 74 | bool SetCellValue(int colIndex,int rowIndex,float resValue); 75 | bool SetCellValue(const char* fieldName,int rowIndex,bool resValue); 76 | bool SetCellValue(int colIndex,int rowIndex,bool resValue); 77 | 78 | std::map& GetFieldsMap() 79 | { 80 | return m_mapFields; 81 | } 82 | 83 | std::vector& GetRowsVector() 84 | { 85 | return m_vecRows; 86 | } 87 | private: 88 | std::map m_mapFields; 89 | std::vector m_vecRows; 90 | }; 91 | 92 | 93 | 94 | #endif -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/fbx_export_option_dialog.py: -------------------------------------------------------------------------------- 1 | ''' 2 | FBX 导出选项设置窗 3 | ''' 4 | 5 | import os 6 | import sys 7 | from pathlib import Path 8 | from functools import partial 9 | 10 | from PySide2 import QtWidgets, QtCore, QtGui 11 | 12 | current_folder = Path(__file__).absolute().parent 13 | father_folder = str(current_folder.parent) 14 | sys.path.append(father_folder) 15 | 16 | from qt_utilities.setting_utility import SettingUtility 17 | from qt_utilities.root_const_mapper import RootConstMapper as RCM 18 | from fbx_res.fbx_export_option_dialog_const_mapper import FbxExportOptionDialogConstMapper as FCM 19 | 20 | 21 | class FbxExportOptionDialog: 22 | 23 | emgr = None 24 | mqt = None 25 | 26 | default_config = [ 27 | FCM.c_export_normal, 28 | FCM.c_export_tangent, 29 | FCM.c_export_uv, 30 | FCM.c_export_uv2, 31 | FCM.c_export_uv3, 32 | ] 33 | widget_dict = {} 34 | 35 | export_config = {} 36 | 37 | 38 | def __init__(self, emgr_): 39 | self.emgr = emgr_ 40 | self.mqt = emgr_.GetMiniQtHelper() 41 | 42 | path, self.settings = SettingUtility.get_tempdir_setting(RCM.setting_preference) 43 | if not os.path.exists(path): 44 | self.refresh_option(0) 45 | pass 46 | 47 | def refresh_option(self, index_): 48 | if hasattr(self, "language"): 49 | language = self.language.itemText(index_) 50 | else: 51 | language = RCM.c_en 52 | self.settings.setValue(RCM.c_language, language) 53 | 54 | # 刷新ui显示 55 | if hasattr(self, "language_label"): 56 | self.mqt.SetWidgetText(self.language_label, FCM.get_text(FCM.c_language)) 57 | 58 | for key, widget in self.widget_dict.items(): 59 | self.mqt.SetWidgetText(widget.label, FCM.get_text(key)) 60 | pass 61 | 62 | def init_ui(self): 63 | # 这里暂时没找到动态修改的方法,全靠每次重启了 64 | self.widget = self.mqt.CreateToplevelWidget(FCM.get_text(FCM.c_dialog_title), None) 65 | 66 | # 语言选项 67 | language_container = self.mqt.CreateHorizontalContainer() 68 | 69 | self.language_label = self.mqt.CreateLabel() 70 | self.mqt.SetWidgetText(self.language_label, FCM.get_text(FCM.c_language)) 71 | 72 | self.language = QtWidgets.QComboBox() 73 | self.language.addItems([RCM.c_en, RCM.c_cn]) 74 | self.language.setCurrentText(self.settings.value(RCM.c_language, RCM.c_en)) 75 | self.language.currentIndexChanged.connect(self.refresh_option) 76 | 77 | self.mqt.AddWidget(language_container, self.language_label) 78 | self.mqt.AddWidget(language_container, self.language) 79 | self.mqt.AddWidget(self.widget, language_container) 80 | 81 | # 创建勾选项 82 | for key in self.default_config: 83 | widget = self.option_widget(key) 84 | self.mqt.AddWidget(self.widget, widget) 85 | self.widget_dict[key] = widget 86 | 87 | self.mqt.SetWidgetText(widget.label, FCM.get_text(key)) 88 | self.mqt.SetWidgetChecked(widget.edit, True) 89 | 90 | # 按钮 91 | button_container = self.mqt.CreateHorizontalContainer() 92 | 93 | callback = lambda *args: self.mqt.CloseCurrentDialog(False) 94 | cancel_button = self.mqt.CreateButton(callback) 95 | self.mqt.SetWidgetText(cancel_button, FCM.get_text(FCM.c_cancel)) 96 | 97 | ok_button = self.mqt.CreateButton(self.button_accept) 98 | self.mqt.SetWidgetText(ok_button, FCM.get_text(FCM.c_ok)) 99 | 100 | self.mqt.AddWidget(button_container, cancel_button) 101 | self.mqt.AddWidget(button_container, ok_button) 102 | self.mqt.AddWidget(self.widget, button_container) 103 | 104 | return self.widget 105 | 106 | #选项的组件 107 | def option_widget(self, key_): 108 | container = self.mqt.CreateHorizontalContainer() 109 | 110 | label = self.mqt.CreateLabel() 111 | edit = self.mqt.CreateCheckbox(partial(self.option_change, key_)) 112 | 113 | self.mqt.AddWidget(container, label) 114 | self.mqt.AddWidget(container, edit) 115 | 116 | container.label = label 117 | container.edit = edit 118 | 119 | return container 120 | 121 | #选项修改时 122 | def option_change(self, key_, context_, widget_, text_): 123 | pass 124 | 125 | #按钮确认 126 | def button_accept(self, context_, widget_, text_): 127 | for key, widget in self.widget_dict.items(): 128 | value = self.mqt.IsWidgetChecked(widget.edit) 129 | self.export_config[key] = value 130 | 131 | self.mqt.CloseCurrentDialog(True) 132 | pass 133 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/RenderdocCSVToFBX.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {32b66845-400b-47ad-a69f-4a52cdac7cb1} 25 | RenderdocCSVToFBX 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | D:\Program Files\Autodesk\FBX\FBX SDK\2020.3.2\include;$(IncludePath) 75 | D:\Program Files\Autodesk\FBX\FBX SDK\2020.3.2\lib\vs2019\x64\debug;$(LibraryPath) 76 | 77 | 78 | D:\Program Files\Autodesk\FBX\FBX SDK\2020.3.2\include;$(IncludePath) 79 | D:\Program Files\Autodesk\FBX\FBX SDK\2020.3.2\lib\vs2019\x64\release;$(LibraryPath) 80 | 81 | 82 | 83 | Level3 84 | true 85 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 86 | true 87 | 88 | 89 | Console 90 | true 91 | 92 | 93 | 94 | 95 | Level3 96 | true 97 | true 98 | true 99 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 100 | true 101 | 102 | 103 | Console 104 | true 105 | true 106 | true 107 | 108 | 109 | 110 | 111 | Level3 112 | true 113 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 114 | true 115 | 116 | 117 | Console 118 | true 119 | libfbxsdk.lib;%(AdditionalDependencies) 120 | 121 | 122 | 123 | 124 | Level3 125 | true 126 | true 127 | true 128 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 129 | true 130 | 131 | 132 | Console 133 | true 134 | true 135 | true 136 | libfbxsdk.lib;%(AdditionalDependencies) 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/RenderdocCSVToFBX.cpp: -------------------------------------------------------------------------------- 1 | // RenderdocCSVToFBX.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 2 | // 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "CSVFile.h" 10 | #include "CommonMath.h" 11 | 12 | using namespace std; 13 | 14 | struct MeshVertex 15 | { 16 | float x, y, z; 17 | 18 | float nx, ny, nz; 19 | float tx, ty, tz, tw; 20 | 21 | float u, v; 22 | float u2, v2; 23 | float u3, v3; 24 | }; 25 | 26 | void ConvertCSV2FBX(const char* sourceCSVFile, 27 | bool export_normal, bool export_tangent, 28 | bool export_uv, bool export_uv2, bool export_uv3) 29 | { 30 | FbxManager* sdkManager; 31 | FbxIOSettings* ioSettings; 32 | FbxScene* scene; 33 | 34 | sdkManager = FbxManager::Create(); 35 | 36 | ioSettings = FbxIOSettings::Create(sdkManager, IOSROOT); 37 | ioSettings->SetBoolProp(EXP_FBX_MATERIAL, true); 38 | ioSettings->SetBoolProp(EXP_FBX_TEXTURE, true); 39 | ioSettings->SetBoolProp(EXP_FBX_EMBEDDED, true); 40 | ioSettings->SetBoolProp(EXP_FBX_ANIMATION, true); 41 | ioSettings->SetBoolProp(EXP_FBX_SHAPE, true); 42 | ioSettings->SetIntProp( 43 | EXP_FBX_EXPORT_FILE_VERSION, FBX_FILE_VERSION_7400); 44 | 45 | sdkManager->SetIOSettings(ioSettings); 46 | scene = FbxScene::Create(sdkManager, ""); 47 | 48 | CCSVFile* pSrcFile = new CCSVFile(sourceCSVFile); 49 | 50 | std::map verticsMap; 51 | int iVertexID = 0; 52 | for (int iRow = 0; iRow < pSrcFile->GetRowNum(); iRow++) 53 | { 54 | pSrcFile->GetCellValue("IDX", iRow, iVertexID); 55 | 56 | if (verticsMap.find(iVertexID) == verticsMap.end()) 57 | { 58 | pSrcFile->GetCellValue("POSITION.x", iRow, verticsMap[iVertexID].x); 59 | pSrcFile->GetCellValue("POSITION.y", iRow, verticsMap[iVertexID].y); 60 | pSrcFile->GetCellValue("POSITION.z", iRow, verticsMap[iVertexID].z); 61 | 62 | if(export_normal) 63 | { 64 | pSrcFile->GetCellValue("NORMAL.x", iRow, verticsMap[iVertexID].nx); 65 | pSrcFile->GetCellValue("NORMAL.y", iRow, verticsMap[iVertexID].ny); 66 | pSrcFile->GetCellValue("NORMAL.z", iRow, verticsMap[iVertexID].nz); 67 | } 68 | if(export_tangent) 69 | { 70 | pSrcFile->GetCellValue("TANGENT.x", iRow, verticsMap[iVertexID].tx); 71 | pSrcFile->GetCellValue("TANGENT.y", iRow, verticsMap[iVertexID].ty); 72 | pSrcFile->GetCellValue("TANGENT.z", iRow, verticsMap[iVertexID].tz); 73 | pSrcFile->GetCellValue("TANGENT.w", iRow, verticsMap[iVertexID].tw); 74 | } 75 | 76 | if(export_uv) 77 | { 78 | pSrcFile->GetCellValue("TEXCOORD0.x", iRow, verticsMap[iVertexID].u); 79 | pSrcFile->GetCellValue("TEXCOORD0.y", iRow, verticsMap[iVertexID].v); 80 | } 81 | if(export_uv2) 82 | { 83 | pSrcFile->GetCellValue("TEXCOORD1.x", iRow, verticsMap[iVertexID].u2); 84 | pSrcFile->GetCellValue("TEXCOORD1.y", iRow, verticsMap[iVertexID].v2); 85 | } 86 | if(export_uv3) 87 | { 88 | pSrcFile->GetCellValue("TEXCOORD2.x", iRow, verticsMap[iVertexID].u3); 89 | pSrcFile->GetCellValue("TEXCOORD2.y", iRow, verticsMap[iVertexID].v3); 90 | } 91 | } 92 | } 93 | 94 | int iTotalVerticsCount = verticsMap.size(); 95 | 96 | // 用csv的文件名作为mesh的名字 97 | std::string meshName = sourceCSVFile; 98 | replace(meshName.begin(), meshName.end(), '/', '\\'); 99 | meshName = meshName.substr(0, meshName.size() - 4); 100 | int pos = meshName.find_last_of('\\'); 101 | if (pos != std::string::npos) 102 | { 103 | meshName = meshName.substr(pos + 1, meshName.size() - pos - 1); 104 | } 105 | 106 | FbxNode* rootNode = scene->GetRootNode(); 107 | FbxNode* subshapeNode = FbxNode::Create(rootNode, meshName.c_str()); 108 | 109 | // convert fbx mesh file 110 | FbxMesh* meshFbx = FbxMesh::Create(subshapeNode, subshapeNode->GetName()); 111 | 112 | FbxGeometryElementNormal* meshNormal = NULL; 113 | FbxGeometryElementTangent* meshTangent = NULL; 114 | FbxGeometryElementUV* meshUV = NULL; 115 | FbxGeometryElementUV* meshUV2 = NULL; 116 | FbxGeometryElementUV* meshUV3 = NULL; 117 | 118 | if(export_normal) 119 | { 120 | meshNormal = meshFbx->CreateElementNormal(); 121 | } 122 | if(export_tangent) 123 | { 124 | meshTangent = meshFbx->CreateElementTangent(); 125 | } 126 | 127 | if(export_uv) 128 | { 129 | meshUV = meshFbx->CreateElementUV("UV"); 130 | } 131 | if(export_uv2) 132 | { 133 | meshUV2 = meshFbx->CreateElementUV("UV1"); 134 | } 135 | if(export_uv3) 136 | { 137 | meshUV3 = meshFbx->CreateElementUV("UV2"); 138 | } 139 | 140 | meshFbx->InitControlPoints(iTotalVerticsCount); 141 | 142 | if(export_normal) 143 | { 144 | meshNormal->SetMappingMode(FbxGeometryElementNormal::eByControlPoint); 145 | meshNormal->SetReferenceMode(FbxGeometryElementNormal::eDirect); 146 | } 147 | if(export_tangent) 148 | { 149 | meshTangent->SetMappingMode(FbxGeometryElementTangent::eByControlPoint); 150 | meshTangent->SetReferenceMode(FbxGeometryElementTangent::eDirect); 151 | } 152 | 153 | if(export_uv) 154 | { 155 | meshUV->SetMappingMode(FbxGeometryElementUV::eByControlPoint); 156 | meshUV->SetReferenceMode(FbxGeometryElementUV::eDirect); 157 | } 158 | if(export_uv2) 159 | { 160 | meshUV2->SetMappingMode(FbxGeometryElementUV::eByControlPoint); 161 | meshUV2->SetReferenceMode(FbxGeometryElementUV::eDirect); 162 | } 163 | if(export_uv3) 164 | { 165 | meshUV3->SetMappingMode(FbxGeometryElementUV::eByControlPoint); 166 | meshUV3->SetReferenceMode(FbxGeometryElementUV::eDirect); 167 | } 168 | 169 | FbxVector4* meshVectors = meshFbx->GetControlPoints(); 170 | Matrix44 matRot; 171 | MatrixRotationZ(&matRot, -FLT_DTOR(0)); 172 | 173 | for (int index = 0; index < verticsMap.size(); index++) 174 | { 175 | Vector3 Vertex( 176 | verticsMap[index].x * 100, verticsMap[index].y * 100, verticsMap[index].z * 100); 177 | Vec3TransformCoord(&Vertex, &Vertex, &matRot); 178 | meshVectors[index].Set(Vertex.x, Vertex.y, Vertex.z); 179 | 180 | if(export_normal) 181 | { 182 | Vector3 VertexNormal( 183 | verticsMap[index].nx, verticsMap[index].ny, verticsMap[index].nz); 184 | Vec3TransformNormal(&VertexNormal, &VertexNormal, &matRot); 185 | 186 | meshNormal->GetDirectArray().Add( 187 | FbxVector4(VertexNormal.x, VertexNormal.y, VertexNormal.z, 0)); 188 | } 189 | if(export_tangent) 190 | { 191 | Vector4 VertexTangent( 192 | verticsMap[index].tx, verticsMap[index].ty, verticsMap[index].tz, verticsMap[index].tw); 193 | VertexTangent = VertexTangent * matRot; 194 | 195 | meshTangent->GetDirectArray().Add( 196 | FbxVector4(VertexTangent.x, VertexTangent.y, VertexTangent.z, VertexTangent.w)); 197 | } 198 | 199 | if(export_uv) 200 | { 201 | meshUV->GetDirectArray().Add( 202 | FbxVector2(verticsMap[index].u, verticsMap[index].v)); 203 | } 204 | if(export_uv2) 205 | { 206 | meshUV2->GetDirectArray().Add( 207 | FbxVector2(verticsMap[index].u2, verticsMap[index].v2)); 208 | } 209 | if(export_uv3) 210 | { 211 | meshUV3->GetDirectArray().Add( 212 | FbxVector2(verticsMap[index].u3, verticsMap[index].v3)); 213 | } 214 | } 215 | 216 | int iFaceID = 0; 217 | for (int iRow = 0; iRow < pSrcFile->GetRowNum(); iRow += 3) 218 | { 219 | meshFbx->BeginPolygon(0); 220 | 221 | pSrcFile->GetCellValue("IDX", iRow, iFaceID); 222 | meshFbx->AddPolygon(iFaceID); 223 | pSrcFile->GetCellValue("IDX", iRow + 1, iFaceID); 224 | meshFbx->AddPolygon(iFaceID); 225 | pSrcFile->GetCellValue("IDX", iRow + 2, iFaceID); 226 | meshFbx->AddPolygon(iFaceID); 227 | 228 | meshFbx->EndPolygon(); 229 | } 230 | 231 | subshapeNode->SetNodeAttribute(meshFbx); 232 | subshapeNode->SetShadingMode(FbxNode::eTextureShading); 233 | 234 | // save fbx 235 | std::string fbxFilePath = sourceCSVFile; 236 | fbxFilePath = fbxFilePath.substr(0, fbxFilePath.size() - 3); 237 | fbxFilePath += "fbx"; 238 | 239 | int startIndex = fbxFilePath.find_last_of('\\'); 240 | std::string fileName = fbxFilePath.substr(startIndex + 1); 241 | 242 | FbxExporter* exporter = FbxExporter::Create(sdkManager, fileName.c_str()); 243 | if (!exporter->Initialize(fbxFilePath.c_str(), -1, ioSettings)) 244 | { 245 | fprintf(stderr, "Failed to initialize FBX exporter\n"); 246 | exporter->Destroy(); 247 | return; 248 | } 249 | exporter->SetFileExportVersion(FBX_2014_00_COMPATIBLE); 250 | 251 | if (!exporter->Export(scene)) 252 | { 253 | fprintf(stderr, "Failed to produce FBX file\n"); 254 | exporter->Destroy(); 255 | return; 256 | } 257 | 258 | exporter->Destroy(); 259 | } 260 | 261 | int main(int argc, char* argv[]) 262 | { 263 | bool export_normal = false; 264 | bool export_tangent = false; 265 | bool export_uv = false; 266 | bool export_uv2 = false; 267 | bool export_uv3 = false; 268 | 269 | if (strncmp(argv[2], "1", 1) == 0) 270 | { 271 | export_normal = true; 272 | } 273 | if (strncmp(argv[3], "1", 1) == 0) 274 | { 275 | export_tangent = true; 276 | } 277 | if (strncmp(argv[4], "1", 1) == 0) 278 | { 279 | export_uv = true; 280 | } 281 | if (strncmp(argv[5], "1", 1) == 0) 282 | { 283 | export_uv2 = true; 284 | } 285 | if (strncmp(argv[6], "1", 1) == 0) 286 | { 287 | export_uv3 = true; 288 | } 289 | 290 | ConvertCSV2FBX(argv[1], 291 | export_normal, export_tangent, 292 | export_uv, export_uv2, export_uv3); 293 | } 294 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/unchecked.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Nemanja Trifunovic 2 | 3 | /* 4 | Permission is hereby granted, free of charge, to any person or organization 5 | obtaining a copy of the software and accompanying documentation covered by 6 | this license (the "Software") to use, reproduce, display, distribute, 7 | execute, and transmit the Software, and to prepare derivative works of the 8 | Software, and to permit third-parties to whom the Software is furnished to 9 | do so, all subject to the following: 10 | 11 | The copyright notices in the Software and this entire statement, including 12 | the above license grant, this restriction and the following disclaimer, 13 | must be included in all copies of the Software, in whole or in part, and 14 | all derivative works of the Software, unless such copies or derivative 15 | works are solely in the form of machine-executable object code generated by 16 | a source language processor. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 21 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 22 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 23 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | 28 | #ifndef UTF8_FOR_CPP_UNCHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731 29 | #define UTF8_FOR_CPP_UNCHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731 30 | 31 | #include "core.h" 32 | 33 | namespace core_utf8 34 | { 35 | namespace unchecked 36 | { 37 | template 38 | octet_iterator append(uint32_t cp, octet_iterator result) 39 | { 40 | if (cp < 0x80) // one octet 41 | *(result++) = static_cast(cp); 42 | else if (cp < 0x800) { // two octets 43 | *(result++) = static_cast((cp >> 6) | 0xc0); 44 | *(result++) = static_cast((cp & 0x3f) | 0x80); 45 | } 46 | else if (cp < 0x10000) { // three octets 47 | *(result++) = static_cast((cp >> 12) | 0xe0); 48 | *(result++) = static_cast(((cp >> 6) & 0x3f) | 0x80); 49 | *(result++) = static_cast((cp & 0x3f) | 0x80); 50 | } 51 | else { // four octets 52 | *(result++) = static_cast((cp >> 18) | 0xf0); 53 | *(result++) = static_cast(((cp >> 12) & 0x3f)| 0x80); 54 | *(result++) = static_cast(((cp >> 6) & 0x3f) | 0x80); 55 | *(result++) = static_cast((cp & 0x3f) | 0x80); 56 | } 57 | return result; 58 | } 59 | 60 | template 61 | uint32_t next(octet_iterator& it) 62 | { 63 | uint32_t cp = core_utf8::internal::mask8(*it); 64 | typename std::iterator_traits::difference_type length = core_utf8::internal::sequence_length(it); 65 | switch (length) { 66 | case 1: 67 | break; 68 | case 2: 69 | it++; 70 | cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f); 71 | break; 72 | case 3: 73 | ++it; 74 | cp = ((cp << 12) & 0xffff) + ((core_utf8::internal::mask8(*it) << 6) & 0xfff); 75 | ++it; 76 | cp += (*it) & 0x3f; 77 | break; 78 | case 4: 79 | ++it; 80 | cp = ((cp << 18) & 0x1fffff) + ((core_utf8::internal::mask8(*it) << 12) & 0x3ffff); 81 | ++it; 82 | cp += (core_utf8::internal::mask8(*it) << 6) & 0xfff; 83 | ++it; 84 | cp += (*it) & 0x3f; 85 | break; 86 | } 87 | ++it; 88 | return cp; 89 | } 90 | 91 | template 92 | uint32_t peek_next(octet_iterator it) 93 | { 94 | return core_utf8::unchecked::next(it); 95 | } 96 | 97 | template 98 | uint32_t prior(octet_iterator& it) 99 | { 100 | while (core_utf8::internal::is_trail(*(--it))) ; 101 | octet_iterator temp = it; 102 | return core_utf8::unchecked::next(temp); 103 | } 104 | 105 | // Deprecated in versions that include prior, but only for the sake of consistency (see core_utf8::previous) 106 | template 107 | inline uint32_t previous(octet_iterator& it) 108 | { 109 | return core_utf8::unchecked::prior(it); 110 | } 111 | 112 | template 113 | void advance (octet_iterator& it, distance_type n) 114 | { 115 | for (distance_type i = 0; i < n; ++i) 116 | core_utf8::unchecked::next(it); 117 | } 118 | 119 | template 120 | typename std::iterator_traits::difference_type 121 | distance (octet_iterator first, octet_iterator last) 122 | { 123 | typename std::iterator_traits::difference_type dist; 124 | for (dist = 0; first < last; ++dist) 125 | core_utf8::unchecked::next(first); 126 | return dist; 127 | } 128 | 129 | template 130 | octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result) 131 | { 132 | while (start != end) { 133 | uint32_t cp = core_utf8::internal::mask16(*start++); 134 | // Take care of surrogate pairs first 135 | if (core_utf8::internal::is_lead_surrogate(cp)) { 136 | uint32_t trail_surrogate = core_utf8::internal::mask16(*start++); 137 | cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET; 138 | } 139 | result = core_utf8::unchecked::append(cp, result); 140 | } 141 | return result; 142 | } 143 | 144 | template 145 | u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result) 146 | { 147 | while (start < end) { 148 | uint32_t cp = core_utf8::unchecked::next(start); 149 | if (cp > 0xffff) { //make a surrogate pair 150 | *result++ = static_cast((cp >> 10) + internal::LEAD_OFFSET); 151 | *result++ = static_cast((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN); 152 | } 153 | else 154 | *result++ = static_cast(cp); 155 | } 156 | return result; 157 | } 158 | 159 | template 160 | octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result) 161 | { 162 | while (start != end) 163 | result = core_utf8::unchecked::append(*(start++), result); 164 | 165 | return result; 166 | } 167 | 168 | template 169 | u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result) 170 | { 171 | while (start < end) 172 | (*result++) = core_utf8::unchecked::next(start); 173 | 174 | return result; 175 | } 176 | 177 | // The iterator class 178 | template 179 | class iterator : public std::iterator { 180 | octet_iterator it; 181 | public: 182 | iterator () {} 183 | explicit iterator (const octet_iterator& octet_it): it(octet_it) {} 184 | // the default "big three" are OK 185 | octet_iterator base () const { return it; } 186 | uint32_t operator * () const 187 | { 188 | octet_iterator temp = it; 189 | return core_utf8::unchecked::next(temp); 190 | } 191 | bool operator == (const iterator& rhs) const 192 | { 193 | return (it == rhs.it); 194 | } 195 | bool operator != (const iterator& rhs) const 196 | { 197 | return !(operator == (rhs)); 198 | } 199 | iterator& operator ++ () 200 | { 201 | ::std::advance(it, core_utf8::internal::sequence_length(it)); 202 | return *this; 203 | } 204 | iterator operator ++ (int) 205 | { 206 | iterator temp = *this; 207 | ::std::advance(it, core_utf8::internal::sequence_length(it)); 208 | return temp; 209 | } 210 | iterator& operator -- () 211 | { 212 | core_utf8::unchecked::prior(it); 213 | return *this; 214 | } 215 | iterator operator -- (int) 216 | { 217 | iterator temp = *this; 218 | core_utf8::unchecked::prior(it); 219 | return temp; 220 | } 221 | }; // class iterator 222 | 223 | } // namespace core_utf8::unchecked 224 | } // namespace utf8 225 | 226 | 227 | #endif // header guard 228 | 229 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/core.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Nemanja Trifunovic 2 | 3 | /* 4 | Permission is hereby granted, free of charge, to any person or organization 5 | obtaining a copy of the software and accompanying documentation covered by 6 | this license (the "Software") to use, reproduce, display, distribute, 7 | execute, and transmit the Software, and to prepare derivative works of the 8 | Software, and to permit third-parties to whom the Software is furnished to 9 | do so, all subject to the following: 10 | 11 | The copyright notices in the Software and this entire statement, including 12 | the above license grant, this restriction and the following disclaimer, 13 | must be included in all copies of the Software, in whole or in part, and 14 | all derivative works of the Software, unless such copies or derivative 15 | works are solely in the form of machine-executable object code generated by 16 | a source language processor. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 21 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 22 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 23 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | 28 | #ifndef UTF8_FOR_CPP_CORE_H_2675DCD0_9480_4c0c_B92A_CC14C027B731 29 | #define UTF8_FOR_CPP_CORE_H_2675DCD0_9480_4c0c_B92A_CC14C027B731 30 | 31 | #include 32 | 33 | namespace core_utf8 34 | { 35 | // The typedefs for 8-bit, 16-bit and 32-bit unsigned integers 36 | // You may need to change them to match your system. 37 | // These typedefs have the same names as ones from cstdint, or boost/cstdint 38 | typedef unsigned char uint8_t; 39 | typedef unsigned short uint16_t; 40 | typedef unsigned int uint32_t; 41 | 42 | // Helper code - not intended to be directly called by the library users. May be changed at any time 43 | namespace internal 44 | { 45 | // Unicode constants 46 | // Leading (high) surrogates: 0xd800 - 0xdbff 47 | // Trailing (low) surrogates: 0xdc00 - 0xdfff 48 | const uint16_t LEAD_SURROGATE_MIN = 0xd800u; 49 | const uint16_t LEAD_SURROGATE_MAX = 0xdbffu; 50 | const uint16_t TRAIL_SURROGATE_MIN = 0xdc00u; 51 | const uint16_t TRAIL_SURROGATE_MAX = 0xdfffu; 52 | const uint16_t LEAD_OFFSET = LEAD_SURROGATE_MIN - (0x10000 >> 10); 53 | const uint32_t SURROGATE_OFFSET = 0x10000u - (LEAD_SURROGATE_MIN << 10) - TRAIL_SURROGATE_MIN; 54 | 55 | // Maximum valid value for a Unicode code point 56 | const uint32_t CODE_POINT_MAX = 0x0010ffffu; 57 | 58 | template 59 | inline uint8_t mask8(octet_type oc) 60 | { 61 | return static_cast(0xff & oc); 62 | } 63 | template 64 | inline uint16_t mask16(u16_type oc) 65 | { 66 | return static_cast(0xffff & oc); 67 | } 68 | template 69 | inline bool is_trail(octet_type oc) 70 | { 71 | return ((core_utf8::internal::mask8(oc) >> 6) == 0x2); 72 | } 73 | 74 | template 75 | inline bool is_lead_surrogate(u16 cp) 76 | { 77 | return (cp >= LEAD_SURROGATE_MIN && cp <= LEAD_SURROGATE_MAX); 78 | } 79 | 80 | template 81 | inline bool is_trail_surrogate(u16 cp) 82 | { 83 | return (cp >= TRAIL_SURROGATE_MIN && cp <= TRAIL_SURROGATE_MAX); 84 | } 85 | 86 | template 87 | inline bool is_surrogate(u16 cp) 88 | { 89 | return (cp >= LEAD_SURROGATE_MIN && cp <= TRAIL_SURROGATE_MAX); 90 | } 91 | 92 | template 93 | inline bool is_code_point_valid(u32 cp) 94 | { 95 | return (cp <= CODE_POINT_MAX && !core_utf8::internal::is_surrogate(cp)); 96 | } 97 | 98 | template 99 | inline typename std::iterator_traits::difference_type 100 | sequence_length(octet_iterator lead_it) 101 | { 102 | uint8_t lead = core_utf8::internal::mask8(*lead_it); 103 | if (lead < 0x80) 104 | return 1; 105 | else if ((lead >> 5) == 0x6) 106 | return 2; 107 | else if ((lead >> 4) == 0xe) 108 | return 3; 109 | else if ((lead >> 3) == 0x1e) 110 | return 4; 111 | else 112 | return 0; 113 | } 114 | 115 | template 116 | inline bool is_overlong_sequence(uint32_t cp, octet_difference_type length) 117 | { 118 | if (cp < 0x80) { 119 | if (length != 1) 120 | return true; 121 | } 122 | else if (cp < 0x800) { 123 | if (length != 2) 124 | return true; 125 | } 126 | else if (cp < 0x10000) { 127 | if (length != 3) 128 | return true; 129 | } 130 | 131 | return false; 132 | } 133 | 134 | enum utf_error {UTF8_OK, NOT_ENOUGH_ROOM, INVALID_LEAD, INCOMPLETE_SEQUENCE, OVERLONG_SEQUENCE, INVALID_CODE_POINT}; 135 | 136 | /// Helper for get_sequence_x 137 | template 138 | utf_error increase_safely(octet_iterator& it, octet_iterator end) 139 | { 140 | if (++it == end) 141 | return NOT_ENOUGH_ROOM; 142 | 143 | if (!core_utf8::internal::is_trail(*it)) 144 | return INCOMPLETE_SEQUENCE; 145 | 146 | return UTF8_OK; 147 | } 148 | 149 | #define UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(IT, END) {utf_error ret = increase_safely(IT, END); if (ret != UTF8_OK) return ret;} 150 | 151 | /// get_sequence_x functions decode utf-8 sequences of the length x 152 | template 153 | utf_error get_sequence_1(octet_iterator& it, octet_iterator end, uint32_t& code_point) 154 | { 155 | if (it == end) 156 | return NOT_ENOUGH_ROOM; 157 | 158 | code_point = core_utf8::internal::mask8(*it); 159 | 160 | return UTF8_OK; 161 | } 162 | 163 | template 164 | utf_error get_sequence_2(octet_iterator& it, octet_iterator end, uint32_t& code_point) 165 | { 166 | if (it == end) 167 | return NOT_ENOUGH_ROOM; 168 | 169 | code_point = core_utf8::internal::mask8(*it); 170 | 171 | UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) 172 | 173 | code_point = ((code_point << 6) & 0x7ff) + ((*it) & 0x3f); 174 | 175 | return UTF8_OK; 176 | } 177 | 178 | template 179 | utf_error get_sequence_3(octet_iterator& it, octet_iterator end, uint32_t& code_point) 180 | { 181 | if (it == end) 182 | return NOT_ENOUGH_ROOM; 183 | 184 | code_point = core_utf8::internal::mask8(*it); 185 | 186 | UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) 187 | 188 | code_point = ((code_point << 12) & 0xffff) + ((core_utf8::internal::mask8(*it) << 6) & 0xfff); 189 | 190 | UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) 191 | 192 | code_point += (*it) & 0x3f; 193 | 194 | return UTF8_OK; 195 | } 196 | 197 | template 198 | utf_error get_sequence_4(octet_iterator& it, octet_iterator end, uint32_t& code_point) 199 | { 200 | if (it == end) 201 | return NOT_ENOUGH_ROOM; 202 | 203 | code_point = core_utf8::internal::mask8(*it); 204 | 205 | UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) 206 | 207 | code_point = ((code_point << 18) & 0x1fffff) + ((core_utf8::internal::mask8(*it) << 12) & 0x3ffff); 208 | 209 | UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) 210 | 211 | code_point += (core_utf8::internal::mask8(*it) << 6) & 0xfff; 212 | 213 | UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) 214 | 215 | code_point += (*it) & 0x3f; 216 | 217 | return UTF8_OK; 218 | } 219 | 220 | #undef UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR 221 | 222 | template 223 | utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t& code_point) 224 | { 225 | // Save the original value of it so we can go back in case of failure 226 | // Of course, it does not make much sense with i.e. stream iterators 227 | octet_iterator original_it = it; 228 | 229 | uint32_t cp = 0; 230 | // Determine the sequence length based on the lead octet 231 | typedef typename std::iterator_traits::difference_type octet_difference_type; 232 | const octet_difference_type length = core_utf8::internal::sequence_length(it); 233 | 234 | // Get trail octets and calculate the code point 235 | utf_error err = UTF8_OK; 236 | switch (length) { 237 | case 0: 238 | return INVALID_LEAD; 239 | case 1: 240 | err = core_utf8::internal::get_sequence_1(it, end, cp); 241 | break; 242 | case 2: 243 | err = core_utf8::internal::get_sequence_2(it, end, cp); 244 | break; 245 | case 3: 246 | err = core_utf8::internal::get_sequence_3(it, end, cp); 247 | break; 248 | case 4: 249 | err = core_utf8::internal::get_sequence_4(it, end, cp); 250 | break; 251 | } 252 | 253 | if (err == UTF8_OK) { 254 | // Decoding succeeded. Now, security checks... 255 | if (core_utf8::internal::is_code_point_valid(cp)) { 256 | if (!core_utf8::internal::is_overlong_sequence(cp, length)){ 257 | // Passed! Return here. 258 | code_point = cp; 259 | ++it; 260 | return UTF8_OK; 261 | } 262 | else 263 | err = OVERLONG_SEQUENCE; 264 | } 265 | else 266 | err = INVALID_CODE_POINT; 267 | } 268 | 269 | // Failure branch - restore the original value of the iterator 270 | it = original_it; 271 | return err; 272 | } 273 | 274 | template 275 | inline utf_error validate_next(octet_iterator& it, octet_iterator end) { 276 | uint32_t ignored; 277 | return core_utf8::internal::validate_next(it, end, ignored); 278 | } 279 | 280 | } // namespace internal 281 | 282 | /// The library API - functions intended to be called by the users 283 | 284 | // Byte order mark 285 | const uint8_t bom[] = {0xef, 0xbb, 0xbf}; 286 | 287 | template 288 | octet_iterator find_invalid(octet_iterator start, octet_iterator end) 289 | { 290 | octet_iterator result = start; 291 | while (result != end) { 292 | core_utf8::internal::utf_error err_code = core_utf8::internal::validate_next(result, end); 293 | if (err_code != internal::UTF8_OK) 294 | return result; 295 | } 296 | return result; 297 | } 298 | 299 | template 300 | inline bool is_valid(octet_iterator start, octet_iterator end) 301 | { 302 | return (core_utf8::find_invalid(start, end) == end); 303 | } 304 | 305 | template 306 | inline bool starts_with_bom (octet_iterator it, octet_iterator end) 307 | { 308 | return ( 309 | ((it != end) && (core_utf8::internal::mask8(*it++)) == bom[0]) && 310 | ((it != end) && (core_utf8::internal::mask8(*it++)) == bom[1]) && 311 | ((it != end) && (core_utf8::internal::mask8(*it)) == bom[2]) 312 | ); 313 | } 314 | 315 | //Deprecated in release 2.3 316 | template 317 | inline bool is_bom (octet_iterator it) 318 | { 319 | return ( 320 | (core_utf8::internal::mask8(*it++)) == bom[0] && 321 | (core_utf8::internal::mask8(*it++)) == bom[1] && 322 | (core_utf8::internal::mask8(*it)) == bom[2] 323 | ); 324 | } 325 | } // namespace utf8 326 | 327 | #endif // header guard 328 | 329 | 330 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/checked.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Nemanja Trifunovic 2 | 3 | /* 4 | Permission is hereby granted, free of charge, to any person or organization 5 | obtaining a copy of the software and accompanying documentation covered by 6 | this license (the "Software") to use, reproduce, display, distribute, 7 | execute, and transmit the Software, and to prepare derivative works of the 8 | Software, and to permit third-parties to whom the Software is furnished to 9 | do so, all subject to the following: 10 | 11 | The copyright notices in the Software and this entire statement, including 12 | the above license grant, this restriction and the following disclaimer, 13 | must be included in all copies of the Software, in whole or in part, and 14 | all derivative works of the Software, unless such copies or derivative 15 | works are solely in the form of machine-executable object code generated by 16 | a source language processor. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 21 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 22 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 23 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | 28 | #ifndef UTF8_FOR_CPP_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731 29 | #define UTF8_FOR_CPP_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731 30 | 31 | #include "core.h" 32 | #include 33 | 34 | namespace core_utf8 35 | { 36 | // Base for the exceptions that may be thrown from the library 37 | class exception : public ::std::exception { 38 | }; 39 | 40 | // Exceptions that may be thrown from the library functions. 41 | class invalid_code_point : public exception { 42 | uint32_t cp; 43 | public: 44 | invalid_code_point(uint32_t cp) : cp(cp) {} 45 | virtual const char* what() const throw() { return "Invalid code point"; } 46 | uint32_t code_point() const {return cp;} 47 | }; 48 | 49 | class invalid_utf8 : public exception { 50 | uint8_t u8; 51 | public: 52 | invalid_utf8 (uint8_t u) : u8(u) {} 53 | virtual const char* what() const throw() { return "Invalid UTF-8"; } 54 | uint8_t utf8_octet() const {return u8;} 55 | }; 56 | 57 | class invalid_utf16 : public exception { 58 | uint16_t u16; 59 | public: 60 | invalid_utf16 (uint16_t u) : u16(u) {} 61 | virtual const char* what() const throw() { return "Invalid UTF-16"; } 62 | uint16_t utf16_word() const {return u16;} 63 | }; 64 | 65 | class not_enough_room : public exception { 66 | public: 67 | virtual const char* what() const throw() { return "Not enough space"; } 68 | }; 69 | 70 | /// The library API - functions intended to be called by the users 71 | 72 | template 73 | octet_iterator append(uint32_t cp, octet_iterator result) 74 | { 75 | if (!core_utf8::internal::is_code_point_valid(cp)) 76 | throw invalid_code_point(cp); 77 | 78 | if (cp < 0x80) // one octet 79 | *(result++) = static_cast(cp); 80 | else if (cp < 0x800) { // two octets 81 | *(result++) = static_cast((cp >> 6) | 0xc0); 82 | *(result++) = static_cast((cp & 0x3f) | 0x80); 83 | } 84 | else if (cp < 0x10000) { // three octets 85 | *(result++) = static_cast((cp >> 12) | 0xe0); 86 | *(result++) = static_cast(((cp >> 6) & 0x3f) | 0x80); 87 | *(result++) = static_cast((cp & 0x3f) | 0x80); 88 | } 89 | else { // four octets 90 | *(result++) = static_cast((cp >> 18) | 0xf0); 91 | *(result++) = static_cast(((cp >> 12) & 0x3f) | 0x80); 92 | *(result++) = static_cast(((cp >> 6) & 0x3f) | 0x80); 93 | *(result++) = static_cast((cp & 0x3f) | 0x80); 94 | } 95 | return result; 96 | } 97 | 98 | template 99 | output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out, uint32_t replacement) 100 | { 101 | while (start != end) { 102 | octet_iterator sequence_start = start; 103 | internal::utf_error err_code = core_utf8::internal::validate_next(start, end); 104 | switch (err_code) { 105 | case internal::UTF8_OK : 106 | for (octet_iterator it = sequence_start; it != start; ++it) 107 | *out++ = *it; 108 | break; 109 | case internal::NOT_ENOUGH_ROOM: 110 | throw not_enough_room(); 111 | case internal::INVALID_LEAD: 112 | out = core_utf8::append (replacement, out); 113 | ++start; 114 | break; 115 | case internal::INCOMPLETE_SEQUENCE: 116 | case internal::OVERLONG_SEQUENCE: 117 | case internal::INVALID_CODE_POINT: 118 | out = core_utf8::append (replacement, out); 119 | ++start; 120 | // just one replacement mark for the sequence 121 | while (start != end && core_utf8::internal::is_trail(*start)) 122 | ++start; 123 | break; 124 | } 125 | } 126 | return out; 127 | } 128 | 129 | template 130 | inline output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out) 131 | { 132 | static const uint32_t replacement_marker = core_utf8::internal::mask16(0xfffd); 133 | return core_utf8::replace_invalid(start, end, out, replacement_marker); 134 | } 135 | 136 | template 137 | uint32_t next(octet_iterator& it, octet_iterator end) 138 | { 139 | uint32_t cp = 0; 140 | internal::utf_error err_code = core_utf8::internal::validate_next(it, end, cp); 141 | switch (err_code) { 142 | case internal::UTF8_OK : 143 | break; 144 | case internal::NOT_ENOUGH_ROOM : 145 | throw not_enough_room(); 146 | case internal::INVALID_LEAD : 147 | case internal::INCOMPLETE_SEQUENCE : 148 | case internal::OVERLONG_SEQUENCE : 149 | throw invalid_utf8(*it); 150 | case internal::INVALID_CODE_POINT : 151 | throw invalid_code_point(cp); 152 | } 153 | return cp; 154 | } 155 | 156 | template 157 | uint32_t peek_next(octet_iterator it, octet_iterator end) 158 | { 159 | return core_utf8::next(it, end); 160 | } 161 | 162 | template 163 | uint32_t prior(octet_iterator& it, octet_iterator start) 164 | { 165 | // can't do much if it == start 166 | if (it == start) 167 | throw not_enough_room(); 168 | 169 | octet_iterator end = it; 170 | // Go back until we hit either a lead octet or start 171 | while (core_utf8::internal::is_trail(*(--it))) 172 | if (it == start) 173 | throw invalid_utf8(*it); // error - no lead byte in the sequence 174 | return core_utf8::peek_next(it, end); 175 | } 176 | 177 | /// Deprecated in versions that include "prior" 178 | template 179 | uint32_t previous(octet_iterator& it, octet_iterator pass_start) 180 | { 181 | octet_iterator end = it; 182 | while (core_utf8::internal::is_trail(*(--it))) 183 | if (it == pass_start) 184 | throw invalid_utf8(*it); // error - no lead byte in the sequence 185 | octet_iterator temp = it; 186 | return core_utf8::next(temp, end); 187 | } 188 | 189 | template 190 | void advance (octet_iterator& it, distance_type n, octet_iterator end) 191 | { 192 | for (distance_type i = 0; i < n; ++i) 193 | core_utf8::next(it, end); 194 | } 195 | 196 | template 197 | typename std::iterator_traits::difference_type 198 | distance (octet_iterator first, octet_iterator last) 199 | { 200 | typename std::iterator_traits::difference_type dist; 201 | for (dist = 0; first < last; ++dist) 202 | core_utf8::next(first, last); 203 | return dist; 204 | } 205 | 206 | template 207 | octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result) 208 | { 209 | while (start != end) { 210 | uint32_t cp = core_utf8::internal::mask16(*start++); 211 | // Take care of surrogate pairs first 212 | if (core_utf8::internal::is_lead_surrogate(cp)) { 213 | if (start != end) { 214 | uint32_t trail_surrogate = core_utf8::internal::mask16(*start++); 215 | if (core_utf8::internal::is_trail_surrogate(trail_surrogate)) 216 | cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET; 217 | else 218 | throw invalid_utf16(static_cast(trail_surrogate)); 219 | } 220 | else 221 | throw invalid_utf16(static_cast(cp)); 222 | 223 | } 224 | // Lone trail surrogate 225 | else if (core_utf8::internal::is_trail_surrogate(cp)) 226 | throw invalid_utf16(static_cast(cp)); 227 | 228 | result = core_utf8::append(cp, result); 229 | } 230 | return result; 231 | } 232 | 233 | template 234 | u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result) 235 | { 236 | while (start != end) { 237 | uint32_t cp = core_utf8::next(start, end); 238 | if (cp > 0xffff) { //make a surrogate pair 239 | *result++ = static_cast((cp >> 10) + internal::LEAD_OFFSET); 240 | *result++ = static_cast((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN); 241 | } 242 | else 243 | *result++ = static_cast(cp); 244 | } 245 | return result; 246 | } 247 | 248 | template 249 | octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result) 250 | { 251 | while (start != end) 252 | result = core_utf8::append(*(start++), result); 253 | 254 | return result; 255 | } 256 | 257 | template 258 | u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result) 259 | { 260 | while (start != end) 261 | (*result++) = core_utf8::next(start, end); 262 | 263 | return result; 264 | } 265 | 266 | // The iterator class 267 | template 268 | class iterator : public std::iterator { 269 | octet_iterator it; 270 | octet_iterator range_start; 271 | octet_iterator range_end; 272 | public: 273 | iterator () {} 274 | explicit iterator (const octet_iterator& octet_it, 275 | const octet_iterator& range_start, 276 | const octet_iterator& range_end) : 277 | it(octet_it), range_start(range_start), range_end(range_end) 278 | { 279 | if (it < range_start || it > range_end) 280 | throw std::out_of_range("Invalid utf-8 iterator position"); 281 | } 282 | // the default "big three" are OK 283 | octet_iterator base () const { return it; } 284 | uint32_t operator * () const 285 | { 286 | octet_iterator temp = it; 287 | return core_utf8::next(temp, range_end); 288 | } 289 | bool operator == (const iterator& rhs) const 290 | { 291 | if (range_start != rhs.range_start || range_end != rhs.range_end) 292 | throw std::logic_error("Comparing utf-8 iterators defined with different ranges"); 293 | return (it == rhs.it); 294 | } 295 | bool operator != (const iterator& rhs) const 296 | { 297 | return !(operator == (rhs)); 298 | } 299 | iterator& operator ++ () 300 | { 301 | core_utf8::next(it, range_end); 302 | return *this; 303 | } 304 | iterator operator ++ (int) 305 | { 306 | iterator temp = *this; 307 | core_utf8::next(it, range_end); 308 | return temp; 309 | } 310 | iterator& operator -- () 311 | { 312 | core_utf8::prior(it, range_start); 313 | return *this; 314 | } 315 | iterator operator -- (int) 316 | { 317 | iterator temp = *this; 318 | core_utf8::prior(it, range_start); 319 | return temp; 320 | } 321 | }; // class iterator 322 | 323 | } // namespace utf8 324 | 325 | #endif //header guard 326 | 327 | 328 | -------------------------------------------------------------------------------- /RenderdocResourceExporter/fbx_res/RenderdocCSVToFBX/RenderdocCSVToFBX/CSVFile.cpp: -------------------------------------------------------------------------------- 1 | #include "CSVFile.h" 2 | #include "FileStream.h" 3 | #include "checked.h" 4 | 5 | inline void StringSplit(std::string& s, const char* delim, std::vector< std::string >& ret) 6 | { 7 | size_t last = 0; 8 | size_t index = s.find_first_of(delim, last); 9 | while (index != std::string::npos) 10 | { 11 | ret.push_back(s.substr(last, index - last)); 12 | last = index + 1; 13 | index = s.find_first_of(delim, last); 14 | } 15 | if (index - last > 0) 16 | { 17 | ret.push_back(s.substr(last, index - last)); 18 | } 19 | } 20 | 21 | void TrimSpace(std::string& strParam) 22 | { 23 | if (strParam.empty()) 24 | return; 25 | 26 | const char* start = strParam.c_str(); 27 | int eraseCount = 0; 28 | while (*start && isspace(*start)) 29 | { 30 | start++; 31 | eraseCount++; 32 | } 33 | if (eraseCount) 34 | strParam = strParam.erase(0, eraseCount); 35 | 36 | eraseCount = 0; 37 | const char* end = strParam.c_str() + strParam.size() - 1; 38 | while (end > start && isspace(*end)) 39 | { 40 | end--; 41 | eraseCount++; 42 | } 43 | if (eraseCount) 44 | strParam = strParam.erase(strParam.size() - eraseCount, eraseCount); 45 | } 46 | 47 | int ConvertUTF8ToUnicode(const char* szUtf8, std::wstring& strOut) 48 | { 49 | std::string utf8Str = szUtf8; 50 | //#ifdef _DEBUG 51 | // std::string::iterator end_it = core_utf8::find_invalid(utf8Str.begin(), utf8Str.end()); 52 | // if (end_it != utf8Str.end()) { 53 | // assert(false); 54 | // } 55 | //#endif 56 | core_utf8::utf8to16(utf8Str.begin(), utf8Str.end(), std::back_inserter(strOut)); 57 | return strOut.size(); 58 | } 59 | 60 | int ConvertUnicodeToUTF8(const wchar_t* srcUniStr, std::string& strOut) 61 | { 62 | std::wstring utf16Str = srcUniStr; 63 | 64 | core_utf8::utf16to8(utf16Str.begin(), utf16Str.end(), std::back_inserter(strOut)); 65 | return strOut.size(); 66 | } 67 | 68 | void TrimQuotes(std::string& strParam) 69 | { 70 | if(strParam.size()>2) 71 | { 72 | if(strParam[0] == '"' && strParam[strParam.size()-1]=='"') 73 | { 74 | strParam = strParam.substr(1,strParam.size()-2); 75 | } 76 | } 77 | } 78 | 79 | void CCSVFileRow::ParseRow(std::string& strLine) 80 | { 81 | StringSplit(strLine,",",m_vecData); 82 | for(int iCol = 0;iColOpen(file,CFileStream::EFILEACCESS_READ) == CFileStream::EFILEOP_OK) 119 | { 120 | std::string strBuffer; 121 | 122 | pFileStream->ReadLine(strBuffer); 123 | 124 | std::vector vecFiledStrings; 125 | StringSplit(strBuffer,",",vecFiledStrings); 126 | 127 | for(int iField = 0;iFieldGetStatus() == CFileStream::EFILEOP_EOS) 136 | break; 137 | 138 | pFileStream->ReadLine(strBuffer); 139 | if(strBuffer.empty()) 140 | continue; 141 | CCSVFileRow row; 142 | m_vecRows.push_back(row); 143 | m_vecRows.back().ParseRow(strBuffer); 144 | } 145 | pFileStream->Close(); 146 | 147 | res = true; 148 | } 149 | 150 | 151 | DestroyFileStream(pFileStream); 152 | 153 | } 154 | else 155 | res = false; 156 | return res; 157 | } 158 | 159 | void CCSVFile::WriteCSVFile(const char* szFileName) 160 | { 161 | #ifndef USE_PACK_FILE 162 | CFileStream* pFileStream = CreateFileStream(); 163 | 164 | if(pFileStream) 165 | { 166 | if(pFileStream->Open(szFileName,CFileStream::EFILEACCESS_WRITE) == CFileStream::EFILEOP_OK) 167 | { 168 | char buf[2048]={0}; 169 | unsigned long dwWrotten = 0; 170 | unsigned long dwLineSize = 0; 171 | 172 | std::vector vecFields; 173 | vecFields.reserve(m_mapFields.size()); 174 | vecFields.resize(m_mapFields.size()); 175 | for(std::map::iterator itr = m_mapFields.begin(); 176 | itr != m_mapFields.end();itr++) 177 | { 178 | vecFields[itr->second] = itr->first; 179 | } 180 | 181 | 182 | for(int iField = 0;iField < vecFields.size() - 1;iField++) 183 | { 184 | strcat_s(buf + dwLineSize ,2048 - dwLineSize,vecFields[iField].c_str()); 185 | dwLineSize += vecFields[iField].size(); 186 | strcat_s(buf + dwLineSize ,2048 - dwLineSize,","); 187 | dwLineSize += 1; 188 | } 189 | 190 | strcat_s(buf + dwLineSize ,2048 - dwLineSize,vecFields.back().c_str()); 191 | dwLineSize += vecFields.back().size(); 192 | strcat_s(buf + dwLineSize ,2048 - dwLineSize,"\n"); 193 | dwLineSize += 1; 194 | 195 | pFileStream->Write(dwLineSize, buf,&dwWrotten); 196 | 197 | 198 | for(int iRow =0;iRow Write(dwLineSize, buf,&dwWrotten); 217 | } 218 | } 219 | 220 | DestroyFileStream(pFileStream); 221 | } 222 | #endif 223 | } 224 | 225 | int CCSVFile::GetRowNum() 226 | { 227 | return m_vecRows.size(); 228 | } 229 | 230 | bool CCSVFile::GetCellValue(const char* fieldName,int rowIndex,std::wstring& resValue) 231 | { 232 | int colIndex = m_mapFields[fieldName]; 233 | if(rowIndex >= m_vecRows.size()) 234 | return false; 235 | if(colIndex >= m_mapFields.size()) 236 | return false; 237 | if(m_vecRows[rowIndex][colIndex] == "null") 238 | resValue.clear(); 239 | else 240 | ConvertUTF8ToUnicode(m_vecRows[rowIndex][colIndex].c_str(),resValue); 241 | 242 | return true; 243 | } 244 | bool CCSVFile::GetCellValue(int colIndex,int rowIndex,std::wstring& resValue) 245 | { 246 | if(rowIndex >= m_vecRows.size()) 247 | return false; 248 | if(colIndex >= m_mapFields.size()) 249 | return false; 250 | if(m_vecRows[rowIndex][colIndex] == "null") 251 | resValue.clear(); 252 | else 253 | ConvertUTF8ToUnicode(m_vecRows[rowIndex][colIndex].c_str(),resValue); 254 | 255 | return true; 256 | } 257 | 258 | bool CCSVFile::GetCellValue(const char* fieldName,int rowIndex,std::string& resValue) 259 | { 260 | 261 | int colIndex = m_mapFields[fieldName]; 262 | if(rowIndex >= m_vecRows.size()) 263 | return false; 264 | if(colIndex >= m_mapFields.size()) 265 | return false; 266 | resValue = m_vecRows[rowIndex][colIndex]; 267 | if(resValue == "null") 268 | resValue.clear(); 269 | return true; 270 | } 271 | bool CCSVFile::GetCellValue(int colIndex,int rowIndex,std::string& resValue) 272 | { 273 | if(rowIndex >= m_vecRows.size()) 274 | return false; 275 | if(colIndex >= m_mapFields.size()) 276 | return false; 277 | resValue = m_vecRows[rowIndex][colIndex]; 278 | if(resValue == "null") 279 | resValue.clear(); 280 | return true; 281 | } 282 | bool CCSVFile::GetCellValue(const char* fieldName,int rowIndex,int& resValue) 283 | { 284 | 285 | int colIndex = m_mapFields[fieldName]; 286 | if(rowIndex >= m_vecRows.size()) 287 | return false; 288 | if(colIndex >= m_mapFields.size()) 289 | return false; 290 | if(m_vecRows[rowIndex][colIndex] == "null") 291 | resValue = 0; 292 | else 293 | resValue = atoi(m_vecRows[rowIndex][colIndex].c_str()); 294 | 295 | return true; 296 | } 297 | bool CCSVFile::GetCellValue(int colIndex,int rowIndex,int& resValue) 298 | { 299 | if(rowIndex >= m_vecRows.size()) 300 | return false; 301 | if(colIndex >= m_mapFields.size()) 302 | return false; 303 | if(m_vecRows[rowIndex][colIndex] == "null") 304 | resValue = 0; 305 | else 306 | resValue = atoi(m_vecRows[rowIndex][colIndex].c_str()); 307 | return true; 308 | } 309 | 310 | bool CCSVFile::GetCellValue(const char* fieldName,int rowIndex,unsigned char& resValue) 311 | { 312 | int colIndex = m_mapFields[fieldName]; 313 | if(rowIndex >= m_vecRows.size()) 314 | return false; 315 | if(colIndex >= m_mapFields.size()) 316 | return false; 317 | if(m_vecRows[rowIndex][colIndex] == "null") 318 | resValue = 0; 319 | else 320 | resValue = atoi(m_vecRows[rowIndex][colIndex].c_str()); 321 | 322 | return true; 323 | } 324 | bool CCSVFile::GetCellValue(int colIndex,int rowIndex,unsigned char& resValue) 325 | { 326 | if(rowIndex >= m_vecRows.size()) 327 | return false; 328 | if(colIndex >= m_mapFields.size()) 329 | return false; 330 | if(m_vecRows[rowIndex][colIndex] == "null") 331 | resValue = 0; 332 | else 333 | resValue = atoi(m_vecRows[rowIndex][colIndex].c_str()); 334 | return true; 335 | } 336 | 337 | 338 | 339 | bool CCSVFile::GetCellValue(const char* fieldName,int rowIndex,float& resValue) 340 | { 341 | int colIndex = m_mapFields[fieldName]; 342 | if(rowIndex >= m_vecRows.size()) 343 | return false; 344 | if(colIndex >= m_mapFields.size()) 345 | return false; 346 | if(m_vecRows[rowIndex][colIndex] == "null") 347 | resValue = 0.0f; 348 | else 349 | resValue = atof(m_vecRows[rowIndex][colIndex].c_str()); 350 | return true; 351 | } 352 | bool CCSVFile::GetCellValue(int colIndex,int rowIndex,float& resValue) 353 | { 354 | if(rowIndex >= m_vecRows.size()) 355 | return false; 356 | if(colIndex >= m_mapFields.size()) 357 | return false; 358 | if(m_vecRows[rowIndex][colIndex] == "null") 359 | resValue = 0.0f; 360 | else 361 | resValue = atof(m_vecRows[rowIndex][colIndex].c_str()); 362 | return true; 363 | } 364 | 365 | bool CCSVFile::GetCellValue(const char* fieldName,int rowIndex,bool& resValue) 366 | { 367 | int colIndex = m_mapFields[fieldName]; 368 | if(rowIndex >= m_vecRows.size()) 369 | return false; 370 | if(colIndex >= m_mapFields.size()) 371 | return false; 372 | if(m_vecRows[rowIndex][colIndex] == "null" || m_vecRows[rowIndex][colIndex] == "FALSE" ||m_vecRows[rowIndex][colIndex] == "false") 373 | resValue = false; 374 | else 375 | resValue = true; 376 | return true; 377 | } 378 | bool CCSVFile::GetCellValue(int colIndex,int rowIndex,bool& resValue) 379 | { 380 | if(rowIndex >= m_vecRows.size()) 381 | return false; 382 | if(colIndex >= m_mapFields.size()) 383 | return false; 384 | if(m_vecRows[rowIndex][colIndex] == "null" || m_vecRows[rowIndex][colIndex] == "FALSE" ||m_vecRows[rowIndex][colIndex] == "false") 385 | resValue = false; 386 | else 387 | resValue = true; 388 | return true; 389 | } 390 | 391 | bool CCSVFile::SetCellValue(const char* fieldName,int rowIndex,std::wstring& resValue) 392 | { 393 | int colIndex = m_mapFields[fieldName]; 394 | if(rowIndex >= m_vecRows.size()) 395 | return false; 396 | if(colIndex >= m_mapFields.size()) 397 | return false; 398 | if(resValue.empty()) 399 | m_vecRows[rowIndex][colIndex] = "null"; 400 | else 401 | { 402 | m_vecRows[rowIndex][colIndex].clear(); 403 | ConvertUnicodeToUTF8(resValue.c_str(),m_vecRows[rowIndex][colIndex]); 404 | } 405 | 406 | return true; 407 | } 408 | bool CCSVFile::SetCellValue(int colIndex,int rowIndex,std::wstring& resValue) 409 | { 410 | if(rowIndex >= m_vecRows.size()) 411 | return false; 412 | if(colIndex >= m_mapFields.size()) 413 | return false; 414 | if(resValue.empty()) 415 | m_vecRows[rowIndex][colIndex] = "null"; 416 | else 417 | { 418 | m_vecRows[rowIndex][colIndex].clear(); 419 | ConvertUnicodeToUTF8(resValue.c_str(),m_vecRows[rowIndex][colIndex]); 420 | } 421 | return true; 422 | } 423 | 424 | bool CCSVFile::SetCellValue(const char* fieldName,int rowIndex,std::string& resValue) 425 | { 426 | int colIndex = m_mapFields[fieldName]; 427 | if(rowIndex >= m_vecRows.size()) 428 | return false; 429 | if(colIndex >= m_mapFields.size()) 430 | return false; 431 | if(resValue.empty()) 432 | m_vecRows[rowIndex][colIndex] = "null"; 433 | else 434 | m_vecRows[rowIndex][colIndex] = resValue; 435 | return true; 436 | } 437 | bool CCSVFile::SetCellValue(int colIndex,int rowIndex,std::string& resValue) 438 | { 439 | if(rowIndex >= m_vecRows.size()) 440 | return false; 441 | if(colIndex >= m_mapFields.size()) 442 | return false; 443 | if(resValue.empty()) 444 | m_vecRows[rowIndex][colIndex] = "null"; 445 | else 446 | m_vecRows[rowIndex][colIndex] = resValue; 447 | return true; 448 | } 449 | bool CCSVFile::SetCellValue(const char* fieldName,int rowIndex,int resValue) 450 | { 451 | int colIndex = m_mapFields[fieldName]; 452 | if(rowIndex >= m_vecRows.size()) 453 | return false; 454 | if(colIndex >= m_mapFields.size()) 455 | return false; 456 | char str[32] = {0}; 457 | sprintf_s(str,"%d",resValue); 458 | m_vecRows[rowIndex][colIndex] = str; 459 | 460 | return true; 461 | } 462 | bool CCSVFile::SetCellValue(int colIndex,int rowIndex,int resValue) 463 | { 464 | if(rowIndex >= m_vecRows.size()) 465 | return false; 466 | if(colIndex >= m_mapFields.size()) 467 | return false; 468 | char str[32] = {0}; 469 | sprintf_s(str,"%d",resValue); 470 | m_vecRows[rowIndex][colIndex] = str; 471 | return true; 472 | } 473 | 474 | bool CCSVFile::SetCellValue(const char* fieldName,int rowIndex,unsigned char resValue) 475 | { 476 | int colIndex = m_mapFields[fieldName]; 477 | if(rowIndex >= m_vecRows.size()) 478 | return false; 479 | if(colIndex >= m_mapFields.size()) 480 | return false; 481 | char str[32] = {0}; 482 | sprintf_s(str,"%d",resValue); 483 | m_vecRows[rowIndex][colIndex] = str; 484 | 485 | return true; 486 | } 487 | bool CCSVFile::SetCellValue(int colIndex,int rowIndex,unsigned char resValue) 488 | { 489 | if(rowIndex >= m_vecRows.size()) 490 | return false; 491 | if(colIndex >= m_mapFields.size()) 492 | return false; 493 | char str[32] = {0}; 494 | sprintf_s(str,"%d",resValue); 495 | m_vecRows[rowIndex][colIndex] = str; 496 | return true; 497 | } 498 | 499 | 500 | 501 | bool CCSVFile::SetCellValue(const char* fieldName,int rowIndex,float resValue) 502 | { 503 | int colIndex = m_mapFields[fieldName]; 504 | if(rowIndex >= m_vecRows.size()) 505 | return false; 506 | if(colIndex >= m_mapFields.size()) 507 | return false; 508 | char str[32] = {0}; 509 | sprintf_s(str,"%f",resValue); 510 | m_vecRows[rowIndex][colIndex] = str; 511 | return true; 512 | } 513 | bool CCSVFile::SetCellValue(int colIndex,int rowIndex,float resValue) 514 | { 515 | if(rowIndex >= m_vecRows.size()) 516 | return false; 517 | if(colIndex >= m_mapFields.size()) 518 | return false; 519 | char str[32] = {0}; 520 | sprintf_s(str,"%f",resValue); 521 | m_vecRows[rowIndex][colIndex] = str; 522 | return true; 523 | } 524 | 525 | bool CCSVFile::SetCellValue(const char* fieldName,int rowIndex,bool resValue) 526 | { 527 | int colIndex = m_mapFields[fieldName]; 528 | if(rowIndex >= m_vecRows.size()) 529 | return false; 530 | if(colIndex >= m_mapFields.size()) 531 | return false; 532 | m_vecRows[rowIndex][colIndex] = resValue?"TRUE":"FALSE"; 533 | return true; 534 | } 535 | bool CCSVFile::SetCellValue(int colIndex,int rowIndex,bool resValue) 536 | { 537 | if(rowIndex >= m_vecRows.size()) 538 | return false; 539 | if(colIndex >= m_mapFields.size()) 540 | return false; 541 | m_vecRows[rowIndex][colIndex] = resValue?"TRUE":"FALSE"; 542 | return true; 543 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | --------------------------------------------------------------------------------