Quantcast
Channel: Rhino Developer - McNeel Forum
Viewing all articles
Browse latest Browse all 8531

WIP7. Material texture not showing on viewport. BUG?

$
0
0

Hi, I’m trying to assign a renderMaterial to a programatically added object using Python. Strange thing happening here:

Once object added to the document, I check in object properties the correct material was assigned.

If material color is defined by a bitmap, the texture is not displaying in Rendered mode.
If material color is defined with a color, the color is displayed correctly in Rendered mode.

In Raytraced mode material texture is correctly displayed IF when I baked the object display mode was NOT Raytraced. Otherwise, if rendermode was Raytraced, material texture wont appear correctly (burned out, incorrecty scaled)

if I manually change the textured material to diffuse material, and then reassign the textured material, then it will correctly show up in rendered mode.

I recorded a video to show this behaviour:


Seems a bug, but maybe I’m not correctly making things with my code…
import Rhino
import Rhino.Geometry as rg
from Rhino.RhinoDoc import ActiveDoc as doc

#create two boxes
interval = rg.Interval(0,100)
box = rg.Box(rg.Plane.WorldXY,interval,interval,interval)
box01 = box.ToBrep()
box02 = box01.Duplicate()
box02.Translate(150,0,0)

#retrieve renderMaterials by name
box01MatName = 'mat_textured'
box02MatName = 'mat_noTexture'
for mat in doc.RenderMaterials:
    if mat.Name == box01MatName:
        renderMat01 = mat
    elif mat.Name == box02MatName:
        renderMat02 = mat

#bake objects and get the RhinoObject
attr = doc.CreateDefaultAttributes()
id01 = doc.Objects.Add(box01,attr)
rhinoObject01 = doc.Objects.FindId(id01)
id02 = doc.Objects.Add(box02,attr)
rhinoObject02 = doc.Objects.FindId(id02)

#assign renderMaterials to RhinoObject
rhinoObject01.RenderMaterial = renderMat01
rhinoObject02.RenderMaterial = renderMat02

#commit changes
rhinoObject01.CommitChanges()
rhinoObject02.CommitChanges()

8 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 8531

Trending Articles