How to get parameters from a scripted object through the SDK

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 04 April 2012   #1
How to get parameters from a scripted object through the SDK

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!
 
Old 04 April 2012   #2
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.
 
Old 04 April 2012   #3
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());
 
Old 04 April 2012   #4
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:46 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.