Call component from BaseModel
Posted: Sat Jan 06, 2018 8:26 am
I'm making some buttons with a common BaseModel. I'm trying to change their color based on certain parameters, and that color should also later be used for some other parts of the buttons, something like this:
How come the square on the Right doesn't blink? I'm confused
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
<OnLoaded>
<SpawnModel Model="Model2"/>
</OnLoaded>
<Content>
<Material Name="Material1"/>
<Model Name="Model1">
<Definitions>
<RenderSetColor Name="setCol_ButtonLabel" Color="1 1 1 1"/>
</Definitions>
<OnUpdate>
<ZExpression Expression="setCol_ButtonLabel.Color = 0.5+sin(App.Time*10)*0.5;"/>
</OnUpdate>
<OnRender>
<UseMaterial Material="Material1"/>
<CallComponent Component="setCol_ButtonLabel"/>
<RenderNet/>
</OnRender>
</Model>
<Model Name="Model2" BaseModel="Model1">
<OnRender>
<UseMaterial Material="Material1"/>
<CallComponent Component="setCol_ButtonLabel"/>
<RenderNet>
<RenderVertexExpression>
<![CDATA[//Update each vertex.
//Vertex : current vertex
//TexCoord : current texture coordinate
//Color : current vertex color
Vertex.X += 2;]]>
</RenderVertexExpression>
</RenderNet>
</OnRender>
</Model>
</Content>
</ZApplication>