diff --git a/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj b/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj
index 2aecd34..14361ed 100644
--- a/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj
+++ b/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj
@@ -94,12 +94,14 @@
+
+
diff --git a/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj.filters b/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj.filters
index aed0824..fbdf3d9 100644
--- a/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj.filters
+++ b/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj.filters
@@ -27,6 +27,9 @@
头文件
+
+ 头文件
+
@@ -38,6 +41,9 @@
源文件
+
+ 源文件
+
diff --git a/SuperScriptMaterializer/database.cpp b/SuperScriptMaterializer/database.cpp
index 564106c..48f64b5 100644
--- a/SuperScriptMaterializer/database.cpp
+++ b/SuperScriptMaterializer/database.cpp
@@ -10,7 +10,11 @@ void dbDataStructHelper::init(CKParameterManager* paramManager) {
_db_pOut = new db_pOut();
_db_bIn = new db_bIn();
_db_bOut = new db_bOut();
- _db_bLlink = new db_bLlink();
+ _db_bLink = new db_bLink();
+ _db_pLocal = new db_pLocal();
+ _db_pLink = new db_pLink();
+ _db_pLocalData = new db_pLocalData();
+ _db_pOper = new db_pOper();
_parameterManager = paramManager;
}
@@ -22,7 +26,11 @@ void dbDataStructHelper::dispose() {
delete _db_pOut;
delete _db_bIn;
delete _db_bOut;
- delete _db_bLlink;
+ delete _db_bLink;
+ delete _db_pLocalData;
+ delete _db_pLink;
+ delete _db_pLocal;
+ delete _db_pOper;
_parameterManager = NULL;
}
@@ -50,19 +58,19 @@ void database::open(const char* file) {
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
- "CREATE TABLE behavior('thisobj' INTEGER, 'name' TEXT, 'type' INTEGER, 'proto_name' TEXT, 'proto_guid' INTEGER, 'flags' INTEGER, 'priority' INTEGER, 'version' INTEGER, 'parent' INTEGER);",
+ "CREATE TABLE behavior('thisobj' INTEGER, 'name' TEXT, 'type' INTEGER, 'proto_name' TEXT, 'proto_guid' TEXT, 'flags' INTEGER, 'priority' INTEGER, 'version' INTEGER, 'parent' INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
- "CREATE TABLE pTarget('thisobj' INTEGER, 'name' TEXT, 'type' TEXT, 'type_guid' INTEGER, 'belong_to' INTEGER, 'direct_source' INTEGER, 'shard_source' INTEGER);",
+ "CREATE TABLE pTarget('thisobj' INTEGER, 'name' TEXT, 'type' TEXT, 'type_guid' TEXT, 'belong_to' INTEGER, 'direct_source' INTEGER, 'shard_source' INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
- "CREATE TABLE pIn('thisobj' INTEGER, 'index' INTEGER, 'name' TEXT, 'type' TEXT, 'type_guid' INTEGER, 'belong_to' INTEGER, 'direct_source' INTEGER, 'shard_source' INTEGER);",
+ "CREATE TABLE pIn('thisobj' INTEGER, 'index' INTEGER, 'name' TEXT, 'type' TEXT, 'type_guid' TEXT, 'belong_to' INTEGER, 'direct_source' INTEGER, 'shard_source' INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
- "CREATE TABLE pOut('thisobj' INTEGER, 'index' INTEGER, 'name' TEXT, 'type' TEXT, 'type_guid' INTEGER, 'belong_to' INTEGER);",
+ "CREATE TABLE pOut('thisobj' INTEGER, 'index' INTEGER, 'name' TEXT, 'type' TEXT, 'type_guid' TEXT, 'belong_to' INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
@@ -77,6 +85,23 @@ void database::open(const char* file) {
"CREATE TABLE bLink('input' INTEGER, 'output' INTEGER, 'delay' INTEGER, 'belong_to' INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
+ result = sqlite3_exec(db,
+ "CREATE TABLE pLocal('thisobj' INTEGER, 'name' TEXT, 'type' TEXT, 'type_guid' TEXT, 'is_setting' INTEGER, 'belong_to' INTEGER);",
+ NULL, NULL, &errmsg);
+ if (result != SQLITE_OK) goto fail;
+ result = sqlite3_exec(db,
+ "CREATE TABLE pLocalData('field' TEXT, 'data' TEXT, 'belong_to' INTEGER);",
+ NULL, NULL, &errmsg);
+ if (result != SQLITE_OK) goto fail;
+ result = sqlite3_exec(db,
+ "CREATE TABLE pLink('input' INTEGER, 'output' INTEGER, 'belong_to' INTEGER);",
+ NULL, NULL, &errmsg);
+ if (result != SQLITE_OK) goto fail;
+ result = sqlite3_exec(db,
+ "CREATE TABLE pOper('thisobj' INTEGER, 'op' TEXT, 'op_guid' TEXT, 'belong_to' INTEGER);",
+ NULL, NULL, &errmsg);
+ if (result != SQLITE_OK) goto fail;
+
//start job
sqlite3_exec(db, "begin;", NULL, NULL, &errmsg);
@@ -108,12 +133,13 @@ void database::close() {
void database::write_CKBehavior(dbCKBehavior* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO behavior VALUES (%d, '%s', %d, '%s', %d, %d, %d, %d, %d);",
+ sprintf(commandStr, "INSERT INTO behavior VALUES (%d, '%s', %d, '%s', '%d, %d', %d, %d, %d, %d);",
data->thisobj,
data->name,
data->type,
data->proto_name,
- data->proto_guid,
+ data->proto_guid[0],
+ data->proto_guid[1],
data->flags,
data->priority,
data->version,
@@ -137,11 +163,12 @@ void database::write_CKScript(dbCKScript* data) {
void database::write_pTarget(db_pTarget* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO pTarget VALUES (%d, '%s', '%s', %d, %d, %d, %d);",
+ sprintf(commandStr, "INSERT INTO pTarget VALUES (%d, '%s', '%s', '%d, %d', %d, %d, %d);",
data->thisobj,
data->name,
data->type,
- data->type_guid,
+ data->type_guid[0],
+ data->type_guid[1],
data->belong_to,
data->direct_source,
data->shared_source);
@@ -152,12 +179,13 @@ void database::write_pTarget(db_pTarget* data) {
void database::write_pIn(db_pIn* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO pIn VALUES (%d, %d, '%s', '%s', %d, %d, %d, %d);",
+ sprintf(commandStr, "INSERT INTO pIn VALUES (%d, %d, '%s', '%s', '%d, %d', %d, %d, %d);",
data->thisobj,
data->index,
data->name,
data->type,
- data->type_guid,
+ data->type_guid[0],
+ data->type_guid[1],
data->belong_to,
data->direct_source,
data->shared_source);
@@ -168,12 +196,13 @@ void database::write_pIn(db_pIn* data) {
void database::write_pOut(db_pOut* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO pOut VALUES (%d, %d, '%s', '%s', %d, %d);",
+ sprintf(commandStr, "INSERT INTO pOut VALUES (%d, %d, '%s', '%s', '%d, %d', %d);",
data->thisobj,
data->index,
data->name,
data->type,
- data->type_guid,
+ data->type_guid[0],
+ data->type_guid[1],
data->belong_to);
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
@@ -203,7 +232,7 @@ void database::write_bOut(db_bOut* data) {
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
-void database::write_bLink(db_bLlink* data) {
+void database::write_bLink(db_bLink* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO bLink VALUES (%d, %d, %d, %d);",
@@ -215,4 +244,55 @@ void database::write_bLink(db_bLlink* data) {
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
+void database::write_pLocal(db_pLocal* data) {
+ if (db == NULL) return;
+
+ sprintf(commandStr, "INSERT INTO pLocal VALUES (%d, '%s', '%s', '%d, %d', %d, %d);",
+ data->thisobj,
+ data->name,
+ data->type,
+ data->type_guid[0],
+ data->type_guid[1],
+ data->is_setting,
+ data->belong_to);
+
+ sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+}
+
+void database::write_pLink(db_pLink* data) {
+ if (db == NULL) return;
+
+ sprintf(commandStr, "INSERT INTO pLink VALUES (%d, %d, %d);",
+ data->input,
+ data->output,
+ data->belong_to);
+
+ sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+}
+
+void database::write_pLocalData(db_pLocalData* data) {
+ if (db == NULL) return;
+
+ sprintf(commandStr, "INSERT INTO pLocalData VALUES ('%s', '%s', %d);",
+ data->field,
+ data->data,
+ data->belong_to);
+
+ sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+}
+
+void database::write_pOper(db_pOper* data) {
+ if (db == NULL) return;
+
+ sprintf(commandStr, "INSERT INTO pOper VALUES (%d, '%s', '%d, %d', %d);",
+ data->thisobj,
+ data->op,
+ data->op_guid[0],
+ data->op_guid[1],
+ data->belong_to);
+
+ sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+}
+
+
#pragma endregion
diff --git a/SuperScriptMaterializer/database.h b/SuperScriptMaterializer/database.h
index 70c2f94..4bb6c58 100644
--- a/SuperScriptMaterializer/database.h
+++ b/SuperScriptMaterializer/database.h
@@ -13,7 +13,7 @@ typedef struct dbCKBehavior {
char name[1024];
CK_BEHAVIOR_TYPE type;
char proto_name[1024];
- CKDWORD proto_guid;
+ CKDWORD proto_guid[2];
CK_BEHAVIOR_FLAGS flags;
int priority;
CKDWORD version;
@@ -31,7 +31,7 @@ typedef struct db_pTarget {
EXPAND_CK_ID thisobj;
char name[1024];
char type[1024];
- CKDWORD type_guid;
+ CKDWORD type_guid[2];
EXPAND_CK_ID belong_to;
EXPAND_CK_ID direct_source;
EXPAND_CK_ID shared_source;
@@ -42,7 +42,7 @@ typedef struct db_pIn {
int index;
char name[1024];
char type[1024];
- CKDWORD type_guid;
+ CKDWORD type_guid[2];
EXPAND_CK_ID belong_to;
EXPAND_CK_ID direct_source;
EXPAND_CK_ID shared_source;
@@ -53,7 +53,7 @@ typedef struct db_pOut {
int index;
char name[1024];
char type[1024];
- CKDWORD type_guid;
+ CKDWORD type_guid[2];
EXPAND_CK_ID belong_to;
};
@@ -66,13 +66,41 @@ typedef struct db_bIO {
typedef db_bIO db_bIn;
typedef db_bIO db_bOut;
-typedef struct db_bLlink {
+typedef struct db_bLink {
EXPAND_CK_ID input;
EXPAND_CK_ID output;
int delay;
EXPAND_CK_ID belong_to;
};
+typedef struct db_pLocal {
+ EXPAND_CK_ID thisobj;
+ char name[1024];
+ char type[1024];
+ CKDWORD type_guid[2];
+ BOOL is_setting;
+ EXPAND_CK_ID belong_to;
+};
+
+typedef struct db_pLocalData {
+ char field[1024];
+ char data[1024];
+ EXPAND_CK_ID belong_to;
+};
+
+typedef struct db_pLink {
+ EXPAND_CK_ID input;
+ EXPAND_CK_ID output;
+ EXPAND_CK_ID belong_to;
+};
+
+typedef struct db_pOper {
+ EXPAND_CK_ID thisobj;
+ char op[1024];
+ CKDWORD op_guid[2];
+ EXPAND_CK_ID belong_to;
+};
+
#pragma endregion
class dbDataStructHelper {
@@ -88,9 +116,11 @@ class dbDataStructHelper {
db_pOut* _db_pOut;
db_bIn* _db_bIn;
db_bOut* _db_bOut;
- db_bLlink* _db_bLlink;
-
-
+ db_bLink* _db_bLink;
+ db_pLocal* _db_pLocal;
+ db_pLink* _db_pLink;
+ db_pLocalData* _db_pLocalData;
+ db_pOper* _db_pOper;
};
class database {
@@ -105,7 +135,11 @@ class database {
void write_pOut(db_pOut* data);
void write_bIn(db_bIn* data);
void write_bOut(db_bOut* data);
- void write_bLink(db_bLlink* data);
+ void write_bLink(db_bLink* data);
+ void write_pLocal(db_pLocal* data);
+ void write_pLink(db_pLink* data);
+ void write_pLocalData(db_pLocalData* data);
+ void write_pOper(db_pOper* data);
private:
sqlite3* db;
diff --git a/SuperScriptMaterializer/script_export.cpp b/SuperScriptMaterializer/script_export.cpp
new file mode 100644
index 0000000..6f0ddb9
--- /dev/null
+++ b/SuperScriptMaterializer/script_export.cpp
@@ -0,0 +1,346 @@
+#include "script_export.h"
+
+#define changeSuffix(a) prefix[endIndex]='\0';strcat(prefix,a)
+
+#pragma region inline func
+
+inline void proc_pTarget(CKParameterIn* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) {
+ helper->_db_pTarget->thisobj = cache->GetID();
+ strcpy(helper->_db_pTarget->name, cache->GetName());
+ strcpy(helper->_db_pTarget->type, helper->_parameterManager->ParameterTypeToName(cache->GetType()));
+ helper->_db_pTarget->type_guid[0] = cache->GetGUID().d1;
+ helper->_db_pTarget->type_guid[1] = cache->GetGUID().d2;
+ helper->_db_pTarget->belong_to = parents;
+ helper->_db_pTarget->direct_source = cache->GetDirectSource() ? cache->GetDirectSource()->GetID() : -1;
+ helper->_db_pTarget->shared_source = cache->GetSharedSource() ? cache->GetSharedSource()->GetID() : -1;
+
+ db->write_pTarget(helper->_db_pTarget);
+}
+
+inline void proc_pIn(CKParameterIn* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, int index) {
+ helper->_db_pIn->thisobj = cache->GetID();
+ helper->_db_pIn->index = index;
+ strcpy(helper->_db_pIn->name, cache->GetName());
+ strcpy(helper->_db_pIn->type, helper->_parameterManager->ParameterTypeToName(cache->GetType()));
+ helper->_db_pIn->type_guid[0] = cache->GetGUID().d1;
+ helper->_db_pIn->type_guid[1] = cache->GetGUID().d2;
+ helper->_db_pIn->belong_to = parents;
+ helper->_db_pIn->direct_source = cache->GetDirectSource() ? cache->GetDirectSource()->GetID() : -1;
+ helper->_db_pIn->shared_source = cache->GetSharedSource() ? cache->GetSharedSource()->GetID() : -1;
+
+ db->write_pIn(helper->_db_pIn);
+
+ //=========try generate pLink
+ EXPAND_CK_ID origin = -1;
+ if (cache->GetDirectSource()) origin = cache->GetDirectSource()->GetID();
+ if (cache->GetSharedSource()) origin = cache->GetSharedSource()->GetID();
+ if (origin == -1) return;
+ helper->_db_pLink->input = origin;
+ helper->_db_pLink->output = cache->GetID();
+ helper->_db_pLink->belong_to = index;
+
+ db->write_pLink(helper->_db_pLink);
+}
+
+inline void proc_pOut(CKParameterOut* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, int index) {
+ helper->_db_pOut->thisobj = cache->GetID();
+ helper->_db_pOut->index = index;
+ strcpy(helper->_db_pOut->name, cache->GetName());
+ strcpy(helper->_db_pOut->type, helper->_parameterManager->ParameterTypeToName(cache->GetType()));
+ helper->_db_pOut->type_guid[0] = cache->GetGUID().d1;
+ helper->_db_pOut->type_guid[1] = cache->GetGUID().d2;
+ helper->_db_pOut->belong_to = parents;
+
+ db->write_pOut(helper->_db_pOut);
+
+ //=========try generate pLink
+ CKParameter* cache_Dest = NULL;
+ for (int j = 0, jCount = cache->GetDestinationCount(); j < jCount; j++) {
+ cache_Dest = cache->GetDestination(j);
+
+ helper->_db_pLink->input = cache->GetID();
+ helper->_db_pLink->output = cache_Dest->GetID();
+ helper->_db_pLink->belong_to = parents;
+
+ db->write_pLink(helper->_db_pLink);
+ }
+}
+
+inline void proc_bIn(CKBehaviorIO* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, int index) {
+ helper->_db_bIn->thisobj = cache->GetID();
+ helper->_db_bIn->index = index;
+ strcpy(helper->_db_bIn->name, cache->GetName());
+ helper->_db_bIn->belong_to = parents;
+
+ db->write_bIn(helper->_db_bIn);
+}
+
+inline void proc_bOut(CKBehaviorIO* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, int index) {
+ helper->_db_bOut->thisobj = cache->GetID();
+ helper->_db_bOut->index = index;
+ strcpy(helper->_db_bOut->name, cache->GetName());
+ helper->_db_bOut->belong_to = parents;
+
+ db->write_bOut(helper->_db_bOut);
+}
+
+inline void proc_bLink(CKBehaviorLink* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) {
+ helper->_db_bLink->input = cache->GetInBehaviorIO()->GetID();
+ helper->_db_bLink->output = cache->GetOutBehaviorIO()->GetID();
+ helper->_db_bLink->delay = cache->GetActivationDelay();
+ helper->_db_bLink->belong_to = parents;
+
+ db->write_bLink(helper->_db_bLink);
+}
+
+inline void proc_pLocal(CKParameterLocal* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, BOOL is_setting) {
+ helper->_db_pLocal->thisobj = cache->GetID();
+ strcpy(helper->_db_pLocal->name, cache->GetName() ? cache->GetName() : "");
+ strcpy(helper->_db_pLocal->type, helper->_parameterManager->ParameterTypeToName(cache->GetType()));
+ helper->_db_pLocal->type_guid[0] = cache->GetGUID().d1;
+ helper->_db_pLocal->type_guid[1] = cache->GetGUID().d2;
+ helper->_db_pLocal->is_setting = is_setting;
+ helper->_db_pLocal->belong_to = parents;
+
+ db->write_pLocal(helper->_db_pLocal);
+
+ //export plocal metadata
+ IteratepLocalData(cache, db, helper, cache->GetID());
+}
+
+inline void proc_pOper(CKParameterOperation* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) {
+ helper->_db_pOper->thisobj = cache->GetID();
+ strcpy(helper->_db_pOper->op, helper->_parameterManager->OperationGuidToName(cache->GetOperationGuid()));
+ helper->_db_pOper->op_guid[0] = cache->GetOperationGuid().d1;
+ helper->_db_pOper->op_guid[1] = cache->GetOperationGuid().d2;
+ helper->_db_pOper->belong_to = parents;
+
+ db->write_pOper(helper->_db_pOper);
+
+ //export 2 input param and 1 output param
+ proc_pIn(cache->GetInParameter1(), db, helper, cache->GetID(), 0);
+ proc_pIn(cache->GetInParameter2(), db, helper, cache->GetID(), 1);
+ proc_pOut(cache->GetOutParameter(), db, helper, cache->GetID(), 0);
+}
+
+
+//============================helper for pLocal data export
+inline void helper_pLocalDataExport(const char* field, const char* data, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) {
+ strcpy(helper->_db_pLocalData->field, field);
+ strcpy(helper->_db_pLocalData->data, data);
+ helper->_db_pLocalData->belong_to = parents;
+
+ db->write_pLocalData(helper->_db_pLocalData);
+}
+inline void helper_pLocalDataExport(const char* field, float data, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) {
+ char str[32];
+ sprintf(str, "%f", data);
+ helper_pLocalDataExport(field, str, db, helper, parents);
+}
+inline void helper_pLocalDataExport(const char* field, long data, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) {
+ char str[32];
+ ltoa(data, str, 10);
+ helper_pLocalDataExport(field, str, db, helper, parents);
+}
+
+
+#pragma endregion
+
+
+#pragma region normal func
+
+void IterateScript(CKContext* ctx, database* db, dbDataStructHelper* helper) {
+ CKBeObject* beobj = NULL;
+ CKBehavior* beh = NULL;
+ XObjectPointerArray objArray = ctx->GetObjectListByType(CKCID_BEOBJECT, TRUE);
+ int len = objArray.Size();
+ int scriptLen = 0;
+ for (int i = 0; i < len; i++) {
+ beobj = (CKBeObject*)objArray.GetObjectA(i);
+ if ((scriptLen = beobj->GetScriptCount()) == 0) continue;
+ for (int j = 0; j < scriptLen; j++) {
+ //write script table
+ beh = beobj->GetScript(j);
+
+ helper->_dbCKScript->thisobj = beobj->GetID();
+ strcpy(helper->_dbCKScript->host_name, beobj->GetName());
+ helper->_dbCKScript->index = j;
+ helper->_dbCKScript->behavior = beh->GetID();
+ db->write_CKScript(helper->_dbCKScript);
+
+ //iterate script
+ IterateBehavior(beh, db, helper, -1);
+ }
+ }
+}
+
+void IterateBehavior(CKBehavior* bhv, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) {
+ //write self data
+ helper->_dbCKBehavior->thisobj = bhv->GetID();
+ strcpy(helper->_dbCKBehavior->name, bhv->GetName());
+ helper->_dbCKBehavior->type = bhv->GetType();
+ strcpy(helper->_dbCKBehavior->proto_name, bhv->GetPrototypeName() ? bhv->GetPrototypeName() : "");
+ helper->_dbCKBehavior->proto_guid[0] = bhv->GetPrototypeGuid().d1;
+ helper->_dbCKBehavior->proto_guid[1] = bhv->GetPrototypeGuid().d2;
+ helper->_dbCKBehavior->flags = bhv->GetFlags();
+ helper->_dbCKBehavior->priority = bhv->GetPriority();
+ helper->_dbCKBehavior->version = bhv->GetVersion();
+ helper->_dbCKBehavior->parent = parents;
+ db->write_CKBehavior(helper->_dbCKBehavior);
+
+ //write target
+ if (bhv->IsUsingTarget())
+ proc_pTarget(bhv->GetTargetParameter(), db, helper, bhv->GetID());
+
+ int count = 0, i = 0;
+ //pIn
+ for (i = 0, count = bhv->GetInputParameterCount(); i < count; i++)
+ proc_pIn(bhv->GetInputParameter(i), db, helper, bhv->GetID(), i);
+ //pOut
+ for (i = 0, count = bhv->GetOutputParameterCount(); i < count; i++)
+ proc_pOut(bhv->GetOutputParameter(i), db, helper, bhv->GetID(), i);
+ //bIn
+ for (i = 0, count = bhv->GetInputCount(); i < count; i++)
+ proc_bIn(bhv->GetInput(i), db, helper, bhv->GetID(), i);
+ //bOut
+ for (i = 0, count = bhv->GetOutputCount(); i < count; i++)
+ proc_bOut(bhv->GetOutput(i), db, helper, bhv->GetID(), i);
+ //bLink
+ for (i = 0, count = bhv->GetSubBehaviorLinkCount(); i < count; i++)
+ proc_bLink(bhv->GetSubBehaviorLink(i), db, helper, bhv->GetID());
+ //pLocal
+ for (i = 0, count = bhv->GetLocalParameterCount(); i < count; i++)
+ proc_pLocal(bhv->GetLocalParameter(i), db, helper, bhv->GetID(),
+ bhv->IsLocalParameterSetting(i));
+ //bOper
+ for (i = 0, count = bhv->GetParameterOperationCount(); i < count; i++)
+ proc_pOper(bhv->GetParameterOperation(i), db, helper, bhv->GetID());
+
+ //iterate sub bb
+ for (i = 0, count = bhv->GetSubBehaviorCount(); i < count; i++)
+ IterateBehavior(bhv->GetSubBehavior(i), db, helper, bhv->GetID());
+}
+
+void IteratepLocalData(CKParameterLocal* p, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) {
+ CKGUID t = p->GetGUID();
+ BOOL unknowType = FALSE;
+
+ if (t.d1 & t.d2) unknowType = TRUE;
+
+ //nothing
+ if (t == CKPGUID_NONE) return;
+ if (p->GetParameterClassID() && p->GetValueObject(false)) {
+ helper_pLocalDataExport("id", (long)p->GetValueObject(false)->GetID(), db, helper, parents);
+ helper_pLocalDataExport("name", p->GetValueObject(false)->GetName(), db, helper, parents);
+ helper_pLocalDataExport("type", p->GetValueObject(false)->GetClassNameA(), db, helper, parents);
+ return;
+ }
+ //float
+ if (t == CKPGUID_FLOAT || t == CKPGUID_ANGLE || t == CKPGUID_PERCENTAGE || t == CKPGUID_TIME
+ || t == CKPGUID_FLOATSLIDER) {
+ helper_pLocalDataExport("float-data", *(float*)(p->GetReadDataPtr(false)), db, helper, parents);
+ return;
+ }
+ //int
+ if (t == CKPGUID_INT || t == CKPGUID_KEY || t == CKPGUID_BOOL || t == CKPGUID_ID || t == CKPGUID_POINTER
+ || t == CKPGUID_MESSAGE || t == CKPGUID_ATTRIBUTE || t == CKPGUID_BLENDMODE || t == CKPGUID_FILTERMODE
+ || t == CKPGUID_BLENDFACTOR || t == CKPGUID_FILLMODE || t == CKPGUID_LITMODE || t == CKPGUID_SHADEMODE
+ || t == CKPGUID_ADDRESSMODE || t == CKPGUID_WRAPMODE || t == CKPGUID_3DSPRITEMODE || t == CKPGUID_FOGMODE
+ || t == CKPGUID_LIGHTTYPE || t == CKPGUID_SPRITEALIGN || t == CKPGUID_DIRECTION || t == CKPGUID_LAYERTYPE
+ || t == CKPGUID_COMPOPERATOR || t == CKPGUID_BINARYOPERATOR || t == CKPGUID_SETOPERATOR
+ || t == CKPGUID_OBSTACLEPRECISION || t == CKPGUID_OBSTACLEPRECISIONBEH) {
+ helper_pLocalDataExport("int-data", (long)(*(int*)(p->GetReadDataPtr(false))), db, helper, parents);
+ return;
+ }
+ if (t == CKPGUID_VECTOR) {
+ VxVector vec;
+ memcpy(&vec, p->GetReadDataPtr(false), sizeof(vec));
+ helper_pLocalDataExport("vector.x", vec.x, db, helper, parents);
+ helper_pLocalDataExport("vector.y", vec.y, db, helper, parents);
+ helper_pLocalDataExport("vector.z", vec.z, db, helper, parents);
+ return;
+ }
+ if (t == CKPGUID_2DVECTOR) {
+ Vx2DVector vec;
+ memcpy(&vec, p->GetReadDataPtr(false), sizeof(vec));
+ helper_pLocalDataExport("2dvector.x", vec.x, db, helper, parents);
+ helper_pLocalDataExport("2dvector.y", vec.y, db, helper, parents);
+ return;
+ }
+ if (t == CKPGUID_MATRIX) {
+ VxMatrix mat;
+ char position[128];
+ memcpy(&mat, p->GetReadDataPtr(false), sizeof(mat));
+
+ for (int i = 0; i < 4; ++i) {
+ for (int j = 0; j < 4; ++j) {
+ sprintf(position, "matrix[%d][%d]", i, j);
+ helper_pLocalDataExport(position, mat[i][j], db, helper, parents);
+ }
+ }
+ return;
+ }
+ if (t == CKPGUID_COLOR) {
+ VxColor col;
+ memcpy(&col, p->GetReadDataPtr(false), sizeof(col));
+ helper_pLocalDataExport("color.r", col.r, db, helper, parents);
+ helper_pLocalDataExport("color.g", col.g, db, helper, parents);
+ helper_pLocalDataExport("color.b", col.b, db, helper, parents);
+ helper_pLocalDataExport("color.a", col.a, db, helper, parents);
+ return;
+ }
+ if (t == CKPGUID_2DCURVE) {
+ CK2dCurve* c;
+ char prefix[128];
+ int endIndex = 0;
+ memcpy(&c, p->GetReadDataPtr(false), sizeof(c));
+ for (int i = 0, cc = c->GetControlPointCount(); i < cc; ++i) {
+ sprintf(prefix, "2dcurve.control_point[%d]", i);
+ endIndex = strlen(prefix);
+
+ changeSuffix(".pos.x");
+ helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetPosition().x, db, helper, parents);
+ changeSuffix(".pos.y");
+ helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetPosition().y, db, helper, parents);
+ changeSuffix(".islinear");
+ helper_pLocalDataExport(prefix, (long)c->GetControlPoint(i)->IsLinear(), db, helper, parents);
+ if (c->GetControlPoint(i)->IsTCB()) {
+ changeSuffix(".bias");
+ helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetBias(), db, helper, parents);
+ changeSuffix(".continuity");
+ helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetContinuity(), db, helper, parents);
+ changeSuffix(".tension");
+ helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetTension(), db, helper, parents);
+ } else {
+ changeSuffix(".intangent.x");
+ helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetInTangent().x, db, helper, parents);
+ changeSuffix(".intangent.y");
+ helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetInTangent().y, db, helper, parents);
+ changeSuffix(".outtangent.x");
+ helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetOutTangent().x, db, helper, parents);
+ changeSuffix(".outtangent.y");
+ helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetOutTangent().y, db, helper, parents);
+ }
+ }
+ return;
+ }
+
+ unknowType = TRUE;
+ //if it gets here, we have no idea what it really is. so simply dump it.
+ //buffer-like
+ if (unknowType || t == CKPGUID_VOIDBUF || t == CKPGUID_STRING || t == CKPGUID_SHADER || t == CKPGUID_TECHNIQUE || t == CKPGUID_PASS) {
+ char* cptr = (char*)p->GetReadDataPtr(false);
+ int cc = p->GetDataSize();
+ for (int i = 0; i < cc; i++)
+ helper->_db_pLocalData->data[i] = cptr[i];
+ helper->_db_pLocalData->data[cc] = '\0';
+ strcpy(helper->_db_pLocalData->field, "dump-data");
+ helper->_db_pLocalData->belong_to = p->GetID();
+ db->write_pLocalData(helper->_db_pLocalData);
+
+ return;
+ }
+}
+
+#pragma endregion
+
diff --git a/SuperScriptMaterializer/script_export.h b/SuperScriptMaterializer/script_export.h
new file mode 100644
index 0000000..46dd06d
--- /dev/null
+++ b/SuperScriptMaterializer/script_export.h
@@ -0,0 +1,24 @@
+#if !defined(_YYCDLL_SCRIPT_EXPORT_H__IMPORTED_)
+#define _YYCDLL_SCRIPT_EXPORT_H__IMPORTED_
+
+#include "stdafx.h"
+#include "database.h"
+
+inline void proc_pTarget(CKParameterIn* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents);
+inline void proc_pIn(CKParameterIn* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, int index);
+inline void proc_pOut(CKParameterOut* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, int index);
+inline void proc_bIn(CKBehaviorIO* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, int index);
+inline void proc_bOut(CKBehaviorIO* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, int index);
+inline void proc_bLink(CKBehaviorLink* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents);
+inline void proc_pLocal(CKParameterLocal* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, BOOL is_setting);
+inline void proc_pOper(CKParameterOperation* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents);
+
+inline void helper_pLocalDataExport(const char* field, long data, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents);
+inline void helper_pLocalDataExport(const char* field, float data, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents);
+inline void helper_pLocalDataExport(const char* field, const char* data, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents);
+
+void IterateBehavior(CKBehavior* bhv, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents);
+void IterateScript(CKContext* ctx, database* db, dbDataStructHelper* helper);
+void IteratepLocalData(CKParameterLocal* pl, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents);
+
+#endif
\ No newline at end of file
diff --git a/SuperScriptMaterializer/vt_menu.cpp b/SuperScriptMaterializer/vt_menu.cpp
index 6545758..1d19ae7 100644
--- a/SuperScriptMaterializer/vt_menu.cpp
+++ b/SuperScriptMaterializer/vt_menu.cpp
@@ -1,5 +1,6 @@
#include "vt_menu.h"
#include "database.h"
+#include "script_export.h"
extern PluginInterface* s_Plugininterface;
CMenu* s_MainMenu = NULL;
@@ -99,141 +100,11 @@ void PluginMenuCallback(int commandID) {
_db->close();
delete _helper;
delete _db;
+
+ ctx->OutputToConsole("[Super Script Materializer] Done");
}
free(file);
-
- ctx->OutputToConsole("[Super Script Materializer] Done");
}
break;
}
}
-
-void IterateScript(CKContext* ctx, database* db, dbDataStructHelper* helper) {
- CKBeObject* beobj = NULL;
- CKBehavior* beh = NULL;
- XObjectPointerArray objArray = ctx->GetObjectListByType(CKCID_BEOBJECT, TRUE);
- int len = objArray.Size();
- int scriptLen = 0;
- for (int i = 0; i < len; i++) {
- beobj = (CKBeObject*)objArray.GetObjectA(i);
- if ((scriptLen = beobj->GetScriptCount()) == 0) continue;
- for (int j = 0; j < scriptLen; j++) {
- //write script table
- beh = beobj->GetScript(j);
-
- helper->_dbCKScript->thisobj = beobj->GetID();
- strcpy(helper->_dbCKScript->host_name, beobj->GetName());
- helper->_dbCKScript->index = j;
- helper->_dbCKScript->behavior = beh->GetID();
- db->write_CKScript(helper->_dbCKScript);
-
- //iterate script
- IterateBehavior(beh, db, helper, -1);
- }
- }
-}
-
-void IterateBehavior(CKBehavior* bhv, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) {
- //write self data
- helper->_dbCKBehavior->thisobj = bhv->GetID();
- strcpy(helper->_dbCKBehavior->name, bhv->GetName());
- helper->_dbCKBehavior->type = bhv->GetType();
- strcpy(helper->_dbCKBehavior->proto_name, bhv->GetPrototypeName() ? bhv->GetPrototypeName() : "");
- //todo: fix guid
- helper->_dbCKBehavior->proto_guid = bhv->GetPrototypeGuid().d1;
- helper->_dbCKBehavior->flags = bhv->GetFlags();
- helper->_dbCKBehavior->priority = bhv->GetPriority();
- helper->_dbCKBehavior->version = bhv->GetVersion();
- helper->_dbCKBehavior->parent = parents;
- db->write_CKBehavior(helper->_dbCKBehavior);
-
- //write target
- if (bhv->IsUsingTarget()) {
- CKParameterIn* cache = bhv->GetTargetParameter();
-
- helper->_db_pTarget->thisobj = cache->GetID();
- strcpy(helper->_db_pTarget->name, cache->GetName());
- strcpy(helper->_db_pTarget->type, helper->_parameterManager->ParameterTypeToName(cache->GetType()));
- //todo: fix guid
- helper->_db_pTarget->type_guid = cache->GetGUID().d1;
- helper->_db_pTarget->belong_to = bhv->GetID();
- helper->_db_pTarget->direct_source = cache->GetDirectSource() ? cache->GetDirectSource()->GetID() : -1;
- helper->_db_pTarget->shared_source = cache->GetSharedSource() ? cache->GetSharedSource()->GetID() : -1;
-
- db->write_pTarget(helper->_db_pTarget);
- }
-
- int count = 0, i = 0;
- CKParameterIn* cache_pIn = NULL;
- CKParameterOut* cache_pOut = NULL;
- CKBehaviorIO* cache_bIO = NULL;
- CKBehaviorLink* cache_bLink = NULL;
- //pIn
- for (i = 0, count = bhv->GetInputParameterCount(); i < count; i++) {
- cache_pIn = bhv->GetInputParameter(i);
- helper->_db_pIn->thisobj = cache_pIn->GetID();
- helper->_db_pIn->index = i;
- strcpy(helper->_db_pIn->name, cache_pIn->GetName());
- strcpy(helper->_db_pIn->type, helper->_parameterManager->ParameterTypeToName(cache_pIn->GetType()));
- //todo: fix guid
- helper->_db_pIn->type_guid = cache_pIn->GetGUID().d1;
- helper->_db_pIn->belong_to = bhv->GetID();
- helper->_db_pIn->direct_source = cache_pIn->GetDirectSource() ? cache_pIn->GetDirectSource()->GetID() : -1;
- helper->_db_pIn->shared_source = cache_pIn->GetSharedSource() ? cache_pIn->GetSharedSource()->GetID() : -1;
-
- db->write_pIn(helper->_db_pIn);
- }
-
- //pOut
- for (i = 0, count = bhv->GetOutputParameterCount(); i < count; i++) {
- cache_pOut = bhv->GetOutputParameter(i);
- helper->_db_pOut->thisobj = cache_pOut->GetID();
- helper->_db_pOut->index = i;
- strcpy(helper->_db_pOut->name, cache_pOut->GetName());
- strcpy(helper->_db_pOut->type, helper->_parameterManager->ParameterTypeToName(cache_pOut->GetType()));
- //todo: fix guid
- helper->_db_pOut->type_guid = cache_pOut->GetGUID().d1;
- helper->_db_pOut->belong_to = bhv->GetID();
-
- db->write_pOut(helper->_db_pOut);
- }
-
- //bIn
- for (i = 0, count = bhv->GetInputCount(); i < count; i++) {
- cache_bIO = bhv->GetInput(i);
- helper->_db_bIn->thisobj = cache_bIO->GetID();
- helper->_db_bIn->index = i;
- strcpy(helper->_db_bIn->name, cache_bIO->GetName());
- helper->_db_bIn->belong_to = bhv->GetID();
-
- db->write_bIn(helper->_db_bIn);
- }
-
- //bOut
- for (i = 0, count = bhv->GetOutputCount(); i < count; i++) {
- cache_bIO = bhv->GetOutput(i);
- helper->_db_bOut->thisobj = cache_bIO->GetID();
- helper->_db_bOut->index = i;
- strcpy(helper->_db_bOut->name, cache_bIO->GetName());
- helper->_db_bOut->belong_to = bhv->GetID();
-
- db->write_bOut(helper->_db_bOut);
- }
-
- //bLink
- for (i = 0, count = bhv->GetSubBehaviorLinkCount(); i < count; i++) {
- cache_bLink = bhv->GetSubBehaviorLink(i);
- helper->_db_bLlink->input = cache_bLink->GetInBehaviorIO()->GetID();
- helper->_db_bLlink->output = cache_bLink->GetOutBehaviorIO()->GetID();
- helper->_db_bLlink->delay = cache_bLink->GetActivationDelay();
- helper->_db_bLlink->belong_to = bhv->GetID();
-
- db->write_bLink(helper->_db_bLlink);
- }
-
-
- //iterate sub bb
- for (i = 0, count = bhv->GetSubBehaviorCount(); i < count; i++)
- IterateBehavior(bhv->GetSubBehavior(i), db, helper, bhv->GetID());
-
-}
\ No newline at end of file
diff --git a/SuperScriptMaterializer/vt_menu.h b/SuperScriptMaterializer/vt_menu.h
index 8b24423..86c6376 100644
--- a/SuperScriptMaterializer/vt_menu.h
+++ b/SuperScriptMaterializer/vt_menu.h
@@ -10,7 +10,5 @@ void InitMenu();
void RemoveMenu();
void UpdateMenu();
void PluginMenuCallback(int commandID);
-void IterateBehavior(CKBehavior* bhv, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents);
-void IterateScript(CKContext* ctx, database* db, dbDataStructHelper* helper);
#endif
\ No newline at end of file