PDA

View Full Version : Newbie question


Noob2
07-11-2003, 03:31 AM
Hello I need some help on something if anyone would be so kind. I compiled the xsi for Studio Max 5.x code and now i am modifing the code to make a directx export for a game called Battlezone 1.

What I need to know is what do these lines do:

fprintf(pStream,"%s\t%s {\n\n", indent.data(), "FrameTransformMatrix");

TSTR indent = GetIndent(indentLevel);

I have to remove indents,the above controls this:

Frame frm-dsp1_col {

FrameTransformMatrix {

1.000000,0.000000,0.000000,0.000000,
0.000000,1.000000,0.000000,0.000000,
0.000000,0.000000,1.000000,0.000000,
0.000000,0.000000,0.000000,1.000000;;


Thanks for your assistance.

DNAunion2000
07-11-2003, 11:58 PM
Noob2: What I need to know is what do these lines do:

fprintf(pStream,"%s\t%s {\n\n", indent.data(), "FrameTransformMatrix");


DNAunion: Since no one else has responded yet, I'll take a whack at it.

fprintf is a function that prints output to a file (a file stream).

The file stream that the output will be inserted into (for writing to a file) was created earlier and assigned to the reference or "file handle" pStream.

"%s\t%s {\n\n" is a format string. %s is a placeholder that indicates a string should be plugged in at that spot; \t indicates a tab should go there; and \n indicates a newline.

indent.data() is a function call that returns a string. Since it is the first string value in the comma delimited list, it is plugged in into the output where the first %s appears.

"FrameTransformMatrix" is a string literal. Being the second in the comma delimited list, it will substituted in for the second %s in the format string.

TSTR indent = GetIndent(indentLevel);

DNAunion: Apparently, TSTR is some kind of a specially defined type (probably based on an application-specific class).

indent is variable that is being declared and memory allocated for. The variable is of type TSTR.

GetIndent is a function that is being invoked. Its return value is assigned to the variable indent.

indentLevel is a variable that is being passed into the function as as argument. It probably has an integer value that indicates how many levels something should be indented (for example, a value of 1 might indicate that a single tab needs to be inserted at the front of a line of text, or that 1 group of 10 (or whatever) pixels should be left blank at the left).

Noob2
07-12-2003, 02:14 AM
Hey thanks that explains it very well.

Noob2
07-13-2003, 04:08 AM
Ok i pretty much understand.That clarifies alot to me.

So if i commented this line out: TSTR indent = GetIndent(indentLevel); i'm not effecting any of the other code.

Where would the TSTR and pStream be defined? like the h file?

Is this it?

// Misc methods
TCHAR* GetMapID(Class_ID cid, int subNo);
Point3 GetVertexNormal(Mesh* mesh, int faceNo, RVertex* rv);
BOOL CheckForAndExportFaceMap(Mtl* mtl, Mesh* mesh, int indentLevel);
void make_face_uv(Face *f, Point3 *tv);
BOOL TMNegParity(Matrix3 &m);
TSTR GetIndent(int indentLevel);
TCHAR* FixupName(TCHAR* name);
void CommaScan(TCHAR* buf);
BOOL CheckForAnimation(INode* node, BOOL& pos, BOOL& rot, BOOL& scale);
TriObject* GetTriObjectFromNode(INode *node, TimeValue t, int &deleteIt);
BOOL IsKnownController(Control* cont);

// Configuration methods
TSTR GetCfgFilename();
BOOL ReadConfig();
void WriteConfig();


What does "BOOL" do?

I made alot of progress on the export so far,just have to remove indents and theres 2 more problems i'll save for later.

DNAunion2000
07-13-2003, 02:25 PM
Noob2: So if i commented this line out: TSTR indent = GetIndent(indentLevel); i'm not effecting any of the other code.

DNAunion: Well, I wouldn't want to wager any money on that. In other words, I sure wouldn't DELETE that line of code. As you suggest, comment it out (and document your reason for commenting it out) so that if you find out later that it is needed, you can then just uncomment it.

Noob2: Where would the TSTR and pStream be defined? like the h file?

DNAunion: TSTR probably would be because that is where application-specific data types are declared (and possibly defined as well).

But to me pStream looks like a local variable and should be declared and assigned a value in the same function as it is used. Perhaps, though, it has a larger scope (public, for example) and is declared and initialized elsewhere. For example, the "p" at the beginning of pStream could possibly indicate that it has a scope of "p"ublic.

Noob2: Is this it?

// Misc methods
TCHAR* GetMapID(Class_ID cid, int subNo);
Point3 GetVertexNormal(Mesh* mesh, int faceNo, RVertex* rv);
BOOL CheckForAndExportFaceMap(Mtl* mtl, Mesh* mesh, int indentLevel);
void make_face_uv(Face *f, Point3 *tv);
BOOL TMNegParity(Matrix3 &m);
TSTR GetIndent(int indentLevel);
TCHAR* FixupName(TCHAR* name);
void CommaScan(TCHAR* buf);
BOOL CheckForAnimation(INode* node, BOOL& pos, BOOL& rot, BOOL& scale);
TriObject* GetTriObjectFromNode(INode *node, TimeValue t, int &deleteIt);
BOOL IsKnownController(Control* cont);

// Configuration methods
TSTR GetCfgFilename();
BOOL ReadConfig();
void WriteConfig();


DNAunion: I saw the function prototype for the TSTR GetIndent(int indentLevel) function, but not any declaration of TSTR itself.

Looking again, I see that the function prototypes also have a TCHAR data type that is used (well, pointers to the type are used) both as return type and as arguments. This suggests that TSTR may mean "TSTRING". It may be that TSTR is a template class for strings...I really don't know.

Noob2: What does "BOOL" do?

DNAunion: BOOL probably is their data type for a boolean value: that is, a value that can take on only one of two mutually exclusive values, true or false. So the functions that list BOOL before their names check something and inform the caller of the result by returning true or false.