C++ Utility plugin

C++ Utility plugin

istan
Advisor Advisor
2,971 Views
25 Replies
Message 1 of 26

C++ Utility plugin

istan
Advisor
Advisor

I have a utility plugin with ClassDesc2 and ParamBlk2 and several rollouts in the GUI. I see all paramblk properties from MXS via:  showClass "myplug.*"

But how can I get access to these utitlity parameters from MXS or C++ ?

0 Likes
Accepted solutions (2)
2,972 Views
25 Replies
Replies (25)
Message 21 of 26

klvnk
Collaborator
Collaborator

all that exists is a ParamBlockDesc2 (the instructions for creating a paramblock) associated to the lesson5aclassdesc. There is no paramblock to set.

 

you need a 

 

IParamBlock2 *pblock;

 

defined in your class tied into  system via...

 

int NumParamBlocks()					
IParamBlock2 *GetParamBlock(int i)
IParamBlock2 *GetParamBlockByID(short id)
int NumRefs();
RefTargetHandle GetReference(int i);			
void SetReference(int i, RefTargetHandle rtarg);

 

then you can create your block in the class constructor with...

pblock = NULL;
GetLesson5aDesc()->MakeAutoParamBlocks(this);

 

whether this will work in static UtilityObj is another matter, there's no example in the samples where a paramblock is used in util plugin. Also you'll need to implement some kind of save and load for the pblock as it won't be part of the usual scene object save system (so your looking at some kind of save/load scene callback).

 

 

 

 

0 Likes
Message 22 of 26

istan
Advisor
Advisor

@omidt_gh wrote:

From C++ it's like this :

 

inf pbRefNo = 1;
Node->pblock->GetInt(pbRefNo ,0);

 

For MXS it will be like this :

 

int numrefs = refObj->NumRefs();
int paramblockRefNumber = 1;
for(int i=0; i < numrefs;i++)
..

 

a) unfortunately this is not MXS (MaxScript) code..

b) where does "refObj" come from ?

0 Likes
Message 23 of 26

istan
Advisor
Advisor
Accepted solution

whether this will work in static UtilityObj is another matter, there's no example in the samples where a paramblock is used in util plugin.


I think, now you understood my request and I'm sure there's a reason why there's no example - if I had found a sample, I would not have asked for 😉

 

Save/restore is already handled by the util plugin itself.

0 Likes
Message 24 of 26

omidt_gh
Enthusiast
Enthusiast

dude, you need to study how the SDK works, in the 2 posts before I send you how to get a reference at least check that.

As i can see where you want someone to write the complete code for you.

in the basic training in parts 4 and 5, you can see how to access a node too.

reference umber basically is an integer number if you need to access the selected object it will be a pointer "&" (i write it in 3 posts before) and if you want to access all object for example you will need to put att integer from 0 to the last number of instance in the scene. if you want to access a certain type of you need to check for Class_ID.

In the end, there are many static const that you need to use as Class_ID or reference number for example Lights/mesh/materials have certain class id, and when you access any kind of object you just request the reference number from it and the paramblock will return the reference number as a value that's the nature of 3dsmax object, it is available in every object/complete scene by default.

INode* maxscene = GetCOREInterface7()->GetRootNode();

 This line will access the whole scene.

INode* currNode = maxscene->GetChildNode(objectnumber);

This line will access the certain object in the scene you already access to it.

now you have the node from the node access the pBlock.

pBlock = currNode->GetParamBlock(0);

now you have pBlock and from that point, you need to access a value.

 

value = pBlock->GetFloat(refno, GetCOREInterface()->GetTime());

 

in this line of code, you will access a float from an object "refno" is an integer you should already know, lets say for example you want to access the first float from param block you will just you "0" as the reference number.

i send you the exact steps a few posts before and all of that is in the basic tutorial of creating a model.
The tutorial is available for C++ and MXS.

0 Likes
Message 25 of 26

A012255
Enthusiast
Enthusiast

remove it..

0 Likes
Message 26 of 26

istan
Advisor
Advisor
Accepted solution

aparently not solveable..

0 Likes