Add rayman2 source files
This commit is contained in:
680
Rayman_X/cpa/Appli/ModExp/ModExp.cpp
Normal file
680
Rayman_X/cpa/Appli/ModExp/ModExp.cpp
Normal file
@@ -0,0 +1,680 @@
|
||||
/**********************************************************************
|
||||
DESCRIPTION: .MOD file export
|
||||
CREATED BY: Boujemaa
|
||||
**********************************************************************/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "resource.h"
|
||||
#include "ModExp.h"
|
||||
#include "modobject.h"
|
||||
|
||||
|
||||
HINSTANCE hInstance;
|
||||
int controlsInit = FALSE;
|
||||
|
||||
CModExport* g_Eporter = NULL;
|
||||
|
||||
TCHAR* GetString(int id)
|
||||
{
|
||||
static TCHAR stBuf[ERROR_MSG_MAX_LEN];
|
||||
if (hInstance)
|
||||
return LoadString(hInstance, id, stBuf, ERROR_MSG_MAX_LEN) ? stBuf : NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int Alert(int s1, int s2 = IDS_MODEXP, int option = MB_OK) {
|
||||
return MessageBox(g_Eporter->m_Gi->GetMAXHWnd(), GetString(s1), GetString(s2), option);
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) {
|
||||
|
||||
// Hang on to this DLL's instance handle.
|
||||
hInstance = hinstDLL;
|
||||
|
||||
if ( !controlsInit ) {
|
||||
controlsInit = TRUE;
|
||||
|
||||
// Initialize 3ds Max's custom controls
|
||||
InitCustomControls(hInstance);
|
||||
|
||||
// Initialize Windows controls
|
||||
InitCommonControls();
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static CModExpClassDesc _ModExpDesc;
|
||||
|
||||
__declspec( dllexport ) const TCHAR * LibDescription() {
|
||||
return GetString(IDS_MODEXPDLL);
|
||||
}
|
||||
|
||||
__declspec( dllexport ) int
|
||||
LibNumberClasses()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
__declspec( dllexport ) ClassDesc *
|
||||
LibClassDesc(int i)
|
||||
{
|
||||
switch(i) {
|
||||
case 0: return &_ModExpDesc; break;
|
||||
default: return 0; break;
|
||||
}
|
||||
}
|
||||
|
||||
// Return version so can detect obsolete DLLs
|
||||
__declspec( dllexport ) ULONG LibVersion()
|
||||
{
|
||||
return VERSION_3DSMAX;
|
||||
}
|
||||
|
||||
inline const TCHAR* CModExpClassDesc::Category()
|
||||
{
|
||||
return GetString(IDS_SCENEEXPORT);
|
||||
}
|
||||
|
||||
inline SClass_ID CModExpClassDesc::SuperClassID()
|
||||
{
|
||||
return SCENE_EXPORT_CLASS_ID;
|
||||
}
|
||||
|
||||
inline Class_ID CModExpClassDesc::ClassID()
|
||||
{
|
||||
return Class_ID(0x7d285801, 0x3c7b4aaa);
|
||||
}
|
||||
|
||||
inline const TCHAR * CModExpClassDesc::ClassName()
|
||||
{
|
||||
return GetString(IDS_UBIMOD);
|
||||
}
|
||||
|
||||
inline int CModExpClassDesc::IsPublic()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline void * CModExpClassDesc::Create(BOOL loading)
|
||||
{
|
||||
g_Eporter = new CModExport;
|
||||
return g_Eporter;
|
||||
|
||||
}
|
||||
|
||||
CModExport::CModExport()
|
||||
{
|
||||
m_exportSelected = 0;
|
||||
m_showPrompts = 1;
|
||||
m_Gi = NULL;
|
||||
m_ei = NULL;
|
||||
}
|
||||
|
||||
CModExport::~CModExport()
|
||||
{
|
||||
}
|
||||
|
||||
int CModExport::GetExportOptions(DWORD _options, BOOL _suppressPrompts)
|
||||
{
|
||||
m_showPrompts = _suppressPrompts ? FALSE : TRUE;
|
||||
m_exportSelected = (_options & SCENE_EXPORT_SELECTED) ? TRUE : FALSE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CModExport::DumpHeader(WorkFile &modFile, BOOL _isSpo)
|
||||
{
|
||||
char currentCmd[MAX_MOD_COMMAND_LEN];
|
||||
|
||||
{
|
||||
modFile.OutLine("; (c) Ubi Casablanca");
|
||||
}
|
||||
{
|
||||
char filename[MAX_FILE_NAME];
|
||||
|
||||
_splitpath(modFile.GetFileName(), NULL, NULL, filename, NULL);
|
||||
|
||||
if (_isSpo)
|
||||
{
|
||||
strcat(filename, ".SPO");
|
||||
sprintf(currentCmd, ";.SPO (graphic Module) : %s", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcat(filename, ".MOD");
|
||||
sprintf(currentCmd, ";.MOD (graphic Module) : %s", filename);
|
||||
}
|
||||
|
||||
modFile.SetShortfName(filename);
|
||||
|
||||
modFile.OutLine(currentCmd);
|
||||
}
|
||||
|
||||
{
|
||||
assert(m_Gi != NULL);
|
||||
sprintf(currentCmd, ";Generated from file %s", m_Gi->GetCurFileName());
|
||||
modFile.OutLine(currentCmd);
|
||||
}
|
||||
|
||||
{
|
||||
struct tm *newtime;
|
||||
time_t aclock;
|
||||
time( &aclock ); // Get time in seconds
|
||||
newtime = localtime( &aclock ); // Convert time to struct tm form
|
||||
/* Print local time as a string */
|
||||
sprintf( currentCmd, ";Creation date : %s", asctime( newtime ) );
|
||||
modFile.OutLine(currentCmd);
|
||||
}
|
||||
|
||||
/*
|
||||
;Version directive, the version number is stored in file result 0
|
||||
$SetCurrentFileDouble(0,"5.20")
|
||||
|
||||
;Unit directive, the unit is stored in file result 1
|
||||
;And correspond to the value of one unit exprimed in meter
|
||||
$SetCurrentFileDouble(1,1)
|
||||
*/
|
||||
modFile.OutLine(";Version directive, the version number is stored in file result 0");
|
||||
modFile.OutLine("$SetCurrentFileDouble(0,\"5.20\")\n");
|
||||
modFile.OutLine(";Unit directive, the unit is stored in file result 1");
|
||||
modFile.OutLine(";And correspond to the value of one unit exprimed in meter");
|
||||
modFile.OutLine("$SetCurrentFileDouble(1,1)\n");
|
||||
|
||||
return 1;
|
||||
}
|
||||
int CModExport::DumpData(WorkFile &_modFile,WorkFile &_spoFile)
|
||||
{
|
||||
|
||||
// Make sure there are nodes we're interested in!
|
||||
// Ask the scene to enumerate all its nodes so we can determine if there are any we can use
|
||||
SceneEnumProc myScene(g_Eporter->m_Gi->GetTime());
|
||||
m_ei->theScene->EnumTree(&myScene);
|
||||
|
||||
// Any useful nodes?
|
||||
if(myScene.Count() == 0)
|
||||
{
|
||||
if(m_showPrompts)
|
||||
Alert(IDS_NODATATOEXPORT);
|
||||
return 1;
|
||||
}
|
||||
|
||||
myScene.DumpGeoms(_modFile);
|
||||
myScene.DumpMtls(_modFile);
|
||||
|
||||
myScene.DumpRoot(_spoFile);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CModExport::ExportFile(const TCHAR *_filename)
|
||||
{
|
||||
|
||||
TSTR LvlName;
|
||||
TSTR LvlPath;
|
||||
SplitFilename((TSTR)_filename, &LvlPath, &LvlName, NULL);
|
||||
strcat(LvlPath, "\\");
|
||||
strcat(LvlPath, LvlName);
|
||||
strcat(LvlPath, ".SPO");
|
||||
|
||||
WorkFile modFile(_filename,"wt");
|
||||
WorkFile spoFile(LvlPath,"wt");
|
||||
|
||||
DumpHeader(modFile);
|
||||
DumpHeader(spoFile, true);
|
||||
DumpData(modFile,spoFile);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CModExport::DoExport(const TCHAR *filename,ExpInterface *ei,Interface *gi, BOOL suppressPrompts, DWORD options)
|
||||
{
|
||||
|
||||
int result;
|
||||
m_Gi = gi;
|
||||
m_ei = ei;
|
||||
result = GetExportOptions(options, suppressPrompts);
|
||||
if (!result)
|
||||
return 0;
|
||||
result = ExportFile(filename);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void CModExport::ShowAbout(HWND hWnd)
|
||||
{
|
||||
// Optional
|
||||
}
|
||||
unsigned int CModExport::Version()
|
||||
{
|
||||
// Version number * 100 (i.e. v3.01 = 301)
|
||||
return 100;
|
||||
}
|
||||
|
||||
int CModExport::ExtCount()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
const TCHAR * CModExport::Ext(int n)
|
||||
{ // Extensions supported for import/export modules
|
||||
switch(n) {
|
||||
case 0:
|
||||
return _T("MOD");
|
||||
}
|
||||
return _T("");
|
||||
}
|
||||
|
||||
const TCHAR * CModExport::LongDesc()
|
||||
{ // Long ASCII description (i.e. "Targa 2.0 Image File")
|
||||
return GetString(IDS_MODSCENEFILE);
|
||||
}
|
||||
|
||||
const TCHAR * CModExport::ShortDesc()
|
||||
{ // Short ASCII description (i.e. "Targa")
|
||||
return GetString(IDS_MODFILE);
|
||||
}
|
||||
|
||||
const TCHAR * CModExport::AuthorName()
|
||||
{ // ASCII Author name
|
||||
return GetString(IDS_UBICASA);
|
||||
}
|
||||
|
||||
const TCHAR * CModExport::OtherMessage1()
|
||||
{ // Other message #1
|
||||
return _T("");
|
||||
}
|
||||
|
||||
const TCHAR * CModExport::OtherMessage2()
|
||||
{ // Other message #2
|
||||
return _T("");
|
||||
}
|
||||
const TCHAR * CModExport::CopyrightMessage()
|
||||
{ // ASCII Copyright message
|
||||
return GetString(IDS_COPYRIGHT_UBI);
|
||||
}
|
||||
|
||||
void WorkFile::OutLine(char* _txtLine)
|
||||
{
|
||||
fprintf(stream, "%s\n", _txtLine);
|
||||
}
|
||||
|
||||
SceneEnumProc::SceneEnumProc(TimeValue time)
|
||||
{
|
||||
m_time = time;
|
||||
m_count = 0;
|
||||
m_root = new CSuperObject(NULL);
|
||||
}
|
||||
SceneEnumProc::~SceneEnumProc()
|
||||
{
|
||||
m_GeomList.clear();
|
||||
m_MatList.clear();
|
||||
delete m_root;
|
||||
}
|
||||
|
||||
int SceneEnumProc::callback(INode *node)
|
||||
{
|
||||
|
||||
if(g_Eporter->m_exportSelected && node->Selected() == FALSE)
|
||||
return TREE_CONTINUE;
|
||||
|
||||
Append(node);
|
||||
|
||||
return TREE_CONTINUE;
|
||||
}
|
||||
|
||||
void SceneEnumProc::Append(INode *_node)
|
||||
{
|
||||
|
||||
if (_node->IsRootNode())
|
||||
return;
|
||||
|
||||
// find parent
|
||||
INode * Parentnode = _node->GetParentNode();
|
||||
|
||||
CSuperObject *ParentSpo;
|
||||
|
||||
if (Parentnode->IsRootNode())
|
||||
ParentSpo = m_root;
|
||||
else
|
||||
ParentSpo = m_root->findSpo(Parentnode);
|
||||
|
||||
if (ParentSpo == NULL)
|
||||
{
|
||||
ParentSpo = m_root;
|
||||
}
|
||||
|
||||
if (ParentSpo == m_root)
|
||||
{
|
||||
|
||||
char NodeName[MAX_NAME_OBJ];
|
||||
strcpy(NodeName,_node->GetName());
|
||||
strlwr(NodeName);
|
||||
if ((NodeName[0] != 's') ||
|
||||
(NodeName[1] != 'c') ||
|
||||
(NodeName[2] != 't'))
|
||||
{
|
||||
// object not linked to any dumy
|
||||
assert(0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// create sop
|
||||
CSuperObject *NewSpo = new CSuperObject(_node);
|
||||
|
||||
ParentSpo->AddNode(NewSpo);
|
||||
|
||||
Object *obj = _node->EvalWorldState(m_time).obj;
|
||||
if (obj->CanConvertToType(triObjectClassID))
|
||||
{
|
||||
m_GeomList.push_back(NewSpo);
|
||||
m_count ++;
|
||||
}
|
||||
|
||||
}
|
||||
void SceneEnumProc::AppendMat(Mtl *_mtl)
|
||||
{
|
||||
std::list <Mtl *>::iterator Iter;
|
||||
for ( Iter = m_MatList.begin( ); Iter != m_MatList.end( ); Iter++ )
|
||||
{
|
||||
Mtl *current = *Iter;
|
||||
if (current == _mtl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_MatList.push_back(_mtl);
|
||||
}
|
||||
|
||||
void SceneEnumProc::DumpGeoms(WorkFile &modFile)
|
||||
{
|
||||
std::list <CSuperObject *>::iterator Iter;
|
||||
for ( Iter = m_GeomList.begin( ); Iter != m_GeomList.end( ); Iter++ )
|
||||
{
|
||||
DumpOneGeom(modFile, *Iter);
|
||||
}
|
||||
}
|
||||
|
||||
void SceneEnumProc::DumpRoot(WorkFile &_spoFile)
|
||||
{
|
||||
m_root->DumpSpo(_spoFile, m_time);
|
||||
}
|
||||
|
||||
void SceneEnumProc::DumpMtls(WorkFile &modFile)
|
||||
{
|
||||
std::list <Mtl*>::iterator Iter;
|
||||
for ( Iter = m_MatList.begin( ); Iter != m_MatList.end( ); Iter++ )
|
||||
{
|
||||
DumpOneMtl(modFile, *Iter);
|
||||
}
|
||||
}
|
||||
|
||||
void SceneEnumProc::DumpOneGeom(WorkFile &modFile, CSuperObject *_node)
|
||||
{
|
||||
char currentCmd[MAX_MOD_COMMAND_LEN];
|
||||
int i = 0;
|
||||
std::vector <CModElem*>::iterator IterElem;
|
||||
std::vector <CFace>::iterator IterFace;
|
||||
std::vector <CUV>::iterator IterUV;
|
||||
|
||||
CModObject curObj(_node->m_maxNode, m_time);
|
||||
|
||||
if (!curObj.m_ValidObj)
|
||||
return;
|
||||
|
||||
int nbrElems = 0;
|
||||
for ( IterElem = curObj.m_elements.begin( ); IterElem != curObj.m_elements.end( ); IterElem++ )
|
||||
{
|
||||
CModElem* elem = *IterElem;
|
||||
if (elem->m_Faces.size() != 0)
|
||||
{
|
||||
SceneEnumProc::AppendMat(elem->m_material);
|
||||
nbrElems++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// set spo link
|
||||
sprintf(currentCmd, "Geometric(\"%s^Geometric:%s\")", modFile.GetShortfName(), curObj.m_name);
|
||||
_node->SetGeomLink(currentCmd);
|
||||
// geom
|
||||
sprintf(currentCmd, "{Geometric:%s(%d,0,%d)", curObj.m_name, curObj.m_nbrVrtx, nbrElems);
|
||||
modFile.OutLine(currentCmd);
|
||||
|
||||
// vertxs
|
||||
|
||||
for (i = 0; i < curObj.m_Vertxs.size(); i++)
|
||||
{
|
||||
sprintf(currentCmd, "\tAddVertex(%d,\"%g\",\"%g\",\"%g\",\"%g\",\"%g\",\"%g\",0,0,0)",
|
||||
i,
|
||||
curObj.m_Vertxs[i].x, curObj.m_Vertxs[i].y, curObj.m_Vertxs[i].z,
|
||||
curObj.m_Vertxs[i].nx, curObj.m_Vertxs[i].ny, curObj.m_Vertxs[i].nz);
|
||||
modFile.OutLine(currentCmd);
|
||||
}
|
||||
|
||||
// Geomelem
|
||||
|
||||
i=0;
|
||||
for ( IterElem = curObj.m_elements.begin( ); IterElem != curObj.m_elements.end( ); IterElem++ )
|
||||
{
|
||||
CModElem* elem = *IterElem;
|
||||
if (elem->m_Faces.size() != 0)
|
||||
{
|
||||
sprintf(currentCmd, "\tAddElement(%d,IndexedTriangles,\"*^ElementIndexedTriangles:%s_%s\")",i, curObj.m_name, elem->m_name);
|
||||
modFile.OutLine(currentCmd);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
modFile.OutLine("}");
|
||||
|
||||
// elems
|
||||
for ( IterElem = curObj.m_elements.begin( ); IterElem != curObj.m_elements.end( ); IterElem++ )
|
||||
{
|
||||
CModElem* elem = *IterElem;
|
||||
if (elem->m_Faces.size() != 0)
|
||||
{
|
||||
sprintf(currentCmd, "{ElementIndexedTriangles:%s_%s(%d,%d)", curObj.m_name, elem->m_name,elem->m_Faces.size(),elem->m_UVs.size());
|
||||
modFile.OutLine(currentCmd);
|
||||
sprintf(currentCmd, "\tMaterial(\"*^Material:%s\")", elem->m_name);
|
||||
modFile.OutLine(currentCmd);
|
||||
i = 0;
|
||||
for (IterFace = elem->m_Faces.begin(); IterFace != elem->m_Faces.end(); IterFace++)
|
||||
{
|
||||
CFace* face =&(*IterFace);
|
||||
sprintf(currentCmd, "\tAddFaceUV(%d,%d,%d,%d,\"%g\",\"%g\",\"%g\",%d,%d,%d)",
|
||||
i,
|
||||
face->I, face->J,face->K,
|
||||
face->nx, face->ny,face->nz,
|
||||
face->IUV, face->JUV,face->KUV);
|
||||
modFile.OutLine(currentCmd);
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
for (IterUV = elem->m_UVs.begin(); IterUV != elem->m_UVs.end(); IterUV++)
|
||||
{
|
||||
CUV* uv =&(*IterUV);
|
||||
sprintf(currentCmd, "\tAddUV(%d,\"%g\",\"%g\")", i, uv->U, uv->V);
|
||||
modFile.OutLine(currentCmd);
|
||||
i++;
|
||||
}
|
||||
modFile.OutLine("}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SceneEnumProc::DumpOneMtl(WorkFile &modFile, Mtl *_mtl)
|
||||
{
|
||||
char currentCmd[MAX_MOD_COMMAND_LEN];
|
||||
|
||||
sprintf(currentCmd, "{Material:%s", _mtl->GetName());
|
||||
modFile.OutLine(currentCmd);
|
||||
|
||||
sprintf(currentCmd, "\tType(Gouraud)");
|
||||
modFile.OutLine(currentCmd);
|
||||
|
||||
sprintf(currentCmd, "\tAmbientColor(\"%g\",\"%g\",\"%g\")", _mtl->GetAmbient().r, _mtl->GetAmbient().g, _mtl->GetAmbient().b);
|
||||
modFile.OutLine(currentCmd);
|
||||
|
||||
sprintf(currentCmd, "\tDiffuseColor(\"%g\",\"%g\",\"%g\")", _mtl->GetDiffuse().r, _mtl->GetDiffuse().g, _mtl->GetDiffuse().b);
|
||||
modFile.OutLine(currentCmd);
|
||||
|
||||
sprintf(currentCmd, "\tSpecularColor(\"%g\",\"%g\",\"%g\",\"%g\")", _mtl->GetSpecular().r, _mtl->GetSpecular().g, _mtl->GetSpecular().b, _mtl->GetShinStr());
|
||||
modFile.OutLine(currentCmd);
|
||||
|
||||
{
|
||||
BitmapTex *tx = (BitmapTex*)_mtl->GetSubTexmap(ID_DI);//ID_DI : diffuse
|
||||
char filename[MAX_FILE_NAME];
|
||||
char ext[5];
|
||||
_splitpath((char*)(tx->GetMapName()), NULL, NULL, filename, ext);
|
||||
sprintf(currentCmd, "\tTexture(\"%s%s\")",filename, ext);
|
||||
modFile.OutLine(currentCmd);
|
||||
}
|
||||
{
|
||||
if (((StdMat *)_mtl)->GetTwoSided())
|
||||
sprintf(currentCmd, "\tBackface(OFF)");
|
||||
else
|
||||
sprintf(currentCmd, "\tBackface(ON)");
|
||||
modFile.OutLine(currentCmd);
|
||||
}
|
||||
|
||||
modFile.OutLine("}");
|
||||
|
||||
}
|
||||
void CSuperObject::AddNode(CSuperObject *_node)
|
||||
{
|
||||
m_childs.push_back(_node);
|
||||
_node->m_Parent = this;
|
||||
}
|
||||
CSuperObject::CSuperObject(INode *_node)
|
||||
{
|
||||
if (_node != NULL)
|
||||
{
|
||||
sprintf(m_name, "SPO_%s", _node->GetName());
|
||||
}
|
||||
else
|
||||
strcpy(m_name, "Root");
|
||||
m_maxNode = _node;
|
||||
m_GeomLink = NULL;
|
||||
m_Parent = NULL;
|
||||
}
|
||||
CSuperObject::~CSuperObject()
|
||||
{
|
||||
std::list <CSuperObject*>::iterator Iter;
|
||||
for ( Iter = m_childs.begin( ); Iter != m_childs.end( ); Iter++ )
|
||||
{
|
||||
CSuperObject *spo = *Iter;
|
||||
delete spo;
|
||||
}
|
||||
m_childs.clear();
|
||||
if (m_GeomLink)
|
||||
delete m_GeomLink;
|
||||
}
|
||||
void CSuperObject::SetGeomLink(char* _GeomLink)
|
||||
{
|
||||
if (m_GeomLink == NULL)
|
||||
m_GeomLink = new char[MAX_MOD_COMMAND_LEN];
|
||||
|
||||
strcpy(m_GeomLink, _GeomLink);
|
||||
}
|
||||
|
||||
char* CSuperObject::GetGeomLink()
|
||||
{
|
||||
return m_GeomLink;
|
||||
}
|
||||
|
||||
CSuperObject* CSuperObject::findSpo(INode *_node)
|
||||
{
|
||||
if (m_maxNode == _node)
|
||||
return this;
|
||||
else
|
||||
{
|
||||
std::list <CSuperObject*>::iterator Iter;
|
||||
for ( Iter = m_childs.begin( ); Iter != m_childs.end( ); Iter++ )
|
||||
{
|
||||
CSuperObject *spo = *Iter;
|
||||
CSuperObject *retSpo = spo->findSpo(_node);
|
||||
if (retSpo != NULL)
|
||||
return retSpo;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CSuperObject::DumpSpo(WorkFile &_spoFile, TimeValue _time)
|
||||
{
|
||||
char currentCmd[MAX_MOD_COMMAND_LEN];
|
||||
std::list <CSuperObject*>::iterator Iter;
|
||||
|
||||
// dump obj
|
||||
|
||||
sprintf(currentCmd, "{SuperObject:%s", m_name);
|
||||
_spoFile.OutLine(currentCmd);
|
||||
|
||||
sprintf(currentCmd, "\tPutMatrix(\"*^Matrix:%s\")", m_name);
|
||||
_spoFile.OutLine(currentCmd);
|
||||
|
||||
if (GetGeomLink())
|
||||
{
|
||||
sprintf(currentCmd, "\t%s", GetGeomLink());
|
||||
_spoFile.OutLine(currentCmd);
|
||||
}
|
||||
|
||||
for ( Iter = m_childs.begin( ); Iter != m_childs.end( ); Iter++ )
|
||||
{
|
||||
CSuperObject *spo = *Iter;
|
||||
sprintf(currentCmd, "\tAddChild(\"*^SuperObject:%s\")", spo->m_name);
|
||||
_spoFile.OutLine(currentCmd);
|
||||
}
|
||||
_spoFile.OutLine("}\n");
|
||||
|
||||
// dump matrix
|
||||
|
||||
sprintf(currentCmd, "{Matrix:%s", m_name);
|
||||
_spoFile.OutLine(currentCmd);
|
||||
|
||||
Matrix3 NodMat;
|
||||
GetLocalMatrix(NodMat, _time);
|
||||
|
||||
Point3 pos = NodMat.GetTrans();
|
||||
|
||||
sprintf(currentCmd, "\tMatrixTranslation(\"%g\",\"%g\",\"%g\")", pos.x, pos.y, pos.z);
|
||||
_spoFile.OutLine(currentCmd);
|
||||
/*
|
||||
Quat quat = node->GetObjOffsetRot();
|
||||
Matrix3 RotMat;
|
||||
quat.MakeMatrix(RotMat);
|
||||
ScaleValue scaleValue = node->GetObjOffsetScale();
|
||||
*/
|
||||
_spoFile.OutLine("}\n");
|
||||
|
||||
// dump childs
|
||||
for ( Iter = m_childs.begin( ); Iter != m_childs.end( ); Iter++ )
|
||||
{
|
||||
CSuperObject *spo = *Iter;
|
||||
spo->DumpSpo(_spoFile, _time);
|
||||
}
|
||||
|
||||
}
|
||||
void CSuperObject::GetLocalMatrix(Matrix3 &_NodMat, TimeValue _time)
|
||||
{
|
||||
if (m_maxNode != NULL)
|
||||
{
|
||||
_NodMat = m_maxNode->GetNodeTM(_time);
|
||||
}
|
||||
else
|
||||
{
|
||||
_NodMat = Matrix3(true);
|
||||
}
|
||||
if ((m_Parent != NULL) && (m_Parent->m_maxNode != NULL))
|
||||
{
|
||||
Matrix3 temp = _NodMat;
|
||||
Matrix3 ip = Inverse(m_Parent->m_maxNode->GetNodeTM(_time));
|
||||
_NodMat = ip * temp;
|
||||
}
|
||||
}
|
109
Rayman_X/cpa/Appli/ModExp/ModExp.h
Normal file
109
Rayman_X/cpa/Appli/ModExp/ModExp.h
Normal file
@@ -0,0 +1,109 @@
|
||||
|
||||
#define ERROR_MSG_MAX_LEN 128
|
||||
#define MAX_MOD_COMMAND_LEN 512
|
||||
#define MAX_NAME_OBJ 40
|
||||
|
||||
class WorkFile
|
||||
{
|
||||
private:
|
||||
FILE *stream;
|
||||
char m_ShortfName[MAX_FILE_NAME];
|
||||
char m_fileName[MAX_FILE_NAME];
|
||||
|
||||
public:
|
||||
WorkFile(const TCHAR *filename,const TCHAR *mode) { stream = NULL; Open(filename, mode); };
|
||||
~WorkFile() { Close(); };
|
||||
FILE * Stream() { return stream; };
|
||||
int Close() { int result=0; if(stream) result=fclose(stream); stream = NULL; return result; }
|
||||
void Open(const TCHAR *filename,const TCHAR *mode) { Close(); stream = _tfopen(filename,mode); strcpy(m_fileName, filename); }
|
||||
void OutLine(char* _txtLine);
|
||||
char* GetFileName(){return m_fileName;};
|
||||
char* GetShortfName(){return m_ShortfName;};
|
||||
void SetShortfName(char* _SFName){ strcpy(m_ShortfName, _SFName);};
|
||||
};
|
||||
|
||||
class CModExport : public SceneExport
|
||||
{
|
||||
public:
|
||||
CModExport();
|
||||
~CModExport();
|
||||
int ExtCount(); // Number of extensions supported
|
||||
const TCHAR * Ext(int n); // Extension #n (i.e. "3DS")
|
||||
const TCHAR * LongDesc(); // Long ASCII description (i.e. "Autodesk 3D Studio File")
|
||||
const TCHAR * ShortDesc(); // Short ASCII description (i.e. "3D Studio")
|
||||
const TCHAR * AuthorName(); // ASCII Author name
|
||||
const TCHAR * CopyrightMessage(); // ASCII Copyright message
|
||||
const TCHAR * OtherMessage1(); // Other message #1
|
||||
const TCHAR * OtherMessage2(); // Other message #2
|
||||
unsigned int Version(); // Version number * 100 (i.e. v3.01 = 301)
|
||||
void ShowAbout(HWND hWnd); // Show DLL's "About..." box
|
||||
int DoExport(const TCHAR *name,ExpInterface *ei,Interface *i, BOOL suppressPrompts, DWORD options); // Export file
|
||||
|
||||
BOOL m_exportSelected;
|
||||
BOOL m_showPrompts;
|
||||
Interface* m_Gi;
|
||||
ExpInterface* m_ei;
|
||||
|
||||
//void Append(INode *_node);
|
||||
private:
|
||||
int GetExportOptions(DWORD options, BOOL suppressPrompts);
|
||||
int ExportFile(const TCHAR *filename);
|
||||
int DumpHeader(WorkFile &modFile, BOOL _isSpo = 0);
|
||||
int DumpData(WorkFile &modFile,WorkFile &_spoFile);
|
||||
};
|
||||
|
||||
|
||||
class CModExpClassDesc:public ClassDesc
|
||||
{
|
||||
public:
|
||||
inline int IsPublic();
|
||||
inline void * Create(BOOL loading = FALSE);
|
||||
inline const TCHAR * ClassName();
|
||||
inline SClass_ID SuperClassID();
|
||||
inline Class_ID ClassID();
|
||||
inline const TCHAR* Category();
|
||||
};
|
||||
|
||||
class CSuperObject
|
||||
{
|
||||
CSuperObject* m_Parent;
|
||||
char m_name[MAX_NAME_OBJ];
|
||||
std::list <CSuperObject*> m_childs;
|
||||
char* m_GeomLink;
|
||||
void GetLocalMatrix(Matrix3 &NodMat, TimeValue _time);
|
||||
public:
|
||||
INode* m_maxNode;
|
||||
CSuperObject(INode *_node);
|
||||
~CSuperObject();
|
||||
void DumpSpo(WorkFile &_spoFile, TimeValue _time);
|
||||
|
||||
CSuperObject* findSpo(INode *_node);
|
||||
void AddNode(CSuperObject *_node);
|
||||
void SetGeomLink(char*);
|
||||
char* GetGeomLink();
|
||||
};
|
||||
|
||||
class SceneEnumProc : public ITreeEnumProc
|
||||
{
|
||||
private:
|
||||
std::list <CSuperObject *> m_GeomList;
|
||||
std::list <Mtl *> m_MatList;
|
||||
void Append(INode *_node);
|
||||
void AppendMat(Mtl *_mtl);
|
||||
TimeValue m_time;
|
||||
void DumpOneGeom(WorkFile &modFile, CSuperObject *_node);
|
||||
void DumpOneMtl(WorkFile &modFile, Mtl *_mtl);
|
||||
CSuperObject* m_root;
|
||||
|
||||
public:
|
||||
SceneEnumProc(TimeValue time);
|
||||
~SceneEnumProc();
|
||||
int Count(){ return m_count; };
|
||||
int callback( INode *node );
|
||||
int m_count;
|
||||
void DumpGeoms(WorkFile &modFile);
|
||||
void DumpMtls(WorkFile &modFile);
|
||||
void DumpRoot(WorkFile &_spoFile);
|
||||
};
|
||||
|
||||
|
94
Rayman_X/cpa/Appli/ModExp/ModExp.rc
Normal file
94
Rayman_X/cpa/Appli/ModExp/ModExp.rc
Normal file
@@ -0,0 +1,94 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// French (France) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MODEXPDLL "Map exporter for max8"
|
||||
IDS_SCENEEXPORT "MOD Scene Export"
|
||||
IDS_UBIMOD "UbiMod"
|
||||
IDS_MODSCENEFILE "Modelisation ACP format"
|
||||
IDS_MODFILE "MOD file"
|
||||
IDS_UBICASA "Ubisoft Casablanca"
|
||||
IDS_COPYRIGHT_UBI "UBISOFT"
|
||||
IDS_NODATATOEXPORT "No data to export"
|
||||
IDS_MODEXP "ModExp"
|
||||
END
|
||||
|
||||
#endif // French (France) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
21
Rayman_X/cpa/Appli/ModExp/ModExp.sln
Normal file
21
Rayman_X/cpa/Appli/ModExp/ModExp.sln
Normal file
@@ -0,0 +1,21 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ModExp", "ModExp.vcproj", "{E216E7F2-CB2F-4A10-B2F9-1AF32DCB1230}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{E216E7F2-CB2F-4A10-B2F9-1AF32DCB1230}.Debug.ActiveCfg = Debug|Win32
|
||||
{E216E7F2-CB2F-4A10-B2F9-1AF32DCB1230}.Debug.Build.0 = Debug|Win32
|
||||
{E216E7F2-CB2F-4A10-B2F9-1AF32DCB1230}.Release.ActiveCfg = Release|Win32
|
||||
{E216E7F2-CB2F-4A10-B2F9-1AF32DCB1230}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
172
Rayman_X/cpa/Appli/ModExp/ModExp.vcproj
Normal file
172
Rayman_X/cpa/Appli/ModExp/ModExp.vcproj
Normal file
@@ -0,0 +1,172 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="ModExp"
|
||||
ProjectGUID="{E216E7F2-CB2F-4A10-B2F9-1AF32DCB1230}"
|
||||
RootNamespace="ModExp"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="C:\Program Files\Autodesk\3dsMax8\plugins\"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MODEXP_EXPORTS"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="3"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="comctl32.lib core.lib maxutil.lib geom.lib mesh.lib"
|
||||
OutputFile="$(OutDir)/ModExp.dle"
|
||||
LinkIncremental="2"
|
||||
ModuleDefinitionFile="modexp.def"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/ModExp.pdb"
|
||||
SubSystem="2"
|
||||
ImportLibrary="$(OutDir)/ModExp.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MODEXP_EXPORTS"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="comctl32.lib core.lib maxutil.lib geom.lib mesh.lib"
|
||||
OutputFile="$(OutDir)/ModExp.dle"
|
||||
LinkIncremental="1"
|
||||
ModuleDefinitionFile="modexp.def"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
ImportLibrary="$(OutDir)/ModExp.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath=".\ModExp.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\modexp.def">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ModObject.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StdAfx.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
<File
|
||||
RelativePath=".\ModExp.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ModObject.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\resource.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StdAfx.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
||||
<File
|
||||
RelativePath=".\ModExp.rc">
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\todo.txt">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
174
Rayman_X/cpa/Appli/ModExp/ModObject.cpp
Normal file
174
Rayman_X/cpa/Appli/ModExp/ModObject.cpp
Normal file
@@ -0,0 +1,174 @@
|
||||
#include "StdAfx.h"
|
||||
#include ".\modobject.h"
|
||||
|
||||
CModObject::CModObject(INode *_node, TimeValue _time)
|
||||
{
|
||||
|
||||
m_ValidObj = false;
|
||||
ObjectState os = _node->EvalWorldState(_time);
|
||||
|
||||
TriObject *triObject = (TriObject *)os.obj->ConvertToType(_time, triObjectClassID);
|
||||
Mesh &mesh = triObject->GetMesh();
|
||||
m_mesh = &mesh;
|
||||
|
||||
Mtl* material = _node->GetMtl();
|
||||
m_nbrVrtx = 0;
|
||||
|
||||
if (material == NULL)
|
||||
{
|
||||
assert(0);
|
||||
return;
|
||||
}
|
||||
m_nbrIds = material->NumSubMtls();
|
||||
|
||||
m_nbrFaces = mesh.getNumFaces();
|
||||
|
||||
assert(m_nbrFaces < 65530);
|
||||
assert(mesh.getNumVerts() < 65530);
|
||||
|
||||
if ((m_nbrIds == 0) ||
|
||||
(m_nbrFaces == 0) ||
|
||||
(mesh.getNumVerts() == 0))
|
||||
{
|
||||
assert(0);
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(m_name,_node->GetName());
|
||||
|
||||
for (int i = 0; i < m_nbrIds; i++)
|
||||
{
|
||||
Mtl* sub = material->GetSubMtl(i);
|
||||
if (sub)
|
||||
{
|
||||
CModElem * elem;
|
||||
elem = new CModElem(sub->GetName(), sub);
|
||||
m_elements.push_back(elem);
|
||||
}
|
||||
}
|
||||
|
||||
// test with & without
|
||||
m_mesh->buildNormals();
|
||||
|
||||
for (int i = 0; i < m_nbrFaces; i++) {
|
||||
Face face = mesh.faces[i];
|
||||
TVFace tvFace = mesh.tvFace[i];
|
||||
unsigned long UV0, UV1, UV2, V0,V1,V2;
|
||||
MtlID elemIdx = face.getMatID();
|
||||
UV0 = AddUV(elemIdx, mesh.tVerts[tvFace.t[0]].x, mesh.tVerts[tvFace.t[0]].y);
|
||||
UV1 = AddUV(elemIdx, mesh.tVerts[tvFace.t[1]].x, mesh.tVerts[tvFace.t[1]].y);
|
||||
UV2 = AddUV(elemIdx, mesh.tVerts[tvFace.t[2]].x, mesh.tVerts[tvFace.t[2]].y);
|
||||
V0 = AddVerxt(face.v[0]);
|
||||
V1 = AddVerxt(face.v[1]);
|
||||
V2 = AddVerxt(face.v[2]);
|
||||
|
||||
Point3 FaceNormal = m_mesh->getFaceNormal(i);
|
||||
//FaceNormal.Normalize();
|
||||
if ((V0 != V1) &&
|
||||
(V0 != V2) &&
|
||||
(V2 != V1))
|
||||
{
|
||||
AddFace(elemIdx, V0, V1, V2, UV0, UV1, UV2, FaceNormal.x, FaceNormal.y, FaceNormal.z);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
m_nbrVrtx = (unsigned long)m_Vertxs.size();
|
||||
m_ValidObj = true;
|
||||
}
|
||||
|
||||
unsigned long CModObject::AddVerxt(DWORD _index)
|
||||
{
|
||||
Point3 vert;
|
||||
Point3 norm;
|
||||
|
||||
vert = m_mesh->verts[_index];
|
||||
norm = m_mesh->getRVert(_index).rn.getNormal();
|
||||
|
||||
|
||||
CVrtx myVect(vert.x,vert.y,vert.z,norm.x,norm.y,norm.z);
|
||||
|
||||
std::vector <CVrtx>::iterator Iter;
|
||||
unsigned long i = 0;
|
||||
for ( Iter = m_Vertxs.begin( ); Iter != m_Vertxs.end( ); Iter++ )
|
||||
{
|
||||
if (*Iter == myVect)
|
||||
return i;
|
||||
i++;
|
||||
}
|
||||
|
||||
m_Vertxs.push_back(myVect);
|
||||
return i;
|
||||
}
|
||||
|
||||
CModObject::~CModObject(void)
|
||||
{
|
||||
std::vector <CModElem*>::iterator Iter;
|
||||
for ( Iter = m_elements.begin( ); Iter != m_elements.end( ); Iter++ )
|
||||
{
|
||||
delete *Iter;
|
||||
}
|
||||
m_elements.clear();
|
||||
m_Vertxs.clear();
|
||||
}
|
||||
|
||||
CModElem::CModElem(char* _name, Mtl* _material)
|
||||
{
|
||||
strcpy(m_name,_name);
|
||||
m_material = _material;
|
||||
}
|
||||
|
||||
bool CVrtx::operator==(const CVrtx& rSrc) const{
|
||||
|
||||
if( (abs(x - rSrc.x) < 0.001) &&
|
||||
(abs(y - rSrc.y) < 0.001) &&
|
||||
(abs(z - rSrc.z) < 0.001) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
void CModObject::AddFace(MtlID _ElemIndex,
|
||||
unsigned long _i, unsigned long _j, unsigned long _k,
|
||||
unsigned long _iUV, unsigned long _jUV, unsigned long _kUV,
|
||||
float _nx, float _ny, float _nz)
|
||||
{
|
||||
m_elements[_ElemIndex]->m_Faces.push_back(CFace(_i,_j,_k, _iUV, _jUV, _kUV, _nx, _ny, _nz));
|
||||
}
|
||||
unsigned long CModObject::AddUV(MtlID _ElemIndex, float _u, float _v)
|
||||
{
|
||||
unsigned long i = 0;
|
||||
CModElem * elem = m_elements[_ElemIndex];
|
||||
std::vector <CUV>::iterator IterUV;
|
||||
|
||||
for (IterUV = elem->m_UVs.begin(); IterUV < elem->m_UVs.end(); IterUV ++)
|
||||
{
|
||||
if (*IterUV == CUV(_u,_v))
|
||||
return i;
|
||||
i++;
|
||||
}
|
||||
|
||||
elem->m_UVs.push_back(CUV(_u,_v));
|
||||
return i;
|
||||
}
|
||||
CFace::CFace(unsigned long _I,unsigned long _J,unsigned long _K,
|
||||
unsigned long _IUV,unsigned long _JUV,unsigned long _KUV,
|
||||
float _nx, float _ny, float _nz)
|
||||
{
|
||||
I=_I; J=_J; K=_K;
|
||||
IUV=_IUV; JUV=_JUV; KUV=_KUV;
|
||||
nx = _nx; ny = _ny; nz = _nz;
|
||||
}
|
||||
bool CUV::operator==(const CUV& rSrc) const
|
||||
{
|
||||
if( (U == rSrc.U) &&
|
||||
(V == rSrc.V))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
CUV::CUV(float _U,float _V)
|
||||
{
|
||||
U=_U; V=_V;
|
||||
}
|
68
Rayman_X/cpa/Appli/ModExp/ModObject.h
Normal file
68
Rayman_X/cpa/Appli/ModExp/ModObject.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
class CFace
|
||||
{
|
||||
public:
|
||||
CFace(unsigned long _I,unsigned long _J,unsigned long _K,
|
||||
unsigned long _IUV,unsigned long _JUV,unsigned long _KUV,
|
||||
float _nx, float _ny, float _nz);
|
||||
unsigned long I,J,K;
|
||||
unsigned long IUV,JUV,KUV;
|
||||
float nx,ny,nz;
|
||||
};
|
||||
|
||||
class CUV
|
||||
{
|
||||
public:
|
||||
CUV(float _U,float _V);
|
||||
float U,V;
|
||||
bool operator==(const CUV& rSrc) const;
|
||||
};
|
||||
|
||||
class CModElem
|
||||
{
|
||||
public:
|
||||
char m_name[MAX_FILE_NAME];
|
||||
std::vector <CFace> m_Faces;
|
||||
std::vector <CUV> m_UVs;
|
||||
Mtl* m_material;
|
||||
|
||||
CModElem(char*, Mtl*);
|
||||
~CModElem(){m_Faces.clear(); m_UVs.clear();};
|
||||
};
|
||||
|
||||
class CVrtx
|
||||
{
|
||||
public:
|
||||
double x, y, z;
|
||||
double nx, ny, nz;
|
||||
CVrtx(double _x,double _y,double _z,double _nx,double _ny,double _nz)
|
||||
{x = _x; y = _y; z = _z;nx = _nx; ny = _ny; nz = _nz;};
|
||||
bool operator==(const CVrtx& rSrc) const;
|
||||
};
|
||||
|
||||
class CModObject
|
||||
{
|
||||
private:
|
||||
Mesh* m_mesh;
|
||||
unsigned long m_nbrFaces;
|
||||
int m_nbrIds ;
|
||||
|
||||
unsigned long AddVerxt(DWORD _index);
|
||||
void AddFace(MtlID _ElemIndex,
|
||||
unsigned long _i, unsigned long _j, unsigned long _k,
|
||||
unsigned long _iUV, unsigned long _jUV, unsigned long _kUV,
|
||||
float _nx, float _ny, float _nz);
|
||||
unsigned long AddUV(MtlID _ElemIndex, float _u, float _v);
|
||||
|
||||
public:
|
||||
BOOL m_ValidObj;
|
||||
std::vector <CModElem*> m_elements;
|
||||
char m_name[MAX_FILE_NAME];
|
||||
unsigned long m_nbrVrtx;
|
||||
std::vector <CVrtx> m_Vertxs;
|
||||
|
||||
CModObject(INode *_node, TimeValue _time);
|
||||
~CModObject(void);
|
||||
};
|
1
Rayman_X/cpa/Appli/ModExp/StdAfx.cpp
Normal file
1
Rayman_X/cpa/Appli/ModExp/StdAfx.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "StdAfx.h"
|
13
Rayman_X/cpa/Appli/ModExp/StdAfx.h
Normal file
13
Rayman_X/cpa/Appli/ModExp/StdAfx.h
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <time.h>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Max.h"
|
||||
#include "STDMAT.h"
|
||||
#include "PLUGAPI.H"
|
||||
|
||||
#define MAX_FILE_NAME 128
|
8
Rayman_X/cpa/Appli/ModExp/modexp.def
Normal file
8
Rayman_X/cpa/Appli/ModExp/modexp.def
Normal file
@@ -0,0 +1,8 @@
|
||||
LIBRARY ModExp
|
||||
EXPORTS
|
||||
LibDescription @1
|
||||
LibNumberClasses @2
|
||||
LibClassDesc @3
|
||||
LibVersion @4
|
||||
SECTIONS
|
||||
.data READ WRITE
|
24
Rayman_X/cpa/Appli/ModExp/resource.h
Normal file
24
Rayman_X/cpa/Appli/ModExp/resource.h
Normal file
@@ -0,0 +1,24 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by ModExp.rc
|
||||
//
|
||||
#define IDS_MODEXPDLL 101
|
||||
#define IDS_SCENEEXPORT 102
|
||||
#define IDS_UBIMOD 103
|
||||
#define IDS_MODSCENEFILE 104
|
||||
#define IDS_MODFILE 105
|
||||
#define IDS_UBICASA 106
|
||||
#define IDS_COPYRIGHT_UBI 107
|
||||
#define IDS_NODATATOEXPORT 108
|
||||
#define IDS_MODEXP 109
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 110
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
4
Rayman_X/cpa/Appli/ModExp/todo.txt
Normal file
4
Rayman_X/cpa/Appli/ModExp/todo.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
1 export selected
|
||||
2 select window on export
|
||||
3 smouting group
|
||||
4 output log
|
Reference in New Issue
Block a user