vcMaterial

vcMaterial is a material used by geometry and solid shapes in the 3D world.

Properties

Name Type Access Description
Ambient vcVector RW Defines a vector used for calculating the ambient value of material.
ColorMask Enumeration RW Defines the RGB/RGBA color mask used for rendering material.

See Material Constants for more information.

DepthComparison Enumeration RW Controls the visibility of geometry assigned the material based on pixel depth (distance from camera) in comparison to a Z-axis buffer.

Depth comparison is important for defining how a material is rendered in terms of elevation and depth and its interference with other materials.

See Material Constants for more information.

Diffuse vcVector RW Defines a vector used for calculating diffuse reflection of light hitting material.
LineStippling Boolean RW Turns on/off the use of stippling in the material to create light and dark shades based on point density.
LineWidth Real RW Defines the width of line primitives used for stippling.
Name String RW Defines the name of material.
Opacity Real RW Defines the material's opacity, thereby its transparency.
OpacityType Enumeration RW Defines the opacity type used by material.

See Material Constants for more information.

RenderOrder Enumeration RW Defines the order in which geometry using this material is rendered in 3D world.

See Material Constants for more information.

Shininess Real RW Defines the intensity of light reflected from material, thereby defining its luster.
Specular vcVector RW Defines a vector used for calculating specular reflection of light hitting material.
StipplingPattern Integer RW Defines the stippling pattern of material based on the bits of an integer.
StipplingScale Integer RW Defines scale factor of the material's stippling pattern which, by default, is 1.
Texture vcBitmap RW Gets a bitmap defining the texture of material.
TextureMapping Enumeration RW Defines how the material's texture is projected or defined using coordinates.

See Material Constants for more information.

Examples

Example. Set material opacity

from vcScript import *

app = getApplication()
myMaterial = app.findMaterial("material name")
myMaterial.Opacity = 2.0
myMaterial.OpacityType = VC_MATERIAL_TRANSPARENCY_NONE

Example. Find, edit and create new material

from vcScript import *
 
def copyMaterial(original_name):
  name_of_the_copy = original_name+'_copy'
 
  # find the materialname matching the given name
  orig_material = app.findMaterial( original_name )
 
  # create new material or use existing one
  new_material = app.findMaterial( name_of_the_copy )
  if not new_material: new_material = app.createMaterial( name_of_the_copy )
 
  # copy all properties from the original
  new_material.Ambient = orig_material.Ambient
  new_material.ColorMask = orig_material.ColorMask
  new_material.Diffuse = orig_material.Diffuse
  new_material.Specular = orig_material.Specular
  new_material.Shininess = orig_material.Shininess
  new_material.Opacity = orig_material.Opacity
  new_material.OpacityType = orig_material.OpacityType
  if orig_material.Texture: new_material.Texture = orig_material.Texture
  new_material.TextureMapping = orig_material.TextureMapping
  new_material.LineWidth = orig_material.LineWidth
  new_material.LineStippling = orig_material.LineStippling
  new_material.StipplingPattern = orig_material.StipplingPattern
  new_material.StipplingScale = orig_material.StipplingScale
  new_material.RenderOrder = orig_material.RenderOrder
  new_material.DepthComparison = orig_material.DepthComparison
 
  # adds material into the group of registered materials.
  # Returns False if a material with the same name already exists.
  app.addMaterial( new_material )
  return new_material
 
app = getApplication()
comp = getComponent()
 
# copy blue material
new_material = copyMaterial('blue')
 
# set opacity for the new copied material
# it's rarely a good idea to modify the standard materials)
new_material.Opacity = .75
new_material.OpacityType = VC_MATERIAL_TRANSPARENCY_CONSTANT
comp.Material = new_material

Example. Inherit and render material

from vcScript import *
 
def setMaterial(part, material_name):
  # find the materialname matching the given name
  material = app.findMaterial(material_name)
  
  # this will force even feature materials to be over-written
  part.MaterialInheritance = VC_MATERIAL_FORCE_INHERIT
  
  # assigning material as node material doesn't force rebuild
  #    => more efficient coz dynamic components still share geometry representation
  part.NodeMaterial = material
 
app = getApplication()
comp = getComponent()
kids = comp.ChildComponents
for kid in kids:
  setMaterial(kid, 'blue') # set a material for all child components
app.render()