Added: #1440 Initial code for shape export

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent 5e1cab83f5
commit 433cf02624

@ -5,6 +5,7 @@
* \author Jan Boon (Kaetemi) * \author Jan Boon (Kaetemi)
* Tool logger is fully implemented in header so small tools do not * Tool logger is fully implemented in header so small tools do not
* need to link to this library unnecessarily. * need to link to this library unnecessarily.
* NOTE: Needs to be changed not to use time_nl and string_common.
*/ */
/* /*
@ -43,8 +44,6 @@
namespace PIPELINE { namespace PIPELINE {
namespace {
#ifdef ERROR #ifdef ERROR
#undef ERROR #undef ERROR
#endif #endif
@ -78,17 +77,17 @@ private:
FILE *m_DependLog; FILE *m_DependLog;
public: public:
CToolLogger() inline CToolLogger()
{ {
} }
virtual ~CToolLogger() inline ~CToolLogger()
{ {
release(); release();
} }
void initError(const std::string &errorLog) inline void initError(const std::string &errorLog)
{ {
releaseError(); releaseError();
@ -99,7 +98,7 @@ public:
} }
void initDepend(const std::string &dependLog) inline void initDepend(const std::string &dependLog)
{ {
releaseDepend(); releaseDepend();
@ -109,7 +108,7 @@ public:
// fflush(m_DependLog); // fflush(m_DependLog);
} }
void writeError(TError type, const std::string &path, const std::string &error) inline void writeError(TError type, const std::string &path, const std::string &error)
{ {
if (m_ErrorLog) if (m_ErrorLog)
{ {
@ -138,7 +137,7 @@ public:
} }
/// inputFile can only be file. [? May be not-yet-existing file for expected input for future build runs. ?] Directories are handled on process level. [? You should call this before calling writeError on inputFile, so the error is also linked from the outputFile. ?] /// inputFile can only be file. [? May be not-yet-existing file for expected input for future build runs. ?] Directories are handled on process level. [? You should call this before calling writeError on inputFile, so the error is also linked from the outputFile. ?]
void writeDepend(TDepend type, const std::string &outputFile, const std::string &inputFile) inline void writeDepend(TDepend type, const std::string &outputFile, const std::string &inputFile)
{ {
if (m_DependLog) if (m_DependLog)
{ {
@ -163,7 +162,7 @@ public:
} }
} }
void releaseError() inline void releaseError()
{ {
if (m_ErrorLog) if (m_ErrorLog)
{ {
@ -173,7 +172,7 @@ public:
} }
} }
void releaseDepend() inline void releaseDepend()
{ {
if (m_DependLog) if (m_DependLog)
{ {
@ -183,15 +182,13 @@ public:
} }
} }
void release() inline void release()
{ {
releaseError(); releaseError();
releaseDepend(); releaseDepend();
} }
}; /* class CToolLogger */ }; /* class CToolLogger */
} /* anonymous namespace */
} /* namespace PIPELINE */ } /* namespace PIPELINE */
#endif /* #ifndef PIPELINE_TOOL_LOGGER_H */ #endif /* #ifndef PIPELINE_TOOL_LOGGER_H */

@ -43,10 +43,16 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
{ {
DWORD dwRetVal = GetTempPathA(MAX_PATH, tempPathBuffer); DWORD dwRetVal = GetTempPathA(MAX_PATH, tempPathBuffer);
if (dwRetVal > MAX_PATH || (dwRetVal == 0)) if (dwRetVal > MAX_PATH || (dwRetVal == 0))
{
ToolLogger.writeError(PIPELINE::ERROR, "*", "GetTempPath failed");
nlerror("GetTempPath failed"); nlerror("GetTempPath failed");
}
UINT uRetVal = GetTempFileNameA(tempPathBuffer, TEXT("_nel_export_mesh_"), 0, tempFileName); UINT uRetVal = GetTempFileNameA(tempPathBuffer, TEXT("_nel_export_mesh_"), 0, tempFileName);
if (uRetVal == 0) if (uRetVal == 0)
{
ToolLogger.writeError(PIPELINE::ERROR, "*", "GetTempFileName failed");
nlerror("GetTempFileName failed"); nlerror("GetTempFileName failed");
}
// Eval the object a time // Eval the object a time
ObjectState os = node.EvalWorldState(time); ObjectState os = node.EvalWorldState(time);
@ -118,6 +124,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
catch (...) catch (...)
{ {
nlwarning("Shape serialization failed!"); nlwarning("Shape serialization failed!");
ToolLogger.writeError(PIPELINE::ERROR, "*", "Shape serialization failed");
try try
{ {
file.close(); file.close();
@ -132,6 +139,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
else else
{ {
nlwarning("Failed to create file %s", tempFileName); nlwarning("Failed to create file %s", tempFileName);
ToolLogger.writeError(PIPELINE::ERROR, "*", "Failed to create temporary shape file");
if (_TerminateOnFileOpenIssues) if (_TerminateOnFileOpenIssues)
nelExportTerminateProcess(); nelExportTerminateProcess();
} }
@ -148,6 +156,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
catch (...) catch (...)
{ {
nlwarning("Failed to delete pShape pointer! Something might be wrong."); nlwarning("Failed to delete pShape pointer! Something might be wrong.");
ToolLogger.writeError(PIPELINE::ERROR, "*", "Failed to delete pShape pointer");
remove(tempFileName); remove(tempFileName);
bRet = false; bRet = false;
} }
@ -174,6 +183,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
else else
{ {
nlwarning("Failed to open file: %s", tempFileName); nlwarning("Failed to open file: %s", tempFileName);
ToolLogger.writeError(PIPELINE::ERROR, "*", "Failed to open temp shape file");
if (_TerminateOnFileOpenIssues) if (_TerminateOnFileOpenIssues)
nelExportTerminateProcess(); nelExportTerminateProcess();
} }
@ -181,6 +191,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
catch (...) catch (...)
{ {
nlwarning("Failed to verify shape. Must crash now."); nlwarning("Failed to verify shape. Must crash now.");
ToolLogger.writeError(PIPELINE::ERROR, "*", "Failed to verify shape");
remove(tempFileName); remove(tempFileName);
bRet = false; bRet = false;
} }
@ -191,11 +202,13 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
catch (...) catch (...)
{ {
nlwarning("Fatal exception at CNelExport::exportMesh."); nlwarning("Fatal exception at CNelExport::exportMesh.");
ToolLogger.writeError(PIPELINE::ERROR, "*", "Fatal exception at CNelExport::exportMesh");
bRet = false; bRet = false;
} }
if (bRet) if (bRet)
{ {
ToolLogger.writeDepend(PIPELINE::BUILD, sPath, "*");
try try
{ {
remove(sPath); remove(sPath);

@ -63,6 +63,13 @@ def_visible_primitive ( set_file_modification_date, "NeLSetFileModificationDate
def_visible_primitive ( force_quit_on_msg_displayer, "NelForceQuitOnMsgDisplayer"); def_visible_primitive ( force_quit_on_msg_displayer, "NelForceQuitOnMsgDisplayer");
def_visible_primitive ( force_quit_right_now, "NelForceQuitRightNow"); def_visible_primitive ( force_quit_right_now, "NelForceQuitRightNow");
def_visible_primitive(tool_logger_init_error, "NelToolLoggerInitError");
def_visible_primitive(tool_logger_init_depend, "NelToolLoggerInitDepend");
def_visible_primitive(tool_logger_write_error, "NelToolLoggerWriteError");
def_visible_primitive(tool_logger_write_depend, "NelToolLoggerWriteDepend");
def_visible_primitive(tool_logger_release_error, "NelToolLoggerReleaseError");
def_visible_primitive(tool_logger_release_depend, "NelToolLoggerReleaseDepend");
char *sExportShapeErrorMsg = "NeLExportShape [Object] [Filename.shape]"; char *sExportShapeErrorMsg = "NeLExportShape [Object] [Filename.shape]";
char *sExportShapeExErrorMsg = "NeLExportShapeEx [Object] [Filename.shape] [bShadow] [bExportLighting] [sLightmapPath] [nLightingLimit] [fLumelSize] [nOverSampling] [bExcludeNonSelected] [bShowLumel]"; char *sExportShapeExErrorMsg = "NeLExportShapeEx [Object] [Filename.shape] [bShadow] [bExportLighting] [sLightmapPath] [nLightingLimit] [fLumelSize] [nOverSampling] [bExcludeNonSelected] [bShowLumel]";
char *sExportAnimationErrorMsg = "NelExportAnimation [node array] [Filename.anim] [bool_scene_animation]"; char *sExportAnimationErrorMsg = "NelExportAnimation [node array] [Filename.anim] [bool_scene_animation]";
@ -114,10 +121,12 @@ Value* export_shape_cf (Value** arg_list, int count)
} }
catch (Exception &e) catch (Exception &e)
{ {
ToolLogger.writeError(PIPELINE::ERROR, "*", e.what());
nlwarning ("ERROR (NelExportShape) %s", e.what()); nlwarning ("ERROR (NelExportShape) %s", e.what());
} }
catch (...) catch (...)
{ {
ToolLogger.writeError(PIPELINE::ERROR, "*", "Exception");
nlwarning ("ERROR (NelExportShape) catch (...)"); nlwarning ("ERROR (NelExportShape) catch (...)");
} }
nlinfo("ret"); nlinfo("ret");
@ -189,10 +198,12 @@ Value* export_shape_ex_cf (Value** arg_list, int count)
} }
catch (Exception &e) catch (Exception &e)
{ {
ToolLogger.writeError(PIPELINE::ERROR, "*", e.what());
nlwarning ("ERROR (NelExportShapeEx) %s", e.what()); nlwarning ("ERROR (NelExportShapeEx) %s", e.what());
} }
catch (...) catch (...)
{ {
ToolLogger.writeError(PIPELINE::ERROR, "*", "Exception");
nlwarning ("ERROR (NelExportShapeEx) catch (...)"); nlwarning ("ERROR (NelExportShapeEx) catch (...)");
} }
nlinfo("ret"); nlinfo("ret");
@ -986,6 +997,68 @@ Value* force_quit_right_now_cf(Value** arg_list, int count)
return &true_value; return &true_value;
} }
Value* tool_logger_init_error_cf(Value** arg_list, int count)
{
check_arg_count(NelToolLoggerInitError, 1, count);
type_check(arg_list[0], String, "");
ToolLogger.initError(arg_list[0]->to_string());
return &true_value;
}
Value* tool_logger_init_depend_cf(Value** arg_list, int count)
{
check_arg_count(NelToolLoggerInitDepend, 1, count);
type_check(arg_list[0], String, "");
ToolLogger.initDepend(arg_list[0]->to_string());
return &true_value;
}
Value* tool_logger_write_error_cf(Value** arg_list, int count)
{
check_arg_count(NelToolLoggerWriteError, 3, count);
type_check(arg_list[0], String, "");
type_check(arg_list[1], String, "");
type_check(arg_list[2], String, "");
// TYPE, PATH, MESSAGE
std::string type = arg_list[0]->to_string();
ToolLogger.writeError(type == "MESSAGE" ? PIPELINE::MESSAGE : type == "WARNING" ? PIPELINE::WARNING : PIPELINE::ERROR, arg_list[1]->to_string(), arg_list[2]->to_string());
return &true_value;
}
Value* tool_logger_write_depend_cf(Value** arg_list, int count)
{
check_arg_count(NelToolLoggerWriteDepend, 3, count);
type_check(arg_list[0], String, "");
type_check(arg_list[1], String, "");
type_check(arg_list[2], String, "");
// TYPE, OUTPUT, INPUT
std::string type = arg_list[0]->to_string();
ToolLogger.writeDepend(type == "RUNTIME" ? PIPELINE::RUNTIME : type == "DIRECTORY" ? PIPELINE::DIRECTORY : PIPELINE::BUILD, arg_list[1]->to_string(), arg_list[2]->to_string());
return &true_value;
}
Value* tool_logger_release_error_cf(Value** arg_list, int count)
{
ToolLogger.releaseError();
return &true_value;
}
Value* tool_logger_release_depend_cf(Value** arg_list, int count)
{
ToolLogger.releaseDepend();
return &true_value;
}
/*===========================================================================*\ /*===========================================================================*\
| MAXScript Plugin Initialization | MAXScript Plugin Initialization
\*===========================================================================*/ \*===========================================================================*/

@ -2012,6 +2012,7 @@ void CExportNel::deleteLM(INode& ZeNode)
if (!CFile::deleteFile(sSaveName)) if (!CFile::deleteFile(sSaveName))
{ {
nlwarning("Failed to delete file %s.", sSaveName.c_str()); nlwarning("Failed to delete file %s.", sSaveName.c_str());
ToolLogger.writeError(PIPELINE::ERROR, sSaveName.c_str(), "Failed to delete previously built lightmap");
} }
} }
} }
@ -2272,6 +2273,7 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB
thetext = "Warning "; thetext = "Warning ";
thetext += ZeNode.GetName(); thetext += ZeNode.GetName();
thetext = "have all faces NOT mapped (UV2)"; thetext = "have all faces NOT mapped (UV2)";
ToolLogger.writeError(PIPELINE::ERROR, "*", thetext);
if (gOptions.FeedBack != NULL) if (gOptions.FeedBack != NULL)
{ {
gOptions.FeedBack->setLine (11, thetext); gOptions.FeedBack->setLine (11, thetext);
@ -2322,6 +2324,8 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB
sTmp += ZeNode.GetName(); sTmp += ZeNode.GetName();
sTmp += " has mapping problem"; sTmp += " has mapping problem";
ToolLogger.writeError(PIPELINE::ERROR, "*", sTmp);
// Script trace // Script trace
mprintf ((sTmp+"\n").c_str()); mprintf ((sTmp+"\n").c_str());
@ -2590,6 +2594,7 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB
nlinfo("DELETE %s", sLMName.c_str()); nlinfo("DELETE %s", sLMName.c_str());
if (!CFile::deleteFile(sLMName)) if (!CFile::deleteFile(sLMName))
{ {
ToolLogger.writeError(PIPELINE::ERROR, sLMName, "Failed to delete previously built lightmap");
nlwarning("Failed to delete file %s", sLMName.c_str()); nlwarning("Failed to delete file %s", sLMName.c_str());
} }
} }
@ -2606,6 +2611,8 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB
// cust copy to 32 bits // cust copy to 32 bits
LightMap.copyColToBitmap32 (pLightMap, j); LightMap.copyColToBitmap32 (pLightMap, j);
ToolLogger.writeDepend(PIPELINE::BUILD, sSaveName, "*");
COFile f( sSaveName ); COFile f( sSaveName );
try try
{ {
@ -2624,6 +2631,7 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB
} }
catch(Exception &e) catch(Exception &e)
{ {
ToolLogger.writeError(PIPELINE::ERROR, sSaveName, "Cannot write the lightmap file");
if (gOptions.FeedBack != NULL) if (gOptions.FeedBack != NULL)
{ {
char message[512]; char message[512];

@ -28,6 +28,9 @@
#include "nel/3d/animation_time.h" #include "nel/3d/animation_time.h"
#include "nel/3d/animation_time.h" #include "nel/3d/animation_time.h"
#include "nel/../../src/pacs/collision_mesh_build.h" #include "nel/../../src/pacs/collision_mesh_build.h"
#include "nel/misc/tool_logger.h"
extern PIPELINE::CToolLogger ToolLogger;
#define UVGEN_MISSING (-1) #define UVGEN_MISSING (-1)
#define UVGEN_REFLEXION (-2) #define UVGEN_REFLEXION (-2)

@ -25,6 +25,11 @@
#endif #endif
#include "export_nel.h" #include "export_nel.h"
#include "export_appdata.h" #include "export_appdata.h"
#include <nel/misc/tool_logger.h>
// ***************************************************************************
PIPELINE::CToolLogger ToolLogger;
// *************************************************************************** // ***************************************************************************

@ -0,0 +1,32 @@
try
(
undo off
(
NelToolLoggerInitError %LogErrorFile%
NelToolLoggerInitDepend %LogDependFiles%
-- Unhide, unselect
unhidecategory()
max unhide all
max select none
-- Setup
lowercasenodes()
dependxref undefined
-- Go!
runNelMaxExport()
NelToolLoggerReleaseError
NelToolLoggerReleaseDepend
gc()
)
)
catch
(
-- Error
nlerror("Fatal error occured")
NelForceQuitRightNow()
)

@ -0,0 +1,134 @@
-- #################################################################
-- ## %PreGenWarning%
-- #################################################################
-- Allocate 20 Me for the script
heapSize += 15000000
-- In case of error just abort the app and don't show nel report window
NelForceQuitOnMsgDisplayer()
-- Global definitions
NEL3D_APPDATA_LOD_NAME_COUNT_MAX = 10
NEL3D_APPDATA_LOD = 1423062537
NEL3D_APPDATA_LOD_NAME_COUNT = NEL3D_APPDATA_LOD
NEL3D_APPDATA_LOD_NAME = NEL3D_APPDATA_LOD_NAME_COUNT+1
NEL3D_APPDATA_LOD_BLEND_IN = NEL3D_APPDATA_LOD_NAME+NEL3D_APPDATA_LOD_NAME_COUNT_MAX
NEL3D_APPDATA_LOD_BLEND_OUT = NEL3D_APPDATA_LOD_BLEND_IN+1
NEL3D_APPDATA_LOD_COARSE_MESH = NEL3D_APPDATA_LOD_BLEND_OUT+1
fn lowercase instring =
(
local upper, lower, outstring
upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
lower="abcdefghijklmnopqrstuvwxyz"
outstring = copy instring
for iii = 1 to outstring.count do
(
jjj = findString upper outstring[iii]
if (jjj != undefined) then
outstring[iii] = lower[jjj]
else
outstring[iii] = instring[iii]
)
return outstring -- value of outstring will be returned as function result
)
fn uppercase instring =
(
local upper, lower, outstring
upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
lower="abcdefghijklmnopqrstuvwxyz"
outstring = copy instring
for iii = 1 to outstring.count do
(
jjj = findString upper outstring[iii]
if (jjj != undefined) then
outstring[iii] = upper[jjj]
else
outstring[iii] = instring[iii]
)
return outstring -- value of outstring will be returned as function result
)
-- Add xrefs as dependencies
fn dependxref root =
(
sceneName = maxFilePath + maxFileName
for i = 1 to xrefs.getXRefFileCount(root) do
(
curxref = xrefs.getXRefFile i root
NelToolLoggerWriteDepend "BUILD" "*" curxref.filename -- not sure if full filepath...
dependxref curxref
)
)
-- Lowercase node names etc, temporary until another full conversion run over the max files is done
fn lowercasenodes =
(
allNodes = $*
for node in allNodes do
(
-- Lowercase the node name
node.name = lowercase(node.name)
-- Lowercase all LOD node name references
lodCount = getAppData node NEL3D_APPDATA_LOD_NAME_COUNT
if (lodCount != undefined) then
(
lodCountNum = nodeCount as Integer
for lod = 1 to lodCountNum do
(
lod = getAppData node (NEL3D_APPDATA_LOD_NAME + lod - 1)
if (lod != undefined) then
(
setAppData node (NEL3D_APPDATA_LOD_NAME + lod - 1) lowercase(lod)
)
)
)
)
)
-- Unhide category
fn unhidecategory =
(
if (geometry.count > 0) then
(
unhide geometry[1]
if (geometry[1].ishidden == true) then
max hide object toggle
)
if (shapes.count > 0) then
(
unhide shapes[1]
if (shapes[1].ishidden == true) then
max hide shape toggle
)
if (lights.count > 0) then
(
unhide lights[1]
if (lights[1].ishidden == true) then
max hide light toggle
)
if (cameras.count > 0) then
(
unhide cameras[1]
if (cameras[1].ishidden == true) then
max hide camera toggle
)
if (helpers.count > 0) then
(
unhide helpers[1]
if (helpers[1].ishidden == true) then
max hide helper toggle
)
)

@ -0,0 +1,322 @@
-- Some globals
NEL3D_APPDATA_ACCEL = 1423062561 -- type of accelerator : "32" = is not an accelerator and IS clusterized
-- "0" = is not an accelerator and IS NOT clusterized (always visible)
-- "1" = is an accelerator type PORTAL
-- "2" = is an accelerator type CLUSTER
-- "6" = is an accelerator type CLUSTER FATHER-VISIBLE
-- "10" = is an accelerator type CLUSTER VISIBLE-FROM-FATHER
-- "14" = is an accelerator type CLUSTER FATHER-VISIBLE and VISIBLE-FROM-FATHER
-- "17" = is an accelerator type PORTAL DYNAMIC
NEL3D_APPDATA_DONOTEXPORT = 1423062565 -- do not export me : "undefined" = export me
-- "0" = export me
-- "1" = DONT export me
NEL3D_APPDATA_COLLISION = 1423062613
NEL3D_APPDATA_COLLISION_EXTERIOR = 1423062614
NEL3D_APPDATA_AUTOMATIC_ANIMATION = 1423062617
-- This node is n accelerator ?
fn isAccelerator node =
(
accel = getappdata node NEL3D_APPDATA_ACCEL
if (accel != undefined) then
(
if (accel == "0") or (accel == "32") then
return false
else
return true
)
return false
)
-- Must export this node ?
fn isToBeExported node =
(
if (isAccelerator node) == true then
return false
if ((classof node) == RklPatch) then
return false
if ((classof node) == nel_ps) then
return false
if ((classof node) == nel_pacs_cylinder) then
return false
if ((classof node) == nel_pacs_box) then
return false
doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT
if (doNotExport != undefined) then
(
if (doNotExport == "1") then
return false
)
doNotExport = getappdata node NEL3D_APPDATA_COLLISION
if (doNotExport != undefined) then
(
if (doNotExport == "1") then
return false
)
doNotExport = getappdata node NEL3D_APPDATA_COLLISION_EXTERIOR
if (doNotExport != undefined) then
(
if (doNotExport == "1") then
return false
)
return true
)
-- Must export this node ?
fn isAnimToBeExported node =
(
automaticAnimation = getappdata node NEL3D_APPDATA_AUTOMATIC_ANIMATION
if (automaticAnimation == undefined) then
return false
if (automaticAnimation == "0") then
return false
if (isAccelerator node) == true then
return false
if ((classof node) == nel_pacs_cylinder) then
return false
if ((classof node) == nel_pacs_box) then
return false
doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT
if (doNotExport != undefined) then
(
if (doNotExport == "1") then
return false
)
doNotExport = getappdata node NEL3D_APPDATA_COLLISION
if (doNotExport != undefined) then
(
if (doNotExport == "1") then
return false
)
doNotExport = getappdata node NEL3D_APPDATA_COLLISION_EXTERIOR
if (doNotExport != undefined) then
(
if (doNotExport == "1") then
return false
)
return true
)
-- Cast shadow ?
fn isCastShadow node =
(
if (classof node == nel_ps) then
return false
if (isAccelerator node) == true then
(
return false
)
else
(
return true
)
)
-- List the lod
lod_array = #()
-- is a lod ?
fn isLod node =
(
for i = 1 to lod_array.count do
(
if (lod_array[i] == node) then
return true
)
return false
)
-- have a coarse mesh ?
fn haveCoarseMesh node =
(
-- Get lod count
nodeCount = getappdata node NEL3D_APPDATA_LOD_NAME_COUNT
if (nodeCount != undefined) then
(
-- For each lod
nodeCountNum = nodeCount as Integer
for lod = 1 to nodeCountNum do
(
-- Get the lod
lod = getappdata node (NEL3D_APPDATA_LOD_NAME+lod-1)
-- Exist ?
if (lod != undefined) then
(
-- Select a node
nd = execute ("$'"+lod+"'")
-- Node exist ?
if (nd != undefined) then
(
-- Is a coarse mesh ?
if (getappdata nd NEL3D_APPDATA_LOD_COARSE_MESH == "1") then
return true
)
)
)
)
return false
)
fn runNelMaxExportSub =
(
sceneName = maxFilePath + maxFileName
-- Exported object count
exported = 0
-- Add the lod
for node in geometry do
(
-- Get lod count
nodeCount = getappdata node NEL3D_APPDATA_LOD_NAME_COUNT
if (nodeCount != undefined) then
(
-- For each lod
nodeCountNum = nodeCount as Integer
for lod = 1 to nodeCountNum do
(
-- Get the lod
lod = getappdata node (NEL3D_APPDATA_LOD_NAME+lod-1)
-- Exist ?
if (lod != undefined) then
(
-- Select a node
try
(
nd = execute("$'"+lod+"'")
)
catch
(
NelToolLoggerWriteError "ERROR" "*" ("Error in Execute $'"+lod+"' from node "+node.name)
nd = undefined
)
-- Node exist ?
if (nd != undefined) then
(
append lod_array nd
)
)
)
)
)
-- Select objects for shadows
for node in geometry do
(
if (node.parent == undefined) then
(
-- Cast shadow ?
if (isCastShadow node == true) then
(
-- Select this node
selectmore node
)
)
)
-- Tag this file ?
tagThisFile = true
-- Array of node to export
array_node = #()
-- Add geometry
for node in geometry do
append array_node node
-- Add shapes
for node in shapes do
append array_node node
-- For each node
for node in array_node do
(
-- It is root ?
if (node.parent == undefined) then
(
-- Is not a skeleton ?
if (node.name != "Bip01") then
(
-- Can be exported ?
if (isToBeExported node == true) then
(
-- Not a lod ?
if ((isLod node) == false) then
(
-- Output directory
if (haveCoarseMesh node) == true then
output = ("%OutputDirectoryWithCoarseMesh%/" + (node.name) + ".shape")
else
output = ("%OutputDirectoryWithoutCoarseMesh%/" + (node.name) + ".shape")
try
(
-- Export the shape
if (NelExportShapeEx node output %ShapeExportOptShadow% %ShapeExportOptExportLighting% "%OutputDirectoryLightmap%" %ShapeExportOptLightingLimit% %ShapeExportOptLumelSize% %ShapeExportOptOversampling% true false %ShapeExportOptLightmapLog%) == true then
(
exported = exported + 1
)
else
(
NelToolLoggerWriteError "ERROR" "*" "Failed exporting shape " + node.name + ".shape"
)
)
catch
(
NelToolLoggerWriteError "ERROR" "*" "Fatal error exporting shape " + node.name + ".shape"
)
)
)
)
)
)
-- Export default animations
for node in objects do
(
-- Can export it ?
if (isAnimToBeExported node) == true then
(
-- Anim output directory
output = ("%OutputDirectoryAnim%/" + (node.name) + ".anim")
-- Export the animation
if (NelExportAnimation #(node) output false) == false then
(
NelToolLoggerWriteError "ERROR" "*" "Exporting animation " + node.name + ".anim"
)
)
)
-- Nothing exported
if exported == 0 then
(
-- Warning
NelToolLoggerWriteError "WARNING" "*" "No shape exported"
)
)
Loading…
Cancel
Save