Problem with accessing vec3 properties of CurrentModel

Found a bug? Post information about it here so we can fix it!

Moderator: Moderators

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Problem with accessing vec3 properties of CurrentModel

Postby Rado1 » 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.

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>

User avatar
Kjell
Posts: 1609
Joined: Sat Feb 23, 2008 11:15 pm

Re: Problem with accessing vec3 properties of CurrentModel

Postby Kjell » Mon Apr 11, 2016 4:01 pm

Hi Rado1,

Although i suspect the snippet you posted was just a example illustrating the bug .. the following expression gives the exact same result as your randMax function with 3 separate random calls.

Code: Select all

CurrentModel.Position = random(0, 3);

Just to make sure that anybody who's reading this is aware of that / doesn't get confused :wink:

K

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Re: Problem with accessing vec3 properties of CurrentModel

Postby Rado1 » Mon Apr 11, 2016 4:12 pm

Sure, I always try to illustrate problems on small examples to be easy reproduced by people (mainly Ville). I would like to use this feature in much bigger project(s) to create effective/small code. But writing "pos = random(0, max);" would make it better having the same functionality.


Return to “Bug reports”

Who is online

Users browsing this forum: No registered users and 1 guest