2D drawing in Point, Edge and Polygon mode

On 24/08/2017 at 01:36, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R18 
Platform:   Windows  ; Mac  ;  Mac OSX  ; 
Language(s) :     C++  ;

---------
Hello,
I have a problem with 2D drawing functions of BaseDraw object in Point, Edge and Polygon mode. They just don't draw anything. 3D functions however works fine. When I switch mode to Model or Texture they draw as usual.

Is that an intended behavior? Can it be changed somehow?

Thank you.

On 25/08/2017 at 07:51, xxxxxxxx wrote:

Hi Miro, thanks for writing us.

Could you please specify in which context the 2D Drawing functionalities don't work? Is in ObjectData-, SceneHookData-, ToolData- or CommandData- derived plugin type?
From a simple test run with a SceneHookData- as well on ObjectData-derived plugins they happear to work flawlessly.

Best, Riccardo

On 25/08/2017 at 23:38, xxxxxxxx wrote:

I'm drawing from ToolData based plugin.

I've done a bit of research here. To avoid errors caused by rest of my code I played with Cinema R18 SDK sample PickObjectTool plugin because it is closest to what I am doing.

I inserted following code at the beginning of PickObjectTool::Draw() function:

  
  if (flags == TOOLDRAWFLAGS_0)            // <-- this is how I'm drawing (and makes the strange bug)  
  //if (flags & TOOLDRAWFLAGS_HIGHLIGHT)    // <-- this looks like the solution  
  {  
      // 3D draw, red line  
      bd->SetMatrix_Matrix(nullptr,Matrix());  
      bd->SetPen(Vector(1, 0, 0));  
      bd->DrawLine(Vector(0, 0, 0), Vector(200, 200, 200), NOCLIP_Z);  
  
      // 2D draw, green line  
      bd->SetMatrix_Screen();  
      bd->SetPen(Vector(0, 1, 0));  
      bd->DrawLine2D(Vector(0, 0, -MAX_Z), Vector(200, 200, -MAX_Z));  
  }  

I found out that it behaves a bit differently than I reported:

If I draw when flags == TOOLDRAWFLAGS_0 it draws 2D green line only if there is at least one object in scene with highlighted orange border (so if I change mode or deselect object or select object without this orange border - for example Null object, green line disappears).

If I draw when flags contain TOOLDRAWFLAGS_HIGHLIGHT everything works fine, so this is my solution. Due to a bit simple description of TOOLDRAWFLAGS in documentation I didn't even consider this option.