Subclassing from CRhinoMeshObject and overriding wireframe curves

I’ve subclassed CRhinoMeshObject and have it working on a basic (it displays correctly). But I want to completely override the wireframe for the object, so I can provide my own curves during display instead of the dense mesh wireframe.

How can I do this? I overrided GetWireframeCurves() but it is never called. I can land in Draw() but I have no idea what to put in there. I want it to render the same as it does now, but with my own custom wireframe curves.

Hi @gccdragoonkain,

The base class doesn’t really no much more than call CRhinoDisplayPipeline::DrawMesh.

Does this help?

– Dale

Could you be more specific? What do I pass to that function?
where do I get a CRhinoCacheHandle?

Edit: doing the below…

ON_SimpleArray<const ON_Mesh *> meshes;
auto mesh = GetMeshes(ON::render_mesh, meshes);
dgs.DrawMeshes(&meshes[0], meshes.Count(), false, true, nullptr);

… It now renders incorrectly when selected. And shaded incorrectly in all 4 viewports now. I’d really like to be able to just affect the supeclass wires argument somehow without having to override Draw()

thanks

This seems to be the best approach for now, unless I can better affect the superclass draw behavior.

void MyMeshObject::Draw(CRhinoDisplayPipeline &dgs) const
{
  if(IsSelected() || !dgs.GetRhinoVP()->DisplayModeIsShaded())
  {
    CRhinoMeshObject::Draw(dgs);
  }
  else
  {
    ON_SimpleArray<const ON_Mesh *> meshes;
    auto mesh = GetMeshes(ON::render_mesh, meshes);
    dgs.DrawMeshes(&meshes[0], meshes.Count(), false, true, nullptr);
  }
}

Your method is clearly

void Draw (CRhinoDisplayPipeline &dp) const

First, if you override it but keep it empty you’ll see that Rhino’s default wireframe is no longer drawn.

Then, you can just draw your own lines or polygons or whatever calling the DrawLines/Polygons etc. contained in CRhinoDisplayPipeline &dgs. This is how I do it.
Take a look at this sample the Draw() part. It’s a bit different here cause it’s overriding CRhinoObjectGrips but you can get the idea.