Problem with accessing vec3 properties of CurrentModel
Posted: Mon Apr 11, 2016 2:37 pm
Running the following example throws exception "Error in expression for node: ZExpression Cannot get address of expression: ((vec3)CurrentModel.Position". Everything is running fine if instead of CurrentModel.Position a vec3 variable (called ObjectPosition in this case) is used. Direct usage of CurrentModel.* vec3 properties as reference vec3 parameters in functions would be useful.
Remark: When writing the Model1/OnSpawn/ZExpression to editor, no syntax error is reported. Only when running the project or copy/pasting to XML editor.
Remark: When writing the Model1/OnSpawn/ZExpression to editor, no syntax error is reported. Only when running the project or copy/pasting to XML editor.
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
<OnLoaded>
<ZLibrary>
<Source>
<![CDATA[vec3 ObjectPosition;
void randMax(ref vec3 pos, float max){
pos.X = random(0, max);
pos.Y = random(0, max);
pos.Z = random(0, max);
}]]>
</Source>
</ZLibrary>
<ZExpression>
<Expression>
<![CDATA[for(int i = 0; i < 100; ++i)
createModel(Model1);]]>
</Expression>
</ZExpression>
</OnLoaded>
<Content>
<Model Name="Model1" Scale="0.1 0.1 0.1">
<OnSpawn>
<ZExpression>
<Expression>
<![CDATA[randMax(CurrentModel.Position, 3);
// this works:
//randMax(ObjectPosition, 3);
//CurrentModel.Position = ObjectPosition;]]>
</Expression>
</ZExpression>
</OnSpawn>
<OnRender>
<RenderSprite/>
</OnRender>
</Model>
</Content>
</ZApplication>