I am working on creating a C++ plugin that allows a user to manipulate surfaces indirectly using a control mesh. The idea is that the user will move mesh vertices around, and as the vertices move, the underlying surfaces should update. Below are a few images demonstrating this:
Here is the start:
This is what it looks like when the user selects a point:
This is how it looks after the user drags the point (imagine the surfaces moving with the point):
The reason for this post is that I want to figure out how to apply zebra stripes to the surfaces while I move the point around. I understand Rhino has a Zebra command, but I don’t know how I would be able to use it in my case.
Here is how I am drawing the surfaces:
void CRhinoGetTranslationPoint::DynamicDraw(CRhinoDisplayPipeline& dp, const ON_3dPoint& point)
{
if (draw)
{
const CDisplayPipelineAttributes* attrs = dp.DisplayAttrs();
CDisplayPipelineMaterial dpm = *attrs->m_pMaterial;
dp.SetupDisplayMaterial(dpm, &m_doc, nullptr);
for (size_t i = 0; i < patches.size(); i++)
{
ON_Brep* b = patches.at(i).BrepForm();
dp.DrawShadedBrep(b, &dpm, nullptr);
delete b;
}
}
CRhinoGetXform::DynamicDraw(dp, point);
}
This sounds somewhat like Rhino’s CageEdit feature. Are you familiar with this?
Rhino’s Zebra display is an analysis mode. That is, you can put an object into Zebra display mode and then edit the object with the striping updating in real time.
If you want to set Rhino objects to use Zebra display, then here is a sample you can use:
Drawing your own zebra stripes is pretty involved. Zebra is implemented as a material with a texture. The texture (dib) is calculate at run-time based on some document properties (CRhinoZebraAnalysisSettings) and then draws the analysis mesh of the Brep.
I appreciate the quick response @dale . I tried out the idea from the sample code you gave me and it sets up the zebra stripes like I want. However, the issue I am having is that the zebra stripes are not showing while I am moving a mesh vertex:
When I am drawing the surfaces during the move operation, I am not using the CRhinoObjects in the document. Instead I calculate the new surfaces, put the data into ON_NurbsSurfaces, make ON_Breps from those and then draw the ON_Breps. Should I be using the CRhinoObjects instead?
@dale I haven’t messed around with CageEdit other than trying out the built-in command. The behavior is similar to what I want to achieve, except that I want to initialize the surfaces with an input mesh and not the other way around (I have code that already accomplishes the surface generation part). I also want to be able to see the zebra stripes move as I move a mesh vertex. Would CageEdit offer that capability?
I’ve added a new CRhinoDisplayPipeline::DrawZebraPreview that can be called from a display conduit. This new method will appear with Rhino 6 Service Release 16 (still a few weeks away). When this filters though to a public SDK, I’ll add a sample command to the developer samples repo.
import Rhino
import System
import rhinoscriptsyntax as rs
ids = rs.GetObjects("Select objects for zebra display", 8+16+32)
breps = [rs.coercebrep(id) for id in ids]
Rhino.Display.DisplayPipeline.DrawZebraPreview(breps, System.Drawing.Color.FromArgb(255,255,255))
Thank you for your help. I want to preview the zebra print display and analysis of objects in Python, but I will not interrupt my command of creating surfaces.
However it would be great, if a similar function could also be offered for a mesh! This would be more general, since I could create mesh(es) also from a Brep or even a single surface/face.
I just downloaded the Rhino 7 SDK and was looking for something like this.
I’m currently working on a smooth mesh command, which could show update of the Zebra stripes during the smoothing.