PDA

View Full Version : How to get parameters from a scripted object through the SDK


daedalean
04-09-2012, 03:35 AM
I'm writing a scene exporter and I need to get parameter information from objects created by simple plugin scripts. I've got a INode* and an Object* for each of these objects, but I can't figure out how to extract the parameter information from them.

If I call object->NumParamBlocks(), I get a value of 1. However, if I call object->GetParamBlock(), I end up getting a null pointer. There's also a Object::GetParamBlockByID method I could try but I have no idea what the ID value is or how to define them in the script.

Here is the script I made for one of the custom objects. The other objects are very similar.

plugin simpleObject nbox_plugin_def
name:"NBox"
classID:#(0x5f70880,0x7a5612b3)
category:"NPhysics"
(
local box1
parameters main rollout:params
(
length type:#worldUnits ui:length default:1E-3
width type:#worldUnits ui:width default:1E-3
height type:#worldUnits ui:height default:1E-3
mass type:#float ui:mass default:1
)
rollout params "NBox Parameters"
(
spinner height "Height" type:#worldUnits range:[1E-3,1E9,1E-3]
spinner width "Width" type:#worldUnits range:[1E-3,1E9,1E-3]
spinner length "Length" type:#worldUnits range:[-1E9,1E9,1E-3]
spinner mass "Mass" type:#float
)
on buildMesh do
(
if box1 == undefined do
(box1 = createInstance box)
box1.height = height
box1.width = width
box1.length = length
mesh = box1.mesh
)
tool create
(
on mousePoint click do
case click of
(
1: nodeTM.translation = gridPoint
3: #stop
)
on mouseMove click do
case click of
(
2: (width = abs gridDist.x; length = abs gridDist.y)
3: height = gridDist.z
)
)
)
For this "NBox," I need to access the values of all four parameters.

Any help would be much appreciated. Thanks!

Klunk
04-09-2012, 09:06 PM
not much help, but a bit of reassurance that the parameters are there and are accessible from the sdk.... I use the Igame wrapper for my exporter and ran this code on one of your scripted objects and the correct values for each parameter at time 0 were returned

#if 1

IGameProperty* prop;
IGameObject* obj = child->GetIGameObject();
IPropertyContainer* ipcont = ((IGameSupportObject*)obj)->GetIPropertyContainer();

float fval;
prop = ipcont->QueryProperty("length");
if(prop)
prop->GetPropertyValue(fval, 0);
prop = ipcont->QueryProperty("width");
if(prop)
prop->GetPropertyValue(fval, 0);
prop = ipcont->QueryProperty("height");
if(prop)
prop->GetPropertyValue(fval, 0);
prop = ipcont->QueryProperty("mass");
if(prop)
prop->GetPropertyValue(fval, 0);

#endif

child is an IGameNode object.

Klunk
04-10-2012, 09:25 AM
this worked (from the SDK help) on one of your scripted objects

IParamBlock2* GetParamBlock(ReferenceMaker* obj)
{
int nRefs = obj->NumRefs();
for(int i = 0; i < nRefs; ++i)
{
ReferenceTarget* ref = obj->GetReference(i);
if(ref && ref->SuperClassID() == PARAMETER_BLOCK2_CLASS_ID)
{
return dynamic_cast<IParamBlock2*>( ref );
}
}
return NULL;
}


called using this...


IParamBlock2* pblk = GetParamBlock((ReferenceMaker* )maxINode->GetObjectRef());

CGTalk Moderation
04-10-2012, 09:25 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.