Grasshopper

algorithmic modeling for Rhino

Still a beginner in VB.NET.  Trying to write some tools to augment Giulio's great rendering component.  I have gotten as far as extracting VRay materials/names from the document object.  

Now I would like to use a single VRay material as a template for creating multiple identical materials with different colors within the GH environment (instead of creating manually in the document).  

I have gotten as far as creating the materials.  Now I need to add them to the document material table so that they can be used with Giulio's rendering component (which looks for either Rhino.Display.DisplayMaterial or a String that references a document object).  I'm not going to learn C# to modify his script, so I am catering to its demands.  

Private Sub RunScript(ByVal M As Object, ByVal C As Color, ByRef Mat As Object)


Dim mTemp As Rhino.DocObjects.Material
mTemp = CType(M, Rhino.DocObjects.Material)
If mTemp.Name.Length > 0 Then
mTemp.DiffuseColor = C
Dim nTemp As String = mTemp.Name & "_" & C.R & "_" & C.G & "_" & C.B
mTemp.Name = nTemp
End If

Rhino.DocObjects.Tables.MaterialTable.Add(mTemp)
Mat = mTemp

End Sub

The code throws the error: Reference to a non-shared member requires an object reference. (line 96)

Do I understand that the material has to be assigned to a particular object in order to enter the Material Table?  Can I assign it to a Layer instead? Any ideas?  A better way to do this?

Thanks,

Marc

Views: 9537

Replies to This Discussion

Hey Hannes, 

I'd love to see a VRay component of Scarab with the same amount of control that you have developed for Maxwell.  

I did manage to get the VRay materials working in Grasshopper using VB.NET but as you may have noticed above, it's not entirely glitch free and I never did try to build any materials from scratch.  My method was to pull the materials from the material table and then use one of those materials as a template, using the .NET script to replace the diffuse color, for instance.  I also got it working for transparency, but I didn't try any other attributes.  

All of my code is posted in this thread, so you're welcome to take from it what you need and make it better.  Be aware that there were some glitches, also noted here. Primary glitches were the failure to assign the first material in the GH material table to the objects, but I have not determined whether this was a problem with my code or with Giulio's Animation component.  Clearly you already have a much better grasp on coding than I do, so I'm sure it will be fairly easy for you to get it up to speed, at least for working with a material as a template.  

As Giulio mentioned, there is no VRay SDK, so I don't know if the same method you used for Maxwell will work with VRay.  Was there a Maxwell SDK?

Cheers,

Marc

I had a glance at your definition and have the feeling that all you did was confuse VRay
...

From what I know from Maxwell, all the relevant material settings are stored inside the plugin. The Rhino material is merely a dummy tho keep the viewport working and the baic setup once you render with other engines. Each rhino material has its own associated maxwell material.

Maxwell interprets all rhinoMaterial that do not have maxwell properties as simple materials. You get all the properties of basic rhino materials (diffuse color, transparency... ) but that's it.

I don't know how the vray plug works but by copying an existing material you might have lead vray to add those properties left to ones gernerated from the rhino material.

Maxwell doesn't have an SDK but the plug is written in C#. So I was able do decomplie the plug literally to the original sources. No such thing for VRAY... :(

I have found some exported functions of the Vray for Rhino plugin but am not sure how they work. My current focus will be Maxwell

Hi Marc, along time ago i saw your Vimeo Video and i was hoping to try that definition out, this is my reinterpretation based on your original animation. 

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service