Sha256: 92de8c47a7ef5efec17c4e1c728d25fa4b65995d37e113505b807cbfc5f879ef

Contents?: true

Size: 1.93 KB

Versions: 9

Compression:

Stored size: 1.93 KB

Contents

require 'fileutils'
FileUtils.copy_entry('projects/ReferencedMaterials','projects/_RefMat',false,false,true)

metadata 'MetaData.xml'

uia 'projects/_RefMat/ReferencedMaterials.uia'
show app.errors if app.errors?

layer   = app/'main:Scene.Layer'
cubemat = layer/"Cube"/"Material"

# Ensure that the diffuse attribute is linked and present on multiple slides
assert cubemat['diffuse'].linked?
assert cubemat.has_slide?(0)
assert cubemat.has_slide?(1)
assert cubemat.has_slide?(2)
assert cubemat['diffuse',1].r == 0.5
assert cubemat['diffuse',2].r == 0.5

# When we do not unlink, values remain shared
cubemat['diffuse',1].r = 1
cubemat['diffuse',2].r = 0.2
assert cubemat['diffuse',1].r == cubemat['diffuse',2].r

# Ensure that we can unlink an attribute and vary the values per slide
cubemat['diffuse'].unlink
assert !cubemat['diffuse'].linked?
cubemat['diffuse',1].r = 1
cubemat['diffuse',2].r = 0.2
assert cubemat['diffuse',1].r == 1
assert cubemat['diffuse',2].r == 0.2

# We can swap a material with a referenced material
model = cubemat.parent
assert model
ref = cubemat.replace_with_referenced_material
assert cubemat.parent.nil?                  # The old material is removed from the graph
assert ref.parent==model                    # The new material is where the old was
assert ref['id'] == cubemat['id']           # The new material has the same id and name
assert ref.name == 'Material'
assert ref['referencedmaterial',0].object.nil?       # New referenced materials start out with no reference
assert ref['referencedmaterial',0].type == :absolute # New references default to absolute

ref['referencedmaterial'].unlink
%w[Sphere Sphere2].each.with_index do |name,s|
	# You can set a reference directly to an object, or alternatively
	# ref['referencedmaterial',1].object = layer/name/"Material"
	ref['referencedmaterial',s+1] = layer/name/"Material"
	ref['referencedmaterial',s+1].type = :path
end

app.save_all!

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
RUIC-0.4.6 test/referencematerials.ruic
RUIC-0.4.5 test/referencematerials.ruic
RUIC-0.4.2 test/referencematerials.ruic
RUIC-0.4.0 test/referencematerials.ruic
RUIC-0.3.0 test/referencematerials.ruic
RUIC-0.2.6 test/referencematerials.ruic
RUIC-0.2.5 test/referencematerials.ruic
RUIC-0.2.0 test/referencematerials.ruic
RUIC-0.1.0 test/referencematerials.ruic