SpecularColor for Faces (Materials per Face)

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
easyw-fc
Veteran
Posts: 3630
Joined: Thu Jul 09, 2015 9:34 am

SpecularColor for Faces (Materials per Face)

Post by easyw-fc »

Hi,
is there a way to add some material properties to Faces instead to the all Shape?
I would like to have for example a Cube with one Face Gold and one other Emerald?

I know it is possible to assign per Face Transparency, so I was thinking of something similar...

That would allow to load i.e. a colored model (union of colored parts) and display it with shininess as for example is possible in CADAssistant

Thx
Maurice
mario52
Veteran
Posts: 4674
Joined: Wed May 16, 2012 2:13 pm

Re: SpecularColor for Faces (Materials per Face)

Post by mario52 »

hi
may be in comboview click right to shape and "Set colors..."

python code:

Code: Select all

Gui.ActiveDocument.Box.DiffuseColor=[(1.,0.,0.),(0.,1.,0.),(0.,0.,1.),(1.,1.,0.),(1.,0.,1.),(0.,1.,1.)]
see here [Résolu] Couleur différentes sur les faces

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
User avatar
easyw-fc
Veteran
Posts: 3630
Joined: Thu Jul 09, 2015 9:34 am

Re: SpecularColor for Faces (Materials per Face)

Post by easyw-fc »

mario52 wrote:hi
may be in comboview click right to shape and "Set colors..."
...
mario
Hi @mario52
thanks for going into this...
unfortunately what you are linking is just Diffuse color per Faces...
what I would need is Materials for Faces...
ATM I think Materials can only be added to all Shape and not to singular Face
Please have a look at the two situations:
1) Cube, Cone, Sphere with Materials added (right click 'Appearance')
2) the same objects fused as one where only Diffuse property is maintained...
materials.png
materials.png (278.6 KiB) Viewed 1877 times
This is only an aesthetic feature, but, I see that something in going into 'UX/UI Design' and user experience
I just noticed that main CADs just have shininess and Specular effect enabled by default (i.e. Catia, SolidWorks, CADAssistance by OCC)
fusion-in-cadassistance.png
fusion-in-cadassistance.png (115.32 KiB) Viewed 1877 times
I tried by python code but it seems there ares no other properties than Diffuse for Faces
Maurice
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: SpecularColor for Faces (Materials per Face)

Post by microelly2 »

You have to hack the pivy node.
User avatar
easyw-fc
Veteran
Posts: 3630
Joined: Thu Jul 09, 2015 9:34 am

Re: SpecularColor for Faces (Materials per Face)

Post by easyw-fc »

microelly2 wrote:You have to hack the pivy node.
would you please give me some tips? or a simple example?
that would be great! :)
Maurice
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: SpecularColor for Faces (Materials per Face)

Post by microelly2 »

Code: Select all

v=App.ActiveDocument.ActiveObject.ViewObject
v.ShapeMaterial
m=v.ShapeMaterial
m.EmissiveColor=(1.0,0.0,0.0,0.5)
m.SpecularColor=(0.0,1.0,0.0,1.0)
m.EmissiveColor=(0.0,0.0,0.0,0.5)
m.DiffuseColor=(0.0,1.0,0.0,1.0)
m.SpecularColor=(1.0,1.0,0.0,1.0)
m.EmissiveColor=(1.0,0.0,0.0,0.5)
User avatar
easyw-fc
Veteran
Posts: 3630
Joined: Thu Jul 09, 2015 9:34 am

Re: SpecularColor for Faces (Materials per Face)

Post by easyw-fc »

microelly2 wrote:

Code: Select all

v=App.ActiveDocument.ActiveObject.ViewObject
v.ShapeMaterial
m=v.ShapeMaterial
m.EmissiveColor=(1.0,0.0,0.0,0.5)
m.SpecularColor=(0.0,1.0,0.0,1.0)
m.EmissiveColor=(0.0,0.0,0.0,0.5)
m.DiffuseColor=(0.0,1.0,0.0,1.0)
m.SpecularColor=(1.0,1.0,0.0,1.0)
m.EmissiveColor=(1.0,0.0,0.0,0.5)
Hi @microelly2
whith that I can associate a diffuse color and a specular color to an object...
what I would need is to assign diffuse and specular per faces... is that possible?
I mean I would need to create a material to be attached to a face

for example if the face has red diffuse color, I would need to attach an orange specular color; if the face has blue color, I would need to attach a lightblue color
cube-multi-color-faces.FCStd
(3.2 KiB) Downloaded 28 times
thx again for support :D
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: SpecularColor for Faces (Materials per Face)

Post by microelly2 »

this can be very complex,
the simplest way ist to generate faceholders for your faces and colorate each this way
I did this with transparency here:
freecadbuch.de/doku.php?id=blog:transparenz_-_peel_the_egg
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: SpecularColor for Faces (Materials per Face)

Post by microelly2 »

An other way is to change the inventor node
I have done this with texture images here

https://freecadbuch.de/doku.php?id=blog ... en_bringen

the structure of a per face coloring you find at the end of this link
http://developer90.openinventor.com/con ... ile-format


https://webdocs.cs.ualberta.ca/~graphic ... mentor.pdf
pages 137,282 ff
User avatar
easyw-fc
Veteran
Posts: 3630
Joined: Thu Jul 09, 2015 9:34 am

Re: SpecularColor for Faces (Materials per Face)

Post by easyw-fc »

microelly2 wrote:this can be very complex,
the simplest way ist to generate faceholders for your faces and colorate each this way
...
Hi @ microelly2
the faceholder way is quite complex and will change the model to reach its visualization... so I wouldn't like to consider it...
microelly2 wrote:An other way is to change the inventor node
I have done this with texture images here ...
that seems the right / feasible approach!
I will have a look at the docs...
thx
M
Post Reply