Grasshopper

algorithmic modeling for Rhino

Question: How to draw two Breps that one of them is 0.5 transparent

Hi,

I'm writing a component in c# that regardless to the input/output parameters is drawing in a different thread two breps that have the same location and i want to be able to control the level of opacity so one of them is half-transparent.

I'm using Rhino.RhinoDoc.ActiveDoc.Objects.Add function to add/delete/purge to objects

I have also constructed an Rhino.DocObjects.ObjectAttributes object in order to control the colors of each brep using and setting it's layer index to a layer that i have added to rhino using an Rhino.DocObjects.Layer that i have also constructed.

With the layer object i can change the colors of the breps though i couldnt figure out how to set the transparency

Is that possible to configure a layer that is 0.5 transparent? 

Thanks,

H.

Views: 477

Replies to This Discussion

[...] drawing in a different thread two breps [...]

I hope not. You should not be doing anything UI related (such as drawing stuff) in a different thread.

You don't need to add objects to the document in order to draw them. In fact it's preferable if you don't. Adding/Removing objects from the document will have memory and performance overhead. You can just draw objects directly from code, with materials that are partially transparent if you want.

--

David Rutten

david@mcneel.com

Hi david,

How is that possible?

I want to be able to draw the objects and remove the objects without going through SolveInstance.

When i said another thread i meant that there's a Timer that works in the background and does all the drawing. I'm using the System.Windows.Threading.DispatcherTimer 

It works perfectly now and i'm in-charge of maintaining the add/remove or the objects so nothing is left without being properly removed. Also it's not alot of objects.

I'd be glad to hear how is that possible to do so without putting it in the output parameters

Adding and removing objects from the Rhino document isn't actually 'drawing' them.

You can create a class that handles Rhino redraw events and you can draw your geometry (or not draw your geometry) on every redraw. You can decide in which viewports to include them and how they should look. To refresh the display, you just need to trigger a viewport update, no SolveInstance required. This is how Grasshopper draws its geometry as well.

If you handle the Display.DisplayPipeline.PostDrawObjects event you can draw your own geometry in whatever way you want.

--

David Rutten

david@mcneel.com

Hi david,

I just tried doing what you suggested and added an event handler to the PostDrawObjects

I notice the major differences between adding an object and drawing it when i'm handling the redraw events, there are few problems and i'm hoping you can help

i'm drawing a group of meshes in each redraw and i'm using this function:
e . Display . DrawMeshShaded (current_mesh, new Rhino . Display . DisplayMaterial(m_first_color, 0));
Now, the drawn mesh is not rendered in high quality and also when it's not fully visible. it seems that it's disappearing when i'm zooming out, also when i'm turning the view port from shaded to wire - the texture does not change.

Is there an example on how to properly handle the redraw event? and how can i overcome the quality differences between a Mesh i add as an object and a Mesh i draw using the DisplayPipeLine

Thanks,
H.






You may also have to adjust the viewport clipping region. If the meshes you draw fall outside of the existing clip range then the front and back may be cut off. I can't tell from your description whether this is what is happening though, an image would be helpful. To adjust the clipping you also need to handle the Display.DisplayPipeline.CalculateBoundingBox event. You can cache a BoundingBox of all your meshes ahead of time to speed things up.

You need to create a mesh that is as accurate as you need it to be. If you need more accuracy, use higher quality mesh settings.

I do not know what "the texture does not change" means.

--

David Rutten

david@mcneel.com

Hi david,

I've created a Rhino.Geometry.Circle object and drew it to the screen, I've attached an image showing that when i'm zooming in/out in the view port the circle is starting to 'disappear'

Hi david,

I've added an handler to the boundingbox event and it's now working great.

I'd love if there was a documentation or a tutorial explaining how to use the display pipe line.

Thanks for the help

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service