typecasting to profile_CG

hi

i have a small custom effect profile to describe a renderman shader. the profile looks almost exactely like profile_CG with a few more attributes. i implemented the profile on the effect level in an extra element like that:


<library effects>
  <effect id="someEffect">
     <profile_COMMON/>
     <extra>
        <technique profile="CE_RMAN">
                   ...
        </technique>
     </extra
   </effect>
</library_effects>  

what i want to do in my code is casting an existing CE_RMAN technique to a profile_CG, so i don’t have to write all the accessing functions myself.
Since I know exactely which elements are additional to profile_CG i can set/get them by using the technique as daeElement and use the standard getChildren() and so on. But as i said above i don’t want to do that for everything but only for the elements that are not included by profile_CG.
so my first try looked something like this:


domTechnique *renderman = effectsNode[n]->getExtra_array()[o]->getTechnique_array()[p];
domEffects_CE_RMAN *custom = new domEffects_CE_RMAN;
			custom = reinterpret_cast<domEffects_CE_RMAN *>(renderman);

where domEffects_CE_RMAN is a class that inherits from profile_CG. so what i want here is: fill all the fields of domEffects_CE_RMAN that correspond to profile_CG fields (inherited members) with the fields read from the technique. all the additional fields i will fill in and handle manually afterwards.
so, what i did above didn’t work. all the profile_CG members are BadPtr. is there a way to do this?

thanks

That is a really cool idea. I wish it worked right off the bat for you, that would have been awesome.

There is probably a way for you to get this to work automatically for you. This is the first attempt of someone to use a much larger system I wish I could implement but it’s not worth the time since like I said… you are the first to want functionality like it. but I digress.

What you will need to do is overwrite the registerElement function for your new class. Make sure the name is changed to the correct element name. Also, here you would need to add the new elements that you use so the DOM will load and parse them for you. If you don’t you will probably lose all that data. (if you need some help here I can help you some more just reply with a more specific example of the new data added).

When your class has it’s registerElement function call it in your program before you load. Its static so myClass::registerElement(); is all you need. Now when the DOM loads the <extra><technique> and finds your element it will create a myClass object and parse the subtree accordingly.

I hope this works for you.
-Andy