On 15/09/2015 at 02:29, xxxxxxxx wrote:
Hi Sebastian,
thanks. I am in a Scene Hook::Execute() and I simply get the cloner (in that case nested cloners parent), the according motag and then use the message system to retrieve the modata accordingly. Something like this:
static inline bool get_cloner_modata(BaseObject* maincloner, GetMoDataMessage& msg_data, int moindex = 0)
{
/* Find the MoData tag. */
BaseTag* tag = maincloner->GetTag(ID_MOTAGDATA); if (!tag) return false;
//if the passed moindex is not 0 I would loop through available motags via tag->GetNext() but there is only 1 motag on the parent cloner
/* Retrieve the MoData. */
if (!tag->Message(MSG_GET_MODATA, &msg_data)) { return false; }
if (!msg_data.modata) {
GePrint("MSG_GET_MODATA did not return a MoData pointer.");
return false;
}
return true;
}
Once I have the modata I browse the cloner's children accordingly with GetDown()/GetNext() (This works all fine. I get the matrix, offset etc. arrays from the modata accordingly. modata->GetCount() returns correctly the amount of clones that cloner produces).
If one of the children is a cloner, I recurse with the same code.
Pseudocode:
void get_mo_clones(BaseObject* root_cloner, BaseObject* cloner)
{
GetMoDataMessage msg;
if(!get_cloner_modata(cloner,msg)) return; //returns here for child cloners because no motag is found
clone_source_i = cloner->GetDown()
browse_cloner_children(cs){
//I cache them here for later use
cs = cs->GetNext();
}
MoData* md = msg.modata;
for_each_clone(child, md->GetCount()){
if(childtype == MOGRAPH_CLONER_ID)
get_mo_clones(root_cloner, child)
else{
//Do stuff...e.g. md->GetMatrixArray(MODATA_MATRIX)[i] etc.
}
but on that cloner child cloner of course and that's what is not working as I explained in the above posts. There is no motag on that child cloner. Also there is only one modata available in the parent cloner and only a single motag (so no multiple data for child clones).
All caches etc should be built when my SceneHook is evaluated, so the data should be there I guess. The question is where to get the motag/modata for possible nested child cloners. Any idea?