First let me say thanks for all your help! I've managed to get it working, and I've been googling for C++ tutorials (the language is a lot harder than I ever imagined!) There a still a couple of points I was wondering if you could help me on:
1) What's the difference between Char and Char*? And how do they work as strings, given that the help files seem to define them as a 1-byte integer?
2)Is it possible to write an expression of the type "if x=1 or x=3"? I haven't come accross it in the tutorials I found, but I'd like to be able to call this:
if (strcmp( dbLower( dbRight( dbGetFileName() ,2) ), ".x") == 0) OR (strcmp( dbLower( dbRight( dbGetFileName() ,4) ), ".3ds") == 0)
3) The dbPerformChecklistForObjectLimbs tells me that an object has 19 limbs, when in DBC the command tells me there are only 18 limbs. Is the checklist counting the root data as a limb, and if so, how do I prevent the program from writing this out?
Here's my code, in case you need it:
// GDk Header file
#include "DarkGDK.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
dbFindFirst();
dbFindNext();
dbSyncOn();
while ( LoopGDK ( ) )
{
dbFindNext();
if (strcmp( dbLower( dbRight( dbGetFileName() ,2) ), ".x") == 0)
{
char* Filename = dbGetFileName();
if (dbFileExist(strcat(Filename, ".Lim" )) == 0 )
{
Filename = dbGetFileName();
dbOpenToWrite(1, strcat(Filename, ".Lim" ));
dbWriteString(1, "Lightning_Limbs_1.0.3alt");
char* Path = dbGetDir();
Path = strcat(Path, dbChr(92));
Path = strcat(Path, dbGetFileName());
dbWriteString(1, Path );
dbLoadObject(dbGetFileName(), 1);
dbEmptyChecklist();
dbPerformChecklistForObjectLimbs (1);
dbWriteString (1, dbStr(dbChecklistQuantity()));
dbWriteString (1, dbStr(dbInt ( dbTotalObjectFrames(1) ) ) );
dbWriteString (1, "0");
dbWriteString (1, "0.5");
dbWriteString (1, "15");
dbWriteString (1, "100");
// Read animation keyframe data
for (float k=1.00000; k<( dbTotalObjectFrames(1) ); k++)
{
dbWriteString (1, dbStr(k));
dbSetObjectFrame(1, k);
for (int L=1; L<dbChecklistQuantity() ; L++)
{
dbWriteString (1, dbStr(dbLimbOffsetX(1, L)));
dbWriteString (1, dbStr(dbLimbOffsetY(1, L)));
dbWriteString (1, dbStr(dbLimbOffsetZ(1, L)));
dbWriteString (1, dbStr(dbLimbDirectionX(1, L)));
dbWriteString (1, dbStr(dbLimbDirectionY(1, L)));
dbWriteString (1, dbStr(dbLimbDirectionZ(1, L)));
}
}
// No parent limbs defined
for (int L=1; L<dbChecklistQuantity() ; L++)
{
dbWriteString (1, "6000");
dbWriteString (1, "0");
}
// Current Limb offset/angles
for (int L=1; L<dbChecklistQuantity() ; L++)
{
dbWriteString (1, dbStr(dbLimbOffsetX(1, L)));
dbWriteString (1, dbStr(dbLimbOffsetY(1, L)));
dbWriteString (1, dbStr(dbLimbOffsetZ(1, L)));
dbWriteString (1, dbStr(dbLimbDirectionX(1, L)));
dbWriteString (1, dbStr(dbLimbDirectionY(1, L)));
dbWriteString (1, dbStr(dbLimbDirectionZ(1, L)));
}
dbWriteString (1, "1");
dbWriteString (1, "-10.8026");
dbWriteString (1, "1000");
dbWriteString (1, "1");
dbWriteString (1, "-10.8026");
dbCloseFile(1);
dbDeleteObject(1);
}
}
if (dbGetFileType() == -1) return;
dbSync();
}
// return back to windows
return;
}
I've had to write out all the data as strings, otherwise DBC won't stand a chance of reading it (dbWriteFloat seems to be writing 8-byte floats instead of 4-byte ones, and DBC only reads 4-byte floats). Actually, is it possible to write out a 4-byte float?
If I admit that I'm lying, am I telling the truth?