Show Zebra Stripes During Dynamic Draw? (C++)

Hello,

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:
image

This is what it looks like when the user selects a point:
Before_Move

This is how it looks after the user drags the point (imagine the surfaces moving with the point):
After_Move

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);
}

Thanks!

Hi @robert.beck12569,

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:

https://github.com/mcneel/rhino-developer-samples/blob/6/cpp/SampleCommands/cmdSampleZebra.cpp

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.

– Dale

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:

Before moving vertex. Zebra stripes display:

While moving vertex. Zebra not showing:

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?

Thanks for your time

I was not familiar with that feature, but it definitely looks similar to what I am trying to do.

@robert.beck12569 - did you make any progress with CageEdit?

@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?

Hi Robert,

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.

https://mcneel.myjetbrains.com/youtrack/issue/RH-53350

– Dale

1 Like

@XNurbs will you add this when it becomes available?

Thanks Dale!

That’s exactly what I am looking for! I’ll be on the lookout for the update when it comes around.

– Robert

Hi @robert.beck12569,

This sample will work with the SR16 SDK when it is available.

cmdSampleZebraPreview.cpp (3.4 KB)

– Dale

Sure. In fact, we asked Rhino to provide the function.

1 Like

RH-53350 is fixed in the latest Service Release Candidate

Hi @dale

When I test in python it shows error.

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))

Hi @Alen_Russ,

DisplayPipeline.DrawZebraPreview is for dynamically drawing Breps with zebra stripe from within a display conduit, which you don’t have.

My guess is you want to do this:

SampleCsZebraAnalysis.cs

Does this help?

– Dale

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.

Hi @Alen_Russ,

You can create display conduits in Python. Here is an example:

SampleDrawMeshConduit.py

– Dale

1 Like

Thanks
I will check this

Hi, I tried DrawZebraPreview and it works fine.

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.

  • Peter

Hi @Peter_Salzman,

I’ve added your request to the pile:

https://mcneel.myjetbrains.com/youtrack/issue/RH-60927

Thanks,

– Dale

Many thanks!

Best
Peter