PDA

View Full Version : Need help with 3dsMax SDK, 3DXI, paramblocks


justinwalsh
10-28-2006, 04:00 AM
I am after a chunk of data that comes from a path constraint, called the % along path. This is an animatable value, and it looks like it is stored in the paramblocks2 for animatable values, according to header file comments.

My problem is i have no idea how to get to this data. Is it a part of the constraint, the controller, the node's paramblock, or something else. And if it is in the nodes paramblock, how would i go about accessing this data.

I mostly use the IGame(3DXI) interface for exporting the data, however i have had to jump into the maxNodes to get to certain pieces of data.

I can access this property in maxscript i just do not know how it all translates back into IGame(3DXI), or the Max SDK.
This will get you the information from maxscript:
showProperties $.pos.controller.PathConstraint.percent

And it appears that pos.controller is a controller, and .PathConstraint is a SubAnim.

Thanks.

ypuech
10-28-2006, 02:04 PM
Hi Justin,

You can easily access these informations with 3DXI :

IGameControl* Control = Node->GetIGameControl();
IGameConstraint* Constraint = Control->GetConstraint(IGAME_POS); // Parameter can be IGAME_POS / IGAME_ROTI / IGAME_TM

I'm also a 3ds max SDK programmer, but it seems that there aren't so much SDK programmers in this forum. Here is two 3ds max SDK forums :

http://dl3d.free.fr/phpBB2/viewforum.php?f=3

http://sparks.discreet.com/webboard/wbpx.dll/~maxsdk (It seems that this forum will disappear in the near future...)

justinwalsh
10-28-2006, 03:36 PM
That is what i suspected, however whenever I try and get the constraint pointer it is just a NULL pointer.

Is there something i must do first to prepare the control or constraint information?

Thanks

ypuech
10-28-2006, 04:59 PM
Look at "path_cnstrnt.cpp" in "samples\controllers" : this file contains path controller source code.

I think you can only access percent value of the path constraint using his parameter block ; percent property is at index 0 (path_percent is defined in the SDK).

justinwalsh
10-28-2006, 05:30 PM
This is what i have been struggling to do, I do not understand how to get access to the paramblock of the contraint. I have been playing around with the paramblocks, but is there one unified paramblock for each node, or does each contraint, animation, etc attached to a node have it's own paramblock entry.

Thanks for your help, i will continue to dig into the paramblocks.

HalfVector
10-28-2006, 08:53 PM
EDITED: sorry, I'll post my answer later.

ypuech
10-28-2006, 09:47 PM
This is what i have been struggling to do, I do not understand how to get access to the paramblock of the contraint. I have been playing around with the paramblocks, but is there one unified paramblock for each node, or does each contraint, animation, etc attached to a node have it's own paramblock entry.

I faced the same problems and asked myself this question :).

I've not enough knowledge on this subject, so I think the best solution for you is to post a topic about this problem in the first forum I've mentionned.

HalfVector
10-29-2006, 03:10 AM
Hi.

I don't know about the IGame interface but I faced this very problem a while ago. I had to access to the properties of a material created with MAXScript. Obviously I hadn't got the definition file for this material.

So I created a ParamBlock manager through which I could access to any parameter of any Animatable object. Here I show you a little snip of my implementation.

This is the header:

/**********************************************
/* File: ParamBlockMngr.h
/* Author: Jonathan Garcia a.k.a HalfVector
/* Date: April 2006
/**********************************************/

#ifndef __HParamBlockMngr__H
#define __HParamBlockMngr__H

#include <Max.h>
#include <StdMat.h>
#include <iparamb2.h>

class ParamBlockMngr
{
public:

static float GetFloat(Animatable *anim, TCHAR *name, TimeValue t = 0, int tabIndex = 0);

private:

ParamBlockMngr() {}

static BOOL GetParamID(Animatable *anim, TCHAR *name, int &blockIndex, int &id);
};

#endif

This is the source:

/**********************************************
/* File: ParamBlockMngr.cpp
/* Author: Jonathan Garcia a.k.a HalfVector
/* Date: April 2006
/**********************************************/

float ParamBlockMngr::GetFloat(Animatable *anim, TCHAR *name, TimeValue t, int tabIndex)
{
assert(anim && name);

float value = 0.0f;

int blockIndex, id;
if(GetParamID(anim, name, blockIndex, id))
{
IParamBlock2 *pb = anim->GetParamBlock(blockIndex);

value = pb->GetFloat(id, t, tabIndex);
}

return value;
}

BOOL ParamBlockMngr::GetParamID(Animatable *anim, TCHAR *name, int &blockIndex, int &id)
{
assert(anim && name);

int nParamBlocks = anim->NumParamBlocks();
for(blockIndex = 0; blockIndex < nParamBlocks; blockIndex++)
{
IParamBlock2 *pb = anim->GetParamBlock(blockIndex);

if(!pb) continue;

int nParams = pb->NumParams();
for(int i = 0; i < nParams; i++)
{
id = pb->IndextoID(i);

ParamDef def = pb->GetParamDef(id);

if(!_tcsicmp(name, def.int_name))
return TRUE;
}
}

return FALSE;
}

And the way to retrieve the percentage parameter from a path constraint:

float percent = ParamBlockMngr::GetFloat(node->GetTMController()->GetPositionController(), _T("percent"));

Hope that helps.

justinwalsh
10-30-2006, 03:14 PM
Thank you very much HalfVector, I would have most likely struggled with this for another week. Now I can move on to much more fun things.

And, thank you for your support and advice as well ypuech, I know have a collection of forums to revieve help on MaxSDK related problems.

Best Regards

justinwalsh
10-31-2006, 02:26 AM
When stepping through this code, the only two values that it finds associated with the controller is the "weight" and "average" value. So my guess is the paramblock is not stored here. Any idea's where it might be stored? Also i am using 3dsmax 8.0, do you know if maybe they relocated something since thiscode was written?

HalfVector
10-31-2006, 02:30 AM
When stepping through this code, the only two values that it finds associated with the controller is the "weight" and "average" value. So my guess is the paramblock is not stored here. Any idea's where it might be stored? Also i am using 3dsmax 8.0, do you know if maybe they relocated something since thiscode was written?
I don't know, I tried this code in MAX8 and I was able to retrieve the percentage property. I'll try again later.

HalfVector
10-31-2006, 03:05 AM
Ok, I've just tried again and it works right. Keep in mind that in the line:

float percent = ParamBlockMngr::GetFloat(node->GetTMController()->GetPositionController(), _T("percent"));

the variable "node" is the object with the path constraint assigned. For example, if I create a sphere and assign to it a path constraint, the node should be the sphere...

Greets.

justinwalsh
10-31-2006, 07:46 AM
That is what i am doing, and for some reason that code is not working for me. I have no Idea why it would work for you and not me, unless we have different versions of the max SDK itself. However I did find a solution...


Animatable *anim = iNode->GetMaxNode()->GetTMController()->SubAnim(0)->SubAnim(1);



I am using IGame so i must get the max node from the IGameNode. However this works like a charm, when passed into the sample code you have above.

Thanks you greatly for all your help.

CGTalk Moderation
10-31-2006, 07:46 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.