Problem populating an XSI_CustomPSet template...

Discussions concerning programming of SOFTIMAGE©
Post Reply
User avatar
Archangel35757
Posts: 15
Joined: 12 Apr 2013, 16:18
Skype: Archangel35757

Problem populating an XSI_CustomPSet template...

Post by Archangel35757 » 27 Jan 2014, 20:48

Are there any programmers here that would be willing to help me solve my problem?

Working with the XSIFTK v3.6.3 and dotXSI 3.0 format, I'm trying to include an XSI_CustomPSet template under the SI_Model template... and populate it with specific game information so the game compiler can take this info and create a game shader file for the character mesh.
Here's an example of what the data should look like in the XSI_CustomPSet template (from reading legacy dotXSI files):

Code: Select all

//*********************************************************
SI_Model MDL-hips {
    .
    .    
    .
    XSI_CustomPSet hips.Game {
    "NODE",
    1,
    "Shader","Text","models/players/kyle/kyle_legs.tga",
    }
    .
    .   
    .
}
//*********************************************************
And here is what I'm getting with my compiled plugin:

Code: Select all

//*********************************************************
SI_Model MDL-hips {
    .
    .   
    .
    XSI_CustomPSet hips.Game {
    "NODE",
    0,
    }
    .
    .   
    .
}
//********************************************************* 
As you can see... it is failing to write out the proper data after the "NODE" propagation parameter.

Here is my actual C++ class method:

Code: Select all

//---------------------------------------------------------------------------
CdotXSITemplates* CdotXSIMapper::ExportGameData ( MAX2XSI_PARAMS )
{
     ADD_XSI_TEMPLATE ( l_pCustomPSet, "XSI_CustomPSet" );

     CSIBCString l_CustomPSetName = ( GetNodeName ( in_pNode ) );
     l_CustomPSetName.Concat( _T(".Game") );
     l_pCustomPSet->SetInstanceName( l_CustomPSetName );

     SetTemplateParam ( l_pCustomPSet, XSI_CUSTOM_PSET_PROPAGATION, "NODE" );
     SetTemplateParam ( l_pCustomPSet, XSI_CUSTOM_PSET_NUM_PARAMS, 1 );
     SetTemplateParam ( l_pCustomPSet, "field_count", 1 );
     SetTemplateParam ( l_pCustomPSet, "field_name", _T("Shader") );
     SetTemplateParam ( l_pCustomPSet, "field_type", "Text" );

     Mtl* l_material = in_pNode->GetMtl();

     TSTR l_matEdSlot = _T('"') + l_material->GetName() + _T('"');

     CSIBCString l_MatName;

     l_MatName.SetText( l_matEdSlot.data() );

     SetTemplateParam ( l_pCustomPSet, "field_value", _T( l_MatName.GetText() ) );

     return NULL;
}
//---------------------------------------------------------------------------
From the snippet, MAX2XSI_PARAMS is defined as:
#define MAX2XSI_PARAMS INode *in_pNode, CdotXSITemplates *in_pTemplateGroup

l_material->GetName() is a 3ds Max function that returns a TSTR (typedef for CStr).

So I'm not sure why the SetTemplateParam statements are failing to populate correctly... please, can anyone tell me what am I doing wrong???

User avatar
Archangel35757
Posts: 15
Joined: 12 Apr 2013, 16:18
Skype: Archangel35757

Re: Problem populating an XSI_CustomPSet template...

Post by Archangel35757 » 28 Jan 2014, 23:19

Has ANYONE in this Softimage Programming forum ever used the dotXSI File Transfer Kit (XSIFTK)???

User avatar
xsisupport
Posts: 713
Joined: 09 Jun 2009, 11:02
Location: Montreal Canada
Contact:

Re: Problem populating an XSI_CustomPSet template...

Post by xsisupport » 29 Jan 2014, 16:06

Archangel35757 wrote:Has ANYONE in this Softimage Programming forum ever used the dotXSI File Transfer Kit (XSIFTK)???
Sorry, I don't remember anything about it, and there's no other code of that vintage to look at.

Are the custom parameters in a CustomPSet actually template params, like that NODE parameter?
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

User avatar
Archangel35757
Posts: 15
Joined: 12 Apr 2013, 16:18
Skype: Archangel35757

Re: Problem populating an XSI_CustomPSet template...

Post by Archangel35757 » 29 Jan 2014, 17:12

xsisupport wrote:
Archangel35757 wrote:Has ANYONE in this Softimage Programming forum ever used the dotXSI File Transfer Kit (XSIFTK)???
Sorry, I don't remember anything about it, and there's no other code of that vintage to look at.

Are the custom parameters in a CustomPSet actually template params, like that NODE parameter?
Steve, it's so good to hear from you! Here is a link from the dotXSI Wiki that describes the XSI_CustomPSet template (it seems to be an improvement on the custom user data template):
http://softimage.wiki.softimage.com/xwa ... omPSet.htm

The source code is actually availabe here (download the v1.7 code):
http://sourceforge.net/projects/dotxsi4 ... I4max/1.7/

The pertinent files that have the helper functions (SetTemplateParam and AddTemplateParam) that populate the templates are defined in files: MaxHelpers.h and MaxHelpers.cpp

The XSI_CustomPSet template was added in v3.0. Do you still have the XSIFTK Programmer's Guide .chm help file?

To answer your question it does seem to me, given the template description that it does have parameters. The only difference I can see from the .CHM Guide and the online link template description is that the .CHM fiile calls the member names differently:
Template

XSI_CustomPSet <custom pset name>
{
<propagation flag>
<number of fields>,
<field_name>, <field_type>, <field_value>,
...
// field information (0 or more)
}

Members

Member name: propagation
Description:
Specifies whether the property is either just for the object it is on only or for the object it is on plus all its children--this status is displayed in XSI’s Explorer. If a custom parameter is on a group, it will be exported as BRANCH, since dotXSI does not export groups). Possible values are:

• BRANCH = material is shared throughout the branch (ie., object and all its nodes)
• NODE = material is applied only to the object’s node
• INHERITED = material has been inherited from a parent object

Member Name: field_count
Description: Number of fields.

Member Name: field_name
Description: Field name.

Member Name: field_type
Description: Field type. Possible values are:

• Text
• Boolean
• Integer
• Small integer number
• Floating point number

Note: For more information on how dotXSI handles variant data type conversion, see How Does dotXSI Deal with Variant Types? on page 70.

Member Name: field_value
Description: Value for the parameter. Possible values differ according to the field_type used.
There are two #defines for the XSI_CustomPSet template in the header file: dotxsidefines.h

Code: Select all

#define XSI_CUSTOM_PSET_PROPAGATION		0
#define XSI_CUSTOM_PSET_NUM_PARAMS		 1
But I can't get the number of params to populate to 1. And the remaining template params don't seem to have #defines for them.

I will buy you a case of your favorite beer for your help!

User avatar
xsisupport
Posts: 713
Joined: 09 Jun 2009, 11:02
Location: Montreal Canada
Contact:

Re: Problem populating an XSI_CustomPSet template...

Post by xsisupport » 29 Jan 2014, 21:31

I think you need to use AddTemplateParam, no?

field_count and field_name and field_value would be the actual names and values of the custom parameters in the custom Pset.
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

User avatar
Archangel35757
Posts: 15
Joined: 12 Apr 2013, 16:18
Skype: Archangel35757

Re: Problem populating an XSI_CustomPSet template...

Post by Archangel35757 » 30 Jan 2014, 06:37

xsisupport wrote:I think you need to use AddTemplateParam, no?

field_count and field_name and field_value would be the actual names and values of the custom parameters in the custom Pset.
Yes, I finally got it sorted out. I was not interpreting the XSI_CustomPSet template correctly. Originally, I thought it was just a single array of named parameters... but I finally figured it out, based on your statement, that the last three template entries were actually properties of the actual CdotXSIParam (Name, Type, Value) and not array parameters to the template.

Here is the final code that I got to work:

Code: Select all

CdotXSITemplates* CdotXSIMapper::ExportGameData ( MAX2XSI_PARAMS )
{
    ADD_XSI_TEMPLATE ( l_pCustomPSet, "XSI_CustomPSet" );

    CSIBCString l_CustomPSetName = ( GetNodeName ( in_pNode ) );
    l_CustomPSetName.Concat( _T(".Game") );
    l_pCustomPSet->SetInstanceName( l_CustomPSetName );

    SetTemplateParam ( l_pCustomPSet, XSI_CUSTOM_PSET_PROPAGATION, "NODE" );

    SetTemplateParam ( l_pCustomPSet, XSI_CUSTOM_PSET_NUM_PARAMS, 1 );

    Mtl* l_material = in_pNode->GetMtl();
    TSTR l_matEdSlot = l_material->GetName();
    CSIBCString l_MatName;
    l_MatName.SetText( l_matEdSlot.data() );

    AddTemplateParam ( l_pCustomPSet, l_MatName.GetText() );

    (l_pCustomPSet->Params().Item(1))->Name().SetText( _T("Shader") );

    return NULL;
}
Which yielded the desired result:

Code: Select all

//*********************************************************
SI_Model MDL-hips {
    .
    .   
    .
    XSI_CustomPSet hips.Game {
    "NODE",
    1,
    "Shader","Text","models/players/kyle/kyle_legs.tga",
    }
    .
    .   
    .
}
//*********************************************************
So where should I mail your beer certificate? :D

User avatar
xsisupport
Posts: 713
Joined: 09 Jun 2009, 11:02
Location: Montreal Canada
Contact:

Re: Problem populating an XSI_CustomPSet template...

Post by xsisupport » 30 Jan 2014, 13:30

Archangel35757 wrote: So where should I mail your beer certificate? :D
If you live some place interesting, I'll put it on my "places to travel to for a beer" list. I've already got something lined up in Copenhagen :)
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

User avatar
Archangel35757
Posts: 15
Joined: 12 Apr 2013, 16:18
Skype: Archangel35757

Re: Problem populating an XSI_CustomPSet template...

Post by Archangel35757 » 30 Jan 2014, 16:48

xsisupport wrote:
Archangel35757 wrote: So where should I mail your beer certificate? :D
If you live some place interesting, I'll put it on my "places to travel to for a beer" list. I've already got something lined up in Copenhagen :)
No place that would justify the travel cost-- unless you're a space junky and want to see the US Space & Rocket Center. :)

Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests