48 | function FillPlane:load(components, xmlFile, xmlNode, i3dMappings) |
49 | local fillPlaneNode = xmlFile:getValue(xmlNode .. "#node", nil, components, i3dMappings) |
50 | if fillPlaneNode ~= nil then |
51 | self.node = fillPlaneNode |
52 | local x, y, z = getTranslation(self.node) |
53 | self.moveMinY = xmlFile:getValue(xmlNode .. "#minY", y) |
54 | self.moveMaxY = xmlFile:getValue(xmlNode .. "#maxY", y) |
55 | self.colorChange = xmlFile:getValue(xmlNode .. "#colorChange", false) |
56 | if self.colorChange then |
57 | if not getHasShaderParameter(self.node, "colorScale") then |
58 | Logging.warning("Fillplane '%s' has no shader parameter 'colorScale'. Disabled color change!", getName(self.node)) |
59 | self.colorChange = false |
60 | end |
61 | end |
62 | if self.moveMinY > self.moveMaxY then |
63 | self.moveMinY, self.moveMaxY = self.moveMaxY, self.moveMinY |
64 | Logging.warning("Fillplane '%s' has inverted moveMinY and moveMaxY values. Switched values!", getName(self.node)) |
65 | end |
66 | |
67 | self.loaded = true |
68 | setTranslation(self.node, x, self.moveMinY, z) |
69 | |
70 | local rotX, _, _ = getRotation(self.node) |
71 | self.rotMinX = xmlFile:getValue(xmlNode .. "#minRotX", rotX) |
72 | self.rotMaxX = xmlFile:getValue(xmlNode .. "#maxRotX", rotX) |
73 | |
74 | self.changeVisibility = xmlFile:getValue(xmlNode .. "#changeVisibility", false) |
75 | |
76 | return true |
77 | end |
78 | |
79 | return false |
80 | end |
114 | function FillPlane.registerXMLPaths(schema, basePath) |
115 | schema:register(XMLValueType.NODE_INDEX, basePath .. "#node", "Fill plane node") |
116 | schema:register(XMLValueType.FLOAT, basePath .. "#minY", "Fill plane min y") |
117 | schema:register(XMLValueType.FLOAT, basePath .. "#maxY", "Fill plane max y") |
118 | schema:register(XMLValueType.ANGLE, basePath .. "#minRotX", "Fill plane min rotation x") |
119 | schema:register(XMLValueType.ANGLE, basePath .. "#maxRotX", "Fill plane max rotation x") |
120 | schema:register(XMLValueType.BOOL, basePath .. "#changeVisibility", "Hide node if state is zero") |
121 | schema:register(XMLValueType.BOOL, basePath .. "#colorChange", "Fill plane color change", false) |
122 | end |
86 | function FillPlane:setState(state) |
87 | if self.loaded then |
88 | local y = MathUtil.lerp(self.moveMinY, self.moveMaxY, state) |
89 | local x, oldY, z = getTranslation(self.node) |
90 | setTranslation(self.node, x, y, z) |
91 | |
92 | local rotX = MathUtil.lerp(self.rotMinX, self.rotMaxX, state) |
93 | setRotation(self.node, rotX, 0, 0) |
94 | |
95 | setVisibility(self.node, not self.changeVisibility or state > 0) |
96 | |
97 | return oldY ~= y |
98 | end |
99 | |
100 | return false |
101 | end |