diff --git a/tools/maya-plugin/Animation/Animation.vcxproj b/tools/maya-plugin/Animation/Animation.vcxproj
new file mode 100644
index 000000000..3d1461510
--- /dev/null
+++ b/tools/maya-plugin/Animation/Animation.vcxproj
@@ -0,0 +1,529 @@
+
+
+
+
+ Maya2020 Debug
+ Win32
+
+
+ Maya2020 Debug
+ x64
+
+
+ Maya2020 Release
+ Win32
+
+
+ Maya2020 Release
+ x64
+
+
+ Maya5.0 Debug
+ Win32
+
+
+ Maya5.0 Debug
+ x64
+
+
+ Maya5.0 Release
+ Win32
+
+
+ Maya5.0 Release
+ x64
+
+
+ Maya8.5 Debug
+ Win32
+
+
+ Maya8.5 Debug
+ x64
+
+
+ Maya8.5 Release
+ Win32
+
+
+ Maya8.5 Release
+ x64
+
+
+
+
+
+
+
+
+
+
+
+
+ 16.0
+ Win32Proj
+ {8620b892-de9c-40c0-9200-6f64b45c599e}
+ Animation
+ 10.0
+
+
+
+ DynamicLibrary
+ true
+ v142
+ Unicode
+
+
+ DynamicLibrary
+ true
+ v142
+ Unicode
+
+
+ DynamicLibrary
+ true
+ v142
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v142
+ true
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v142
+ true
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v142
+ true
+ Unicode
+
+
+ DynamicLibrary
+ true
+ v142
+ Unicode
+
+
+ DynamicLibrary
+ true
+ v142
+ Unicode
+
+
+ DynamicLibrary
+ true
+ v142
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v142
+ true
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v142
+ true
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v142
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ $(SolutionDir)$(PlatformShortName)\$(Configuration)\
+ $(PlatformShortName)\$(Configuration)\
+ ..\Common;$(DXSDK)\Include;$(Maya50x86)\include;$(VC_IncludePath);$(WindowsSDK_IncludePath)
+ $(DXSDK)\Lib\x86;$(Maya50x86)\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86)
+ SD2AniExport
+ .mll
+
+
+ true
+ $(SolutionDir)$(PlatformShortName)\$(Configuration)\
+ $(PlatformShortName)\$(Configuration)\
+ ..\Common;$(DXSDK)\Include;$(Maya85x86)\include;$(VC_IncludePath);$(WindowsSDK_IncludePath)
+ $(DXSDK)\Lib\x86;$(Maya85x86)\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86)
+ SD2AniExport
+ .mll
+
+
+ true
+ $(SolutionDir)$(PlatformShortName)\$(Configuration)\
+ $(PlatformShortName)\$(Configuration)\
+ ..\Common;$(DXSDK)\Include;$(Maya2020x86)\include;$(VC_IncludePath);$(WindowsSDK_IncludePath)
+ $(DXSDK)\Lib\x86;$(Maya2020x86)\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86)
+ SD2AniExport
+ .mll
+
+
+ false
+ $(SolutionDir)$(PlatformShortName)\$(Configuration)\
+ $(PlatformShortName)\$(Configuration)\
+ ..\Common;$(DXSDK)\Include;$(Maya50x86)\include;$(VC_IncludePath);$(WindowsSDK_IncludePath)
+ $(DXSDK)\Lib\x86;$(Maya50x86)\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86)
+ SD2AniExport
+ .mll
+
+
+ false
+ $(SolutionDir)$(PlatformShortName)\$(Configuration)\
+ $(PlatformShortName)\$(Configuration)\
+ ..\Common;$(DXSDK)\Include;$(Maya85x86)\include;$(VC_IncludePath);$(WindowsSDK_IncludePath)
+ $(DXSDK)\Lib\x86;$(Maya85x86)\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86)
+ SD2AniExport
+ .mll
+
+
+ false
+ $(SolutionDir)$(PlatformShortName)\$(Configuration)\
+ $(PlatformShortName)\$(Configuration)\
+ ..\Common;$(DXSDK)\Include;$(Maya2020x86)\include;$(VC_IncludePath);$(WindowsSDK_IncludePath)
+ $(DXSDK)\Lib\x86;$(Maya2020x86)\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86)
+ SD2AniExport
+ .mll
+
+
+ true
+ $(SolutionDir)$(PlatformShortName)\$(Configuration)\
+ $(PlatformShortName)\$(Configuration)\
+ ..\Common;$(DXSDK)\Include;$(Maya50x64)\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);
+ $(DXSDK)\Lib\x64;$(Maya50x64)\lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)
+ SD2AniExport
+ .mll
+
+
+ true
+ $(SolutionDir)$(PlatformShortName)\$(Configuration)\
+ $(PlatformShortName)\$(Configuration)\
+ ..\Common;$(DXSDK)\Include;$(Maya85x64)\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);
+ $(DXSDK)\Lib\x64;$(Maya85x64)\lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)
+ SD2AniExport
+ .mll
+
+
+ true
+ $(SolutionDir)$(PlatformShortName)\$(Configuration)\
+ $(PlatformShortName)\$(Configuration)\
+ ..\Common;$(DXSDK)\Include;$(Maya2020x64)\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);
+ $(DXSDK)\Lib\x64;$(Maya2020x64)\lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)
+ SD2AniExport
+ .mll
+
+
+ false
+ $(SolutionDir)$(PlatformShortName)\$(Configuration)\
+ $(PlatformShortName)\$(Configuration)\
+ ..\Common;$(DXSDK)\Include;$(Maya50x64)\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);
+ $(DXSDK)\Lib\x64;$(Maya50x64)\lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)
+ SD2AniExport
+ .mll
+
+
+ false
+ $(SolutionDir)$(PlatformShortName)\$(Configuration)\
+ $(PlatformShortName)\$(Configuration)\
+ ..\Common;$(DXSDK)\Include;$(Maya85x64)\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);
+ $(DXSDK)\Lib\x64;$(Maya85x64)\lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)
+ SD2AniExport
+ .mll
+
+
+ false
+ $(SolutionDir)$(PlatformShortName)\$(Configuration)\
+ $(PlatformShortName)\$(Configuration)\
+ ..\Common;$(DXSDK)\Include;$(Maya2020x64)\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);
+ $(DXSDK)\Lib\x64;$(Maya2020x64)\lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)
+ SD2AniExport
+ .mll
+
+
+
+ Level3
+ true
+ NOMINMAX;_BOOL;REQUIRE_IOSTREAM;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;ANIMATION_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
+ true
+ NotUsing
+ pch.h
+ stdcpplatest
+
+
+ Windows
+ true
+ false
+ OpenMaya.lib;OpenMayaAnim.lib;Image.lib;Foundation.lib;d3dx9.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ true
+ NOMINMAX;_BOOL;REQUIRE_IOSTREAM;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;ANIMATION_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
+ true
+ NotUsing
+ pch.h
+ stdcpplatest
+
+
+ Windows
+ true
+ false
+ OpenMaya.lib;OpenMayaAnim.lib;Image.lib;Foundation.lib;d3dx9.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ true
+ NOMINMAX;_BOOL;REQUIRE_IOSTREAM;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;ANIMATION_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
+ true
+ NotUsing
+ pch.h
+ stdcpplatest
+
+
+ Windows
+ true
+ false
+ OpenMaya.lib;OpenMayaAnim.lib;Image.lib;Foundation.lib;d3dx9.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NOMINMAX;_BOOL;REQUIRE_IOSTREAM;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;ANIMATION_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
+ true
+ NotUsing
+ pch.h
+ stdcpplatest
+
+
+ Windows
+ true
+ true
+ true
+ false
+ OpenMaya.lib;OpenMayaAnim.lib;Image.lib;Foundation.lib;d3dx9.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NOMINMAX;_BOOL;REQUIRE_IOSTREAM;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;ANIMATION_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
+ true
+ NotUsing
+ pch.h
+ stdcpplatest
+
+
+ Windows
+ true
+ true
+ true
+ false
+ OpenMaya.lib;OpenMayaAnim.lib;Image.lib;Foundation.lib;d3dx9.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NOMINMAX;_BOOL;REQUIRE_IOSTREAM;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;ANIMATION_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
+ true
+ NotUsing
+ pch.h
+ stdcpplatest
+
+
+ Windows
+ true
+ true
+ true
+ false
+ OpenMaya.lib;OpenMayaAnim.lib;Image.lib;Foundation.lib;d3dx9.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ true
+ NOMINMAX;_BOOL;REQUIRE_IOSTREAM;_CRT_SECURE_NO_WARNINGS;_DEBUG;ANIMATION_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
+ true
+ NotUsing
+ pch.h
+ stdcpplatest
+
+
+ Windows
+ true
+ false
+ OpenMaya.lib;OpenMayaAnim.lib;Image.lib;Foundation.lib;d3dx9.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ true
+ NOMINMAX;_BOOL;REQUIRE_IOSTREAM;_CRT_SECURE_NO_WARNINGS;_DEBUG;ANIMATION_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
+ true
+ NotUsing
+ pch.h
+ stdcpplatest
+
+
+ Windows
+ true
+ false
+ OpenMaya.lib;OpenMayaAnim.lib;Image.lib;Foundation.lib;d3dx9.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ true
+ NOMINMAX;_BOOL;REQUIRE_IOSTREAM;_CRT_SECURE_NO_WARNINGS;_DEBUG;ANIMATION_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
+ true
+ NotUsing
+ pch.h
+ stdcpplatest
+
+
+ Windows
+ true
+ false
+ OpenMaya.lib;OpenMayaAnim.lib;Image.lib;Foundation.lib;d3dx9.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NOMINMAX;_BOOL;REQUIRE_IOSTREAM;_CRT_SECURE_NO_WARNINGS;NDEBUG;ANIMATION_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
+ true
+ NotUsing
+ pch.h
+ stdcpplatest
+
+
+ Windows
+ true
+ true
+ true
+ false
+ OpenMaya.lib;OpenMayaAnim.lib;Image.lib;Foundation.lib;d3dx9.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NOMINMAX;_BOOL;REQUIRE_IOSTREAM;_CRT_SECURE_NO_WARNINGS;NDEBUG;ANIMATION_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
+ true
+ NotUsing
+ pch.h
+ stdcpplatest
+
+
+ Windows
+ true
+ true
+ true
+ false
+ OpenMaya.lib;OpenMayaAnim.lib;Image.lib;Foundation.lib;d3dx9.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NOMINMAX;_BOOL;REQUIRE_IOSTREAM;_CRT_SECURE_NO_WARNINGS;NDEBUG;ANIMATION_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
+ true
+ NotUsing
+ pch.h
+ stdcpplatest
+
+
+ Windows
+ true
+ true
+ true
+ false
+ OpenMaya.lib;OpenMayaAnim.lib;Image.lib;Foundation.lib;d3dx9.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tools/maya-plugin/Animation/Animation.vcxproj.filters b/tools/maya-plugin/Animation/Animation.vcxproj.filters
new file mode 100644
index 000000000..69fddc846
--- /dev/null
+++ b/tools/maya-plugin/Animation/Animation.vcxproj.filters
@@ -0,0 +1,36 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Файлы заголовков
+
+
+ Файлы заголовков
+
+
+ Файлы заголовков
+
+
+ Файлы заголовков
+
+
+
+
+ Исходные файлы
+
+
+
\ No newline at end of file
diff --git a/tools/maya-plugin/Animation/AnimationExport.cpp b/tools/maya-plugin/Animation/AnimationExport.cpp
new file mode 100644
index 000000000..2e7dda535
--- /dev/null
+++ b/tools/maya-plugin/Animation/AnimationExport.cpp
@@ -0,0 +1,283 @@
+/******************************************************************************
+File: AnimationExport.cpp
+
+Author: Nick Chirkov
+Copyright (C) 2001 Akella corp.
+
+Comments:
+Maya export
+******************************************************************************/
+#include
+#include "AnimationExport.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "anim_file.h"
+#include
+#include "cvector.h"
+#include "matrix.h"
+#include
+
+#define CM2M_SCALE 0.01f
+
+FILE *LogFile=0;
+void Log(const char *fmt,...)
+{
+ va_list args;
+ va_start(args,fmt);
+ vfprintf(LogFile, fmt, args);
+ va_end(args);
+}
+
+bool GetDoubleValue(MObject &obj, const char *name, double &d)
+{
+ MFnDependencyNode NodeFnDn;
+ NodeFnDn.setObject(obj);
+ MStatus status;
+#if MAYA_API_VERSION <= 500
+ MPlug rpuv = NodeFnDn.findPlug(name, &status);
+#else
+ MPlug rpuv = NodeFnDn.findPlug(name, false, &status);
+#endif
+ if(!status) return false;
+ MObject val;
+ rpuv.getValue(d);
+ return true;
+}
+
+FILE *anifile;
+MStatus status;
+
+AniExport::AniExport()
+{
+}
+
+AniExport::~AniExport()
+{
+}
+
+MStatus AniExport::writer(const MFileObject &file, const MString &optionsString, FileAccessMode mode)
+{
+#if MAYA_API_VERSION <= 500
+ MString fname = file.fullName();
+#else
+ MString fname = file.expandedFullName();
+#endif
+ ExportAll(fname.asChar());
+ return (MS::kSuccess);
+}
+bool AniExport::haveWriteMethod () const
+{
+ return (true);
+}
+MString AniExport::defaultExtension () const
+{
+ return MString("an");
+}
+
+MPxFileTranslator::MFileKind AniExport::identifyFile( const MFileObject &file, const char *buffer,short size) const
+{
+ //const char *name = file.resolvedName().asChar();
+ //int nameLength = strlen(name);
+ return (kIsMyFileType);
+}
+
+void *AniExport::creator()
+{
+ return new AniExport();
+}
+
+//****************************************************************
+__declspec(dllexport) MStatus initializePlugin (MObject obj)
+{
+ using namespace std::string_literals;
+ MStatus status;
+ MFnPlugin plugin (obj, "Nick Chirkov (C) 2001", "1.0");
+ auto pixmap_name = ""s;
+ auto options_script_name = "SD2AniExportMel"s;
+ status = plugin.registerFileTranslator("SD2AniExport", &pixmap_name[0], AniExport::creator,&options_script_name[0]);
+ return status;
+}
+
+__declspec(dllexport) MStatus uninitializePlugin (MObject obj)
+{
+ MFnPlugin plugin (obj);
+ plugin.deregisterFileTranslator ("SD2AniExport");
+ return (MS::kSuccess);
+}
+
+//------------------------------------------------------------------------
+//find root
+//------------------------------------------------------------------------
+void AniExport::ExportAll(const char *fname)
+{
+ MGlobal::executeCommand("window -tlc 300 300 -w 300 -h 200 -title \"ani Export\" StatusWin",true);
+ MGlobal::executeCommand("columnLayout -adjustableColumn true",true);
+ MGlobal::executeCommand("text -label \"Default\" MyLable",true);
+ MGlobal::executeCommand("showWindow StatusWin",true);
+ MGlobal::executeCommand("text -edit -label \"Search root\" MyLable",true);
+ MGlobal::executeCommand("showWindow StatusWin",true);
+
+ char newname[256];
+ sprintf(newname, "%s.ant", fname);
+ LogFile = fopen(newname,"w+");
+ char aniname[256];
+ strcpy(aniname, newname);
+ aniname[strlen(aniname)-4] = 0;
+ anifile = fopen(aniname,"w+b");
+
+ //get selected locator
+ MSelectionList slist;
+ MGlobal::getActiveSelectionList(slist);
+ MItSelectionList iter(slist);
+ if(iter.isDone()) return;
+ MDagPath locator;
+ iter.getDagPath(locator);
+ if(!locator.hasFn(MFn::kLocator)) return;
+
+ //------------------------------------------------------------------------------
+ //EXPORT FRAMES
+ //------------------------------------------------------------------------------
+ MTime startFrame( MAnimControl::minTime().value(), MTime::uiUnit() );
+ float startTime = (float)startFrame.value();
+
+ MTime endFrame( MAnimControl::maxTime().value(), MTime::uiUnit() );
+ float endTime = (float)endFrame.value();
+
+ ANIFILE::HEADER ah;
+ fwrite(&ah, sizeof ah, 1, anifile);
+ ah.nJoints = 0;
+ ah.nFrames = 0;
+ ah.framesPerSec = 15.0f;
+
+ //--------------------------------------------------------
+ //all joints
+ //--------------------------------------------------------
+ //find all joints
+ MDagPathArray mJointsList;
+ MItDag dagIterator( MItDag::kBreadthFirst, MFn::kJoint, &status);
+ if(!status) return;
+ for ( ; !dagIterator.isDone(); dagIterator.next() )
+ {
+ MDagPath dagPath;
+ status = dagIterator.getPath(dagPath); // Get DagPath
+ if(!status) continue;
+
+ status = mJointsList.append(dagPath);
+ ah.nJoints++;
+ }
+
+ //-------------------------------------------------------------
+ //parent index to handle hierarchy
+ //-------------------------------------------------------------
+ long *parIdx = new long[ah.nJoints];
+ long j;
+ for(j=0; j begPos;
+ std::vector rootPos;
+ std::vector jointAngle;
+
+ for(float time = startTime; time
+
+class AniExport : public MPxFileTranslator
+{
+public:
+ AniExport();
+ ~AniExport();
+
+ MStatus writer(const MFileObject &file, const MString &optionsString, FileAccessMode mode);
+ bool haveWriteMethod() const;
+ MString defaultExtension() const;
+ MFileKind identifyFile (const MFileObject &, const char *buffer, short size) const;
+ static void *creator();
+protected:
+ void ExportAll(const char *fname);
+
+};
+
+#endif
\ No newline at end of file
diff --git a/tools/maya-plugin/Animation/anim_file.h b/tools/maya-plugin/Animation/anim_file.h
new file mode 100644
index 000000000..ef81399d4
--- /dev/null
+++ b/tools/maya-plugin/Animation/anim_file.h
@@ -0,0 +1,20 @@
+#pragma once
+
+//ANIMATION_HEADER
+//long parentIndex[nJoints]
+//CVECTOR jointPos[nJoints]
+
+//Frames:
+//CVECTOR rootPos[nFrames]
+//CVECTOR jointAngle[nJoints][nFrames]
+
+namespace ANIFILE
+{
+ struct HEADER
+ {
+ long nFrames;
+ long nJoints;
+ float framesPerSec;
+ };
+
+};
\ No newline at end of file
diff --git a/tools/maya-plugin/Common/chunk.h b/tools/maya-plugin/Common/chunk.h
new file mode 100644
index 000000000..4498b112b
--- /dev/null
+++ b/tools/maya-plugin/Common/chunk.h
@@ -0,0 +1,16 @@
+#ifndef _CHUNK_H_
+#define _CHUNK_H_
+
+#pragma pack(push,1)
+
+#define CHUNK_RDF_GEOMETRY 0
+
+struct CHUNK
+{
+ unsigned long id;
+ unsigned long size;
+};
+
+#pragma pack(pop)
+
+#endif
\ No newline at end of file
diff --git a/tools/maya-plugin/Common/cvector.h b/tools/maya-plugin/Common/cvector.h
new file mode 100644
index 000000000..160bbe1f5
--- /dev/null
+++ b/tools/maya-plugin/Common/cvector.h
@@ -0,0 +1,212 @@
+#ifndef __CVECTOR_H__
+#define __CVECTOR_H__
+
+#include
+
+struct CVECTOR
+{
+public:
+ float x;
+ float y;
+ float z;
+ CVECTOR(){};
+ CVECTOR(float a) { x = a; y = a; z = a; };
+ CVECTOR(double a) { x = float(a); y = float(a); z = float(a); };
+ CVECTOR(float _x, float _y, float _z) { x = _x; y = _y; z = _z; };
+ CVECTOR(double _x, double _y, double _z) { x = float(_x); y = float(_y); z = float(_z); };
+ CVECTOR(float a[3]) { x = a[0]; y = a[1]; z = a[2]; };
+ CVECTOR(double a[3]) { x = float(a[0]); y = float(a[1]); z = float(a[2]); };
+ //CVECTOR(const DVECTOR &d) : x((float)d.x), y((float)d.y), z((float)d.z){};
+
+ inline CVECTOR& operator += (const CVECTOR& v)
+ {
+ x += v.x; y += v.y; z += v.z;
+ return *this;
+ };
+ inline CVECTOR& operator -= (const CVECTOR& v)
+ {
+ x -= v.x; y -= v.y; z -= v.z;
+ return *this;
+ };
+ inline CVECTOR& operator *= (const CVECTOR& v)
+ {
+ x *= v.x; y *= v.y; z *= v.z;
+ return *this;
+ };
+ inline CVECTOR& operator /= (const CVECTOR& v)
+ {
+ x /= v.x; y /= v.y; z /= v.z;
+ return *this;
+ };
+
+ //square magnitude
+ friend inline float operator ~ (const CVECTOR& v)
+ {
+ return v.x*v.x + v.y*v.y + v.z*v.z;
+ };
+
+ //normalize
+ friend inline CVECTOR operator ! (const CVECTOR& v)
+ {
+ double len = 1.0/sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
+ return CVECTOR(v.x*len, v.y*len, v.z*len);
+ };
+
+ //none
+ friend inline CVECTOR operator + (const CVECTOR& v)
+ {
+ return v;
+ };
+ //add
+ friend inline CVECTOR operator + (const CVECTOR& v1, const CVECTOR& v2)
+ {
+ return CVECTOR(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z);
+ };
+ //negative
+ friend inline CVECTOR operator - (const CVECTOR& v)
+ {
+ return CVECTOR(-v.x, -v.y, -v.z);
+ };
+ //sub
+ friend inline CVECTOR operator - (const CVECTOR& v1, const CVECTOR& v2)
+ {
+ return CVECTOR(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z);
+ };
+ //multiply each element by each
+ friend inline CVECTOR operator * (const CVECTOR& v1, const CVECTOR& v2)
+ {
+ return CVECTOR(v1.x*v2.x, v1.y*v2.y, v1.z*v2.z);
+ };
+ //multiply each element by float
+ friend inline CVECTOR operator * (const CVECTOR& v1, float f)
+ {
+ return CVECTOR(v1.x*f, v1.y*f, v1.z*f);
+ };
+ //divide each element by each
+ friend inline CVECTOR operator / (const CVECTOR& v1, const CVECTOR& v2)
+ {
+ return CVECTOR(v1.x/v2.x, v1.y/v2.y, v1.z/v2.z);
+ };
+ //divide each element by float
+ friend inline CVECTOR operator / (const CVECTOR& v1, float f)
+ {
+ double _f = 1.0/f; return CVECTOR(v1.x*_f, v1.y*_f, v1.z*_f);
+ };
+ //cross product
+ friend inline CVECTOR operator ^ (const CVECTOR& v1, const CVECTOR& v2)
+ {
+ return CVECTOR(v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x);
+ }
+ //dot product
+ friend inline float operator | (const CVECTOR& v1, const CVECTOR& v2)
+ {
+ return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
+ }
+
+ //==
+ inline bool operator==(const CVECTOR& v)
+ {
+ return (v.x==x && v.y==y && v.z==z);
+ }
+
+} ;
+
+struct DVECTOR
+{
+public:
+ double x;
+ double y;
+ double z;
+ DVECTOR(){};
+ DVECTOR(double a) { x = a; y = a; z = a; };
+ DVECTOR(double _x, double _y, double _z) { x = _x; y = _y; z = _z; };
+ DVECTOR(double a[3]) { x = a[0]; y = a[1]; z = a[2]; };
+ DVECTOR(const CVECTOR &d) { x = d.x; y = d.y; z = d.z; };
+
+ inline DVECTOR& operator += (const DVECTOR& v)
+ {
+ x += v.x; y += v.y; z += v.z;
+ return *this;
+ };
+ inline DVECTOR& operator -= (const DVECTOR& v)
+ {
+ x -= v.x; y -= v.y; z -= v.z;
+ return *this;
+ };
+ inline DVECTOR& operator *= (const DVECTOR& v)
+ {
+ x *= v.x; y *= v.y; z *= v.z;
+ return *this;
+ };
+ inline DVECTOR& operator /= (const DVECTOR& v)
+ {
+ x /= v.x; y /= v.y; z /= v.z;
+ return *this;
+ };
+
+ //square magnitude
+ friend inline double operator ~ (const DVECTOR& v)
+ {
+ return v.x*v.x + v.y*v.y + v.z*v.z;
+ };
+
+ //normalize
+ friend inline DVECTOR operator ! (const DVECTOR& v)
+ {
+ double len = 1.0/sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
+ return DVECTOR(v.x*len, v.y*len, v.z*len);
+ };
+
+ //none
+ friend inline DVECTOR operator + (const DVECTOR& v)
+ {
+ return v;
+ };
+ //add
+ friend inline DVECTOR operator + (const DVECTOR& v1, const DVECTOR& v2)
+ {
+ return DVECTOR(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z);
+ };
+ //negative
+ friend inline DVECTOR operator - (const DVECTOR& v)
+ {
+ return DVECTOR(-v.x, -v.y, -v.z);
+ };
+ //sub
+ friend inline DVECTOR operator - (const DVECTOR& v1, const DVECTOR& v2)
+ {
+ return DVECTOR(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z);
+ };
+ //multiply each element by each
+ friend inline DVECTOR operator * (const DVECTOR& v1, const DVECTOR& v2)
+ {
+ return DVECTOR(v1.x*v2.x, v1.y*v2.y, v1.z*v2.z);
+ };
+ //multiply each element by double
+ friend inline DVECTOR operator * (const DVECTOR& v1, double f)
+ {
+ return DVECTOR(v1.x*f, v1.y*f, v1.z*f);
+ };
+ //divide each element by each
+ friend inline DVECTOR operator / (const DVECTOR& v1, const DVECTOR& v2)
+ {
+ return DVECTOR(v1.x/v2.x, v1.y/v2.y, v1.z/v2.z);
+ };
+ //divide each element by double
+ friend inline DVECTOR operator / (const DVECTOR& v1, double f)
+ {
+ double _f = 1.0/f; return DVECTOR(v1.x*_f, v1.y*_f, v1.z*_f);
+ };
+ //cross product
+ friend inline DVECTOR operator ^ (const DVECTOR& v1, const DVECTOR& v2)
+ {
+ return DVECTOR(v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x);
+ }
+ //dot product
+ friend inline double operator | (const DVECTOR& v1, const DVECTOR& v2)
+ {
+ return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
+ }
+} ;
+
+#endif
diff --git a/tools/maya-plugin/Common/matrix.h b/tools/maya-plugin/Common/matrix.h
new file mode 100644
index 000000000..3a9bc5940
--- /dev/null
+++ b/tools/maya-plugin/Common/matrix.h
@@ -0,0 +1,684 @@
+#ifndef _MATRIX_H_
+#define _MATRIX_H_
+
+
+#include "cvector.h"
+
+
+//============================================================================================
+
+/*
+ 0 4 8 12 [0][0] [1][0] [2][0] [3][0]
+ 1 5 9 13 [0][1] [1][1] [2][1] [3][1]
+ 2 6 10 14 [0][2] [1][2] [2][2] [3][2]
+ 3 7 11 15 [0][3] [1][3] [2][3] [3][3]
+*/
+
+//============================================================================================
+
+struct MTX_PRJ_VECTOR
+{
+ float x, y, z;
+ float rhw;
+};
+
+struct D3DXMATRIX;
+
+//============================================================================================
+
+class CMatrix
+{
+public:
+ union
+ {
+ float matrix[16];
+ float m[4][4];
+ };
+
+//-----------------------------------------------------------
+//Constructors
+//-----------------------------------------------------------
+ CMatrix();//Identity matrix
+ CMatrix(float angX, float angY, float angZ, float x, float y, float z);
+ CMatrix(float angX, float angY, float angZ);
+ CMatrix(CVECTOR & ang, CVECTOR & pos);
+ CMatrix(CVECTOR & ang);
+ CMatrix(const CMatrix & matrix);
+ CMatrix(CMatrix * matrix);
+ //this = m1*m2
+ CMatrix(CMatrix & m1, CMatrix & m2);
+
+
+//-----------------------------------------------------------
+//Main
+//-----------------------------------------------------------
+ //Create identity matrix
+ void SetIdentity();
+
+ //Build matrix
+ //M = rotZ*rotX*rotY*Pos
+ void BuildMatrix(float angX, float angY, float angZ, float x, float y, float z);
+ void BuildMatrix(float angX, float angY, float angZ);
+ void BuildMatrix(CVECTOR & ang, CVECTOR & pos);
+ void BuildMatrix(CVECTOR & ang);
+ //M = rotX*rotY*rotZ*Pos
+ void BuildMatrixXYZ(float angX, float angY, float angZ, float x, float y, float z);
+
+ //Build rotate matrix
+ void BuildRotateX(float ang);
+ void BuildRotateY(float ang);
+ void BuildRotateZ(float ang);
+ //Build position matrix
+ void BuildPosition(float x, float y, float z);
+
+ //Equal
+ void operator = (const CMatrix & matrix);
+
+ //Multiply
+ void operator *= (CMatrix & matrix);
+ void operator *= (float k);
+ CMatrix operator * (CMatrix & matrix);
+ CVECTOR operator * (CVECTOR & vector);
+
+
+ //this = m1*m2, (m1 != this, m2 != this)
+ void EqMultiply(CMatrix & m1, CMatrix & m2);
+ //Transform vertex to local coordinate system
+ void MulToInv(const CVECTOR & srcVrt, CVECTOR & resVrt);
+ //Transform normal to local coordinate system
+ void MulToInvNorm(CVECTOR & srcNorm, CVECTOR & resNorm);
+
+ //Transposition
+ void Transposition();
+ void Transposition3X3();
+
+ //Rotate
+ void RotateX(float ang);
+ void RotateY(float ang);
+ void RotateZ(float ang);
+ //Move
+ void Move(float dX, float dY, float dZ);
+ //Move(-(pos * this))
+ void MoveInversePosition(float x, float y, float z);
+ //Set new position
+ void SetPosition(float x, float y, float z);
+ void SetPosition(CVECTOR & pos);
+ //SetPosition(-(pos * this))
+ void SetInversePosition(float x, float y, float z);
+
+//-----------------------------------------------------------
+//Utils
+//-----------------------------------------------------------
+
+ //Access to axis vectors
+ CVECTOR & Vx() const; // X ()
+ CVECTOR & Vy() const; // Y ()
+ CVECTOR & Vz() const; // Z ()
+ CVECTOR & Pos() const; // ()
+
+ //Access to matrix element
+ float & operator () (long i, long j);
+
+
+ //Create only rotate matrix
+ void Get3X3(CMatrix & mtr);
+ void Get3X3(CMatrix * mtr);
+
+ //Projection
+ void BuildProjectionMatrix(float viewAngle, float vpWidth, float vpHeight, float zNear, float zFar);
+ void Projection(CVECTOR * srcArray, MTX_PRJ_VECTOR * dstArray, long num, float vphWidth05, float vphHeight05, long srcStrcSize, long dstStrcSize);
+
+ //View
+ bool BuildViewMatrix(CVECTOR lookFrom, CVECTOR lookTo, CVECTOR upVector);
+
+ //Mirror
+ void BuildMirrorMatrix(float Nx, float Ny, float Nz, float D);
+
+ //D3D extends (return (D3DXMATRIX *)pointer)
+ operator D3DXMATRIX * ();
+
+};
+
+//============================================================================================
+//Constructors
+//============================================================================================
+
+inline CMatrix::CMatrix()
+{
+ SetIdentity();
+}
+
+inline CMatrix::CMatrix(float angX, float angY, float angZ)
+{
+ BuildMatrix(angX, angY, angZ, 0.0f, 0.0f, 0.0f);
+}
+
+inline CMatrix::CMatrix(float angX, float angY, float angZ, float x, float y, float z)
+{
+ BuildMatrix(angX, angY, angZ, x, y, z);
+}
+
+inline CMatrix::CMatrix(CVECTOR & ang, CVECTOR & pos)
+{
+ BuildMatrix(ang.x, ang.y, ang.z, pos.x, pos.y, pos.z);
+}
+
+inline CMatrix::CMatrix(CVECTOR & ang)
+{
+ BuildMatrix(ang.x, ang.y, ang.z, 0.0f, 0.0f, 0.0f);
+}
+
+inline CMatrix::CMatrix(const CMatrix & matrix)
+{
+ *this = matrix;
+}
+
+inline CMatrix::CMatrix(CMatrix * matrix)
+{
+ *this = *matrix;
+}
+
+//this = m1*m2
+inline CMatrix::CMatrix(CMatrix & m1, CMatrix & m2)
+{
+ EqMultiply(m1, m2);
+}
+
+//============================================================================================
+//Main
+//============================================================================================
+
+//Create identity matrix
+inline void CMatrix::SetIdentity()
+{
+ matrix[0] = 1.f;
+ matrix[1] = 0;
+ matrix[2] = 0;
+ matrix[3] = 0;
+ matrix[4] = 0;
+ matrix[5] = 1.f;
+ matrix[6] = 0;
+ matrix[7] = 0;
+ matrix[8] = 0;
+ matrix[9] = 0;
+ matrix[10] = 1.f;
+ matrix[11] = 0;
+ matrix[12] = 0;
+ matrix[13] = 0;
+ matrix[14] = 0;
+ matrix[15] = 1.f;
+}
+
+//Build matrix
+inline void CMatrix::BuildMatrix(float angX, float angY, float angZ, float x, float y, float z)
+{
+ register float sinAx = sinf(angX);
+ register float cosAx = cosf(angX);
+ register float sinAy = sinf(angY);
+ register float cosAy = cosf(angY);
+ register float sinAz = sinf(angZ);
+ register float cosAz = cosf(angZ);
+
+ // rz*rx*ry
+ m[0][0] = cosAz*cosAy + sinAz*sinAx*sinAy;
+ m[1][0] = -sinAz*cosAy + cosAz*sinAx*sinAy;
+ m[2][0] = cosAx*sinAy;
+ m[3][0] = x;
+
+ m[0][1] = sinAz*cosAx;
+ m[1][1] = cosAz*cosAx;
+ m[2][1] = -sinAx;
+ m[3][1] = y;
+
+ m[0][2] = cosAz*-sinAy + sinAz*sinAx*cosAy;
+ m[1][2] = -sinAz*-sinAy + cosAz*sinAx*cosAy;
+ m[2][2] = cosAx*cosAy;
+ m[3][2] = z;
+
+ m[0][3] = 0.0f;
+ m[1][3] = 0.0f;
+ m[2][3] = 0.0f;
+ m[3][3] = 1.0f;
+}
+
+inline void CMatrix::BuildMatrixXYZ(float angX, float angY, float angZ, float x, float y, float z)
+{
+ register float sinAx = sinf(angX);
+ register float cosAx = cosf(angX);
+ register float sinAy = sinf(angY);
+ register float cosAy = cosf(angY);
+ register float sinAz = sinf(angZ);
+ register float cosAz = cosf(angZ);
+
+ m[0][0] = cosAy*cosAz;
+ m[1][0] = sinAx*sinAy*cosAz-cosAx*sinAz;
+ m[2][0] = cosAx*sinAy*cosAz+sinAx*sinAz;
+ m[3][0] = x;
+
+ m[0][1] = cosAy*sinAz;
+ m[1][1] = sinAx*sinAy*sinAz+cosAx*cosAz;
+ m[2][1] = cosAx*sinAy*sinAz-sinAx*cosAz;
+ m[3][1] = y;
+
+ m[0][2] = -sinAy;
+ m[1][2] = sinAx*cosAy;
+ m[2][2] = cosAx*cosAy;
+ m[3][2] = z;
+
+ m[0][3] = 0.0f;
+ m[1][3] = 0.0f;
+ m[2][3] = 0.0f;
+ m[3][3] = 1.0f;
+}
+
+
+inline void CMatrix::BuildMatrix(float angX, float angY, float angZ)
+{
+ BuildMatrix(angX, angY, angZ, 0.0f, 0.0f, 0.0f);
+}
+
+inline void CMatrix::BuildMatrix(CVECTOR & ang, CVECTOR & pos)
+{
+ BuildMatrix(ang.x, ang.y, ang.z, pos.x, pos.y, pos.z);
+}
+
+inline void CMatrix::BuildMatrix(CVECTOR & ang)
+{
+ BuildMatrix(ang.x, ang.y, ang.z, 0.0f, 0.0f, 0.0f);
+}
+
+//Build rotate matrix
+inline void CMatrix::BuildRotateX(float ang)
+{
+ SetIdentity();
+ m[1][1] = cosf(ang);
+ m[2][1] = -sinf(ang);
+ m[1][2] = sinf(ang);
+ m[2][2] = cosf(ang);
+}
+
+inline void CMatrix::BuildRotateY(float ang)
+{
+ SetIdentity();
+ m[0][0] = cosf(ang);
+ m[2][0] = sinf(ang);
+ m[0][2] = -sinf(ang);
+ m[2][2] = cosf(ang);
+}
+
+inline void CMatrix::BuildRotateZ(float ang)
+{
+ SetIdentity();
+ m[0][0] = cosf(ang);
+ m[1][0] = -sinf(ang);
+ m[0][1] = sinf(ang);
+ m[1][1] = cosf(ang);
+}
+
+//Build position matrix
+inline void CMatrix::BuildPosition(float x, float y, float z)
+{
+ SetIdentity();
+ matrix[12] = x;
+ matrix[13] = y;
+ matrix[14] = z;
+}
+
+//Equal
+inline void CMatrix::operator = (const CMatrix & matrix)
+{
+ this->matrix[0] = matrix.matrix[0];
+ this->matrix[1] = matrix.matrix[1];
+ this->matrix[2] = matrix.matrix[2];
+ this->matrix[3] = matrix.matrix[3];
+ this->matrix[4] = matrix.matrix[4];
+ this->matrix[5] = matrix.matrix[5];
+ this->matrix[6] = matrix.matrix[6];
+ this->matrix[7] = matrix.matrix[7];
+ this->matrix[8] = matrix.matrix[8];
+ this->matrix[9] = matrix.matrix[9];
+ this->matrix[10] = matrix.matrix[10];
+ this->matrix[11] = matrix.matrix[11];
+ this->matrix[12] = matrix.matrix[12];
+ this->matrix[13] = matrix.matrix[13];
+ this->matrix[14] = matrix.matrix[14];
+ this->matrix[15] = matrix.matrix[15];
+}
+
+//Multiply
+inline void CMatrix::operator *= (CMatrix & matrix)
+{
+ CMatrix tmp;
+ tmp.EqMultiply(*this, matrix);
+ *this = tmp;
+}
+
+
+inline void CMatrix::operator *= (float k)
+{
+ m[0][0] *= k; m[1][0] *= k; m[2][0] *= k; m[3][0] *= k;
+ m[0][1] *= k; m[1][1] *= k; m[2][1] *= k; m[3][1] *= k;
+ m[0][2] *= k; m[1][2] *= k; m[2][2] *= k; m[3][2] *= k;
+ m[0][3] *= k; m[1][3] *= k; m[2][3] *= k; m[3][3] *= k;
+}
+
+inline CMatrix CMatrix::operator * (CMatrix & matrix)
+{
+ CMatrix tmp;
+ tmp.EqMultiply(*this, matrix);
+ return tmp;
+}
+
+inline CVECTOR CMatrix::operator * (CVECTOR & vector)
+{
+ CVECTOR tmp;
+ tmp.x = matrix[0]*vector.x + matrix[4]*vector.y + matrix[8]*vector.z + matrix[12];
+ tmp.y = matrix[1]*vector.x + matrix[5]*vector.y + matrix[9]*vector.z + matrix[13];
+ tmp.z = matrix[2]*vector.x + matrix[6]*vector.y + matrix[10]*vector.z + matrix[14];
+ return tmp;
+}
+
+//this = m1*m2, (m1 != this, m2 != this)
+inline void CMatrix::EqMultiply(CMatrix & m1, CMatrix & m2)
+{
+ matrix[0] = m2.matrix[0]*m1.matrix[0] + m2.matrix[4]*m1.matrix[1] + m2.matrix[8]*m1.matrix[2] + m2.matrix[12]*m1.matrix[3];
+ matrix[1] = m2.matrix[1]*m1.matrix[0] + m2.matrix[5]*m1.matrix[1] + m2.matrix[9]*m1.matrix[2] + m2.matrix[13]*m1.matrix[3];
+ matrix[2] = m2.matrix[2]*m1.matrix[0] + m2.matrix[6]*m1.matrix[1] + m2.matrix[10]*m1.matrix[2] + m2.matrix[14]*m1.matrix[3];
+ matrix[3] = m2.matrix[3]*m1.matrix[0] + m2.matrix[7]*m1.matrix[1] + m2.matrix[11]*m1.matrix[2] + m2.matrix[15]*m1.matrix[3];
+
+ matrix[4] = m2.matrix[0]*m1.matrix[4] + m2.matrix[4]*m1.matrix[5] + m2.matrix[8]*m1.matrix[6] + m2.matrix[12]*m1.matrix[7];
+ matrix[5] = m2.matrix[1]*m1.matrix[4] + m2.matrix[5]*m1.matrix[5] + m2.matrix[9]*m1.matrix[6] + m2.matrix[13]*m1.matrix[7];
+ matrix[6] = m2.matrix[2]*m1.matrix[4] + m2.matrix[6]*m1.matrix[5] + m2.matrix[10]*m1.matrix[6] + m2.matrix[14]*m1.matrix[7];
+ matrix[7] = m2.matrix[3]*m1.matrix[4] + m2.matrix[7]*m1.matrix[5] + m2.matrix[11]*m1.matrix[6] + m2.matrix[15]*m1.matrix[7];
+
+ matrix[8] = m2.matrix[0]*m1.matrix[8] + m2.matrix[4]*m1.matrix[9] + m2.matrix[8]*m1.matrix[10] + m2.matrix[12]*m1.matrix[11];
+ matrix[9] = m2.matrix[1]*m1.matrix[8] + m2.matrix[5]*m1.matrix[9] + m2.matrix[9]*m1.matrix[10] + m2.matrix[13]*m1.matrix[11];
+ matrix[10] = m2.matrix[2]*m1.matrix[8] + m2.matrix[6]*m1.matrix[9] + m2.matrix[10]*m1.matrix[10] + m2.matrix[14]*m1.matrix[11];
+ matrix[11] = m2.matrix[3]*m1.matrix[8] + m2.matrix[7]*m1.matrix[9] + m2.matrix[11]*m1.matrix[10] + m2.matrix[15]*m1.matrix[11];
+
+ matrix[12] = m2.matrix[0]*m1.matrix[12] + m2.matrix[4]*m1.matrix[13] + m2.matrix[8]*m1.matrix[14] + m2.matrix[12]*m1.matrix[15];
+ matrix[13] = m2.matrix[1]*m1.matrix[12] + m2.matrix[5]*m1.matrix[13] + m2.matrix[9]*m1.matrix[14] + m2.matrix[13]*m1.matrix[15];
+ matrix[14] = m2.matrix[2]*m1.matrix[12] + m2.matrix[6]*m1.matrix[13] + m2.matrix[10]*m1.matrix[14] + m2.matrix[14]*m1.matrix[15];
+ matrix[15] = m2.matrix[3]*m1.matrix[12] + m2.matrix[7]*m1.matrix[13] + m2.matrix[11]*m1.matrix[14] + m2.matrix[15]*m1.matrix[15];
+}
+
+//Transform vertex to local coordinate system
+inline void CMatrix::MulToInv(const CVECTOR & src, CVECTOR & res)
+{
+ res.x = (src.x - matrix[12])*matrix[0] + (src.y - matrix[13])*matrix[1] + (src.z - matrix[14])*matrix[2];
+ res.y = (src.x - matrix[12])*matrix[4] + (src.y - matrix[13])*matrix[5] + (src.z - matrix[14])*matrix[6];
+ res.z = (src.x - matrix[12])*matrix[8] + (src.y - matrix[13])*matrix[9] + (src.z - matrix[14])*matrix[10];
+}
+
+//Transform normal to local coordinate system
+inline void CMatrix::MulToInvNorm(CVECTOR & src, CVECTOR & res)
+{
+ res.x = src.x*matrix[0] + src.y*matrix[1] + src.z*matrix[2];
+ res.y = src.x*matrix[4] + src.y*matrix[5] + src.z*matrix[6];
+ res.z = src.x*matrix[8] + src.y*matrix[9] + src.z*matrix[10];
+}
+
+//Transposition
+inline void CMatrix::Transposition()
+{
+ float x = Pos()|Vx();
+ float y = Pos()|Vy();
+ float z = Pos()|Vz();
+ Pos().x = -x;
+ Pos().y = -y;
+ Pos().z = -z;
+ Transposition3X3();
+}
+
+inline void CMatrix::Transposition3X3()
+{
+ float tmp;
+ tmp = matrix[1];
+ matrix[1] = matrix[4];
+ matrix[4] = tmp;
+ tmp = matrix[2];
+ matrix[2] = matrix[8];
+ matrix[8] = tmp;
+ tmp = matrix[6];
+ matrix[6] = matrix[9];
+ matrix[9] = tmp;
+}
+
+//Rotate
+inline void CMatrix::RotateX(float ang)
+{
+ CMatrix mtr;
+ mtr.BuildRotateX(ang);
+ *this *= mtr;
+}
+
+inline void CMatrix::RotateY(float ang)
+{
+ CMatrix mtr;
+ mtr.BuildRotateY(ang);
+ *this *= mtr;
+}
+
+inline void CMatrix::RotateZ(float ang)
+{
+ CMatrix mtr;
+ mtr.BuildRotateZ(ang);
+ *this *= mtr;
+}
+
+//Move
+inline void CMatrix::Move(float dX, float dY, float dZ)
+{
+ matrix[12] += dX; matrix[13] += dY; matrix[14] += dZ;
+}
+
+//Move(-(pos * this))
+inline void CMatrix::MoveInversePosition(float x, float y, float z)
+{
+ m[3][0] -= m[0][0]*x + m[1][0]*y + m[2][0]*z;
+ m[3][1] -= m[0][1]*x + m[1][1]*y + m[2][1]*z;
+ m[3][2] -= m[0][2]*x + m[1][2]*y + m[2][2]*z;
+}
+
+//Set new position
+inline void CMatrix::SetPosition(float x, float y, float z)
+{
+ matrix[12] = x; matrix[13] = y; matrix[14] = z;
+}
+
+inline void CMatrix::SetPosition(CVECTOR & pos)
+{
+ matrix[12] = pos.x; matrix[13] = pos.y; matrix[14] = pos.z;
+}
+
+//SetPosition(-(pos * this))
+inline void CMatrix::SetInversePosition(float x, float y, float z)
+{
+ m[3][0] = -(m[0][0]*x + m[1][0]*y + m[2][0]*z);
+ m[3][1] = -(m[0][1]*x + m[1][1]*y + m[2][1]*z);
+ m[3][2] = -(m[0][2]*x + m[1][2]*y + m[2][2]*z);
+}
+
+//============================================================================================
+//Utils
+//============================================================================================
+
+//Access to axis vectors
+inline CVECTOR & CMatrix::Vx() const
+{
+ return *(CVECTOR *)(matrix);
+}
+
+inline CVECTOR & CMatrix::Vy() const
+{
+ return *(CVECTOR *)(matrix + 4);
+}
+
+inline CVECTOR & CMatrix::Vz() const
+{
+ return *(CVECTOR *)(matrix + 8);
+}
+
+inline CVECTOR & CMatrix::Pos() const
+{
+ return *(CVECTOR *)(matrix + 12);
+}
+
+//Access to matrix element
+inline float & CMatrix::operator () (long i, long j)
+{
+ return m[i][j];
+}
+
+//Create only rotate matrix
+inline void CMatrix::Get3X3(CMatrix & mtr)
+{
+ mtr.matrix[0] = matrix[0];
+ mtr.matrix[1] = matrix[1];
+ mtr.matrix[2] = matrix[2];
+ mtr.matrix[4] = matrix[4];
+ mtr.matrix[5] = matrix[5];
+ mtr.matrix[6] = matrix[6];
+ mtr.matrix[8] = matrix[8];
+ mtr.matrix[9] = matrix[9];
+ mtr.matrix[10] = matrix[10];
+}
+
+inline void CMatrix::Get3X3(CMatrix * mtr)
+{
+ Get3X3(*mtr);
+}
+
+//Projection
+inline void CMatrix::BuildProjectionMatrix(float viewAngle, float vpWidth, float vpHeight, float zNear, float zFar)
+{
+ matrix[0] = 0;
+ matrix[1] = 0;
+ matrix[2] = 0;
+ matrix[3] = 0;
+ matrix[4] = 0;
+ matrix[5] = 0;
+ matrix[6] = 0;
+ matrix[7] = 0;
+ matrix[8] = 0;
+ matrix[9] = 0;
+ matrix[10] = 0;
+ matrix[11] = 0;
+ matrix[12] = 0;
+ matrix[13] = 0;
+ matrix[14] = 0;
+ matrix[15] = 0;
+
+ const auto Q = static_cast(zFar) / static_cast(zFar - zNear);
+
+ matrix[0] = 1.0f / tanf(viewAngle * 0.5f);
+ matrix[5] = 1.0f / tanf((vpHeight / vpWidth) * viewAngle * 0.5f);
+ matrix[10] = static_cast(Q);
+ matrix[11] = 1.0f;
+ matrix[14] = -static_cast(Q) * zNear;
+}
+
+inline void CMatrix::Projection(CVECTOR * srcArray, MTX_PRJ_VECTOR * dstArray, long num, float vphWidth05, float vphHeight05, long srcStrcSize, long dstStrcSize)
+{
+ float k;
+ for (; num > 0; num--)
+ {
+ dstArray->x = matrix[0] * srcArray->x + matrix[4] * srcArray->y + matrix[8] * srcArray->z + matrix[12];
+ dstArray->y = matrix[1] * srcArray->x + matrix[5] * srcArray->y + matrix[9] * srcArray->z + matrix[13];
+ dstArray->z = matrix[2] * srcArray->x + matrix[6] * srcArray->y + matrix[10] * srcArray->z + matrix[14];
+ dstArray->rhw = matrix[3] * srcArray->x + matrix[7] * srcArray->y + matrix[11] * srcArray->z + matrix[15];
+
+ k = 1.0f / dstArray->rhw;
+
+ dstArray->x = (1.0f + dstArray->x * k) * vphWidth05;
+ dstArray->y = (1.0f - dstArray->y * k) * vphHeight05;
+ dstArray->z *= k;
+
+ dstArray->rhw = k;
+
+ srcArray = (CVECTOR*)((char*)(srcArray)+srcStrcSize);
+ dstArray = (MTX_PRJ_VECTOR*)((char*)(dstArray)+dstStrcSize);
+ }
+}
+
+//View
+inline bool CMatrix::BuildViewMatrix(CVECTOR lookFrom, CVECTOR lookTo, CVECTOR upVector)
+{
+ SetIdentity();
+ //
+ lookTo -= lookFrom;
+ float l = ~lookTo;
+ if(l == 0.0f)
+ {
+ //
+ Pos() = -lookFrom;
+ return false;
+ }
+ lookTo *= 1.0f/sqrtf(l);
+ //
+ upVector -= lookTo*(lookTo | upVector);
+ //
+ l = ~upVector;
+ if(l == 0.0f) upVector.y = 1.0f;
+ else upVector *= 1.0f/sqrtf(l);
+ //
+ CVECTOR v = upVector ^ lookTo;
+ l = ~v;
+ if(l != 0.0f)
+ {
+ v *= (1.0f/sqrtf(l));
+ //
+ Vx() = upVector;
+ Vy() = lookTo;
+ Vz() = v;
+
+ m[0][0] = v.x;
+ m[1][0] = v.y;
+ m[2][0] = v.z;
+ m[0][1] = upVector.x;
+ m[1][1] = upVector.y;
+ m[2][1] = upVector.z;
+ m[0][2] = lookTo.x;
+ m[1][2] = lookTo.y;
+ m[2][2] = lookTo.z;
+
+ }
+ //
+ SetInversePosition(lookFrom.x, lookFrom.y, lookFrom.z);
+ return true;
+}
+
+//Mirror
+//
+inline void CMatrix::BuildMirrorMatrix(float Nx, float Ny, float Nz, float D)
+{
+ m[0][0] = -Nx*2.0f*Nx + 1.0f;
+ m[1][0] = -Nx*2.0f*Ny;
+ m[2][0] = -Nx*2.0f*Nz;
+ m[3][0] = -Nx*2.0f*-D;
+
+ m[0][1] = -Ny*2.0f*Nx;
+ m[1][1] = -Ny*2.0f*Ny + 1.0f;
+ m[2][1] = -Ny*2.0f*Nz;
+ m[3][1] = -Ny*2.0f*-D;
+
+ m[0][2] = -Nz*2.0f*Nx;
+ m[1][2] = -Nz*2.0f*Ny;
+ m[2][2] = -Nz*2.0f*Nz + 1.0f;
+ m[3][2] = -Nz*2.0f*-D;
+
+ m[0][3] = 0.0f;
+ m[1][3] = 0.0f;
+ m[2][3] = 0.0f;
+ m[3][3] = 1.0f;
+}
+
+//D3D extends (return (D3DXMATRIX *)pointer)
+inline CMatrix::operator D3DXMATRIX * ()
+{
+ return ((D3DXMATRIX*)matrix);
+};
+
+//============================================================================================
+
+#endif
diff --git a/tools/maya-plugin/Common/rdf.h b/tools/maya-plugin/Common/rdf.h
new file mode 100644
index 000000000..7b56ca698
--- /dev/null
+++ b/tools/maya-plugin/Common/rdf.h
@@ -0,0 +1,284 @@
+/******************************************************************************
+File: rdf.h
+
+Author: Nick Chirkov
+Copyright (C) 2000, 2001 Nick Chirkov
+
+Comments:
+geometry file format
+******************************************************************************/
+
+#ifndef __RDF_H__
+#define __RDF_H__
+
+#include
+#include
+
+#pragma pack(push,1)
+
+#include "cvector.h"
+
+/*
+
+RDF_HEAD;
+NAMES;
+textures;
+materials;
+lights;
+labels;
+objects;
+triangles;
+vertex_buffers;
+vertices;
+
+BSP_HEAD
+BSP_NODE - bsp nodes
+BSP_VERTEX - bsp vertices
+BSP_TRIANGLE - bsp triangles
+
+*/
+
+//------------------------------------------------------------
+//header
+//------------------------------------------------------------
+
+#define RDF_VERSION '1.05'
+
+enum RDF_FLAGS
+{
+ FLAGS_VISIBLE_PRESENT = 1,
+ FLAGS_BSP_PRESENT = 2,
+ RDFFLAGS_FORCEDWORD = 0x7FFFFFFF
+};
+
+struct RDF_HEAD
+{
+ long version; //RDF_VERSION
+ long flags; //combination of RDF_FLAGS
+ long name_size;
+ long names;
+ long ntextures;
+ long nmaterials;
+ long nlights;
+ long nlabels;
+ long nobjects;
+ long ntriangles;
+ long nvrtbuffs;
+
+ CVECTOR bbox_size, bbox_center;
+ float radius;
+};
+
+//------------------------------------------------------------
+//strings
+//------------------------------------------------------------
+//char NAMES[name_size];
+
+//------------------------------------------------------------
+//names of textures used
+//------------------------------------------------------------
+struct RDF_TEXTURE
+{
+ long name;
+};
+
+//------------------------------------------------------------
+//material
+//------------------------------------------------------------
+enum RDF_TEXTURE_TYPE
+{
+ TEXTURE_NONE = 0,
+ TEXTURE_BASE,
+ TEXTURE_NORMAL,
+ TEXTURE_FORCE_DWORD = 0x7FFFFFFF
+};
+struct RDF_MATERIAL
+{
+ long group_name;
+ long name;
+ float diffuse; //0 - no diffuse material
+ float specular, gloss; //spec=0 - no specular, gloss is a power of cosine
+ float selfIllum; //for area light sources
+ RDF_TEXTURE_TYPE texture_type[4];
+ long texture[4];
+};
+
+//------------------------------------------------------------
+//dynamic light
+//------------------------------------------------------------
+enum RDF_LIGHT_TYPE
+{
+ LIGHT_POINT = 0,
+ LIGHT_SPOT,
+ LIGHT_DIRECTIONAL,
+ LIGHT_FORCE_DWORD = 0x7FFFFFFF
+};
+enum RDF_LIGHT_FLAGS
+{
+ LIGHT_SHADOW = 1,
+ LIGHT_FORCEDWORD = 0x7FFFFFFF
+};
+struct RDF_LIGHT
+{
+ long flags;
+ RDF_LIGHT_TYPE type;
+ long group_name;
+ long name;
+ float r,g,b;
+ float range;
+ CVECTOR pos;
+ float atten[3];
+ float inner, outer, falloff;
+ CVECTOR dir;
+};
+
+//------------------------------------------------------------
+//label
+//------------------------------------------------------------
+enum RDF_LABEL_FLAGS
+{
+ LABEL_FORCEDWORD = 0x7FFFFFFF
+};
+struct RDF_LABEL
+{
+ long group_name;
+ long name;
+ long flags; //combination of LABEL_FLAGS
+ float m[4][4];
+ long bones[4];
+ float weight[4];
+};
+
+//------------------------------------------------------------
+//object
+//------------------------------------------------------------
+enum RDF_OBJECT_FLAGS
+{
+ VISIBLE = (1<<0),
+ STATIC_LIGHT_ENABLE = (1<<1), //if no - object will not be lited
+ DINAMIC_LIGHT_ENABLE = (1<<2), //if no - no dynamic lighting perfomed
+ CAST_SHADOWS_ENABLE = (1<<3), //if material makes shadows
+ COLLISION_ENABLE = (1<<4), //if yes - object will be stored to BSP
+ VERTEX_WEIGHT = (1<<5), //animation
+ MERGE = (1<<6), //object is "merged"-type
+ CULLENABLE = (1<<7), //single-sided object
+ OBJECT_FORCEDWORD = 0x7FFFFFFF
+};
+struct RDF_OBJECT
+{
+ long group_name;
+ long name;
+ long flags;
+ CVECTOR center;
+ float radius;
+ long vertex_buff;
+ long ntriangles, striangle, nvertices, svertex;
+ long material;
+ long lights[8];
+ long bones[4];
+ long atriangles;
+};
+
+//------------------------------------------------------------
+//triangle 16bit indices
+//------------------------------------------------------------
+struct RDF_TRIANGLE
+{
+ unsigned short vindex[3];
+};
+
+//------------------------------------------------------------
+//vertex buffer descriptor
+//------------------------------------------------------------
+struct RDF_VERTEXBUFF
+{
+ long type;
+ long size;
+};
+
+//------------------------------------------------------------
+//vertex type
+//------------------------------------------------------------
+struct RDF_VERTEX0
+{
+ CVECTOR pos;
+ CVECTOR norm;
+ long color;
+ float tu0, tv0;
+};
+
+struct RDF_VERTEX1
+{
+ CVECTOR pos;
+ CVECTOR norm;
+ long color;
+ float tu0, tv0;
+ float tu1, tv1;
+};
+
+struct RDF_VERTEX2
+{
+ CVECTOR pos;
+ CVECTOR norm;
+ long color;
+ float tu0, tv0;
+ float tu1, tv1;
+ float tu2, tv2;
+};
+
+struct RDF_VERTEX3
+{
+ CVECTOR pos;
+ CVECTOR norm;
+ long color;
+ float tu0, tv0;
+ float tu1, tv1;
+ float tu2, tv2;
+ float tu3, tv3;
+};
+
+//-------------------animated vertex---------------
+struct RDF_AVERTEX0
+{
+ CVECTOR pos;
+ float weight;
+ unsigned long boneid;
+ CVECTOR norm;
+ long color;
+ float tu0, tv0;
+};
+
+//------------------------------------------------------------
+//bsp
+//------------------------------------------------------------
+struct RDF_BSPHEAD
+{
+ long nnodes;
+ long nvertices;
+ long ntriangles;
+};
+
+struct RDF_BSPTRIANGLE
+{
+ unsigned char vindex[3][3];
+};
+
+#define RDF_BSPVERTEX CVECTOR
+
+struct BSP_NODE
+{
+ CVECTOR norm;
+ float pd;
+ unsigned long
+ node:22,
+ sign:1,
+ left:1,
+ nfaces:4,
+ right:2,
+ type:2;
+
+ long face;
+};
+
+#pragma pack(pop)
+#endif
\ No newline at end of file
diff --git a/tools/maya-plugin/Common/texture.h b/tools/maya-plugin/Common/texture.h
new file mode 100644
index 000000000..a453b573f
--- /dev/null
+++ b/tools/maya-plugin/Common/texture.h
@@ -0,0 +1,29 @@
+/******************************************************************************
+File: texture.h
+
+Author: Nick Chirkov
+Copyright (C) 2000-2002 Nick Chirkov
+
+Comments:
+******************************************************************************/
+#ifndef __TEXTURE_H__
+#define __TEXTURE_H__
+
+#pragma pack(push)
+#pragma pack(1)
+
+
+struct RDF_TEXTURE
+{
+ long flags;
+ long width, height;
+ long nmips;
+ long format;
+ long texel_size;
+ //palette;
+ //data;
+};
+
+#pragma pack(pop)
+
+#endif
\ No newline at end of file
diff --git a/tools/maya-plugin/Export/Export.vcxproj b/tools/maya-plugin/Export/Export.vcxproj
new file mode 100644
index 000000000..f39fa0c14
--- /dev/null
+++ b/tools/maya-plugin/Export/Export.vcxproj
@@ -0,0 +1,185 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 16.0
+ Win32Proj
+ {b2a3b561-1b1c-4025-8a77-522fcb52e08a}
+ Export
+ 10.0
+
+
+
+ StaticLibrary
+ true
+ v142
+ Unicode
+
+
+ StaticLibrary
+ false
+ v142
+ true
+ Unicode
+
+
+ StaticLibrary
+ true
+ v142
+ Unicode
+
+
+ StaticLibrary
+ false
+ v142
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ $(SolutionDir)$(PlatformShortName)\$(Configuration)\
+ $(PlatformShortName)\$(Configuration)\
+ ../Common;$(VC_IncludePath);$(WindowsSDK_IncludePath);
+
+
+ false
+ $(SolutionDir)$(PlatformShortName)\$(Configuration)\
+ $(PlatformShortName)\$(Configuration)\
+ ../Common;$(VC_IncludePath);$(WindowsSDK_IncludePath);
+
+
+ true
+ ../Common;$(VC_IncludePath);$(WindowsSDK_IncludePath);
+ $(SolutionDir)$(PlatformShortName)\$(Configuration)\
+ $(PlatformShortName)\$(Configuration)\
+
+
+ false
+ ../Common;$(VC_IncludePath);$(WindowsSDK_IncludePath);
+ $(SolutionDir)$(PlatformShortName)\$(Configuration)\
+ $(PlatformShortName)\$(Configuration)\
+
+
+
+ Level3
+ true
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)
+ true
+ NotUsing
+ pch.h
+ stdcpplatest
+
+
+
+
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)
+ true
+ NotUsing
+ pch.h
+ stdcpplatest
+
+
+
+
+ true
+ true
+ true
+
+
+
+
+ Level3
+ true
+ _CRT_SECURE_NO_WARNINGS;_DEBUG;_LIB;%(PreprocessorDefinitions)
+ true
+ NotUsing
+ pch.h
+ stdcpplatest
+
+
+
+
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ _CRT_SECURE_NO_WARNINGS;NDEBUG;_LIB;%(PreprocessorDefinitions)
+ true
+ NotUsing
+ pch.h
+ stdcpplatest
+
+
+
+
+ true
+ true
+ true
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tools/maya-plugin/Export/Export.vcxproj.filters b/tools/maya-plugin/Export/Export.vcxproj.filters
new file mode 100644
index 000000000..af3e3807a
--- /dev/null
+++ b/tools/maya-plugin/Export/Export.vcxproj.filters
@@ -0,0 +1,48 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Исходные файлы
+
+
+ Исходные файлы
+
+
+ Исходные файлы
+
+
+ Исходные файлы
+
+
+
+
+ Файлы заголовков
+
+
+ Файлы заголовков
+
+
+ Файлы заголовков
+
+
+ Файлы заголовков
+
+
+ Файлы заголовков
+
+
+
\ No newline at end of file
diff --git a/tools/maya-plugin/Export/bsp.cpp b/tools/maya-plugin/Export/bsp.cpp
new file mode 100644
index 000000000..448a9c6c1
--- /dev/null
+++ b/tools/maya-plugin/Export/bsp.cpp
@@ -0,0 +1,409 @@
+/******************************************************************************
+File: bsp.cpp
+
+Author: Nick Chirkov
+Copyright (C) 2000-2002 Nick Chirkov
+
+Comments:
+******************************************************************************/
+#include "bsp.h"
+
+extern CVECTOR *vrt;
+extern BTRG *trg;
+extern DVECTOR bbox;
+extern long ssize, max_depth, ndepth[MAX_TREE_DEPTH];
+extern BSP_NODE *sroot;
+extern long cur_node;
+extern long cur_depth;
+extern long cdepth;
+extern long tnode;
+
+#define LIE_PREC 0.0001
+
+BUILD_BSP_NODE::~BUILD_BSP_NODE()
+{
+ delete _face;
+ if(right!=NULL) delete right;
+ if(left!=NULL) delete left;
+}
+
+double TOT_FACES, CUR_FACE;
+long min_l, min_r, min_c, min_m;
+
+#include "rdf_exp.h"
+extern RESULT_FUNC resultfn;
+//-----------------------------------------------------------------------------------
+//fill node
+//-----------------------------------------------------------------------------------
+BSP_NODE *BUILD_BSP_NODE::FillNode(BUILD_BSP_FACE **list, long nfaces)
+{
+ static long time = 0;
+ if(GetTickCount()-time>1000)
+ {
+ double prc = 100.0*CUR_FACE/TOT_FACES;
+ char ee[256];
+ sprintf(ee, "Building BSP: %.2f %%", float(prc));
+ if(resultfn(std::string(ee))==false) throw "Building BSP process was terminated";
+ time = GetTickCount();
+ }
+
+ long best_plane = BestPlane(list, nfaces);
+//######################################__SORT__######################################
+ norm = list[best_plane]->normal;
+ pld = norm | vrt[trg[list[best_plane]->trg].vindex[0]];
+
+ if(min_m>MAX_PLANE_FACES)
+ {
+ BestEmptyPlane(list, nfaces, &norm, &pld);
+ best_plane = -1;
+ }
+
+ BUILD_BSP_FACE **rlist = new BUILD_BSP_FACE*[min_r + min_c];
+ BUILD_BSP_FACE **llist = new BUILD_BSP_FACE*[min_l + min_c];
+
+ CUR_FACE += min_m; TOT_FACES += min_c;
+
+ cur_node++;
+ cur_depth++; if(cur_depth>max_depth) max_depth = cur_depth;
+ if(cur_depth>1000)
+ __debugbreak();
+
+ tot_faces=0;
+ _face = new long[min_m];
+
+ // sort all faces
+ long l=0,r=0;
+ for(long i=0; itrg].vindex[0]]) - pld;
+ res[1] = (norm | vrt[trg[list[i]->trg].vindex[1]]) - pld;
+ res[2] = (norm | vrt[trg[list[i]->trg].vindex[2]]) - pld;
+ if(fabs(res[0])trg) break;
+ //add new trg
+ if(tf==tot_faces) _face[tot_faces++] = list[i]->trg;
+
+ delete list[i]->vertices;
+ delete list[i];
+ continue;
+ }
+
+ double vdist[256];
+ long min_did, max_did;
+ double min_dist=1e300, max_dist=-1e300;
+ for(long v=0; vnvertices; v++)
+ {
+ vdist[v] = (norm | list[i]->vertices[v]) - pld;
+ if(vdist[v]>max_dist)
+ {
+ max_dist = vdist[v];
+ max_did = v;
+ }
+ if(vdist[v]=-PRECISION && max_dist>=-PRECISION)
+ {
+ rlist[r++] = list[i];
+ continue;
+ }
+ if(min_dist<=PRECISION && max_dist<=PRECISION)
+ {
+ llist[l++] = list[i];
+ continue;
+ }
+
+ //face is on the both sides
+ BUILD_BSP_FACE *right_face = new BUILD_BSP_FACE;
+ *right_face = *list[i];
+ while(vdist[max_did]>-PRECISION) //search for a first vertex
+ {
+ max_did--;
+ if(max_did==-1) max_did=list[i]->nvertices-1;
+ } //max_did - first
+
+ right_face->nvertices=0;
+ right_face->vertices=NULL;
+ do
+ {
+ right_face->nvertices++;
+ right_face->vertices = (DVECTOR*)realloc(right_face->vertices, right_face->nvertices*sizeof(DVECTOR));
+
+ if(vdist[max_did]<=-PRECISION) //split edge
+ {
+ long v = max_did+1; if(v==list[i]->nvertices) v=0;
+
+ double d = vdist[max_did]/(vdist[max_did]-vdist[v]);
+ right_face->vertices[right_face->nvertices-1] = list[i]->vertices[max_did] + d*(list[i]->vertices[v] - list[i]->vertices[max_did]);
+ }
+ else right_face->vertices[right_face->nvertices-1] = list[i]->vertices[max_did]; //copy vertex
+
+ max_did++; if(max_did==list[i]->nvertices) max_did=0;
+ }while(vdist[max_did]>-PRECISION);
+
+ right_face->nvertices++;
+ right_face->vertices = (DVECTOR*)realloc(right_face->vertices, right_face->nvertices*sizeof(DVECTOR));
+ //split the last edge
+ long v = max_did-1; if(v==-1) v=list[i]->nvertices-1;
+ double d = vdist[max_did]/(vdist[max_did]-vdist[v]);
+ right_face->vertices[right_face->nvertices-1] = list[i]->vertices[max_did] + d*(list[i]->vertices[v] - list[i]->vertices[max_did]);
+ // add to the right list
+ rlist[r++] = right_face;
+
+ //------------------------------------LEFT-----------------------------------------
+ right_face = new BUILD_BSP_FACE;
+ *right_face = *list[i];
+ while(vdist[min_did]nvertices-1;
+ } //min_did - first
+
+ right_face->nvertices=0;
+ right_face->vertices=NULL;
+ do
+ {
+ right_face->nvertices++;
+ right_face->vertices = (DVECTOR*)realloc(right_face->vertices, right_face->nvertices*sizeof(DVECTOR));
+
+ if(vdist[min_did]>=PRECISION) //split edge
+ {
+ long v = min_did+1; if(v==list[i]->nvertices) v=0;
+
+ double d = vdist[min_did]/(vdist[min_did]-vdist[v]);
+ right_face->vertices[right_face->nvertices-1] = list[i]->vertices[min_did] + d*(list[i]->vertices[v] - list[i]->vertices[min_did]);
+ }
+ else right_face->vertices[right_face->nvertices-1] = list[i]->vertices[min_did]; //copy vertex
+
+ min_did++; if(min_did==list[i]->nvertices) min_did=0;
+ }while(vdist[min_did]nvertices++;
+ right_face->vertices = (DVECTOR*)realloc(right_face->vertices, right_face->nvertices*sizeof(DVECTOR));
+ //split the last edge
+ v = min_did-1; if(v==-1) v=list[i]->nvertices-1;
+ d = vdist[min_did]/(vdist[min_did]-vdist[v]);
+ right_face->vertices[right_face->nvertices-1] = list[i]->vertices[min_did] + d*(list[i]->vertices[v] - list[i]->vertices[min_did]);
+ // add to the right list
+ llist[l++] = right_face;
+
+ delete list[i]->vertices;
+ delete list[i];
+ }
+
+ delete list;
+
+ //calculate size of BSP
+ ssize += NODESIZE(tot_faces);
+ ndepth[cur_depth] += NODESIZE(tot_faces);
+
+ if(r>0)
+ {
+ right = new BUILD_BSP_NODE();
+ right->FillNode(rlist,r);
+ }
+ else right = NULL;
+
+ if(l>0)
+ {
+ left = new BUILD_BSP_NODE();
+ left->FillNode(llist,l);
+ }
+ else left = NULL;
+
+ cur_depth--;
+
+ return 0;
+}
+
+
+//-----------------------------------------------------------------------------------
+//best blane
+//-----------------------------------------------------------------------------------
+long BUILD_BSP_NODE::BestPlane(BUILD_BSP_FACE **list, long nfaces)
+{
+ double res0, res1, res2;
+ long best_plane;
+
+ double gd = 1e20;
+ for(long f=0; fnormal | vrt[trg[list[i]->trg].vindex[0]]) - list[f]->plane_distance;
+ res1 = (list[f]->normal | vrt[trg[list[i]->trg].vindex[1]]) - list[f]->plane_distance;
+ res2 = (list[f]->normal | vrt[trg[list[i]->trg].vindex[2]]) - list[f]->plane_distance;
+ if(fabs(res0)nvertices; v++)
+ {
+ double dist = (list[f]->normal | list[i]->vertices[v]) - list[f]->plane_distance;
+ if(dist>max_dist) max_dist = dist;
+ if(dist=-PRECISION && max_dist>=-PRECISION)
+ {
+ r++;
+ continue;
+ }
+ if(min_dist<=PRECISION && max_dist<=PRECISION)
+ {
+ l++;
+ continue;
+ }
+ c++; //triangle is on the both sides
+ }
+
+ double dist = 3.0*c + 1.0*fabs(r-l);
+ if(distvertices[e1] - list[f]->vertices[e];
+ DVECTOR bnormal = !(((list[f]->normal*sqrt(~edge)) ^ edge));
+ double bplane_distance = bnormal | list[f]->vertices[e];
+
+ long l=0, r=0, c=0, m=0;
+ long i;
+ for(i=0; itrg].vindex[0]]) - bplane_distance;
+ res1 = (bnormal | vrt[trg[list[i]->trg].vindex[1]]) - bplane_distance;
+ res2 = (bnormal | vrt[trg[list[i]->trg].vindex[2]]) - bplane_distance;
+ if(fabs(res0)nvertices; v++)
+ {
+ double dist = (bnormal | list[i]->vertices[v]) - bplane_distance;
+ if(dist>max_dist) max_dist = dist;
+ if(dist=-PRECISION && max_dist>=-PRECISION)
+ {
+ r++;
+ continue;
+ }
+ if(min_dist<=PRECISION && max_dist<=PRECISION)
+ {
+ l++;
+ continue;
+ }
+ c++; //triangle is on the both sides
+ }
+
+ if(i0 && l>0 && distsign = 0;
+ node->type = 0;
+ node->norm.x = float(norm.x);
+ node->norm.y = float(norm.y);
+ node->norm.z = float(norm.z);
+ node->pd = float(pld);
+
+ //store all faces
+ unsigned char *a = (unsigned char*)&node->face;
+ for(long f=0; fnfaces = tot_faces;
+ if(node->nfaces>MAX_PLANE_FACES) throw "Internal error: too many faces on the BSP node";
+
+
+ ndepth[cdepth] += NODESIZE(node->nfaces);
+
+ cdepth++;
+
+ node->left = 0;
+ node->node = 0;
+ if(left!=NULL)
+ {
+ node->node = left->Store();
+ //left is present
+ node->left = 1;
+ }
+
+ if(right!=NULL) //right is present
+ if(left==NULL)
+ {
+ //left is not present
+ node->node = right->Store() - 1;
+ node->right = 1;
+ }
+ else
+ {
+ //node's size 1..3 blocks of 24 byte
+ node->right = right->Store() - node->node;
+ }
+
+ cdepth--;
+ return long(node-sroot);
+}
diff --git a/tools/maya-plugin/Export/bsp.h b/tools/maya-plugin/Export/bsp.h
new file mode 100644
index 000000000..3ba6982c2
--- /dev/null
+++ b/tools/maya-plugin/Export/bsp.h
@@ -0,0 +1,68 @@
+/******************************************************************************
+File: bsp.h
+
+Author: Nick Chirkov
+Copyright (C) 2000-2002 Nick Chirkov
+
+Comments:
+******************************************************************************/
+#ifndef __BSP_H__
+#define __BSP_H__
+
+#include "cvector.h"
+#include "rdf.h"
+#include
+
+#define MAX_TREE_DEPTH 1024
+#define MAX_PLANES_CALCULATED 256
+//#define PRECISION 5e-7
+#define PRECISION 0.00001
+#define KDISTANCE 0.0
+#define KBALANCE 1.0
+#define KCLIP 30.0
+//calculate size of node in blocks
+#define NODESIZE(a) (1+(a*3+sizeof(BSP_NODE)-sizeof(long))/sizeof(BSP_NODE))
+//max faces on node
+#define MAX_PLANE_FACES min(15, (sizeof(BSP_NODE)*2+sizeof(long))/3)
+
+#pragma pack(push)
+#pragma pack(1)
+
+struct BTRG
+{
+ long vindex[3];
+};
+
+//-----------BSP_FACE-----------
+typedef struct
+{
+ long trg;
+ DVECTOR *vertices;
+ long nvertices;
+ DVECTOR normal; //temporary
+ double plane_distance; //temporary
+}BUILD_BSP_FACE;
+
+// builder
+class BUILD_BSP_NODE;
+class BUILD_BSP_NODE
+{
+public:
+ BUILD_BSP_NODE *right,*left;
+
+ long current;
+ DVECTOR norm;
+ double pld;
+ long tot_faces;
+ long *_face;
+
+ BUILD_BSP_NODE(){};
+ ~BUILD_BSP_NODE();
+ BSP_NODE *FillNode(BUILD_BSP_FACE **list, long nfaces);
+ long BestPlane(BUILD_BSP_FACE **list, long nfaces);
+ void BestEmptyPlane(BUILD_BSP_FACE **list, long nfaces, DVECTOR *epnorm, double *epdist);
+ long Store();
+};
+#pragma pack(pop)
+
+#endif
\ No newline at end of file
diff --git a/tools/maya-plugin/Export/collide.cpp b/tools/maya-plugin/Export/collide.cpp
new file mode 100644
index 000000000..470335a77
--- /dev/null
+++ b/tools/maya-plugin/Export/collide.cpp
@@ -0,0 +1,222 @@
+/******************************************************************************
+File: collide.cpp
+
+Author: Nick Chirkov
+Copyright (C) 2000-2002 Nick Chirkov
+
+Comments:
+******************************************************************************/
+#include "collide.h"
+
+
+long nvrts, ntrgs, _ntrgs;
+long cur_node, cur_depth;
+BTRG *trg, *_trg; CVECTOR *vrt;
+long cdepth, tnode;
+
+DVECTOR bbox;
+BSP_NODE *sroot;
+long max_depth, ssize, ndepth[MAX_TREE_DEPTH];
+
+std::vector lvert;
+std::vector geolink;
+RESULT_FUNC resultfn;
+extern double TOT_FACES, CUR_FACE;
+
+COLLIDE::COLLIDE(RESULT_FUNC _rfn)
+{
+ resultfn = _rfn;
+ rfn = _rfn;
+ nvrts=0;
+ ntrgs = _ntrgs = 0;
+ cur_node=-1;
+ cur_depth=0;
+ cdepth=0;
+ tnode=0;
+ max_depth = 0;
+
+ iterations = 0;
+ triangles=0;
+ trg = _trg = 0; vrt = 0;
+}
+
+COLLIDE::~COLLIDE()
+{
+ delete vrt; vrt = nullptr;
+ delete trg; trg = nullptr;
+ delete _trg; _trg = nullptr;
+ delete sroot; sroot = nullptr;
+ lvert.clear();
+ geolink.clear();
+}
+
+void COLLIDE::AddCollideVertices(long obj, std::vector &av, long nav, RDF_TRIANGLE *at, long nat)
+{
+ for(long v0=0; v0