PDA

View Full Version : Access base class parameters of script extended class from c++ ?


kittikun
06-18-2009, 09:25 AM
Hi all,

I’ve been trying to access the paramblock of a child class deriving from a simple object like sphere. Something like this

plugin geometry testSphere
name:"test sphere”
category:"test"
classID:#(0x13456, 0x12468)
extends:sphere
replaceui:true
(
)

and from c++

Interface* ip = GetCOREInterface()

Object *obj = (Object*) ip->CreateInstance(GEOMOBJECT_CLASS_ID, Class_ID(0x13456, 0x12468))

char* toto = obj->GetObjectName() // name is correct

// Get a hold of the parameter block
IParamArray * params = obj->GetParamBlock()
assert(params)

The param block will be null.

I’m trying to access SPHERE_RADIUS and others parameters from c++ to create objects like I want

Thanks !

guruware
06-18-2009, 08:51 PM
try:
IParamBlock2* pBlock2 = obj->GetParamBlock(i);
"i" you have to figure out, think its 0 in your case

then:
int pid_radius = obj->GetParamBlockIndex(SPHERE_RADIUS);
float sphereRadius = 0.0f;
pBlock2->GetValue(pid_radius, 0, &sphereRadius);

or something like that... :)


guruware

kittikun
06-19-2009, 07:23 AM
IParamBlock2* GetParamBlock(int i)

Is defined from Animatable, so I can't access it from Object

I tried to cast into a Animatable* but I suppose life isn't that easy :rolleyes:

kittikun
06-19-2009, 08:59 AM
Solved it !

if you do

plugin geometry testSphere
name:"test sphere”
category:"test"
classID:#(0x13456, 0x12468)
extends:sphere
replaceui:true
(
parameters basic
(
radius type:#float default: 0.0
segs type:#float default: 0.0

on radius set val do
(
delegate.radius = val
)

on segs set val do
(
delegate.segs = val
)
)
)

You'll have a paramblock that you can access from Object

CGTalk Moderation
06-19-2009, 08:59 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.