SceneHook... how to?

On 09/06/2014 at 13:13, xxxxxxxx wrote:


OK, I see what's wrong with the code you posted.

You have this function:

virtual Bool InitDisplayControl(BaseDocument *doc, BaseContainer &data, BaseDraw *bd, const AtomArray *active);

... when it should be this:

virtual Bool InitDisplayControl(BaseSceneHook* node, BaseDocument* doc, BaseDraw* bd, const AtomArray* active);

That's why your InitDisplayControl() function wasn't being called. The parameters were not correct, so in essence you were defining your own new virtual function that was never called. :dizzy_face:

Cactus Dan

On 09/06/2014 at 13:16, xxxxxxxx wrote:

I'm glad you got it to do what you want. Because I can't control the stupid thing at all. :angry:

I know you say that the Draw() method won't work for you. But I find that to be strange.
I've never used these strange SH methods is because I've found that I can usually do all of my drawing stuff just fine in the tag's Draw() method.

Here's an example of drawing the object the tag is on in the scene. Only with a with a blue color. And with little red cubes Drawn on it's verts.
All of this is done in the Draw() method.

I still can't imagine why what you're doing won't work there too.*shrug*


On 09/06/2014 at 13:25, xxxxxxxx wrote:

I figured that I was declaring the InitDisplayControl wrong, also, Dan :-)

Scott, I'm using the Draw method of the Tag to draw the faces.
But what I needed was to draw the object with custom colors for all faces and what I can only do in the Draw method is to draw faces with custom colors, one by one.
That is quite slow, for objects with a lot of faces.

Is there a way, inside the Draw method, that allows me to turn off the painting on the original object and manually paint all the faces with custom colors for each vertex?

On 09/06/2014 at 13:51, xxxxxxxx wrote:

I'm not really sure about the vertex colors thing.
When I create my text HUD images. I do get each corner of the plane object that the image will stick onto and color them. But that's only four verts. Not a lot of them.

When I started out using Draw(). One of the things I did wrong was to instantiate things in there instead of in the Init() method. And that tended to make the Draw() run slow.


//You should allocate draw objects at the Init() of the plugin and free at Free() of the plugin  
class MyObject : public ObjectData  
          virtual Bool Init(GeListNode *node);  
          virtual  void             Free(GeListNode* node);  
          virtual  Bool             Message(GeListNode *node, LONG type, void *data);  
          virtual  DRAWRESULT       Draw (BaseObject *op, DRAWPASS type, BaseDraw *bd, BaseDrawHelp *bh);  
          virtual  Bool             AddToExecution(BaseObject *op, PriorityList *list);  //Lets you define your own execution pointer  
          virtual  EXECUTIONRESULT  Execute(BaseObject *op, BaseDocument *doc, BaseThread *bt, LONG priority, EXECUTIONFLAGS flags);   
          static NodeData *Alloc(void) { return gNew MyObject; }  
          PolygonObject* sphere;  
Bool MyObject::Init(GeListNode *node)  
  //Create a polygon sphere by creating a primitive sphere first..then casting it to a polygon object type   
  sphere = (PolygonObject* )GeneratePrimitive(node->GetDocument(), Osphere, BaseContainer(), 1.0, FALSE, NULL);  
  BaseObject    *op   = (BaseObject* )node;  
  BaseContainer *bc = op->GetDataInstance();      
  return TRUE;  
void MyObject::Free(GeListNode* node)  

I've never tried to color each polygon face a different color. Let alone a lot of them.
Normally I am either coloring the whole object a different color...Or coloring (highlighting) the selected polygons. So I don't know if that presents a problem in the Draw() method or not.
But it just seems wrong to me to have to use a SH just to draw polygons like that. But I'm not an expert on this stuff and I could be (and I often am :slightly_smiling_face:) wrong.


On 09/06/2014 at 14:05, xxxxxxxx wrote:

Until now I didn't had many problems with the Draw method (of Tags and Objects). But I'm not a true coder. I'm just a geek designer ;-)

For what I'm doing, I really need to color "manually" the faces since there are no UVs attached to the type of objects that I'm dealing with.
Providing Cinema4D with an array of Vector containing all the RGB values of all points and having it deal with them is too good to be true :-)
It is a shame that it only works with selected objects.
Manually, I have to go through the list of polygons. Get the a,b,c and d indexes. Use those indexes to get the RGB values of my list and the points coordinates to create two arrays that can be fed to the DrawPoly.
It is a whole lot more work to do than simply providing a list of RGBs ;-)
That is why the SceneHook thingy is so useful to me.

On 09/06/2014 at 15:07, xxxxxxxx wrote:

Nothing to see here...Just Scott being a moron.


On 09/06/2014 at 15:09, xxxxxxxx wrote:


Originally posted by xxxxxxxx

Is there a way, inside the Draw method, that allows me to turn off the painting on the original object and manually paint all the faces with custom colors for each vertex?

Well, I don't think there is, and that may be the reason for using a SceneHook's ControlDisplay functions to do the drawing for something like that, so that the polygons aren't drawn twice.

Cactus Dan

On 09/06/2014 at 15:53, xxxxxxxx wrote:

Scott, I tried your code and nothing is painted in color.
Aren't we supposed to only use ControlDisplayStruct cds inside a SceneHook?

On 09/06/2014 at 16:01, xxxxxxxx wrote:

Sorry about that Rui. I goofed up.

When I tested it I forgot to remove the SH plugin from my plugins folder. That's why it seemed to work in my tag plugin. :blush:

Would have been nice if it worked that easy.


On 09/06/2014 at 16:02, xxxxxxxx wrote:

Yes indeed. It would be excellent :-D

On 09/06/2014 at 16:04, xxxxxxxx wrote:


Originally posted by xxxxxxxx

...When I tested it I forgot to remove the SH plugin from my plugins folder. That's why it seemed to work in my tag plugin. :blush:...

Hehe, I wish I had a dollar for every time I did something like that.  :joy:

Cactus Dan